Added descriptions to actor profile page, using profiles for secondary photos.
This commit is contained in:
parent
e691aedc73
commit
c33ea6064e
|
@ -244,25 +244,25 @@
|
||||||
|
|
||||||
<div class="descriptions-container">
|
<div class="descriptions-container">
|
||||||
<div
|
<div
|
||||||
v-if="actor.descriptions && actor.descriptions.length > 0"
|
v-if="descriptions.length > 0"
|
||||||
class="descriptions"
|
class="descriptions"
|
||||||
>
|
>
|
||||||
<p
|
<p
|
||||||
v-for="description in actor.descriptions"
|
v-for="description in descriptions"
|
||||||
:key="`description-${description.entity.id}`"
|
:key="`description-${description.entity.id}`"
|
||||||
class="description"
|
class="description"
|
||||||
>
|
>
|
||||||
{{ description.text }}
|
{{ description.text }}
|
||||||
<a :href="`/${description.entity.type}/${description.entity.slug}`">
|
<a :href="`/${description.entity.type}/${description.entity.slug}`">
|
||||||
<img
|
<img
|
||||||
v-if="description.entity.type === 'network' || !description.entity.parent || description.entity.independent"
|
v-if="description.entity.type === 'network' || !description.entity.parent || description.entity.isIndependent"
|
||||||
:src="`/img/logos/${description.entity.slug}/thumbs/network.png`"
|
:src="`/logos/${description.entity.slug}/thumbs/network.png`"
|
||||||
class="description-logo"
|
class="description-logo"
|
||||||
>
|
>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
v-else
|
v-else
|
||||||
:src="`/img/logos/${description.entity.parent.slug}/thumbs/${description.entity.slug}.png`"
|
:src="`/logos/${description.entity.parent.slug}/thumbs/${description.entity.slug}.png`"
|
||||||
class="description-logo"
|
class="description-logo"
|
||||||
>
|
>
|
||||||
</a>
|
</a>
|
||||||
|
@ -325,6 +325,13 @@ const showExpand = [
|
||||||
'waist',
|
'waist',
|
||||||
'weight',
|
'weight',
|
||||||
].some((attribute) => !!props.actor[attribute]);
|
].some((attribute) => !!props.actor[attribute]);
|
||||||
|
|
||||||
|
const descriptions = Object.values(Object.fromEntries(props.actor.profiles
|
||||||
|
.filter((profile) => !!profile.description)
|
||||||
|
.map((profile) => [profile.descriptionHash, {
|
||||||
|
text: profile.description,
|
||||||
|
entity: profile.entity,
|
||||||
|
}])));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -72,13 +72,12 @@ const pageContext = inject('pageContext');
|
||||||
const { pageProps } = pageContext;
|
const { pageProps } = pageContext;
|
||||||
const { actor } = pageProps;
|
const { actor } = pageProps;
|
||||||
|
|
||||||
const photos = [
|
const photos = actor.profiles
|
||||||
actor.avatar && {
|
.filter((profile) => !!profile.avatar)
|
||||||
...actor.avatar,
|
.map((profile) => ({
|
||||||
isAvatar: true,
|
...profile.avatar,
|
||||||
},
|
isAvatar: profile.avatar.id === actor.avatar.id,
|
||||||
...actor.photos,
|
}));
|
||||||
].filter(Boolean);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
@ -6,6 +6,8 @@ import { knexOwner as knex, knexManticore } from './knex.js';
|
||||||
import { utilsApi } from './manticore.js';
|
import { utilsApi } from './manticore.js';
|
||||||
import { HttpError } from './errors.js';
|
import { HttpError } from './errors.js';
|
||||||
import { fetchCountriesByAlpha2 } from './countries.js';
|
import { fetchCountriesByAlpha2 } from './countries.js';
|
||||||
|
import { curateEntity } from './entities.js';
|
||||||
|
import { curateMedia } from './media.js';
|
||||||
import { curateStash } from './stashes.js';
|
import { curateStash } from './stashes.js';
|
||||||
import escape from '../utils/escape-manticore.js';
|
import escape from '../utils/escape-manticore.js';
|
||||||
import slugify from '../utils/slugify.js';
|
import slugify from '../utils/slugify.js';
|
||||||
|
@ -53,25 +55,13 @@ export function curateActor(actor, context = {}) {
|
||||||
alias: actor.residence_country_alias,
|
alias: actor.residence_country_alias,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
avatar: actor.avatar && {
|
avatar: curateMedia(actor.avatar),
|
||||||
id: actor.avatar.id,
|
profiles: context.profiles?.map((profile) => ({
|
||||||
path: actor.avatar.path,
|
id: profile.id,
|
||||||
thumbnail: actor.avatar.thumbnail,
|
description: profile.description,
|
||||||
lazy: actor.avatar.lazy,
|
descriptionHash: profile.description_hash,
|
||||||
width: actor.avatar.width,
|
entity: curateEntity({ ...profile.entity, parent: profile.parent_entity }),
|
||||||
height: actor.avatar.height,
|
avatar: curateMedia(profile.avatar),
|
||||||
isS3: actor.avatar.is_s3,
|
|
||||||
credit: actor.avatar.credit,
|
|
||||||
},
|
|
||||||
photos: context.photos?.map((photo) => ({
|
|
||||||
id: photo.id,
|
|
||||||
path: photo.path,
|
|
||||||
thumbnail: photo.thumbnail,
|
|
||||||
lazy: photo.lazy,
|
|
||||||
width: photo.width,
|
|
||||||
height: photo.height,
|
|
||||||
isS3: photo.is_s3,
|
|
||||||
credit: photo.credit,
|
|
||||||
})),
|
})),
|
||||||
createdAt: actor.created_at,
|
createdAt: actor.created_at,
|
||||||
updatedAt: actor.updated_at,
|
updatedAt: actor.updated_at,
|
||||||
|
@ -109,7 +99,7 @@ export function sortActorsByGender(actors, context = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
||||||
const [actors, photos, stashes] = await Promise.all([
|
const [actors, profiles, stashes] = await Promise.all([
|
||||||
knex('actors')
|
knex('actors')
|
||||||
.select(
|
.select(
|
||||||
'actors.*',
|
'actors.*',
|
||||||
|
@ -129,13 +119,13 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
knex('actors_profiles')
|
knex('actors_profiles')
|
||||||
.select('actors_profiles.actor_id', 'media.*')
|
.select('actors_profiles.*', knex.raw('row_to_json(entities) as entity'), knex.raw('row_to_json(parents) as parent_entity'), knex.raw('row_to_json(media) as avatar'))
|
||||||
.leftJoin('actors', 'actors.id', 'actors_profiles.actor_id')
|
.leftJoin('actors', 'actors.id', 'actors_profiles.actor_id')
|
||||||
|
.leftJoin('entities', 'entities.id', 'actors_profiles.entity_id')
|
||||||
|
.leftJoin('entities as parents', 'parents.id', 'entities.parent_id')
|
||||||
.leftJoin('media', 'media.id', 'actors_profiles.avatar_media_id')
|
.leftJoin('media', 'media.id', 'actors_profiles.avatar_media_id')
|
||||||
.whereIn('actor_id', actorIds)
|
.whereIn('actor_id', actorIds)
|
||||||
.whereNotNull('actors_profiles.avatar_media_id')
|
.groupBy('actors_profiles.id', 'entities.id', 'parents.id', 'media.id'),
|
||||||
.whereNot('actors_profiles.avatar_media_id', knex.raw('actors.avatar_media_id')) // don't include main avatar as photo
|
|
||||||
.groupBy('actors_profiles.actor_id', 'media.id', 'media.hash'),
|
|
||||||
reqUser
|
reqUser
|
||||||
? knex('stashes_actors')
|
? knex('stashes_actors')
|
||||||
.leftJoin('stashes', 'stashes.id', 'stashes_actors.stash_id')
|
.leftJoin('stashes', 'stashes.id', 'stashes_actors.stash_id')
|
||||||
|
@ -161,7 +151,7 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
||||||
|
|
||||||
return curateActor(actor, {
|
return curateActor(actor, {
|
||||||
stashes: stashes.filter((stash) => stash.actor_id === actor.id),
|
stashes: stashes.filter((stash) => stash.actor_id === actor.id),
|
||||||
photos: photos.filter((photo) => photo.actor_id === actor.id),
|
profiles: profiles.filter((profile) => profile.actor_id === actor.id),
|
||||||
append: options.append,
|
append: options.append,
|
||||||
});
|
});
|
||||||
}).filter(Boolean);
|
}).filter(Boolean);
|
||||||
|
|
|
@ -11,5 +11,6 @@ export function curateMedia(media) {
|
||||||
isS3: media.is_s3,
|
isS3: media.is_s3,
|
||||||
width: media.width,
|
width: media.width,
|
||||||
height: media.height,
|
height: media.height,
|
||||||
|
index: media.index,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,27 +8,10 @@ import { fetchActorsById, curateActor, sortActorsByGender } from './actors.js';
|
||||||
import { fetchTagsById } from './tags.js';
|
import { fetchTagsById } from './tags.js';
|
||||||
import { fetchEntitiesById } from './entities.js';
|
import { fetchEntitiesById } from './entities.js';
|
||||||
import { curateStash } from './stashes.js';
|
import { curateStash } from './stashes.js';
|
||||||
|
import { curateMedia } from './media.js';
|
||||||
import escape from '../utils/escape-manticore.js';
|
import escape from '../utils/escape-manticore.js';
|
||||||
import promiseProps from '../utils/promise-props.js';
|
import promiseProps from '../utils/promise-props.js';
|
||||||
|
|
||||||
function curateMedia(media) {
|
|
||||||
if (!media) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: media.id,
|
|
||||||
path: media.path,
|
|
||||||
thumbnail: media.thumbnail,
|
|
||||||
lazy: media.lazy,
|
|
||||||
hash: media.hash,
|
|
||||||
isS3: media.is_s3,
|
|
||||||
width: media.width,
|
|
||||||
height: media.height,
|
|
||||||
index: media.index,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function curateScene(rawScene, assets) {
|
function curateScene(rawScene, assets) {
|
||||||
if (!rawScene) {
|
if (!rawScene) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue