Added actor profile revisions.

This commit is contained in:
2024-10-22 03:12:42 +02:00
parent b5bef49f73
commit 3967745fb3
31 changed files with 1907 additions and 67 deletions

View File

@@ -1,10 +1,11 @@
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
import { redirect, render } from 'vike/abort'; /* eslint-disable-line import/extensions */
import { fetchActorsById } from '#/src/actors.js';
import { fetchScenes } from '#/src/scenes.js';
import { fetchMovies } from '#/src/movies.js';
import { curateScenesQuery } from '#/src/web/scenes.js';
import { curateMoviesQuery } from '#/src/web/movies.js';
import { fetchCountries } from '#/src/countries.js';
async function fetchReleases(pageContext) {
if (pageContext.routeParams.domain === 'movies') {
@@ -33,9 +34,16 @@ async function fetchReleases(pageContext) {
}
export async function onBeforeRender(pageContext) {
const [[actor], actorReleases] = await Promise.all([
const isEditing = pageContext._pageId === '/pages/actors/@actorId/edit';
if (isEditing && !pageContext.user) {
throw redirect(`/login?r=${encodeURIComponent(pageContext.urlOriginal)}`);
}
const [[actor], actorReleases, countries] = await Promise.all([
fetchActorsById([Number(pageContext.routeParams.actorId)], {}, pageContext.user),
fetchReleases(pageContext),
isEditing && fetchCountries(),
]);
if (!actor) {
@@ -44,9 +52,12 @@ export async function onBeforeRender(pageContext) {
return {
pageContext: {
title: actor.name,
title: isEditing
? `Editing '${actor.name}'`
: actor.name,
pageProps: {
actor,
countries,
...actorReleases,
},
},

View File

@@ -1,7 +1,7 @@
import { match } from 'path-to-regexp';
// import { resolveRoute } from 'vike/routing'; // eslint-disable-line import/extensions
const path = '/actor/:actorId/:actorSlug?/:domain(scenes|movies)?/:scope?/:page?';
const path = '/actor/:actorId(\\d+)/:actorSlug?/:domain(scenes|movies)?/:scope?/:page?';
const urlMatch = match(path, { decode: decodeURIComponent });
export default (pageContext) => {

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
export default '/actor/edit/@actorId/*';

View File

@@ -0,0 +1,62 @@
<template>
<div class="content">
<div class="revs-header">
<h2 class="heading">Revisions for "{{ scene.title }}"</h2>
<div class="revs-actions">
<a
:href="`/scene/edit/${scene.id}/${scene.slug}`"
class="link"
>Edit scene</a>
<a
:href="`/scene/${scene.id}/${scene.slug}`"
target="_blank"
class="link"
>Go to scene</a>
</div>
</div>
<Revisions context="scene" />
</div>
</template>
<script setup>
import { inject } from 'vue';
import Revisions from '#/components/edit/revisions.vue';
const pageContext = inject('pageContext');
const scene = pageContext.pageProps.scene;
</script>
<style scoped>
.content {
padding: 1rem;
flex-grow: 1;
}
.revs-header {
display: flex;
justify-content: space-between;
align-items: center;
.heading {
line-height: 1.5;
}
}
.revs-actions {
display: flex;
gap: 2rem;
flex-shrink: 0;
}
@media(--compact) {
.revs-header {
display: flex;
flex-direction: column;
margin-bottom: 1rem;
}
}
</style>

View File

@@ -0,0 +1,24 @@
import { fetchActorsById } from '#/src/actors.js';
import { fetchSceneRevisions } from '#/src/scenes.js';
export async function onBeforeRender(pageContext) {
const [actor] = await fetchActorsById([Number(pageContext.routeParams.actorId)], {}, pageContext.user);
const {
revisions,
} = await fetchSceneRevisions(null, {
sceneId: actor.id,
isFinalized: true,
limit: 100,
}, pageContext.user);
return {
pageContext: {
title: `Revisions for '${actor.name}'`,
pageProps: {
actor,
revisions,
},
},
};
}

View File

@@ -0,0 +1 @@
export default '/actor/revisions/@actorId/*';

View File

@@ -1 +0,0 @@
export default '/admin/@section/*';

View File

@@ -0,0 +1,24 @@
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
import { fetchActorRevisions } from '#/src/actors.js';
export async function onBeforeRender(pageContext) {
if (!pageContext.user || pageContext.user.role === 'user') {
throw render(404);
}
const {
revisions,
} = await fetchActorRevisions(null, {
isFinalized: false,
limit: 50,
}, pageContext.user);
return {
pageContext: {
title: pageContext.routeParams.section,
pageProps: {
revisions,
},
},
};
}

View File

@@ -0,0 +1,19 @@
import { match } from 'path-to-regexp';
const path = '/admin/:section/:domain(actors)';
const urlMatch = match(path, { decode: decodeURIComponent });
export default (pageContext) => {
const matched = urlMatch(pageContext.urlPathname);
if (matched) {
return {
routeParams: {
section: matched.params.section,
domain: matched.params.domain,
},
};
}
return false;
};

View File

@@ -0,0 +1,19 @@
import { match } from 'path-to-regexp';
const path = '/admin/:section/:domain(scenes)';
const urlMatch = match(path, { decode: decodeURIComponent });
export default (pageContext) => {
const matched = urlMatch(pageContext.urlPathname);
if (matched) {
return {
routeParams: {
section: matched.params.section,
domain: matched.params.domain,
},
};
}
return false;
};

View File

@@ -36,8 +36,11 @@
>
<img
v-if="network.hasLogo"
:src="network.type === 'network' || network.isIndependent || !network.parent ? `/logos/${network.slug}/thumbs/network.png` : `/logos/${network.parent.slug}/thumbs/${network.slug}.png`"
:src="network.type === 'network' || network.isIndependent || !network.parent
? `/logos/${network.slug}/thumbs/network.png`
: `/logos/${network.parent.slug}/thumbs/${network.slug}.png`"
:alt="network.name"
loading="lazy"
class="logo"
>
@@ -58,7 +61,7 @@
</template>
<script setup>
import { ref, inject } from 'vue';
import { ref, inject, onMounted } from 'vue';
import navigate from '#/src/navigate.js';
@@ -120,6 +123,12 @@ const sections = [
async function search() {
navigate('/channels', { q: query.value || undefined }, { redirect: true });
}
onMounted(() => {
window.addEventListener('load', (event) => {
console.log(event);
});
});
</script>
<style scoped>
@@ -194,6 +203,9 @@ async function search() {
height: 100%;
width: 100%;
object-fit: contain;
background-repeat: no-repeat;
background-size: contain;
background-position: center;
}
@media(--small-30) {

View File

@@ -676,7 +676,9 @@ function copySummary() {
.templates {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: .25rem 0;
margin-top: .5rem;
.icon {

View File

@@ -38,7 +38,7 @@
<li v-if="user.role !== 'user'">
<a
href="/admin/revisions"
href="/admin/revisions/scenes"
class="link"
>Go to revisions admin</a>
</li>
@@ -50,7 +50,7 @@
@submit.prevent
>
<div class="editor-header">
<h2 class="heading ellipsis">Edit scene #{{ scene.id }}</h2>
<h2 class="heading ellipsis">Edit scene #{{ scene.id }} - {{ scene.title }}</h2>
<a
:href="`/scene/${scene.id}/${scene.slug}`"