Compare commits

...

3 Commits

30 changed files with 1035 additions and 1164 deletions

View File

@ -26,7 +26,7 @@
flex-shrink: 0;
align-items: stretch;
box-sizing: border-box;
padding: .5rem 0 .5rem .5rem;
padding: .5rem;
border: none;
border-radius: .25rem;
background: var(--background);
@ -57,16 +57,30 @@
}
.button-label {
margin-right: .75rem;
margin-right: .25rem;
}
.button-submit {
color: var(--primary);
background: var(--primary);
color: var(--text-light);
justify-content: center;
&:hover:not(:disabled) {
background: var(--primary-dark-10);
}
&:disabled {
background: var(--shadow-weak-10);
}
}
.button-primary {
background: var(--primary);
color: var(--text-light);
justify-content: center;
&:hover:not(:disabled) {
background: var(--primary);
cursor: pointer;
}
&:disabled {

View File

@ -1,4 +1,5 @@
:root {
--primary-dark-10: #e54485;
--primary: #f65596;
--primary-light-10: #f075a6;
--primary-light-30: #f7c9dc;

View File

@ -0,0 +1,6 @@
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<title>pen6</title>
<path d="M16 2.5c0-1.381-1.119-2.5-2.5-2.5-0.818 0-1.544 0.393-2 1l-9 9 3.5 3.5 9-9c0.607-0.456 1-1.182 1-2z"></path>
<path d="M0 16l1.5-5 3.5 3.5z"></path>
</svg>

After

Width:  |  Height:  |  Size: 315 B

View File

@ -0,0 +1,6 @@
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<title>pencil5</title>
<path d="M12 8.5v5.5h-10v-10h5.5l2-2h-8c-0.825 0-1.5 0.675-1.5 1.5v11c0 0.825 0.675 1.5 1.5 1.5h11c0.825 0 1.5-0.675 1.5-1.5v-8l-2 2z"></path>
<path d="M13.5 0l-9.5 9.5v2.5h2.5l9.5-9.5c0-1.5-1-2.5-2.5-2.5z"></path>
</svg>

After

Width:  |  Height:  |  Size: 376 B

View File

@ -0,0 +1,6 @@
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<title>pencil7</title>
<path d="M12 8.5v5.5h-10v-10h5.5l2-2h-8c-0.825 0-1.5 0.675-1.5 1.5v11c0 0.825 0.675 1.5 1.5 1.5h11c0.825 0 1.5-0.675 1.5-1.5v-8l-2 2z"></path>
<path d="M13.5 0l-9.5 9.5v2.5h2.5l9.5-9.5c0-1.5-1-2.5-2.5-2.5zM6.5 10l-0.75-0.75 7.5-7.5 0.75 0.75-7.5 7.5z"></path>
</svg>

After

Width:  |  Height:  |  Size: 421 B

View File

@ -28,18 +28,13 @@
>
</Link>
<Icon
v-show="favorited"
icon="heart7"
class="heart favorited"
@click.native.stop="unstash"
/>
<Icon
v-show="!favorited && user"
icon="heart8"
class="heart"
@click.native.stop="stash"
<Heart
domain="actors"
:item="actor"
:show-secondary="false"
class="light tiled"
@stashed="(stash) => { favorited = stash.isPrimary ? true : favorited; }"
@unstashed="(stash) => { favorited = stash.isPrimary ? false : favorited; }"
/>
</div>
@ -79,9 +74,8 @@
import { ref, inject } from 'vue';
import { formatDate } from '#/utils/format.js';
import { post, del } from '#/src/api.js';
import events from '#/src/events.js';
import Heart from '#/components/stashes/heart.vue';
import Gender from './gender.vue';
const props = defineProps({
@ -95,49 +89,7 @@ const pageContext = inject('pageContext');
const { user } = pageContext;
const pageStash = pageContext.pageProps.stash;
// console.log(props.actor);
const favorited = ref(props.actor.stashes?.some((sceneStash) => sceneStash.primary) || false);
async function stash() {
try {
favorited.value = true;
await post(`/stashes/${user.primaryStash.id}/actors`, { actorId: props.actor.id });
events.emit('feedback', {
type: 'success',
message: `${props.actor.name} stashed to ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = false;
events.emit('feedback', {
type: 'error',
message: `Failed to stash ${props.actor.name} to ${user.primaryStash.name}`,
});
}
}
async function unstash() {
try {
favorited.value = false;
await del(`/stashes/${user.primaryStash.id}/actors/${props.actor.id}`);
events.emit('feedback', {
type: 'remove',
message: `${props.actor.name} unstashed from ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = true;
console.error(error);
events.emit('feedback', {
type: 'error',
message: `Failed to unstash ${props.actor.name} from ${user.primaryStash.name}`,
});
}
}
const favorited = ref(props.actor.stashes?.some((sceneStash) => sceneStash.isPrimary) || false);
</script>
<style scoped>
@ -157,6 +109,10 @@ async function unstash() {
.name {
color: var(--primary);
}
:deep(.bookmarks) .icon:not(.favorited):not(:hover) {
fill: var(--text-light);
}
}
&.unstashed {
@ -205,26 +161,6 @@ async function unstash() {
opacity: .1;
}
.icon.heart {
width: 2rem;
height: 1.5rem;
position: absolute;
top: 0;
right: 0;
padding: .5rem .5rem 1rem 1rem;
fill: var(--highlight-strong-10);
filter: drop-shadow(0 0 3px var(--shadow));
&:hover {
cursor: pointer;
fill: var(--primary);
}
&.favorited {
fill: var(--primary);
}
}
.details {
width: 100%;
height: 1.5rem;

View File

@ -68,6 +68,14 @@ const activePage = computed(() => pageContext.urlParsed.pathname.split('/')[1]);
font-weight: bold;
font-size: .9rem;
&:first-child {
padding-left: .5rem;
}
&:last-child {
padding-right: .5rem;
}
&:hover {
cursor: pointer;

View File

@ -67,10 +67,13 @@
placeholder="Search"
class="input"
@focus="searchFocused = true"
@blur="searchFocused = false"
@blur="blurSearch"
>
<button class="search-button">
<button
class="search-button"
data-search
>
<Icon icon="search" />
</button>
</form>
@ -104,7 +107,7 @@
class="menu-button nolink"
>
<Icon icon="user7" />
My profile
Profile
</a>
</li>
@ -148,7 +151,12 @@
</template>
<script setup>
import { ref, computed, inject } from 'vue';
import {
ref,
computed,
inject,
} from 'vue';
import navigate from '#/src/navigate.js';
import { del } from '#/src/api.js';
@ -172,6 +180,12 @@ async function logout() {
del('/session');
navigate('/login', null, { redirect: true });
}
function blurSearch(event) {
if (!event.relatedTarget || !Object.hasOwn(event.relatedTarget?.dataset, 'search')) {
searchFocused.value = false;
}
}
</script>
<style scoped>

View File

@ -26,18 +26,13 @@
>
</a>
<Icon
v-show="favorited"
icon="heart7"
class="heart favorited"
@click.native.stop="unstash"
/>
<Icon
v-show="!favorited && user"
icon="heart8"
class="heart"
@click.native.stop="stash"
<Heart
domain="movies"
:item="movie"
:show-secondary="false"
class="light tiled"
@stashed="(stash) => { favorited = stash.isPrimary ? true : favorited; }"
@unstashed="(stash) => { favorited = stash.isPrimary ? false : favorited; }"
/>
</div>
@ -111,9 +106,7 @@
import { ref, inject } from 'vue';
import { format } from 'date-fns';
import { post, del } from '#/src/api.js';
import events from '#/src/events.js';
import ellipsis from '#/utils/ellipsis.js';
import Heart from '#/components/stashes/heart.vue';
const props = defineProps({
movie: {
@ -127,51 +120,8 @@ const user = pageContext.user;
const pageStash = pageContext.pageProps.stash;
const currentYear = new Date().getFullYear();
const fbCutoff = 20;
const favorited = ref(props.movie.stashes.some((sceneStash) => sceneStash.primary));
async function stash() {
try {
favorited.value = true;
await post(`/stashes/${user.primaryStash.id}/movies`, { movieId: props.movie.id });
events.emit('feedback', {
type: 'success',
message: `"${ellipsis(props.movie.title, fbCutoff)}" stashed to ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = false;
events.emit('feedback', {
type: 'error',
message: `Failed to stash "${ellipsis(props.movie.title, fbCutoff)}" to ${user.primaryStash.name}`,
});
}
}
async function unstash() {
try {
favorited.value = false;
await del(`/stashes/${user.primaryStash.id}/movies/${props.movie.id}`);
events.emit('feedback', {
type: 'remove',
message: `"${ellipsis(props.movie.title, fbCutoff)}" unstashed from ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = true;
console.error(error);
events.emit('feedback', {
type: 'error',
message: `Failed to unstash "${ellipsis(props.movie.title, fbCutoff)}" from ${user.primaryStash.name}`,
});
}
}
const favorited = ref(props.movie.stashes.some((sceneStash) => sceneStash.isPrimary));
</script>
<style scoped>
@ -186,7 +136,7 @@ async function unstash() {
&:hover {
box-shadow: 0 0 3px var(--shadow-weak-20);
.heart {
:deep(.bookmarks) .icon:not(.favorited):not(:hover) {
fill: var(--text-light);
}
}

View File

@ -8,15 +8,15 @@
>
<div class="poster-container">
<Link
:href="`/scene/${scene.id}/${scene.slug}`"
:href="`/scene/${scene.id}/${scene.slug || ''}`"
:title="scene.title"
target="_blank"
class="poster"
>
<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})` }"
:src="getPath(scene.poster, 'thumbnail')"
:style="{ 'background-image': `url(${getPath(scene.poster, 'lazy')})` }"
loading="lazy"
class="thumbnail"
>
@ -27,18 +27,13 @@
/>
</Link>
<Icon
v-show="favorited"
icon="heart7"
class="heart favorited"
@click.native.stop="unstash"
/>
<Icon
v-show="!favorited && user"
icon="heart8"
class="heart"
@click.native.stop="stash"
<Heart
domain="scenes"
:item="scene"
:show-secondary="false"
class="light tiled"
@stashed="(stash) => { favorited = stash.isPrimary ? true : favorited; }"
@unstashed="(stash) => { favorited = stash.isPrimary ? false : favorited; }"
/>
<span
@ -73,7 +68,7 @@
</div>
<Link
:href="`/scene/${scene.id}/${scene.slug}`"
:href="`/scene/${scene.id}/${scene.slug || ''}`"
:title="scene.title"
target="_blank"
class="row title nolink"
@ -117,11 +112,9 @@
import { ref, inject } from 'vue';
import { format } from 'date-fns';
import { post, del } from '#/src/api.js';
import events from '#/src/events.js';
import ellipsis from '#/utils/ellipsis.js';
import getPath from '#/src/get-path.js';
import Icon from '../icon/icon.vue';
import Heart from '#/components/stashes/heart.vue';
const props = defineProps({
scene: {
@ -134,50 +127,7 @@ const pageContext = inject('pageContext');
const user = pageContext.user;
const pageStash = pageContext.pageProps.stash;
const favorited = ref(props.scene.stashes.some((sceneStash) => sceneStash.primary));
const fbCutoff = 20;
async function stash() {
try {
favorited.value = true;
await post(`/stashes/${user.primaryStash.id}/scenes`, { sceneId: props.scene.id });
events.emit('feedback', {
type: 'success',
message: `"${ellipsis(props.scene.title, fbCutoff)}" stashed to ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = false;
events.emit('feedback', {
type: 'error',
message: `Failed to stash "${ellipsis(props.scene.title, fbCutoff)}" to ${user.primaryStash.name}`,
});
}
}
async function unstash() {
try {
favorited.value = false;
await del(`/stashes/${user.primaryStash.id}/scenes/${props.scene.id}`);
events.emit('feedback', {
type: 'remove',
message: `"${ellipsis(props.scene.title, fbCutoff)}" unstashed from ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = true;
console.error(error);
events.emit('feedback', {
type: 'error',
message: `Failed to unstash "${ellipsis(props.scene.title, fbCutoff)}" from ${user.primaryStash.name}`,
});
}
}
const favorited = ref(props.scene.stashes.some((sceneStash) => sceneStash.isPrimary));
</script>
<style scoped>
@ -191,7 +141,7 @@ async function unstash() {
&:hover {
box-shadow: 0 0 3px var(--shadow-weak-20);
.heart {
:deep(.bookmarks) .icon:not(.favorited):not(:hover) {
fill: var(--text-light);
}
}
@ -232,26 +182,6 @@ async function unstash() {
background-position: center;
}
.icon.heart {
width: 2rem;
height: 1.5rem;
position: absolute;
top: 0;
right: 0;
padding: .5rem .5rem 1rem 1rem;
fill: var(--highlight-strong-10);
filter: drop-shadow(0 0 3px var(--shadow));
&:hover {
cursor: pointer;
fill: var(--primary);
}
&.favorited {
fill: var(--primary);
}
}
.new {
display: flex;
flex-direction: row-reverse;

View File

@ -7,66 +7,78 @@
class="sidebar"
@click.stop
>
<Link href="/updates">
<h1 class="title">
<div
class="logo"
v-html="logo"
/>
</h1>
</Link>
<div class="nav">
<Link href="/updates">
<h1 class="title">
<div
class="logo"
v-html="logo"
/>
</h1>
</Link>
<ul class="nolist menu">
<li
class="menu-item"
:class="{ active: activePage === 'updates' }"
>
<a
href="/updates"
class="menu-link nolink"
>Updates</a>
</li>
<ul class="nolist menu">
<li
class="menu-item"
:class="{ active: activePage === 'updates' }"
>
<a
href="/updates"
class="menu-link nolink"
>Updates</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'actors' }"
>
<a
href="/actors"
class="menu-link nolink"
>Actors</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'actors' }"
>
<a
href="/actors"
class="menu-link nolink"
>Actors</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'channels' }"
>
<a
href="/channels"
class="menu-link nolink"
>Channels</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'channels' }"
>
<a
href="/channels"
class="menu-link nolink"
>Channels</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'tags' }"
>
<a
href="/tags"
class="menu-link nolink"
>Tags</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'tags' }"
>
<a
href="/tags"
class="menu-link nolink"
>Tags</a>
</li>
<li
class="menu-item"
:class="{ active: activePage === 'movies' }"
>
<a
href="/movies"
class="menu-link nolink"
>Movies</a>
</li>
</ul>
<li
class="menu-item"
:class="{ active: activePage === 'movies' }"
>
<a
href="/movies"
class="menu-link nolink"
>Movies</a>
</li>
</ul>
</div>
<div
class="footer"
@click="emit('sidebar')"
>
<Icon
icon="cross2"
class="close"
/>
</div>
</div>
</div>
</template>
@ -96,6 +108,8 @@ const activePage = computed(() => pageContext.urlParsed.pathname.split('/')[1]);
}
.sidebar {
display: flex;
flex-direction: column;
width: 15rem;
max-width: 100%;
height: 100%;
@ -104,6 +118,10 @@ const activePage = computed(() => pageContext.urlParsed.pathname.split('/')[1]);
box-shadow: 0 0 3px var(--shadow-strong-30);
}
.nav {
flex-grow: 1;
}
.title {
margin: 0;
}
@ -134,4 +152,27 @@ const activePage = computed(() => pageContext.urlParsed.pathname.split('/')[1]);
color: var(--primary);
}
}
.footer {
height: 3rem;
display: flex;
align-items: stretch;
justify-content: flex-end;
box-shadow: 0 0 3px var(--shadow-weak-30);
.close {
width: 1rem;
padding: 0 1rem;
height: auto;
fill: var(--shadow);
}
&:hover {
cursor: pointer;
.icon {
fill: var(--primary);
}
}
}
</style>

View File

@ -0,0 +1,186 @@
<template>
<div
v-if="user"
class="bookmarks"
>
<VDropdown v-if="showSecondary">
<Icon
icon="folder-heart"
class="heart noselect"
:class="{ favorited: itemStashes.some((itemStash) => !itemStash.isPrimary) }"
/>
<template #popper>
<ul class="stash-menu nolist">
<li
v-for="userStash in user.stashes"
:key="`stash-${userStash.id}`"
class="menu-item"
>
<label class="menu-stash">
<Checkbox
:checked="itemStashes.some((itemStash) => itemStash.id === userStash.id)"
@change="(checked) => checked ? stashItem(userStash) : unstashItem(userStash)"
/>{{ userStash.name }}
</label>
</li>
</ul>
</template>
</VDropdown>
<Icon
v-if="itemStashes.some((itemStash) => itemStash.isPrimary)"
icon="heart7"
class="heart favorited noselect"
@click.native.stop="unstashItem(user.primaryStash)"
/>
<Icon
v-else
icon="heart8"
class="heart noselect"
@click.native.stop="stashItem(user.primaryStash)"
/>
</div>
</template>
<script setup>
import { ref, inject } from 'vue';
import { post, del } from '#/src/api.js';
import ellipsis from '#/utils/ellipsis.js';
import Icon from '#/components/icon/icon.vue';
import Checkbox from '#/components/form/checkbox.vue';
const props = defineProps({
domain: {
type: String,
default: 'scenes',
},
item: {
type: Object,
default: null,
},
showSecondary: {
type: Boolean,
default: true,
},
});
const emit = defineEmits(['stashed', 'unstashed']);
const { user } = inject('pageContext');
const itemStashes = ref(props.item.stashes);
const done = ref(true);
const feedbackCutoff = 20;
const itemKeys = {
scenes: 'sceneId',
actors: 'actorId',
movies: 'movieId',
};
async function stashItem(stash) {
if (!done.value) {
return;
}
const stashState = itemStashes.value;
done.value = false;
itemStashes.value = itemStashes.value.concat(stash);
try {
await post(`/stashes/${stash.id}/${props.domain}`, { [itemKeys[props.domain]]: props.item.id }, {
successFeedback: `"${ellipsis(props.item.title || props.item.name, feedbackCutoff)}" stashed to ${stash.name}`,
errorFeedback: `Failed to stash "${ellipsis(props.item.title || props.item.name, feedbackCutoff)}" to ${stash.name}`,
});
emit('stashed', stash);
} catch (error) {
itemStashes.value = stashState;
}
done.value = true;
}
async function unstashItem(stash) {
if (!done.value) {
return;
}
const stashState = itemStashes.value;
done.value = false;
itemStashes.value = itemStashes.value.filter((itemStash) => itemStash.id !== stash.id);
try {
await del(`/stashes/${stash.id}/${props.domain}/${props.item.id}`, {
undoFeedback: `"${ellipsis(props.item.title || props.item.name, feedbackCutoff)}" unstashed from ${stash.name}`,
errorFeedback: `Failed to unstash "${ellipsis(props.item.title || props.item.name, feedbackCutoff)}" from ${stash.name}`,
});
emit('unstashed', stash);
} catch (error) {
itemStashes.value = stashState;
}
done.value = true;
}
</script>
<style scoped>
.bookmarks {
display: flex;
.icon {
width: 1.5rem;
height: 1.5rem;
padding: .5rem .5rem;
fill: var(--shadow);
}
&.light .icon {
fill: var(--highlight);
}
&.tiled {
position: absolute;
top: 0;
right: 0;
.icon {
fill: var(--highlight-strong-20);
filter: drop-shadow(0 0 3px var(--shadow-strong-10));
}
}
.icon.heart:hover,
.icon.heart.favorited {
cursor: pointer;
fill: var(--primary);
}
}
.menu-item {
display: block;
}
.menu-stash {
display: flex;
align-items: center;
padding: .5rem;
&:hover {
cursor: pointer;
color: var(--primary);
}
.check-container {
margin-right: .5rem;
}
}
</style>

View File

@ -3,7 +3,7 @@
<div class="header">
<h2 class="title">
<Icon
v-if="stash.primary"
v-if="stash.isPrimary"
icon="heart7"
/>

331
components/stashes/tile.vue Normal file
View File

@ -0,0 +1,331 @@
<template>
<div class="stash">
<div class="stash-header">
<a
:href="`/stash/${profile.username}/${stash.slug}`"
class="stash-name ellipsis nolink"
>
<span class="ellipsis">{{ stash.name }}</span>
<Icon
v-if="stash.isPrimary"
icon="heart7"
class="primary"
/>
</a>
<Icon
v-if="!stash.public"
v-tooltip="'This stash is private'"
icon="eye-blocked"
class="private noselect"
/>
<VDropdown>
<Icon
v-if="profile.id === user?.id"
icon="more2"
class="stash-more noselect"
/>
<template #popper>
<ul class="stash-menu nolist">
<li
v-if="stash.public"
class="menu-item"
@click="setPublic(false)"
>
<Icon
icon="eye-blocked"
class="noselect"
/>Set private
</li>
<li
v-else
class="menu-item"
@click="setPublic(true)"
>
<Icon
icon="eye"
class="noselect"
/>Set public
</li>
<li
v-if="!stash.isPrimary"
v-close-popper
class="menu-item"
@click="showRenameDialog = true"
>
<Icon
icon="pencil5"
class="noselect"
/>Rename
</li>
<li
v-if="!stash.isPrimary"
class="menu-item remove"
@click="remove()"
>
<Icon
icon="bin"
class="noselect"
/>Remove
</li>
</ul>
</template>
</VDropdown>
</div>
<div class="stash-counts">
<a
:href="`/stash/${profile.username}/${stash.slug}/scenes`"
class="stash-count nolink"
><Icon icon="clapboard-play" />{{ abbreviateNumber(stash.stashedScenes) }}</a>
<a
:href="`/stash/${profile.username}/${stash.slug}/actors`"
class="stash-count nolink"
><Icon icon="star" />{{ abbreviateNumber(stash.stashedActors) }}</a>
<a
:href="`/stash/${profile.username}/${stash.slug}/movies`"
class="stash-count nolink"
><Icon icon="movie" />{{ abbreviateNumber(stash.stashedMovies) }}</a>
</div>
<Dialog
v-if="showRenameDialog"
title="Rename stash"
@close="showRenameDialog = false"
@open="stashNameInput?.focus()"
>
<form
class="dialog-body"
@submit.prevent="rename"
>
<input
ref="stashNameInput"
v-model="stashName"
class="input"
placeholder="Stash name"
maxlength="24"
>
<button
class="button button-submit"
>Rename stash</button>
</form>
</Dialog>
</div>
</template>
<script setup>
import { ref, inject } from 'vue';
import { del, patch } from '#/src/api.js';
import Dialog from '#/components/dialog/dialog.vue';
const props = defineProps({
stash: {
type: Object,
default: null,
},
profile: {
type: Object,
default: null,
},
});
const emit = defineEmits(['reload']);
const pageContext = inject('pageContext');
const user = pageContext.user;
const stashName = ref(props.stash.name);
const stashNameInput = ref(null);
const showRenameDialog = ref(false);
const done = ref(true);
function abbreviateNumber(number) {
return number?.toLocaleString('en-US', { notation: 'compact' }) || 0;
}
async function setPublic(isPublic) {
if (done.value === false) {
return;
}
done.value = false;
await patch(`/stashes/${props.stash.id}`, { public: isPublic }, {
undoFeedback: !isPublic && `Stash '${props.stash.name}' set to private`,
successFeedback: isPublic && `Stash '${props.stash.name}' set to public`,
errorFeedback: 'Failed to update stash',
appendErrorMessage: true,
}).finally(() => { done.value = true; });
emit('reload');
}
async function remove() {
if (done.value === false) {
return;
}
if (!confirm(`Are you sure you want to remove the stash '${props.stash.name}' and all its scenes, movies and actors? This is permament, it cannot be undone by you or staff!`)) { // eslint-disable-line no-restricted-globals, no-alert
return;
}
done.value = false;
await del(`/stashes/${props.stash.id}`, {
undoFeedback: `Stash '${props.stash.name}' removed`,
errorFeedback: 'Failed to remove stash',
appendErrorMessage: true,
}).finally(() => { done.value = true; });
emit('reload');
}
async function rename() {
if (done.value === false) {
return;
}
done.value = false;
await patch(`/stashes/${props.stash.id}`, { name: stashName.value }, {
successFeedback: `Stash renamed to ${stashName.value}`,
errorFeedback: 'Failed to rename stash',
appendErrorMessage: true,
}).finally(() => { done.value = true; });
emit('reload');
showRenameDialog.value = false;
}
</script>
<style scoped>
.stash {
width: 100%;
border-radius: .25rem;
background: var(--background);
box-shadow: 0 0 3px var(--shadow-weak-30);
&:hover {
box-shadow: 0 0 3px var(--shadow-weak-20);
}
}
.stash-header {
display: flex;
align-items: stretch;
border-bottom: solid 1px var(--shadow-weak-30);
font-weight: bold;
}
.stash-more {
display: flex;
height: 100%;
padding: 0 .75rem;
fill: var(--shadow);
&:hover {
cursor: pointer;
fill: var(--shadow-strong-30);
}
}
.stash-name {
display: flex;
flex-grow: 1;
padding: .5rem;
overflow: hidden;
.icon {
margin-left: .75rem;
}
.icon.primary {
fill: var(--primary);
transform: translateY(1px);
}
}
.stash-counts {
display: flex;
justify-content: space-between;
}
.stash-count {
display: inline-flex;
align-items: center;
padding: .5rem;
flex-grow: 1;
font-size: .9rem;
.icon {
margin-right: .5rem;
fill: var(--shadow);
}
&:hover {
color: var(--primary);
.icon {
fill: var(--primary);
}
}
}
.icon.private {
display: flex;
height: auto;
fill: var(--shadow-weak-20);
padding-left: .5rem;
}
.menu-item {
display: flex;
align-items: center;
padding: .75rem;
.icon {
display: flex;
margin-right: .75rem;
fill: var(--shadow);
}
&.remove {
.icon {
fill: var(--error);
}
}
&:hover {
color: var(--primary);
cursor: pointer;
&.remove {
color: var(--error);
}
.icon {
fill: var(--primary);
}
}
}
.dialog-body {
padding: 1rem;
.input {
margin-bottom: .5rem;
}
}
</style>

View File

@ -1,275 +0,0 @@
<template>
<div
class="tile"
:class="{
unstashed: !favorited && pageStash && user && pageStash.id === user.primaryStash?.id
}"
>
<span class="name">{{ actor.name }}</span>
<div class="avatar-container">
<Link
:href="`/actor/${actor.id}/${actor.slug}`"
class="avatar-link no-link"
>
<img
v-if="actor.avatar"
:src="actor.avatar.isS3 ? `https://cdndev.traxxx.me/${actor.avatar.thumbnail}` : `/media/${actor.avatar.thumbnail}`"
:style="{ 'background-image': actor.avatar.isS3 ? `url(https://cdndev.traxxx.me/${actor.avatar.lazy})` : `url(/media/${actor.avatar.lazy})` }"
loading="lazy"
class="avatar"
>
<img
v-else
:src="`/img/avatars/${actor.gender || 'female'}.svg`"
loading="lazy"
class="fallback"
>
</Link>
<Icon
v-show="favorited"
icon="heart7"
class="heart favorited"
@click.native.stop="unstash"
/>
<Icon
v-show="!favorited && user"
icon="heart8"
class="heart"
@click.native.stop="stash"
/>
</div>
<div class="details">
<span class="birth">
<Gender :gender="actor.gender" />
<span
v-if="actor.ageFromBirth"
:title="`Born ${formatDate(actor.dateOfBirth, 'MMMM d, yyyy')}`"
class="age"
>{{ actor.ageFromBirth }}</span>
<span
v-if="actor.ageThen && actor.ageThen < actor.ageFromBirth"
title="Age on date of release"
class="age age-then"
>{{ actor.ageThen }}</span>
</span>
<span
v-if="actor.origin?.country"
:title="`Born in ${actor.origin.country.name}`"
class="country"
>
{{ actor.origin.country.alpha2 }}
<img
:src="`/img/flags/${actor.origin.country.alpha2.toLowerCase()}.svg`"
class="flag"
>
</span>
</div>
</div>
</template>
<script setup>
import { ref, inject } from 'vue';
import { formatDate } from '#/utils/format.js';
import { post, del } from '#/src/api.js';
import events from '#/src/events.js';
import Gender from './gender.vue';
const props = defineProps({
actor: {
type: Object,
default: null,
},
});
const pageContext = inject('pageContext');
const { user } = pageContext;
const pageStash = pageContext.pageProps.stash;
// console.log(props.actor);
const favorited = ref(props.actor.stashes?.some((sceneStash) => sceneStash.primary) || false);
async function stash() {
try {
favorited.value = true;
await post(`/stashes/${user.primaryStash.id}/actors`, { actorId: props.actor.id });
events.emit('feedback', {
type: 'success',
message: `${props.actor.name} stashed to ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = false;
events.emit('feedback', {
type: 'error',
message: `Failed to stash ${props.actor.name} to ${user.primaryStash.name}`,
});
}
}
async function unstash() {
try {
favorited.value = false;
await del(`/stashes/${user.primaryStash.id}/actors/${props.actor.id}`);
events.emit('feedback', {
type: 'remove',
message: `${props.actor.name} unstashed from ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = true;
console.error(error);
events.emit('feedback', {
type: 'error',
message: `Failed to unstash ${props.actor.name} from ${user.primaryStash.name}`,
});
}
}
</script>
<style scoped>
.tile {
display: flex;
flex-direction: column;
width: 100%;
aspect-ratio: 2/3;
position: relative;
border-radius: .25rem;
margin: .25rem;
box-shadow: 0 0 3px var(--shadow-weak-30);
overflow: hidden;
&:hover {
box-shadow: 0 0 3px var(--shadow-weak-20);
.name {
color: var(--primary);
}
}
&.unstashed {
opacity: .5;
}
}
.name {
flex-shrink: 0;
padding: .25rem .5rem;
font-weight: bold;
font-size: .9rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
user-select: all;
}
.avatar-container {
position: relative;
flex-grow: 1;
overflow: hidden;
background: var(--grey-dark-40);
}
.avatar-link {
height: 100%;
display: block;
overflow: hidden;
}
.avatar {
height: 100%;
width: 100%;
object-fit: cover;
object-position: center 0;
background-size: cover;
background-position: center 0;
}
.fallback {
height: 100%;
width: 100%;
display: block;
object-fit: contain;
opacity: .1;
}
.icon.heart {
width: 2rem;
height: 1.5rem;
position: absolute;
top: 0;
right: 0;
padding: .5rem .5rem 1rem 1rem;
fill: var(--highlight-strong-10);
filter: drop-shadow(0 0 3px var(--shadow));
&:hover {
cursor: pointer;
fill: var(--primary);
}
&.favorited {
fill: var(--primary);
}
}
.details {
width: 100%;
height: 1.5rem;
display: flex;
justify-content: space-between;
align-items: center;
position: absolute;
bottom: 0;
box-sizing: border-box;
padding: 0 .5rem;
color: var(--text-light);
background: var(--shadow);
font-size: .9rem;
font-weight: bold;
}
.gender {
display: inline-block;
padding: .25rem 0;
margin-right: .25rem;
transform: translateY(1px);
}
.birth {
display: flex;
align-items: center;
}
.age {
margin-right: .25rem;
}
.age-then {
color: var(--grey-light-20);
font-weight: normal;
}
.country {
display: flex;
align-items: center;
}
.flag {
height: .75rem;
margin-left: .25rem;
}
</style>

View File

@ -1,39 +0,0 @@
<template>
<span
v-if="gender"
class="gender"
:class="{ [gender]: true }"
>
<Icon :icon="gender" />
</span>
</template>
<script setup>
defineProps({
gender: {
type: String,
default: null,
},
});
</script>
<style scoped>
.gender {
&.female .icon {
fill: var(--female);
filter: drop-shadow(0 0 1px var(--shadow-weak-20));
}
&.male .icon {
fill: var(--male);
filter: drop-shadow(0 0 1px var(--shadow-weak-20));
}
&.transsexual .icon {
fill: var(--text-light);
filter: drop-shadow(1px 0 0 var(--female)) drop-shadow(-1px 0 0 var(--female)) drop-shadow(0 1px 0 var(--female)) drop-shadow(0 -1px 0 var(--female))
drop-shadow(1px 0 0 var(--male)) drop-shadow(-1px 0 0 var(--male)) drop-shadow(0 1px 0 var(--male)) drop-shadow(0 -1px 0 var(--male))
drop-shadow(0 0 1px var(--shadow-weak-20))
}
}
</style>

View File

@ -66,8 +66,12 @@ module.exports = {
},
stashes: {
nameLength: [2, 24],
namePattern: /^[a-zA-Z0-9_-]+$/,
viewRefreshCooldown: 60, // minutes
namePattern: /^[a-zA-Z0-9!?$&\s_-]+$/,
viewRefreshCron: '* * * * *', // every minute
viewRefreshCooldowns: {
actors: 60, // minutes
stashes: 1,
},
},
media: {
path: './media',

46
package-lock.json generated
View File

@ -1,11 +1,11 @@
{
"name": "traxxx-web",
"version": "0.16.0",
"version": "0.17.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "0.16.0",
"version": "0.17.0",
"dependencies": {
"@brillout/json-serializer": "^0.5.8",
"@dicebear/collection": "^7.0.5",
@ -24,6 +24,7 @@
"config": "^3.3.9",
"connect-redis": "^7.1.1",
"convert": "^4.14.1",
"cron": "^3.1.6",
"cross-env": "^7.0.3",
"date-fns": "^3.0.0",
"error-stack-parser": "^2.1.4",
@ -3475,6 +3476,11 @@
"dev": true,
"peer": true
},
"node_modules/@types/luxon": {
"version": "3.3.8",
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.3.8.tgz",
"integrity": "sha512-jYvz8UMLDgy3a5SkGJne8H7VA7zPV2Lwohjx0V8V31+SqAjNmurWMkk9cQhfvlcnXWudBpK9xPM1n4rljOcHYQ=="
},
"node_modules/@types/triple-beam": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz",
@ -4656,6 +4662,15 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
},
"node_modules/cron": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/cron/-/cron-3.1.6.tgz",
"integrity": "sha512-cvFiQCeVzsA+QPM6fhjBtlKGij7tLLISnTSvFxVdnFGLdz+ZdXN37kNe0i2gefmdD17XuZA6n2uPVwzl4FxW/w==",
"dependencies": {
"@types/luxon": "~3.3.0",
"luxon": "~3.4.0"
}
},
"node_modules/cross-env": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
@ -7060,6 +7075,14 @@
"yallist": "^3.0.2"
}
},
"node_modules/luxon": {
"version": "3.4.4",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.4.4.tgz",
"integrity": "sha512-zobTr7akeGHnv7eBOXcRgMeCP6+uyYsczwmeRCauvpvaAltgNyTbLH/+VaEAPUeWBT+1GuNmz4wC/6jtQzbbVA==",
"engines": {
"node": ">=12"
}
},
"node_modules/m3u8-parser": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/m3u8-parser/-/m3u8-parser-7.1.0.tgz",
@ -12679,6 +12702,11 @@
"dev": true,
"peer": true
},
"@types/luxon": {
"version": "3.3.8",
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.3.8.tgz",
"integrity": "sha512-jYvz8UMLDgy3a5SkGJne8H7VA7zPV2Lwohjx0V8V31+SqAjNmurWMkk9cQhfvlcnXWudBpK9xPM1n4rljOcHYQ=="
},
"@types/triple-beam": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz",
@ -13532,6 +13560,15 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
},
"cron": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/cron/-/cron-3.1.6.tgz",
"integrity": "sha512-cvFiQCeVzsA+QPM6fhjBtlKGij7tLLISnTSvFxVdnFGLdz+ZdXN37kNe0i2gefmdD17XuZA6n2uPVwzl4FxW/w==",
"requires": {
"@types/luxon": "~3.3.0",
"luxon": "~3.4.0"
}
},
"cross-env": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
@ -15294,6 +15331,11 @@
"yallist": "^3.0.2"
}
},
"luxon": {
"version": "3.4.4",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.4.4.tgz",
"integrity": "sha512-zobTr7akeGHnv7eBOXcRgMeCP6+uyYsczwmeRCauvpvaAltgNyTbLH/+VaEAPUeWBT+1GuNmz4wC/6jtQzbbVA=="
},
"m3u8-parser": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/m3u8-parser/-/m3u8-parser-7.1.0.tgz",

View File

@ -24,6 +24,7 @@
"config": "^3.3.9",
"connect-redis": "^7.1.1",
"convert": "^4.14.1",
"cron": "^3.1.6",
"cross-env": "^7.0.3",
"date-fns": "^3.0.0",
"error-stack-parser": "^2.1.4",
@ -71,5 +72,5 @@
"postcss-custom-media": "^10.0.2",
"postcss-nesting": "^12.0.2"
},
"version": "0.16.0"
"version": "0.17.0"
}

View File

@ -25,18 +25,10 @@
</span>
</li>
<Icon
v-show="favorited"
icon="heart7"
class="heart favorited"
@click.native.stop="unstash"
/>
<Icon
v-show="!favorited && user"
icon="heart8"
class="heart"
@click.native.stop="stash"
<Heart
domain="actors"
:item="actor"
class="light"
/>
</div>
@ -49,61 +41,16 @@
</template>
<script setup>
import { ref, inject } from 'vue';
import { post, del } from '#/src/api.js';
import events from '#/src/events.js';
import { inject } from 'vue';
import Bio from '#/components/actors/bio.vue';
import Gender from '#/components/actors/gender.vue';
import Scenes from '#/components/scenes/scenes.vue';
import Heart from '#/components/stashes/heart.vue';
const pageContext = inject('pageContext');
const { pageProps, user } = pageContext;
const { pageProps } = pageContext;
const { actor } = pageProps;
const favorited = ref(actor.stashes?.some((sceneStash) => sceneStash.primary) || false);
async function stash() {
try {
favorited.value = true;
await post(`/stashes/${user.primaryStash.id}/actors`, { actorId: actor.id });
events.emit('feedback', {
type: 'success',
message: `${actor.name} stashed to ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = false;
events.emit('feedback', {
type: 'error',
message: `Failed to stash ${actor.name} to ${user.primaryStash.name}`,
});
}
}
async function unstash() {
try {
favorited.value = false;
await del(`/stashes/${user.primaryStash.id}/actors/${actor.id}`);
events.emit('feedback', {
type: 'remove',
message: `${actor.name} unstashed from ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = true;
console.error(error);
events.emit('feedback', {
type: 'error',
message: `Failed to unstash ${actor.name} from ${user.primaryStash.name}`,
});
}
}
</script>
<style scoped>
@ -150,23 +97,7 @@ async function unstash() {
overflow-y: auto;
}
.icon.heart {
width: 2rem;
height: 1.5rem;
position: absolute;
top: 0;
right: 0;
padding: .5rem 1rem 1rem 1rem;
fill: var(--highlight-strong-10);
filter: drop-shadow(0 0 3px var(--shadow));
&:hover {
cursor: pointer;
fill: var(--primary);
}
&.favorited {
fill: var(--primary);
}
.bookmarks {
margin-right: .5rem;
}
</style>

View File

@ -111,26 +111,10 @@
>No title</h2>
<div class="actions">
<div
v-if="user"
class="bookmarks"
>
<Icon icon="folder-heart" />
<Icon
v-show="favorited"
icon="heart7"
class="heart favorited"
@click.native.stop="unstash"
/>
<Icon
v-show="!favorited"
icon="heart8"
class="heart"
@click.native.stop="stash"
/>
</div>
<Heart
domain="movies"
:item="movie"
/>
<div class="view">
<button
@ -243,69 +227,20 @@
</template>
<script setup>
import { ref, inject } from 'vue';
import { inject } from 'vue';
import { post, del } from '#/src/api.js';
import events from '#/src/events.js';
import { formatDate, formatDuration } from '#/utils/format.js';
import getPath from '#/src/get-path.js';
import ellipsis from '#/utils/ellipsis.js';
import ActorTile from '#/components/actors/tile.vue';
import SceneTile from '#/components/scenes/tile.vue';
import Player from '#/components/video/player.vue';
import Heart from '#/components/stashes/heart.vue';
const pageContext = inject('pageContext');
const movie = pageContext.pageProps.movie;
const scenes = pageContext.pageProps.scenes;
const user = pageContext.user;
const fbCutoff = 20;
const favorited = ref(movie.stashes.some((sceneStash) => sceneStash.primary));
async function stash() {
try {
favorited.value = true;
await post(`/stashes/${user.primaryStash.id}/movies`, { movieId: movie.id });
events.emit('feedback', {
type: 'success',
message: `"${ellipsis(movie.title, fbCutoff)}" stashed to ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = false;
events.emit('feedback', {
type: 'error',
message: `Failed to stash "${ellipsis(movie.title, fbCutoff)}" to ${user.primaryStash.name}`,
});
}
}
async function unstash() {
try {
favorited.value = false;
await del(`/stashes/${user.primaryStash.id}/movies/${movie.id}`);
events.emit('feedback', {
type: 'remove',
message: `"${ellipsis(movie.title, fbCutoff)}" unstashed from ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = true;
console.error(error);
events.emit('feedback', {
type: 'error',
message: `Failed to unstash "${ellipsis(movie.title, fbCutoff)}" from ${user.primaryStash.name}`,
});
}
}
</script>
<style scoped>
@ -507,6 +442,10 @@ async function unstash() {
}
}
.bookmarks {
margin-right: .75rem;
}
.view {
display: flex;
}
@ -516,21 +455,6 @@ async function unstash() {
color: var(--text-light);
}
.bookmarks {
display: flex;
margin-right: .75rem;
.icon {
padding: .5rem .5rem;
}
.icon.heart:hover,
.icon.heart.favorited {
cursor: pointer;
fill: var(--primary);
}
}
.cover {
height: 20rem;
}

View File

@ -123,26 +123,10 @@
>No title</h2>
<div class="actions">
<div
v-if="user"
class="bookmarks"
>
<Icon icon="folder-heart" />
<Icon
v-show="favorited"
icon="heart7"
class="heart favorited"
@click.native.stop="unstash"
/>
<Icon
v-show="!favorited"
icon="heart8"
class="heart"
@click.native.stop="stash"
/>
</div>
<Heart
domain="scenes"
:item="scene"
/>
<div class="view">
<button
@ -244,26 +228,19 @@
<script setup>
import { ref, computed, inject } from 'vue';
import { post, del } from '#/src/api.js';
import { formatDate, formatDuration } from '#/utils/format.js';
import events from '#/src/events.js';
import getPath from '#/src/get-path.js';
import ellipsis from '#/utils/ellipsis.js';
import Icon from '#/components/icon/icon.vue';
import ActorTile from '#/components/actors/tile.vue';
import Player from '#/components/video/player.vue';
import Heart from '#/components/stashes/heart.vue';
const { pageProps, user } = inject('pageContext');
const { pageProps } = inject('pageContext');
const { scene } = pageProps;
const favorited = ref(scene.stashes.some((sceneStash) => sceneStash.primary));
const playing = ref(false);
const paused = ref(false);
const fbCutoff = 20;
const poster = computed(() => {
if (scene.poster) {
return getPath(scene.poster, 'thumbnail');
@ -279,48 +256,6 @@ const poster = computed(() => {
return null;
});
async function stash() {
try {
favorited.value = true;
await post(`/stashes/${user.primaryStash.id}/scenes`, { sceneId: scene.id });
events.emit('feedback', {
type: 'success',
message: `"${ellipsis(scene.title, fbCutoff)}" stashed to ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = false;
events.emit('feedback', {
type: 'error',
message: `Failed to stash "${ellipsis(scene.title, fbCutoff)}" to ${user.primaryStash.name}`,
});
}
}
async function unstash() {
try {
favorited.value = false;
await del(`/stashes/${user.primaryStash.id}/scenes/${scene.id}`);
events.emit('feedback', {
type: 'remove',
message: `"${ellipsis(scene.title, fbCutoff)}" unstashed from ${user.primaryStash.name}`,
});
} catch (error) {
favorited.value = true;
console.error(error);
events.emit('feedback', {
type: 'error',
message: `Failed to unstash "${ellipsis(scene.title, fbCutoff)}" from ${user.primaryStash.name}`,
});
}
}
</script>
<style scoped>
@ -506,12 +441,6 @@ async function unstash() {
justify-content: space-between;
flex-shrink: 0;
.icon {
width: 1.5rem;
height: 1.5rem;
fill: var(--shadow);
}
.button {
flex-shrink: 0;
padding: .75rem;
@ -523,18 +452,7 @@ async function unstash() {
}
.bookmarks {
display: flex;
margin-right: .75rem;
.icon {
padding: .5rem .5rem;
}
.icon.heart:hover,
.icon.heart.favorited {
cursor: pointer;
fill: var(--primary);
}
}
.view {

View File

@ -12,7 +12,7 @@
<h2 class="username ellipsis">{{ profile.username }}</h2>
</div>
<span class="age"><Icon icon="cake" />{{ formatDistanceStrict(Date.now(), profile.createdAt) }}</span>
<span class="age">{{ formatDistanceStrict(Date.now(), profile.createdAt) }}</span>
</div>
<section class="profile-section">
@ -41,8 +41,9 @@
<input
ref="stashNameInput"
v-model="stashName"
class="input"
maxlength="24"
placeholder="Stash name"
class="input"
>
<button
@ -56,53 +57,11 @@
v-for="stash in profile.stashes"
:key="`stash-${stash.id}`"
>
<div class="stash">
<div class="stash-header">
<a
:href="`/stash/${profile.username}/${stash.slug}`"
class="stash-name ellipsis nolink"
>
<span class="ellipsis">{{ stash.name }}</span>
<Icon
v-if="stash.primary"
icon="heart7"
class="primary"
/>
</a>
<Icon
v-if="profile.id === user?.id && stash.public"
icon="eye"
class="public noselect"
@click="setStashPublic(stash, false)"
/>
<Icon
v-else-if="profile.id === user?.id"
icon="eye-blocked"
class="public noselect"
@click="setStashPublic(stash, true)"
/>
</div>
<div class="stash-counts">
<a
:href="`/stash/${profile.username}/${stash.slug}/scenes`"
class="stash-count nolink"
><Icon icon="clapboard-play" />{{ abbreviateNumber(stash.stashedScenes) }}</a>
<a
:href="`/stash/${profile.username}/${stash.slug}/actors`"
class="stash-count nolink"
><Icon icon="star" />{{ abbreviateNumber(stash.stashedActors) }}</a>
<a
:href="`/stash/${profile.username}/${stash.slug}/movies`"
class="stash-count nolink"
><Icon icon="movie" />{{ abbreviateNumber(stash.stashedMovies) }}</a>
</div>
</div>
<StashTile
:stash="stash"
:profile="profile"
@reload="reloadProfile"
/>
</li>
</ul>
</section>
@ -114,14 +73,13 @@
import { ref, inject } from 'vue';
import { formatDistanceStrict } from 'date-fns';
import { get, post, patch } from '#/src/api.js';
import events from '#/src/events.js';
import { get, post } from '#/src/api.js';
import StashTile from '#/components/stashes/tile.vue';
import Dialog from '#/components/dialog/dialog.vue';
const pageContext = inject('pageContext');
const profile = ref(pageContext.pageProps.profile);
const user = pageContext.user;
const stashName = ref(null);
const stashNameInput = ref(null);
@ -129,8 +87,8 @@ const stashNameInput = ref(null);
const done = ref(true);
const showStashDialog = ref(false);
function abbreviateNumber(number) {
return number?.toLocaleString('en-US', { notation: 'compact' }) || 0;
async function reloadProfile() {
profile.value = await get(`/users/${profile.value.id}`);
}
async function createStash() {
@ -140,56 +98,19 @@ async function createStash() {
done.value = false;
try {
await post('/stashes', {
name: stashName.value,
public: false,
});
await post('/stashes', {
name: stashName.value,
public: false,
}, {
successFeedback: `Created stash '${stashName.value}'`,
errorFeedback: `Failed to create stash '${stashName.value}'`,
appendErrorMessage: true,
}).finally(() => { done.value = true; });
profile.value = await get(`/users/${profile.value.id}`);
showStashDialog.value = false;
showStashDialog.value = false;
stashName.value = null;
events.emit('feedback', {
type: 'success',
message: `Created stash '${stashName.value}'`,
});
} catch (error) {
events.emit('feedback', {
type: 'error',
message: `Failed to create stash '${stashName.value}': ${error.message}`,
});
}
done.value = true;
}
async function setStashPublic(stash, isPublic) {
if (done.value === false) {
return;
}
try {
done.value = false;
await patch(`/stashes/${stash.id}`, { public: isPublic });
profile.value = await get(`/users/${profile.value.id}`);
events.emit('feedback', {
type: isPublic ? 'success' : 'remove',
message: isPublic
? `Stash '${stash.name}' set to public`
: `Stash '${stash.name}' set to private`,
});
} catch (error) {
console.error(error);
events.emit('feedback', {
type: 'error',
message: 'Failed to update stash',
});
}
done.value = true;
await reloadProfile();
}
</script>
@ -229,8 +150,10 @@ async function setStashPublic(stash, isPublic) {
.age {
display: flex;
flex-shrink: 0;
font-size: .9rem;
.icon {
width: .9rem;
fill: var(--highlight-strong-20);
margin-right: .75rem;
transform: translateY(-1px);
@ -268,78 +191,6 @@ async function setStashPublic(stash, isPublic) {
padding: 0 .5rem 1rem .5rem;
}
.stash {
width: 100%;
border-radius: .25rem;
background: var(--background);
box-shadow: 0 0 3px var(--shadow-weak-30);
&:hover {
box-shadow: 0 0 3px var(--shadow-weak-20);
}
}
.stash-header {
display: flex;
align-items: stretch;
border-bottom: solid 1px var(--shadow-weak-30);
font-weight: bold;
}
.icon.public {
display: flex;
height: auto;
padding: 0 .75rem;
fill: var(--shadow);
&:hover {
cursor: pointer;
fill: var(--shadow-strong-30);
}
}
.stash-name {
display: flex;
flex-grow: 1;
padding: .5rem;
overflow: hidden;
.icon {
margin-left: .75rem;
}
.icon.primary {
fill: var(--primary);
transform: translateY(1px);
}
}
.stash-counts {
display: flex;
justify-content: space-between;
}
.stash-count {
display: inline-flex;
align-items: center;
padding: .5rem;
flex-grow: 1;
font-size: .9rem;
.icon {
margin-right: .5rem;
fill: var(--shadow);
}
&:hover {
color: var(--primary);
.icon {
fill: var(--primary);
}
}
}
.dialog-body {
padding: 1rem;

View File

@ -5,6 +5,8 @@ import { fetchUser } from '#/src/users.js';
export async function onBeforeRender(pageContext) {
const profile = await fetchUser(pageContext.routeParams.username, {}, pageContext.user);
// console.log(profile);
if (!profile) {
throw render(404, `Cannot find user '${pageContext.routeParams.username}'.`);
}

View File

@ -164,7 +164,8 @@ onMounted(() => {
background: var(--error);
}
&.remove {
&.remove,
&.undo {
background: var(--warn);
}
}

View File

@ -1,4 +1,5 @@
import { parse } from '@brillout/json-serializer/parse'; /* eslint-disable-line import/extensions */
import events from '#/src/events.js';
const postHeaders = {
mode: 'cors',
@ -18,73 +19,128 @@ function getQuery(data) {
return `?${encodeURI(decodeURIComponent(new URLSearchParams(curatedQuery).toString()))}`; // recode so commas aren't encoded
}
export async function get(path, query = {}) {
const res = await fetch(`/api${path}${getQuery(query)}`);
const body = parse(await res.text());
if (res.ok) {
return body;
function showFeedback(isSuccess, options = {}, errorMessage) {
if (!isSuccess && typeof options.errorFeedback) {
events.emit('feedback', {
type: 'error',
message: options.appendErrorMessage && errorMessage
? `${options.errorFeedback}: ${errorMessage}`
: options.errorFeedback,
});
}
throw new Error(body.statusMessage);
if (isSuccess && options.successFeedback) {
events.emit('feedback', {
type: 'success',
message: options.successFeedback,
});
}
if (isSuccess && options.undoFeedback) {
events.emit('feedback', {
type: 'undo',
message: options.undoFeedback,
});
}
}
export async function post(path, data, { query } = {}) {
const res = await fetch(`/api${path}${getQuery(query)}`, {
method: 'POST',
body: JSON.stringify(data),
...postHeaders,
});
export async function get(path, query = {}, options = {}) {
try {
const res = await fetch(`/api${path}${getQuery(query)}`);
const body = parse(await res.text());
if (res.status === 204) {
return null;
if (res.ok) {
showFeedback(true, options);
return body;
}
showFeedback(false, options, body.statusMessage);
throw new Error(body.statusMessage);
} catch (error) {
showFeedback(false, options, error.message);
throw error;
}
const body = parse(await res.text());
if (res.ok) {
return body;
}
throw new Error(body.statusMessage);
}
export async function patch(path, data, { query } = {}) {
const res = await fetch(`/api${path}${getQuery(query)}`, {
method: 'PATCH',
body: JSON.stringify(data),
...postHeaders,
});
export async function post(path, data, options = {}) {
try {
const res = await fetch(`/api${path}${getQuery(options.query)}`, {
method: 'POST',
body: JSON.stringify(data),
...postHeaders,
});
if (res.status === 204) {
return null;
if (res.status === 204) {
showFeedback(true, options);
return null;
}
const body = parse(await res.text());
if (res.ok) {
showFeedback(true, options);
return body;
}
showFeedback(false, options, body.statusMessage);
throw new Error(body.statusMessage);
} catch (error) {
showFeedback(false, options, error.message);
throw error;
}
const body = parse(await res.text());
if (res.ok) {
return body;
}
throw new Error(body.statusMessage);
}
export async function del(path, { data, query } = {}) {
const res = await fetch(`/api${path}${getQuery(query)}`, {
method: 'DELETE',
body: JSON.stringify(data),
...postHeaders,
});
export async function patch(path, data, options = {}) {
try {
const res = await fetch(`/api${path}${getQuery(options.query)}`, {
method: 'PATCH',
body: JSON.stringify(data),
...postHeaders,
});
if (res.status === 204) {
return null;
if (res.status === 204) {
return null;
}
const body = parse(await res.text());
if (res.ok) {
showFeedback(true, options);
return body;
}
showFeedback(false, options, body.statusMessage);
throw new Error(body.statusMessage);
} catch (error) {
showFeedback(false, options, error.message);
throw error;
}
}
export async function del(path, options = {}) {
try {
const res = await fetch(`/api${path}${getQuery(options.query)}`, {
method: 'DELETE',
body: JSON.stringify(options.data),
...postHeaders,
});
if (res.status === 204) {
showFeedback(true, options);
return null;
}
const body = parse(await res.text());
if (res.ok) {
showFeedback(true, options);
return body;
}
showFeedback(false, options, body.statusMessage);
throw new Error(body.statusMessage);
} catch (error) {
showFeedback(false, options, error.message);
throw error;
}
const body = parse(await res.text());
if (res.ok) {
return body;
}
throw new Error(body.statusMessage);
}

View File

@ -128,7 +128,8 @@ export async function fetchMoviesById(movieIds, reqUser) {
.orderBy('priority', 'desc'),
covers: knex('movies_covers')
.whereIn('movie_id', movieIds)
.leftJoin('media', 'media.id', 'movies_covers.media_id'),
.leftJoin('media', 'media.id', 'movies_covers.media_id')
.orderBy('media.index'),
photos: knex('movies')
.whereIn('movies.id', movieIds)
.leftJoin('movies_scenes', 'movies_scenes.movie_id', 'movies.id')

View File

@ -1,4 +1,5 @@
import config from 'config';
import { CronJob } from 'cron';
import { knexOwner as knex } from './knex.js';
import { indexApi } from './manticore.js';
@ -8,7 +9,10 @@ import initLogger from './logger.js';
const logger = initLogger();
let lastActorsViewRefresh = 0;
const lastViewRefresh = {
actors: 0,
stashes: 0,
};
export function curateStash(stash, assets = {}) {
if (!stash) {
@ -19,7 +23,7 @@ export function curateStash(stash, assets = {}) {
id: stash.id,
name: stash.name,
slug: stash.slug,
primary: stash.primary,
isPrimary: stash.primary,
public: stash.public,
createdAt: stash.created_at,
stashedScenes: stash.stashed_scenes ?? null,
@ -38,10 +42,10 @@ export function curateStash(stash, assets = {}) {
function curateStashEntry(stash, user) {
const curatedStashEntry = {
user_id: user.id,
name: stash.name,
slug: slugify(stash.name),
public: false,
user_id: user?.id || undefined,
name: stash.name || undefined,
slug: slugify(stash.name) || undefined,
public: stash.public ?? false,
};
return curatedStashEntry;
@ -85,35 +89,57 @@ export async function fetchStashByUsernameAndSlug(username, stashSlug, sessionUs
export async function fetchStashes(domain, itemId, sessionUser) {
const stashes = await knex(`stashes_${domain}s`)
.select('stashes.*')
.leftJoin('stashes', 'stashes.id', `stashes_${domain}s.stash_id`)
.where({
[`${domain}_id`]: itemId,
user_id: sessionUser.id,
})
.leftJoin('stashes', 'stashes.id', `stashes_${domain}s.stash_id`);
});
return stashes.map((stash) => curateStash(stash));
}
function verifyStashName(stash) {
if (!stash.name) {
throw new HttpError('Stash name required', 400);
}
if (stash.name.length < config.stashes.nameLength[0]) {
throw new HttpError('Stash name is too short', 400);
}
if (stash.name.length > config.stashes.nameLength[1]) {
throw new HttpError('Stash name is too long', 400);
}
if (!config.stashes.namePattern.test(stash.name)) {
throw new HttpError('Stash name contains invalid characters', 400);
}
}
export async function refreshView(domain = 'stashes') {
// throttle view refreshes
if (new Date() - lastViewRefresh[domain] > config.stashes.viewRefreshCooldowns[domain] * 60000) {
lastViewRefresh[domain] = new Date();
logger.verbose(`Refreshing ${domain} view`);
await knex.schema.refreshMaterializedView(`${domain}_meta`);
await knex.schema.refreshMaterializedView('stashes_meta');
return true;
}
logger.debug(`Skipping ${domain} view refresh`);
return false;
}
export async function createStash(newStash, sessionUser) {
if (!sessionUser) {
throw new HttpError('You are not authenthicated', 401);
}
if (!newStash.name) {
throw new HttpError('Stash name required', 400);
}
if (newStash.name.length < config.stashes.nameLength[0]) {
throw new HttpError('Stash name is too short', 400);
}
if (newStash.name.length > config.stashes.nameLength[1]) {
throw new HttpError('Stash name is too long', 400);
}
if (!config.stashes.namePattern.test(newStash.name)) {
throw new HttpError('Stash name contains invalid characters', 400);
}
verifyStashName(newStash);
try {
const stash = await knex('stashes')
@ -130,24 +156,36 @@ export async function createStash(newStash, sessionUser) {
}
}
export async function updateStash(stashId, newStash, sessionUser) {
export async function updateStash(stashId, updatedStash, sessionUser) {
if (!sessionUser) {
throw new HttpError('You are not authenthicated', 401);
}
const stash = await knex('stashes')
.where({
id: stashId,
user_id: sessionUser.id,
})
.update(newStash)
.returning('*');
if (!stash) {
throw new HttpError('You are not authorized to modify this stash', 403);
if (updatedStash.name) {
verifyStashName(updatedStash);
}
return curateStash(stash);
try {
const stash = await knex('stashes')
.where({
id: stashId,
user_id: sessionUser.id,
})
.update(curateStashEntry(updatedStash))
.returning('*');
if (!stash) {
throw new HttpError('You are not authorized to modify this stash', 403);
}
return curateStash(stash);
} catch (error) {
if (error.routine === '_bt_check_unique') {
throw new HttpError('Stash name should be unique', 409);
}
throw error;
}
}
export async function removeStash(stashId, sessionUser) {
@ -168,21 +206,6 @@ export async function removeStash(stashId, sessionUser) {
}
}
export async function refreshActorsView() {
if (new Date() - lastActorsViewRefresh > config.stashes.viewRefreshCooldown * 60000) {
// don't refresh actors view more than once an hour
lastActorsViewRefresh = new Date();
logger.debug('Refreshing actors view');
return knex.schema.refreshMaterializedView('actors_meta');
}
logger.silly('Skipping actors view refresh');
return false;
}
export async function stashActor(actorId, stashId, sessionUser) {
const stash = await fetchStashById(stashId, sessionUser);
@ -206,7 +229,7 @@ export async function stashActor(actorId, stashId, sessionUser) {
logger.verbose(`${sessionUser.username} (${sessionUser.id}) stashed actor ${actorId} to stash ${stash.id} (${stash.name})`);
refreshActorsView();
refreshView('actors');
return fetchStashes('actor', actorId, sessionUser);
}
@ -241,7 +264,7 @@ export async function unstashActor(actorId, stashId, sessionUser) {
logger.verbose(`${sessionUser.username} (${sessionUser.id}) unstashed actor ${actorId} from stash ${stashId}`);
refreshActorsView();
refreshView('actors');
return fetchStashes('actor', actorId, sessionUser);
}
@ -270,6 +293,8 @@ export async function stashScene(sceneId, stashId, sessionUser) {
logger.verbose(`${sessionUser.username} (${sessionUser.id}) stashed scene ${sceneId} to stash ${stash.id} (${stash.name})`);
refreshView('scenes');
return fetchStashes('scene', sceneId, sessionUser);
}
@ -299,6 +324,8 @@ export async function unstashScene(sceneId, stashId, sessionUser) {
logger.verbose(`${sessionUser.username} (${sessionUser.id}) unstashed scene ${sceneId} from stash ${stashId}`);
refreshView('scenes');
return fetchStashes('scene', sceneId, sessionUser);
}
@ -325,6 +352,8 @@ export async function stashMovie(movieId, stashId, sessionUser) {
logger.verbose(`${sessionUser.username} (${sessionUser.id}) stashed movie ${movieId} to stash ${stash.id} (${stash.name})`);
refreshView('movies');
return fetchStashes('movie', movieId, sessionUser);
}
@ -354,5 +383,21 @@ export async function unstashMovie(movieId, stashId, sessionUser) {
logger.verbose(`${sessionUser.username} (${sessionUser.id}) unstashed movie ${movieId} from stash ${stashId}`);
refreshView('movies');
return fetchStashes('movie', movieId, sessionUser);
}
CronJob.from({
cronTime: config.stashes.viewRefreshCron,
async onTick() {
logger.verbose('Updating stash views');
await refreshView('scenes');
await refreshView('actors');
await refreshView('movies');
await refreshView('stashes');
},
start: true,
runOnInit: true,
});

View File

@ -18,7 +18,7 @@ export function curateUser(user, assets = {}) {
avatar: `/media/avatars/${user.id}_${user.username}.png`,
createdAt: user.created_at,
stashes: curatedStashes,
primaryStash: curatedStashes.find((stash) => stash.primary),
primaryStash: curatedStashes.find((stash) => stash.isPrimary),
};
return curatedUser;
@ -51,13 +51,14 @@ export async function fetchUser(userId, options = {}, reqUser) {
}
const stashes = await knex('stashes')
.select('stashes.*', 'stashes_meta.*')
.leftJoin('stashes_meta', 'stashes_meta.stash_id', 'stashes.id')
.where('user_id', user.id)
.modify((builder) => {
if (reqUser?.id !== user.id && !options.includeStashes) {
builder.where('public', true);
}
})
.leftJoin('stashes_meta', 'stashes_meta.stash_id', 'stashes.id');
});
if (options.raw) {
return { user, stashes };

View File

@ -1,21 +0,0 @@
export function curateUser(user, assets = {}) {
if (!user) {
return null;
}
const curatedStashes = assets.stashes?.filter(Boolean).map((stash) => curateStash(stash)) || [];
const curatedUser = {
id: user.id,
username: user.username,
email: user.email,
emailVerified: user.email_verified,
identityVerified: user.identity_verified,
avatar: `/media/avatars/${user.id}_${user.username}.png`,
createdAt: user.created_at,
stashes: curatedStashes,
primaryStash: curatedStashes.find((stash) => stash.primary),
};
return curatedUser;
}