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>
|
2020-12-08 14:14:40 -08:00
|
|
|
<div class="text-right">
|
|
|
|
<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>
|
2020-10-24 12:50:08 -07:00
|
|
|
<div class="list-group" v-if="Object.keys(profiles).length > 1">
|
2020-12-06 08:15:08 -08:00
|
|
|
<a :href="`https://pronouns.page/@${username}`" v-if="$user() && $user().username === username"
|
|
|
|
class="list-group-item list-group-item-action small px-4 py-2 text-center"
|
|
|
|
>
|
|
|
|
<Icon v="external-link"/>
|
|
|
|
pronouns.page/@{{username}}
|
|
|
|
</a>
|
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}`"
|
2020-12-06 08:15:08 -08:00
|
|
|
:class="['list-group-item list-group-item-action small px-4 py-2 text-center', locale === config.locale ? 'active disabled' : '']">
|
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">
|
|
|
|
{{ line }}
|
|
|
|
</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
|
|
|
|
2020-10-26 16:47:56 -07:00
|
|
|
<section v-if="profile.flags.length">
|
2020-10-23 11:24:43 -07:00
|
|
|
<ul class="list-inline">
|
2020-10-26 16:47:56 -07:00
|
|
|
<li v-for="flag in profile.flags" class="list-inline-item pr-2">
|
2020-12-10 08:47:48 -08:00
|
|
|
<Flag :name="flag.startsWith('-') ? allFlags[flag] : $translateForPronoun(allFlags[flag], mainPronoun)" :alt="allFlags[flag]" :img="`/flags/${flag}.png`"/>
|
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">
|
2020-12-10 07:23:39 -08:00
|
|
|
<Opinion :word="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>
|
|
|
|
<div v-for="group in profile.words" v-if="Object.keys(profile.words).length" class="float-left 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>
|
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
|
|
|
username: this.$route.params.pathMatch,
|
|
|
|
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-10-16 11:17:50 -07:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
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; }
|
|
|
|
|
2020-11-24 15:54:02 -08:00
|
|
|
const link = decodeURIComponent(
|
|
|
|
pronoun
|
2020-12-04 14:26:59 -08:00
|
|
|
.toLowerCase()
|
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('^/'), '')
|
|
|
|
);
|
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) {
|
|
|
|
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;
|
|
|
|
border-left: 3px solid $primary;
|
|
|
|
padding-left: calc(#{$list-group-item-padding-x} - 2px);
|
|
|
|
}
|
|
|
|
}
|
2020-10-16 11:17:50 -07:00
|
|
|
</style>
|