2020-10-16 11:17:50 -07:00
|
|
|
<template>
|
2020-11-16 11:43:44 -08:00
|
|
|
<div v-if="profile">
|
2021-07-24 05:54:15 -07:00
|
|
|
<section v-if="$isGranted('users') && user.bannedReason">
|
2021-06-17 13:24:15 -07:00
|
|
|
<div class="alert alert-warning">
|
|
|
|
<p class="h4">
|
|
|
|
<Icon v="ban"/>
|
|
|
|
{{$t('ban.banned')}}
|
|
|
|
</p>
|
2021-07-24 05:54:15 -07:00
|
|
|
<p class="mb-0">{{user.bannedReason}}</p>
|
2021-06-17 13:24:15 -07:00
|
|
|
</div>
|
|
|
|
</section>
|
2021-06-16 07:08:38 -07:00
|
|
|
|
2021-07-24 05:54:15 -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-09-05 10:22:18 -07:00
|
|
|
<div v-if="$user() && $user().username === user.username" class="alert alert-info">
|
|
|
|
<div class="mb-2">
|
|
|
|
<nuxt-link to="/editor" class="btn btn-primary btn-sm mx-1">
|
|
|
|
<Icon v="edit"/>
|
|
|
|
<T>profile.edit</T>
|
|
|
|
</nuxt-link>
|
|
|
|
<a :href="`https://pronouns.page/@${user.username}`" v-if="Object.keys(user.profiles).length > 1"
|
|
|
|
class="btn btn-outline-secondary btn-sm mx-1"
|
|
|
|
>
|
|
|
|
<Icon v="external-link"/>
|
|
|
|
pronouns.page/@{{user.username}}
|
2021-07-10 07:46:29 -07:00
|
|
|
</a>
|
2021-09-05 10:22:18 -07:00
|
|
|
</div>
|
2021-11-26 01:13:14 -08:00
|
|
|
<div>
|
2021-09-05 10:22:18 -07:00
|
|
|
<small>
|
|
|
|
<Icon v="id-card"/>
|
2021-12-02 08:18:25 -08:00
|
|
|
<T>profile.card.link</T><T>quotation.colon</T>
|
2021-09-05 10:22:18 -07:00
|
|
|
</small>
|
2021-10-13 12:56:39 -07:00
|
|
|
<small v-if="profile.card === null && profile.cardDark === null">
|
|
|
|
<button class="btn btn-outline-success btn-sm" @click="generateCard(false)">
|
|
|
|
<Icon v="sun"/>
|
|
|
|
<T>mode.light</T>
|
|
|
|
</button>
|
|
|
|
<button class="btn btn-outline-success btn-sm" @click="generateCard(true)">
|
|
|
|
<Icon v="moon"/>
|
|
|
|
<T>mode.dark</T>
|
2021-09-05 10:22:18 -07:00
|
|
|
</button>
|
|
|
|
</small>
|
2021-10-13 12:56:39 -07:00
|
|
|
<small v-else-if="profile.card === '' || profile.cardDark === ''">
|
2021-09-05 10:22:18 -07:00
|
|
|
<Spinner/>
|
|
|
|
<T>profile.card.generating</T>
|
|
|
|
</small>
|
2021-10-29 09:24:22 -07:00
|
|
|
<span v-else>
|
|
|
|
<a v-if="profile.card" :href="profile.card" target="_blank" rel="noopener"
|
|
|
|
class="btn btn-outline-success btn-sm mx-1">
|
|
|
|
<Icon v="sun"/>
|
|
|
|
<T>mode.light</T>
|
|
|
|
</a>
|
|
|
|
<a v-if="profile.cardDark" :href="profile.cardDark" target="_blank" rel="noopener"
|
|
|
|
class="btn btn-outline-success btn-sm mx-1">
|
|
|
|
<Icon v="moon"/>
|
|
|
|
<T>mode.dark</T>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<button v-if="!profile.card" class="btn btn-outline-success btn-sm" @click="generateCard(false)">
|
|
|
|
<Icon v="sun"/>
|
|
|
|
</button>
|
|
|
|
<button v-if="!profile.cardDark" class="btn btn-outline-success btn-sm" @click="generateCard(true)">
|
|
|
|
<Icon v="moon"/>
|
|
|
|
</button>
|
|
|
|
</span>
|
2021-09-05 10:22:18 -07:00
|
|
|
</div>
|
2020-10-23 11:24:43 -07:00
|
|
|
</div>
|
2021-07-10 07:46:29 -07:00
|
|
|
</Profile>
|
2021-04-04 13:45:42 -07:00
|
|
|
|
2021-07-24 05:54:15 -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/>
|
2021-04-21 14:13:04 -07:00
|
|
|
<section>
|
|
|
|
<Share/>
|
|
|
|
</section>
|
2020-10-16 11:17:50 -07:00
|
|
|
</div>
|
2021-12-14 06:40:33 -08:00
|
|
|
<div v-else-if="user.username" class="my-5">
|
2020-10-28 08:22:29 -07:00
|
|
|
<h2 class="text-nowrap mb-3">
|
2021-07-24 05:54:15 -07:00
|
|
|
<Avatar :user="user"/>
|
2020-10-28 08:22:29 -07:00
|
|
|
@{{username}}
|
|
|
|
</h2>
|
|
|
|
|
2021-07-24 05:54:15 -07:00
|
|
|
<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}`"
|
2021-12-14 15:45:28 -08:00
|
|
|
class="list-group-item list-group-item-action list-group-item-hoverable d-flex flex-column flex-md-row justify-content-between">
|
2020-10-28 08:22:29 -07:00
|
|
|
<div class="h3">
|
|
|
|
{{options.name}}
|
|
|
|
</div>
|
2021-12-14 15:45:28 -08:00
|
|
|
<div class="d-flex align-items-center">
|
|
|
|
<ForeignPronoun v-for="pronoun in selectMainPronouns(user.profiles[locale].pronouns)" :key="pronoun"
|
|
|
|
:pronoun="pronoun" :locale="locale"/>
|
|
|
|
</div>
|
2020-10-28 08:22:29 -07:00
|
|
|
</LocaleLink>
|
|
|
|
</div>
|
2021-07-24 05:54:15 -07:00
|
|
|
<div v-else class="alert alert-info">
|
|
|
|
<p class="mb-0">
|
|
|
|
<Icon v="info-circle"/>
|
|
|
|
<T>profile.empty</T>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
2021-12-14 06:40:33 -08:00
|
|
|
<a v-for="link in verifiedLinks" :href="link" rel="me"> </a>
|
|
|
|
|
2021-07-24 05:54:15 -07:00
|
|
|
<Ban :user="user"/>
|
2020-10-28 08:22:29 -07:00
|
|
|
</div>
|
|
|
|
<NotFound v-else/>
|
2020-10-16 11:17:50 -07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-07-10 07:46:29 -07:00
|
|
|
import { head } from "../src/helpers";
|
2021-06-16 10:18:51 -07:00
|
|
|
import ClientOnly from 'vue-client-only'
|
2020-10-16 11:17:50 -07:00
|
|
|
|
|
|
|
export default {
|
2021-06-16 10:18:51 -07:00
|
|
|
components: { ClientOnly },
|
2020-10-16 11:17:50 -07:00
|
|
|
data() {
|
2020-10-28 08:22:29 -07:00
|
|
|
return {
|
2021-06-17 14:10:26 -07:00
|
|
|
terms: [],
|
2021-09-05 05:12:40 -07:00
|
|
|
cardCheckHandle: null,
|
2020-10-16 11:17:50 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async asyncData({ app, route }) {
|
|
|
|
return {
|
2021-07-24 05:54:15 -07:00
|
|
|
user: await app.$axios.$get(`/profile/get/${encodeURIComponent(route.params.pathMatch)}`),
|
2020-10-16 11:17:50 -07:00
|
|
|
};
|
|
|
|
},
|
2021-06-17 14:10:26 -07:00
|
|
|
async mounted() {
|
2021-08-28 14:44:30 -07:00
|
|
|
if (this.config.terminology.enabled) {
|
2021-06-17 14:10:26 -07:00
|
|
|
this.terms = await this.$axios.$get(`/terms`);
|
|
|
|
}
|
|
|
|
},
|
2020-10-16 11:17:50 -07:00
|
|
|
computed: {
|
2021-07-10 07:46:29 -07:00
|
|
|
profile() {
|
2021-07-24 05:54:15 -07:00
|
|
|
for (let locale in this.user.profiles) {
|
2021-07-10 07:46:29 -07:00
|
|
|
if (locale === this.config.locale) {
|
2021-07-24 05:54:15 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-07-24 05:54:15 -07:00
|
|
|
if (this.user.username !== base && process.client) {
|
2021-01-01 12:11:37 -08:00
|
|
|
history.pushState(
|
|
|
|
'',
|
|
|
|
document.title,
|
2021-07-24 05:54:15 -07:00
|
|
|
'/@' + this.user.username,
|
2021-01-01 12:11:37 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-07-24 05:54:15 -07:00
|
|
|
return this.user.username;
|
2021-01-01 12:11:37 -08:00
|
|
|
},
|
2021-12-14 06:40:33 -08:00
|
|
|
verifiedLinks() {
|
|
|
|
return [...new Set(Object.values(this.user.profiles).map(p => Object.keys(p.verifiedLinks || {})).flat())];
|
|
|
|
},
|
2020-10-16 11:17:50 -07:00
|
|
|
},
|
2021-09-05 05:12:40 -07:00
|
|
|
watch: {
|
|
|
|
profile() {
|
|
|
|
this.startCheckingForCard();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
2021-10-13 12:56:39 -07:00
|
|
|
async generateCard(dark) {
|
|
|
|
await this.$axios.$post(`/profile/request-card?dark=${dark ? '1' : '0'}`);
|
|
|
|
this.profile[dark ? 'cardDark' : 'card'] = '';
|
2021-09-05 05:12:40 -07:00
|
|
|
this.startCheckingForCard();
|
|
|
|
},
|
|
|
|
startCheckingForCard() {
|
2021-10-13 12:56:39 -07:00
|
|
|
if (this.cardCheckHandle || !this.profile || this.profile.card || this.profile.cardDark) {
|
2021-09-05 05:12:40 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.cardCheckHandle = setInterval(this.checkForCard, 3000);
|
|
|
|
},
|
|
|
|
async checkForCard() {
|
|
|
|
try {
|
|
|
|
const card = await this.$axios.$get(`/profile/has-card`);
|
2021-10-29 09:24:22 -07:00
|
|
|
if (card.card !== '' && card.cardDark !== '') {
|
2021-10-13 12:56:39 -07:00
|
|
|
this.profile.card = card.card;
|
|
|
|
this.profile.cardDark = card.cardDark;
|
2021-09-05 05:12:40 -07:00
|
|
|
clearInterval(this.cardCheckHandle);
|
|
|
|
}
|
|
|
|
} catch {
|
|
|
|
clearInterval(this.cardCheckHandle);
|
|
|
|
}
|
2021-12-14 15:45:28 -08:00
|
|
|
},
|
|
|
|
selectMainPronouns(pronouns) {
|
|
|
|
const best = {
|
|
|
|
1: [], // yes
|
|
|
|
0: [], // meh
|
|
|
|
3: [], // close
|
|
|
|
2: [], // jokingly
|
|
|
|
}
|
|
|
|
for (let pronoun in pronouns) {
|
|
|
|
if (!pronouns.hasOwnProperty(pronoun)) { continue; }
|
|
|
|
const opinion = pronouns[pronoun];
|
|
|
|
if (best[opinion] !== undefined) {
|
|
|
|
best[opinion].push(pronoun);
|
|
|
|
}
|
|
|
|
}
|
2021-12-14 15:55:17 -08:00
|
|
|
for (let opinion of [1, 0, 3, 2]) {
|
2021-12-14 15:45:28 -08:00
|
|
|
if (best[opinion].length) {
|
2021-12-16 12:09:17 -08:00
|
|
|
return best[opinion].slice(0, 3);
|
2021-12-14 15:45:28 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return [];
|
|
|
|
},
|
2021-09-05 05:12:40 -07:00
|
|
|
},
|
2020-10-16 11:17:50 -07:00
|
|
|
head() {
|
|
|
|
return head({
|
|
|
|
title: `@${this.username}`,
|
2021-12-23 08:56:27 -08:00
|
|
|
description: this.profile ? this.profile.description : null,
|
2020-10-31 13:33:59 -07:00
|
|
|
banner: `api/banner/@${this.username}.png`,
|
2020-10-16 11:17:50 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</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
|
|
|
}
|
|
|
|
}
|
2020-10-16 11:17:50 -07:00
|
|
|
</style>
|