2020-10-16 11:17:50 -07:00
|
|
|
<template>
|
2020-11-16 11:43:44 -08:00
|
|
|
<div v-if="profile">
|
2020-10-24 12:50:08 -07:00
|
|
|
<div class="mb-3 d-flex justify-content-between flex-column flex-md-row">
|
2020-10-23 11:24:43 -07:00
|
|
|
<h2 class="text-nowrap">
|
|
|
|
<Avatar :user="profile"/>
|
|
|
|
@{{username}}
|
|
|
|
</h2>
|
2020-10-24 12:50:08 -07:00
|
|
|
<div>
|
2021-03-01 13:35:03 -08:00
|
|
|
<div class="text-end">
|
2020-12-08 14:14:40 -08:00
|
|
|
<nuxt-link v-if="$user() && $user().username === username" to="/editor"
|
|
|
|
class="btn btn-outline-primary btn-sm mb-2"
|
|
|
|
>
|
|
|
|
<Icon v="edit"/>
|
|
|
|
<T>profile.edit</T>
|
|
|
|
</nuxt-link>
|
|
|
|
</div>
|
2021-01-21 09:56:08 -08:00
|
|
|
<div v-if="Object.keys(profiles).length > 1" class="locale-list">
|
2020-12-06 08:15:08 -08:00
|
|
|
<a :href="`https://pronouns.page/@${username}`" v-if="$user() && $user().username === username"
|
2021-01-22 14:54:24 -08:00
|
|
|
class="btn btn-outline-secondary btn-sm mb-1 me-1"
|
2020-12-06 08:15:08 -08:00
|
|
|
>
|
|
|
|
<Icon v="external-link"/>
|
|
|
|
pronouns.page/@{{username}}
|
|
|
|
</a>
|
2021-01-21 09:56:08 -08:00
|
|
|
<br/>
|
2020-10-24 12:50:08 -07:00
|
|
|
<LocaleLink v-for="(options, locale) in locales" :key="locale" v-if="profiles[locale] !== undefined"
|
|
|
|
:locale="locale" :link="`/@${username}`"
|
2021-01-22 14:54:24 -08:00
|
|
|
:class="['btn', locale === config.locale ? 'btn-primary disabled' : 'btn-outline-primary', 'btn-sm', 'mb-1 me-1']">
|
2020-10-24 12:50:08 -07:00
|
|
|
{{options.name}}
|
|
|
|
</LocaleLink>
|
|
|
|
</div>
|
2020-10-17 09:19:11 -07:00
|
|
|
</div>
|
2020-10-23 11:24:43 -07:00
|
|
|
</div>
|
2020-10-16 11:17:50 -07:00
|
|
|
|
2020-10-25 05:05:52 -07:00
|
|
|
<section v-if="profile.age ||profile.description.trim().length">
|
2020-10-23 11:24:43 -07:00
|
|
|
<p v-for="line in profile.description.split('\n')" class="mb-1">
|
2021-04-12 04:57:18 -07:00
|
|
|
<Spelling escape :text="line"/>
|
2020-10-23 11:24:43 -07:00
|
|
|
</p>
|
2020-10-25 05:05:52 -07:00
|
|
|
<p v-if="profile.age">
|
|
|
|
<Icon v="birthday-cake"/>
|
|
|
|
{{ profile.age }}
|
|
|
|
</p>
|
2020-10-23 11:24:43 -07:00
|
|
|
</section>
|
2020-10-16 11:17:50 -07:00
|
|
|
|
2021-06-03 13:53:57 -07:00
|
|
|
<section v-if="profile.flags.length || Object.keys(profile.customFlags).length">
|
2020-10-23 11:24:43 -07:00
|
|
|
<ul class="list-inline">
|
2020-12-11 09:04:44 -08:00
|
|
|
<li v-for="flag in profile.flags" v-if="allFlags[flag]" class="list-inline-item pr-2">
|
2021-04-05 08:03:13 -07:00
|
|
|
<Flag :name="flag.startsWith('-') ? allFlags[flag] : $translateForPronoun(allFlags[flag], mainPronoun)"
|
|
|
|
:alt="allFlags[flag]"
|
|
|
|
:img="`/flags/${flag}.png`"
|
|
|
|
:terms="terms"/>
|
|
|
|
</li>
|
|
|
|
<li v-for="(desc, flag) in profile.customFlags" class="list-inline-item pr-2">
|
|
|
|
<Flag :name="desc"
|
|
|
|
:alt="desc"
|
|
|
|
:img="buildImageUrl(flag, 'flag')"
|
|
|
|
:terms="terms"
|
|
|
|
custom/>
|
2020-10-23 11:24:43 -07:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
|
2020-10-26 16:47:56 -07:00
|
|
|
<section v-if="profile.links.length">
|
2020-10-23 11:24:43 -07:00
|
|
|
<ul class="list-inline">
|
2020-10-26 16:47:56 -07:00
|
|
|
<li v-for="link in profile.links" class="list-inline-item pr-2">
|
|
|
|
<ProfileLink :link="link"/>
|
2020-10-23 11:24:43 -07:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section class="d-flex">
|
|
|
|
<div class="w-50" v-if="Object.keys(profile.names).length">
|
|
|
|
<h3>
|
|
|
|
<Icon v="signature"/>
|
|
|
|
<T>profile.names</T>
|
|
|
|
</h3>
|
2020-10-16 11:17:50 -07:00
|
|
|
|
2020-10-23 11:24:43 -07:00
|
|
|
<ul class="list-unstyled">
|
|
|
|
<li v-for="(opinion, name) in profile.names"><Opinion :word="name" :opinion="opinion"/></li>
|
2020-10-16 11:17:50 -07:00
|
|
|
</ul>
|
2020-10-23 11:24:43 -07:00
|
|
|
</div>
|
|
|
|
<div class="w-50" v-if="Object.keys(profile.pronouns).length">
|
|
|
|
<h3>
|
|
|
|
<Icon v="tags"/>
|
|
|
|
<T>profile.pronouns</T>
|
|
|
|
</h3>
|
2020-10-16 11:17:50 -07:00
|
|
|
|
2020-10-23 11:24:43 -07:00
|
|
|
<ul class="list-unstyled">
|
2020-11-10 15:47:44 -08:00
|
|
|
<li v-for="{link, pronoun, opinion} in pronounOpinions">
|
2021-03-09 07:36:17 -08:00
|
|
|
<Opinion :word="typeof pronoun === 'string' ? pronoun : (pronoun.name(glue) + (pronoun.smallForm ? '/' + pronoun.morphemes[pronoun.smallForm] : ''))" :opinion="opinion" :link="`/${link}`"/>
|
2020-10-24 12:50:08 -07:00
|
|
|
</li>
|
2020-10-23 11:24:43 -07:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</section>
|
2020-10-16 11:17:50 -07:00
|
|
|
|
2020-11-27 10:57:14 -08:00
|
|
|
<section class="clearfix">
|
2020-10-23 11:24:43 -07:00
|
|
|
<h3>
|
|
|
|
<Icon v="scroll-old"/>
|
|
|
|
<T>profile.words</T>
|
|
|
|
</h3>
|
2020-10-16 11:17:50 -07:00
|
|
|
|
2020-10-25 04:00:45 -07:00
|
|
|
<div>
|
2021-01-22 14:54:24 -08:00
|
|
|
<div v-for="group in profile.words" v-if="Object.keys(profile.words).length" class="float-start w-50 w-md-25">
|
2020-10-16 11:17:50 -07:00
|
|
|
<ul class="list-unstyled">
|
2020-10-23 11:24:43 -07:00
|
|
|
<li v-for="(opinion, word) in group"><Opinion :word="word" :opinion="opinion"/></li>
|
2020-10-16 11:17:50 -07:00
|
|
|
</ul>
|
|
|
|
</div>
|
2020-10-23 11:24:43 -07:00
|
|
|
</div>
|
|
|
|
</section>
|
2020-11-23 09:14:46 -08:00
|
|
|
|
|
|
|
<section>
|
|
|
|
<OpinionLegend/>
|
|
|
|
</section>
|
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>
|
2020-11-16 11:43:44 -08:00
|
|
|
<div v-else-if="Object.keys(profiles).length">
|
2020-10-28 08:22:29 -07:00
|
|
|
<h2 class="text-nowrap mb-3">
|
|
|
|
<Avatar :user="profiles[Object.keys(profiles)[0]]"/>
|
|
|
|
@{{username}}
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
<div class="list-group">
|
|
|
|
<LocaleLink v-for="(options, locale) in locales" :key="locale" v-if="profiles[locale] !== undefined"
|
|
|
|
: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>
|
|
|
|
<NotFound v-else/>
|
2020-10-16 11:17:50 -07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { head } from "../src/helpers";
|
2020-11-10 15:47:44 -08:00
|
|
|
import { pronouns } from "~/src/data";
|
|
|
|
import { buildPronoun } from "../src/buildPronoun";
|
2020-10-16 11:17:50 -07:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
2020-10-28 08:22:29 -07:00
|
|
|
return {
|
2020-10-16 11:17:50 -07:00
|
|
|
profiles: {},
|
2020-11-10 15:47:44 -08:00
|
|
|
glue: ' ' + this.$t('pronouns.or') + ' ',
|
2020-10-26 16:42:42 -07:00
|
|
|
allFlags: process.env.FLAGS,
|
2020-10-16 11:17:50 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async asyncData({ app, route }) {
|
|
|
|
return {
|
2020-11-05 02:50:22 -08:00
|
|
|
profiles: await app.$axios.$get(`/profile/get/${encodeURIComponent(route.params.pathMatch)}`),
|
2020-12-18 09:22:35 -08:00
|
|
|
terms: await app.$axios.$get(`/terms`),
|
2020-10-16 11:17:50 -07:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2021-01-01 12:11:37 -08:00
|
|
|
username() {
|
|
|
|
const base = this.$route.params.pathMatch;
|
|
|
|
|
|
|
|
if (!this.profile) {
|
|
|
|
return base;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.profile.username !== base && process.client) {
|
|
|
|
history.pushState(
|
|
|
|
'',
|
|
|
|
document.title,
|
|
|
|
'/@' + this.profile.username,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.profile.username;
|
|
|
|
},
|
2020-10-16 11:17:50 -07:00
|
|
|
profile() {
|
|
|
|
for (let locale in this.profiles) {
|
|
|
|
if (locale === this.config.locale) {
|
|
|
|
return this.profiles[locale];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
2020-11-10 15:47:44 -08:00
|
|
|
pronounOpinions() {
|
|
|
|
const pronounOpinions = [];
|
2020-10-24 12:50:08 -07:00
|
|
|
for (let pronoun in this.profile.pronouns) {
|
|
|
|
if (!this.profile.pronouns.hasOwnProperty(pronoun)) { continue; }
|
|
|
|
|
2021-05-12 13:53:25 -07:00
|
|
|
let link = decodeURIComponent(
|
2020-11-24 15:54:02 -08:00
|
|
|
pronoun
|
2020-12-05 13:01:12 -08:00
|
|
|
.trim()
|
2020-11-24 15:54:02 -08:00
|
|
|
.replace(new RegExp('^' + this.$base), '')
|
|
|
|
.replace(new RegExp('^' + this.$base.replace(/^https?:\/\//, '')), '')
|
|
|
|
.replace(new RegExp('^/'), '')
|
|
|
|
);
|
2021-05-12 13:53:25 -07:00
|
|
|
if (!link.startsWith(':')) {
|
|
|
|
link = link.toLowerCase();
|
|
|
|
}
|
2021-03-09 07:36:17 -08:00
|
|
|
|
2021-05-12 13:53:25 -07:00
|
|
|
if (link === this.config.pronouns.any || link === this.config.pronouns.avoiding) {
|
2021-03-09 07:36:17 -08:00
|
|
|
pronounOpinions.push({
|
|
|
|
link,
|
|
|
|
pronoun: link,
|
|
|
|
opinion: this.profile.pronouns[pronoun],
|
|
|
|
});
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-11-10 15:47:44 -08:00
|
|
|
const pronounEntity = buildPronoun(pronouns, link);
|
2020-10-24 12:50:08 -07:00
|
|
|
|
2020-11-10 15:47:44 -08:00
|
|
|
if (pronounEntity) {
|
|
|
|
pronounOpinions.push({
|
2020-10-24 12:50:08 -07:00
|
|
|
link,
|
2020-11-10 15:47:44 -08:00
|
|
|
pronoun: pronounEntity,
|
2020-11-12 07:32:58 -08:00
|
|
|
opinion: this.profile.pronouns[pronoun],
|
2020-10-24 12:50:08 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2020-11-10 15:47:44 -08:00
|
|
|
return pronounOpinions;
|
2020-10-24 12:50:08 -07:00
|
|
|
},
|
2020-12-08 14:14:40 -08:00
|
|
|
mainPronoun() {
|
|
|
|
let mainPronoun = buildPronoun(pronouns, this.config.profile.flags.defaultPronoun);
|
|
|
|
let mainOpinion = -1;
|
|
|
|
for (let {pronoun, opinion} of this.pronounOpinions) {
|
2021-03-09 07:36:17 -08:00
|
|
|
if (typeof pronoun === 'string') {
|
|
|
|
continue;
|
|
|
|
}
|
2020-12-08 14:14:40 -08:00
|
|
|
if (opinion === 2) {
|
|
|
|
opinion = 0.5;
|
|
|
|
}
|
|
|
|
if (opinion > mainOpinion) {
|
|
|
|
mainPronoun = pronoun;
|
|
|
|
mainOpinion = opinion;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return mainPronoun;
|
|
|
|
},
|
2020-10-16 11:17:50 -07:00
|
|
|
},
|
|
|
|
head() {
|
|
|
|
return head({
|
|
|
|
title: `@${this.username}`,
|
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
|
|
|
|
2020-10-16 11:17:50 -07:00
|
|
|
.avatar {
|
|
|
|
width: 100%;
|
|
|
|
max-width: 5rem;
|
|
|
|
max-height: 5rem;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
2021-01-21 09:56:08 -08:00
|
|
|
|
|
|
|
@include media-breakpoint-up('md', $grid-breakpoints) {
|
|
|
|
.locale-list {
|
|
|
|
max-width: 16rem;
|
|
|
|
text-align: right;
|
|
|
|
}
|
|
|
|
}
|
2020-10-16 11:17:50 -07:00
|
|
|
</style>
|