This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/routes/profile.vue

160 lines
5.3 KiB
Vue
Raw Normal View History

<template>
2020-11-16 11:43:44 -08:00
<div v-if="profile">
<section v-if="$isGranted('users') && user.bannedReason">
<div class="alert alert-warning">
<p class="h4">
<Icon v="ban"/>
{{$t('ban.banned')}}
</p>
<p class="mb-0">{{user.bannedReason}}</p>
</div>
</section>
2021-06-16 07:08:38 -07:00
<Profile :user="user" :profile="profile" :terms="terms">
<div v-if="Object.keys(user.profiles).length > 1">
<LocaleLink v-for="(options, locale) in locales" :key="locale" v-if="user.profiles[locale] !== undefined"
2021-07-27 05:14:57 -07:00
:locale="locale" :link="`/@${user.username}`"
2021-07-10 07:46:29 -07:00
:class="['btn', locale === config.locale ? 'btn-primary disabled' : 'btn-outline-primary', 'btn-sm', 'mb-2 mx-1']">
{{options.name}}
</LocaleLink>
2020-10-23 11:24:43 -07:00
</div>
2021-07-24 10:18:39 -07:00
<div v-if="$user() && $user().username === user.username">
2021-07-10 09:30:31 -07:00
<nuxt-link to="/editor" class="btn btn-primary btn-sm mb-2 mx-1">
2021-07-10 07:46:29 -07:00
<Icon v="edit"/>
<T>profile.edit</T>
</nuxt-link>
2021-07-24 10:18:39 -07:00
<a :href="`https://pronouns.page/@${user.username}`" v-if="Object.keys(user.profiles).length > 1"
2021-07-10 07:46:29 -07:00
class="btn btn-outline-secondary btn-sm mb-2 mx-1"
>
<Icon v="external-link"/>
2021-07-24 10:18:39 -07:00
pronouns.page/@{{user.username}}
2021-07-10 07:46:29 -07:00
</a>
2020-10-23 11:24:43 -07:00
</div>
2021-08-28 13:06:23 -07:00
<!--
2021-07-10 09:30:31 -07:00
<div v-if="($user() && $user().username === profile.username) || $isGranted('users')">
2021-07-10 07:46:29 -07:00
<small>
<Icon v="id-card"/>
<T>profile.card.link</T>:
</small>
<template v-if="profile.card">
<a :href="profile.card" target="_blank" rel="noopener"
class="btn btn-outline-success btn-sm mb-2 mx-1">
<Icon v="sun"/>
<T>mode.light</T>
</a>
<a :href="profile.card.replace('.png', '-dark.png')" target="_blank" rel="noopener"
class="btn btn-outline-success btn-sm mb-2 mx-1">
<Icon v="moon"/>
<T>mode.dark</T>
</a>
</template>
<small v-else><T>profile.card.generating</T></small>
2020-10-23 11:24:43 -07:00
</div>
2021-08-28 13:06:23 -07:00
-->
2021-07-10 07:46:29 -07:00
</Profile>
2021-04-04 13:45:42 -07:00
<Ban :user="user"/>
2021-06-16 07:08:38 -07:00
2021-04-04 13:45:42 -07:00
<Separator icon="heart"/>
2021-04-06 06:15:59 -07:00
<Support/>
<section>
<Share/>
</section>
</div>
<div v-else-if="user.username">
2020-10-28 08:22:29 -07:00
<h2 class="text-nowrap mb-3">
<Avatar :user="user"/>
2020-10-28 08:22:29 -07:00
@{{username}}
</h2>
<div v-if="Object.keys(user.profiles).length" class="list-group">
<LocaleLink v-for="(options, locale) in locales" :key="locale" v-if="user.profiles[locale] !== undefined"
2020-10-28 08:22:29 -07:00
:locale="locale" :link="`/@${username}`"
class="list-group-item list-group-item-action list-group-item-hoverable">
<div class="h3">
{{options.name}}
</div>
</LocaleLink>
</div>
<div v-else class="alert alert-info">
<p class="mb-0">
<Icon v="info-circle"/>
<T>profile.empty</T>
</p>
</div>
<Ban :user="user"/>
2020-10-28 08:22:29 -07:00
</div>
<NotFound v-else/>
</template>
<script>
2021-07-10 07:46:29 -07:00
import { head } from "../src/helpers";
import ClientOnly from 'vue-client-only'
export default {
components: { ClientOnly },
data() {
2020-10-28 08:22:29 -07:00
return {
terms: [],
}
},
async asyncData({ app, route }) {
return {
user: await app.$axios.$get(`/profile/get/${encodeURIComponent(route.params.pathMatch)}`),
};
},
async mounted() {
if (this.config.terminology.enabled) {
this.terms = await this.$axios.$get(`/terms`);
}
},
computed: {
2021-07-10 07:46:29 -07:00
profile() {
for (let locale in this.user.profiles) {
2021-07-10 07:46:29 -07:00
if (locale === this.config.locale) {
return this.user.profiles[locale];
2021-07-10 07:46:29 -07:00
}
}
return null;
},
2021-01-01 12:11:37 -08:00
username() {
const base = this.$route.params.pathMatch;
if (!this.profile) {
return base;
}
if (this.user.username !== base && process.client) {
2021-01-01 12:11:37 -08:00
history.pushState(
'',
document.title,
'/@' + this.user.username,
2021-01-01 12:11:37 -08:00
);
}
return this.user.username;
2021-01-01 12:11:37 -08:00
},
},
head() {
return head({
title: `@${this.username}`,
2020-10-31 13:33:59 -07:00
banner: `api/banner/@${this.username}.png`,
});
},
}
</script>
<style lang="scss" scoped>
2020-11-23 14:14:31 -08:00
@import "assets/variables";
2020-10-28 08:22:29 -07:00
.list-group-item-hoverable {
&:hover {
color: $primary;
2021-03-01 13:35:03 -08:00
border-inline-start: 3px solid $primary;
padding-inline-start: calc(#{$list-group-item-padding-x} - 2px);
2020-10-28 08:22:29 -07:00
}
}
</style>