Reinitialized commit. Update and actors overview with some filters.

This commit is contained in:
2023-12-30 06:29:53 +01:00
commit 3f099b5e95
1208 changed files with 134732 additions and 0 deletions

14
pages/_error/+Page.vue Normal file
View File

@@ -0,0 +1,14 @@
<template>
<div v-if="is404">
<h1>404 Page Not Found</h1>
<p>This page could not be found.</p>
</div>
<div v-else>
<h1>500 Internal Error</h1>
<p>Something went wrong.</p>
</div>
</template>
<script setup>
defineProps(['is404'])
</script>

13
pages/about/+Page.vue Normal file
View File

@@ -0,0 +1,13 @@
<template>
<h1>About</h1>
<p>Example of app using Vike.</p>
</template>
<style>
code {
font-family: monospace;
background-color: #eaeaea;
padding: 3px 5px;
border-radius: 4px;
}
</style>

173
pages/actors/+Page.vue Normal file
View File

@@ -0,0 +1,173 @@
<template>
<div class="page">
<form
class="filters"
@submit.prevent
>
<div class="filter">
<input
v-model="q"
type="search"
placeholder="Search actors"
class="input search"
@search="search"
>
</div>
<div class="filter">
<RangeFilter
label="age"
:min="18"
:max="100"
:value="filters.age"
:disabled="!filters.ageRequired"
@enable="(checked) => updateFilter('ageRequired', checked, filters.ageRequired !== checked)"
@input="(range) => updateFilter('age', range, false)"
@change="(range) => updateFilter('age', range, true)"
>
<template #start><Icon icon="leaf" /></template>
<template #end><Icon icon="tree3" /></template>
</RangeFilter>
</div>
<div class="filter">
<RangeFilter
label="height"
:min="50"
:max="220"
:value="filters.height"
:disabled="!filters.heightRequired"
unit="cm"
@enable="(checked) => updateFilter('heightRequired', checked, filters.heightRequired !== checked)"
@input="(range) => updateFilter('height', range, false)"
@change="(range) => updateFilter('height', range, true)"
>
<template #start><Icon icon="height-short" /></template>
<template #end><Icon icon="height" /></template>
</RangeFilter>
</div>
<div class="filter">
<RangeFilter
label="weight"
:min="30"
:max="200"
:value="filters.weight"
:disabled="!filters.weightRequired"
unit="kg"
@enable="(checked) => updateFilter('weightRequired', checked, filters.weightRequired !== checked)"
@input="(range) => updateFilter('weight', range, false)"
@change="(range) => updateFilter('weight', range, true)"
>
<template #start><Icon icon="meter-slow" /></template>
<template #end><Icon icon="meter-fast" /></template>
</RangeFilter>
</div>
<div class="filter">
<Checkbox
:checked="avatarRequired"
label="Require photo"
@change="(checked) => { avatarRequired = checked; search(); }"
/>
</div>
</form>
<ul class="actors nolist">
<li
v-for="actor in actors"
:key="`actor-${actor.id}`"
>
<ActorTile
:actor="actor"
/>
</li>
</ul>
</div>
</template>
<script setup>
import { ref, inject } from 'vue';
import navigate from '#/src/navigate.js';
import { get } from '#/src/api.js';
import ActorTile from '#/components/actors/tile.vue';
import Checkbox from '#/components/form/checkbox.vue';
import RangeFilter from '#/components/filters/range.vue';
const actors = ref([]);
const { pageProps, urlParsed } = inject('pageContext');
actors.value = pageProps.actors;
const q = ref(urlParsed.search.q);
const filters = ref({
ageRequired: !!urlParsed.search.age,
age: urlParsed.search.age?.split(',').map((age) => Number(age)) || [18, 100],
heightRequired: !!urlParsed.search.height,
height: urlParsed.search.height?.split(',').map((height) => Number(height)) || [50, 220],
weightRequired: !!urlParsed.search.weight,
weight: urlParsed.search.weight?.split(',').map((weight) => Number(weight)) || [30, 200],
});
const avatarRequired = ref(Object.hasOwn(urlParsed.search, 'avatar'));
async function search() {
const query = {
q: q.value || undefined,
avatar: avatarRequired.value || undefined,
age: filters.value.ageRequired ? filters.value.age.join(',') : undefined,
height: filters.value.heightRequired ? filters.value.height.join(',') : undefined,
weight: filters.value.weightRequired ? filters.value.weight.join(',') : undefined,
};
navigate('/actors', query, { redirect: false });
const res = await get('/actors', query);
actors.value = res.actors;
}
function updateFilter(prop, value, reload = true) {
filters.value[prop] = value;
if (reload) {
search();
}
}
</script>
<style scoped>
.page {
height: 100%;
display: flex;
overflow: hidden;
}
.filters {
flex-shrink: 0;
padding: .5rem 0;
border-right: solid 1px var(--shadow-weak-30);
overflow-y: auto;
.input {
width: 100%;
}
}
.filter {
padding: .5rem;
}
.actors {
display: grid;
flex-grow: 1;
grid-template-columns: repeat(auto-fill, 10rem);
gap: .25rem;
padding: 1rem;
overflow-y: auto;
}
</style>

View File

@@ -0,0 +1,27 @@
import { fetchActors } from '#/src/actors.js';
export async function onBeforeRender(pageContext) {
const query = pageContext.urlParsed.search;
const { actors, limit, total } = await fetchActors({
query: query.q,
requireAvatar: Object.hasOwn(query, 'avatar'),
age: query.age?.split(',').map((age) => Number(age)),
height: query.height?.split(',').map((height) => Number(height)),
weight: query.weight?.split(',').map((weight) => Number(weight)),
}, {
page: Number(pageContext.routeParams.page) || 1,
limit: Number(pageContext.urlParsed.search.limit) || 50,
});
return {
pageContext: {
title: 'actors',
pageProps: {
actors,
limit,
total,
},
},
};
}

View File

@@ -0,0 +1,11 @@
<template>
<div class="page">
<h2>Actor</h2>
</div>
</template>
<script setup>
import { inject } from 'vue';
const { routeParams } = inject('pageContext');
</script>

View File

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

12
pages/index/+Page.vue Normal file
View File

@@ -0,0 +1,12 @@
<template>
<h1>Welcome</h1>
This page is:
<ul>
<li>Rendered to HTML.</li>
<li>Interactive. <Counter /></li>
</ul>
</template>
<script setup>
import Counter from './Counter.vue'
</script>

8
pages/index/Counter.vue Normal file
View File

@@ -0,0 +1,8 @@
<template>
<button type="button" @click="state.count++">Counter {{ state.count }}</button>
</template>
<script setup>
import { reactive } from 'vue'
const state = reactive({ count: 0 })
</script>

400
pages/scene/+Page.vue Normal file
View File

@@ -0,0 +1,400 @@
<template>
<div class="page">
<div class="content">
<div class="banner">
<div class="poster-container">
<img
v-if="scene.poster"
:src="scene.poster.isS3 ? `https://cdndev.traxxx.me/${scene.poster.thumbnail}` : `/media/${scene.poster.thumbnail}`"
:style="{ 'background-image': scene.poster.isS3 ? `url(https://cdndev.traxxx.me/${scene.poster.lazy})` : `url(/media/${scene.poster.lazy})` }"
:width="scene.poster.width"
:height="scene.poster.height"
class="poster"
>
</div>
<div
v-if="scene.photos.length > 0"
class="album"
>
<div
v-for="photo in scene.photos"
:key="`photo-${photo.id}`"
class="photo-container"
>
<img
:src="photo.isS3 ? `https://cdndev.traxxx.me/${photo.thumbnail}` : `/media/${photo.thumbnail}`"
:style="{ 'background-image': photo.isS3 ? `url(https://cdndev.traxxx.me/${photo.lazy})` : `url(/media/${photo.lazy})` }"
:width="photo.width"
:height="photo.height"
class="photo"
>
</div>
</div>
</div>
<div class="meta">
<div class="entity">
<Link
v-if="scene.channel"
:href="`/${scene.channel.type}/${scene.channel.slug}`"
class="channel-link entity-link"
>
<img
v-if="scene.channel.hasLogo"
:src="scene.channel.isIndependent || !scene.network ? `/logos/${scene.channel.slug}/network.png` : `/logos/${scene.network.slug}/${scene.channel.slug}.png`"
class="channel-logo entity-logo"
>
</Link>
<template v-if="!scene.channel.isIndependent && scene.network">
by
<Link
:href="`/${scene.network.type}/${scene.network.slug}`"
class="network-link entity-link"
>
<img
v-if="scene.network.hasLogo"
:src="`/logos/${scene.network.slug}/network.png`"
class="network-logo entity-logo"
>
</Link>
</template>
</div>
<time
:datetime="scene.effectiveDate.toISOString()"
class="date"
>{{ formatDate(scene.effectiveDate, 'MMMM d, y') }}</time>
</div>
<div class="header">
<h2
:title="scene.title"
class="title"
>{{ scene.title }}</h2>
<div class="actions">
<div class="view">
<button
v-if="scene.photos.length > 0"
class="button view nolink"
>View photos</button>
<Link
v-if="scene.url"
:href="scene.url"
target="_blank"
class="button watch nolink"
>Watch scene</Link>
</div>
<div class="bookmarks">
<Icon icon="folder-heart" />
<Icon icon="heart8" />
</div>
</div>
</div>
<div class="info">
<ul class="actors nolist">
<li
v-for="actor in scene.actors"
:key="`actor-${actor.id}`"
class="actor"
>
<ActorTile :actor="actor" />
</li>
</ul>
<ul class="tags nolist">
<li
v-for="tag in scene.tags"
:key="`tag-${tag.id}`"
>
<Link
:href="`/tag/${tag.slug}`"
class="tag nolink"
>{{ tag.name }}</Link>
</li>
</ul>
<div class="section">
<h3 class="heading">Description</h3>
<p
v-if="scene.description"
class="description"
>{{ scene.description }}</p>
</div>
<div class="section details">
<div
v-if="scene.duration"
class="detail"
>
<h3 class="heading">Duration</h3>
{{ formatDuration(scene.duration) }}
</div>
<div
v-if="scene.directors.length > 0"
class="detail"
>
<h3 class="heading">Director</h3>
{{ scene.directors.map((director) => director.name).join(', ') }}
</div>
</div>
<div class="section details">
<div class="detail">
<h3 class="heading">Added</h3>
<span class="added-date">{{ formatDate(scene.createdAt, 'yyyy-MM-dd hh:mm') }}</span> <span class="added-batch">batch #{{ scene.createdBatchId }}</span>
</div>
<div
v-if="scene.comment"
class="detail"
>
<h3 class="heading">Comment</h3>
{{ scene.comment }}
</div>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { inject } from 'vue';
import { formatDate, formatDuration } from '#/src/format.js';
import Icon from '../../components/icon/icon.vue';
import ActorTile from '../../components/actors/tile.vue';
const { pageProps } = inject('pageContext');
const { scene } = pageProps;
</script>
<style scoped>
.page {
display: flex;
justify-content: center;
background: var(--background-base-10);
}
.content {
width: 100%;
max-width: 1200px;
display: flex;
flex-direction: column;
}
.banner {
height: 18rem;
display: flex;
margin-top: .5rem;
}
.poster {
height: 100%;
width: auto;
border-radius: .25rem .25rem 0 0;
}
.poster,
.photo {
object-fit: cover;
background-size: cover;
background-position: center;
box-shadow: 0 0 3px var(--shadow-weak-10);
}
.album {
height: 100%;
flex-grow: 1;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
gap: .5rem;
padding: 0 .5rem .5rem .5rem;
overflow-y: auto;
}
.photo-container {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.photo {
width: 100%;
height: 100%;
border-radius: .25rem;
}
.meta {
display: flex;
justify-content: space-between;
align-items: center;
background: var(--grey-dark-40);
border-radius: 0 0 .25rem .25rem;
color: var(--text-light);
}
.entity {
display: flex;
align-items: center;
font-weight: bold;
color: var(--highlight);
}
.entity-link {
padding: .5rem 1rem;
}
.entity-logo {
height: 1.5rem;
}
.date {
padding: 1rem;
font-weight: bold;
}
.info,
.header {
border: solid 1px var(--shadow-weak-40);
border-top: none;
border-bottom: none;
}
.header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 1rem 1.5rem 1rem;
}
.title {
margin: 0 1rem 0 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.actions {
display: flex;
align-items: center;
justify-content: space-between;
.icon {
width: 1.5rem;
height: 1.5rem;
fill: var(--shadow);
}
.button {
flex-shrink: 0;
padding: .75rem;
margin-right: .5rem;
}
}
.bookmarks {
display: flex;
gap: 1rem;
margin-left: .5rem;
}
.view {
display: flex;
}
.watch {
background: var(--primary);
color: var(--text-light);
}
.info {
padding: 0 1rem;
}
.actors,
.tags {
margin-bottom: 1rem;
}
.actors {
display: flex;
gap: .5rem;
overflow-x: auto;
flex-wrap: nowrap;
}
.tag {
padding: .5rem;
border-radius: .25rem;
margin: 0 .25rem .25rem 0;
background: var(--background);
box-shadow: 0 0 3px var(--shadow-weak-30);
&:hover {
color: var(--primary);
box-shadow: 0 0 3px var(--shadow-weak-20);
cursor: pointer;
}
}
.section {
margin-bottom: 1rem;
}
.heading {
color: var(--primary);
margin: 0 0 .5rem 0;
font-size: .9rem;
}
.details {
display: flex;
gap: 1rem;
}
.description {
font-size: 1rem;
line-height: 1.5;
text-align: justify;
margin: 0;
}
.added-batch {
color: var(--shadow);
}
@media (--compact) {
.header {
flex-direction: column-reverse;
}
.actions {
width: 100%;
justify-content: space-between;
margin-bottom: 1.5rem;
}
.view {
flex-direction: row-reverse;
}
.title {
width: 100%;
margin-left: 1rem;
}
.meta {
border-radius: 0;
}
}
</style>

View File

@@ -0,0 +1,14 @@
import { fetchScenesById } from '../../src/scenes';
export async function onBeforeRender(pageContext) {
const [scene] = await fetchScenesById([Number(pageContext.routeParams.sceneId)]);
return {
pageContext: {
title: scene.title,
pageProps: {
scene,
},
},
};
}

1
pages/scene/+route.js Normal file
View File

@@ -0,0 +1 @@
export default '/scene/@sceneId/*';

16
pages/updates/+Page.vue Normal file
View File

@@ -0,0 +1,16 @@
<template>
<div>
<Scenes
:scenes="scenes"
/>
</div>
</template>
<script setup>
import { inject } from 'vue';
import Scenes from '../../components/scenes/scenes.vue';
const { pageProps } = inject('pageContext');
const { scenes } = pageProps;
</script>

View File

@@ -0,0 +1,30 @@
import { fetchLatest, fetchUpcoming, fetchNew } from '../../src/scenes';
async function fetchScenes(scope, page, limit) {
if (scope === 'new') {
return fetchNew(page, { limit });
}
if (scope === 'upcoming') {
return fetchUpcoming(page, { limit });
}
return fetchLatest(page, { limit });
}
export async function onBeforeRender(pageContext) {
const { scenes, limit, total } = await fetchScenes(pageContext.routeParams.scope, Number(pageContext.routeParams.page) || 1, Number(pageContext.urlParsed.search.limit) || 30);
// console.log(scenes);
return {
pageContext: {
title: pageContext.routeParams.scope,
pageProps: {
scenes,
limit,
total,
},
},
};
}

34
pages/updates/+route.js Normal file
View File

@@ -0,0 +1,34 @@
import { resolveRoute } from 'vike/routing';
export default (pageContext) => {
{
const result = resolveRoute('/updates/@scope/@page', pageContext.urlPathname);
if (result.match) {
return result;
}
}
{
const result = resolveRoute('/updates/@scope', pageContext.urlPathname);
if (result.match) {
result.routeParams.page = '1';
return result;
}
}
{
const result = resolveRoute('/updates', pageContext.urlPathname);
if (result.match) {
result.routeParams.scope = 'latest';
result.routeParams.page = '1';
return result;
}
}
return false;
};