2020-10-16 11:17:50 -07:00
|
|
|
<template>
|
2020-11-16 11:43:44 -08:00
|
|
|
<div v-if="profile">
|
2021-06-17 13:24:15 -07:00
|
|
|
<section v-if="$isGranted('users') && profile.bannedReason">
|
|
|
|
<div class="alert alert-warning">
|
|
|
|
<p class="h4">
|
|
|
|
<Icon v="ban"/>
|
|
|
|
{{$t('ban.banned')}}
|
|
|
|
</p>
|
|
|
|
<p class="mb-0">{{profile.bannedReason}}</p>
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-06-16 07:08:38 -07:00
|
|
|
|
2021-07-10 07:46:29 -07:00
|
|
|
<Profile :profile="profile" :terms="terms">
|
|
|
|
<div v-if="Object.keys(profiles).length > 1">
|
|
|
|
<LocaleLink v-for="(options, locale) in locales" :key="locale" v-if="profiles[locale] !== undefined"
|
|
|
|
:locale="locale" :link="`/@${profile.username}`"
|
|
|
|
: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-10 07:46:29 -07:00
|
|
|
<div v-if="$user() && $user().username === profile.username">
|
|
|
|
<nuxt-link to="/editor"
|
|
|
|
class="btn btn-primary btn-sm mb-2 mx-1"
|
|
|
|
>
|
|
|
|
<Icon v="edit"/>
|
|
|
|
<T>profile.edit</T>
|
|
|
|
</nuxt-link>
|
|
|
|
<a :href="`https://pronouns.page/@${profile.username}`" v-if="Object.keys(profiles).length > 1"
|
|
|
|
class="btn btn-outline-secondary btn-sm mb-2 mx-1"
|
|
|
|
>
|
|
|
|
<Icon v="external-link"/>
|
|
|
|
pronouns.page/@{{profile.username}}
|
|
|
|
</a>
|
2020-10-23 11:24:43 -07:00
|
|
|
</div>
|
2021-07-10 07:46:29 -07:00
|
|
|
<div v-if="$user() && $user().username === profile.username">
|
|
|
|
<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-07-10 07:46:29 -07:00
|
|
|
</Profile>
|
2021-04-04 13:45:42 -07:00
|
|
|
|
2021-06-16 10:18:51 -07:00
|
|
|
<client-only>
|
|
|
|
<section v-if="$isGranted('users')">
|
|
|
|
<div class="alert alert-warning">
|
2021-07-10 03:03:21 -07:00
|
|
|
<textarea v-model="profile.bannedReason" class="form-control" rows="3" :placeholder="$t('ban.reason') + ' ' + $t('ban.visible')" :disabled="saving"></textarea>
|
2021-06-16 10:18:51 -07:00
|
|
|
<button class="btn btn-danger d-block w-100 mt-2" :disabled="saving" @click="ban">
|
|
|
|
<Icon v="ban"/>
|
|
|
|
{{$t('ban.action')}}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</client-only>
|
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>
|
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>
|
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-16 07:08:38 -07:00
|
|
|
saving: false,
|
2021-06-17 14:10:26 -07:00
|
|
|
terms: [],
|
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
|
|
|
};
|
|
|
|
},
|
2021-06-17 14:10:26 -07:00
|
|
|
async mounted() {
|
|
|
|
if (this.config.nouns.terms.enabled) {
|
|
|
|
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() {
|
|
|
|
for (let locale in this.profiles) {
|
|
|
|
if (locale === this.config.locale) {
|
|
|
|
return this.profiles[locale];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
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
|
|
|
},
|
2021-06-16 07:08:38 -07:00
|
|
|
methods: {
|
|
|
|
async ban() {
|
|
|
|
await this.$confirm(this.$t('ban.confirm', {username: this.username}), 'danger');
|
|
|
|
this.saving = true;
|
|
|
|
try {
|
|
|
|
await this.$post(`/admin/ban/${encodeURIComponent(this.username)}`, {
|
|
|
|
reason: this.profile.bannedReason,
|
|
|
|
});
|
|
|
|
window.location.reload();
|
|
|
|
} finally {
|
|
|
|
this.saving = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
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
|
|
|
|
|
|
|
.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>
|