2020-10-16 11:17:50 -07:00
|
|
|
<template>
|
2020-10-28 08:22:29 -07:00
|
|
|
<div v-if="profile" class="container">
|
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-11-03 14:11:01 -08:00
|
|
|
<nuxt-link v-if="$user() && $user().username === username" to="/editor"
|
2020-10-31 13:33:59 -07:00
|
|
|
class="btn btn-outline-primary btn-sm mb-2"
|
2020-10-24 12:50:08 -07:00
|
|
|
>
|
|
|
|
<Icon v="edit"/>
|
|
|
|
<T>profile.edit</T>
|
|
|
|
</nuxt-link>
|
|
|
|
<div class="list-group" v-if="Object.keys(profiles).length > 1">
|
|
|
|
<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 small px-3 py-2 text-center', locale === config.locale ? 'active disabled' : '']">
|
|
|
|
{{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">
|
|
|
|
<Flag :name="allFlags[flag]" :src="`/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">
|
|
|
|
<Opinion :word="pronoun.name(glue)" :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-10-23 11:24:43 -07:00
|
|
|
<section>
|
|
|
|
<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-10-16 11:17:50 -07:00
|
|
|
</div>
|
2020-10-28 08:22:29 -07:00
|
|
|
<div v-else-if="Object.keys(profiles).length" class="container">
|
|
|
|
<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-10 14:41:56 -08:00
|
|
|
const link = pronoun.replace(new RegExp('^' + this.$base), '').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,
|
|
|
|
opinion: this.profile.pronouns[pronounEntity],
|
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-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-10-28 08:22:29 -07:00
|
|
|
@import "assets/style";
|
|
|
|
|
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>
|