From d739975d36f478b41d83dca39d7e3e0323788440 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Thu, 25 Jan 2024 03:07:26 +0100 Subject: [PATCH] Fixed pagination. Added entity page channel tile expand. --- assets/css/breakpoints.css | 2 + assets/css/theme.css | 1 + components/actors/tile.vue | 2 +- components/entities/tile.vue | 51 ++++ components/filters/actor.vue | 94 +++++++ components/filters/actors.vue | 122 ++++----- components/filters/channels.vue | 11 +- components/filters/filters.vue | 2 +- components/filters/tags.vue | 2 +- components/pagination/pagination.vue | 11 +- components/scenes/scenes.vue | 61 +++-- package-lock.json | 252 ++++++++++++++++++ package.json | 3 + pages/_error/+Page.vue | 31 ++- pages/actors/@actorId/+Page.vue | 1 - pages/entities/+Page.vue | 125 +++++++++ pages/entities/+onBeforeRender.js | 14 + pages/entities/+route.js | 1 + pages/entities/@entitySlug/+Page.vue | 246 +++++++++++++++++ pages/entities/@entitySlug/+onBeforeRender.js | 51 ++++ pages/entities/@entitySlug/+route.js | 23 ++ pages/updates/+Page.vue | 1 + renderer/+onRenderClient.js | 9 +- renderer/app.js | 3 + renderer/container.vue | 14 + src/actors.js | 4 +- src/entities.js | 39 ++- src/scenes.js | 5 + utils/media-path.js | 3 - 29 files changed, 1056 insertions(+), 128 deletions(-) create mode 100644 components/entities/tile.vue create mode 100644 components/filters/actor.vue create mode 100644 pages/entities/+Page.vue create mode 100644 pages/entities/+onBeforeRender.js create mode 100644 pages/entities/+route.js create mode 100644 pages/entities/@entitySlug/+Page.vue create mode 100644 pages/entities/@entitySlug/+onBeforeRender.js create mode 100644 pages/entities/@entitySlug/+route.js diff --git a/assets/css/breakpoints.css b/assets/css/breakpoints.css index cb46cf0..015083e 100644 --- a/assets/css/breakpoints.css +++ b/assets/css/breakpoints.css @@ -1 +1,3 @@ +@custom-media --small-10 (max-width: 768px); +@custom-media --small (max-width: 900px); @custom-media --compact (max-width: 1200px); diff --git a/assets/css/theme.css b/assets/css/theme.css index 3819b75..75e2c9f 100644 --- a/assets/css/theme.css +++ b/assets/css/theme.css @@ -3,6 +3,7 @@ --primary-strong: #f90071; --primary-faded: #ffcce4; + --grey-dark-50: #111; --grey-dark-40: #222; --grey-dark-30: #444; --grey-dark-20: #666; diff --git a/components/actors/tile.vue b/components/actors/tile.vue index 9eaa99b..0624893 100644 --- a/components/actors/tile.vue +++ b/components/actors/tile.vue @@ -32,7 +32,7 @@ diff --git a/components/entities/tile.vue b/components/entities/tile.vue new file mode 100644 index 0000000..af4d677 --- /dev/null +++ b/components/entities/tile.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/components/filters/actor.vue b/components/filters/actor.vue new file mode 100644 index 0000000..047ab67 --- /dev/null +++ b/components/filters/actor.vue @@ -0,0 +1,94 @@ + + + + + diff --git a/components/filters/actors.vue b/components/filters/actors.vue index 8303a06..4739e57 100644 --- a/components/filters/actors.vue +++ b/components/filters/actors.vue @@ -4,7 +4,7 @@ @@ -46,60 +46,44 @@ + + + + diff --git a/pages/entities/+onBeforeRender.js b/pages/entities/+onBeforeRender.js new file mode 100644 index 0000000..f43a690 --- /dev/null +++ b/pages/entities/+onBeforeRender.js @@ -0,0 +1,14 @@ +import { fetchEntities } from '#/src/entities.js'; + +export async function onBeforeRender(_pageContext) { + const networks = await fetchEntities({ type: 'primary' }); + + return { + pageContext: { + title: 'Channels', + pageProps: { + networks, + }, + }, + }; +} diff --git a/pages/entities/+route.js b/pages/entities/+route.js new file mode 100644 index 0000000..f625472 --- /dev/null +++ b/pages/entities/+route.js @@ -0,0 +1 @@ +export default '/channels'; diff --git a/pages/entities/@entitySlug/+Page.vue b/pages/entities/@entitySlug/+Page.vue new file mode 100644 index 0000000..a5406fa --- /dev/null +++ b/pages/entities/@entitySlug/+Page.vue @@ -0,0 +1,246 @@ + + + + + diff --git a/pages/entities/@entitySlug/+onBeforeRender.js b/pages/entities/@entitySlug/+onBeforeRender.js new file mode 100644 index 0000000..4c00a23 --- /dev/null +++ b/pages/entities/@entitySlug/+onBeforeRender.js @@ -0,0 +1,51 @@ +import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */ + +import { fetchEntitiesById } from '#/src/entities.js'; +import { fetchScenes } from '#/src/scenes.js'; +import { curateScenesQuery } from '#/src/web/scenes.js'; +import redis from '#/src//redis.js'; + +export async function onBeforeRender(pageContext) { + const entityId = await redis.hGet('traxxx:entities:id_by_slug', pageContext.routeParams.entityType === 'network' ? `_${pageContext.routeParams.entitySlug}` : pageContext.routeParams.entitySlug); + + if (!entityId) { + throw render(404, `Cannot find ${pageContext.routeParams.entityType} '${pageContext.routeParams.entitySlug}'.`); + } + + const [[entity], entityScenes] = await Promise.all([ + fetchEntitiesById([Number(entityId)], { includeChildren: true }), + fetchScenes(await curateScenesQuery({ + ...pageContext.urlQuery, + scope: pageContext.routeParams.scope || 'latest', + entityId: Number(entityId), + }), { + page: Number(pageContext.routeParams.page) || 1, + limit: Number(pageContext.urlParsed.search.limit) || 30, + aggregate: true, + }), + ]); + + const { + scenes, + aggActors, + aggTags, + aggChannels, + total, + limit, + } = entityScenes; + + return { + pageContext: { + title: entity.name, + pageProps: { + entity, + scenes, + aggActors, + aggTags, + aggChannels, + total, + limit, + }, + }, + }; +} diff --git a/pages/entities/@entitySlug/+route.js b/pages/entities/@entitySlug/+route.js new file mode 100644 index 0000000..3fbcf82 --- /dev/null +++ b/pages/entities/@entitySlug/+route.js @@ -0,0 +1,23 @@ +import { match } from 'path-to-regexp'; +// import { resolveRoute } from 'vike/routing'; // eslint-disable-line import/extensions + +const path = '/:entityType(channel|network)/:entitySlug/:scope?/:page?'; +const urlMatch = match(path, { decode: decodeURIComponent }); + +export default (pageContext) => { + const matched = urlMatch(pageContext.urlPathname); + + if (matched) { + return { + routeParams: { + entityType: matched.params.entityType, + entitySlug: matched.params.entitySlug, + scope: matched.params.scope || 'latest', + page: matched.params.page || '1', + path, + }, + }; + } + + return false; +}; diff --git a/pages/updates/+Page.vue b/pages/updates/+Page.vue index 21efa06..dcfc476 100644 --- a/pages/updates/+Page.vue +++ b/pages/updates/+Page.vue @@ -4,6 +4,7 @@ :scenes="scenes" :show-filters="false" :show-meta="false" + :show-scope-tabs="true" /> diff --git a/renderer/+onRenderClient.js b/renderer/+onRenderClient.js index 5ad94ea..4e7fd8f 100644 --- a/renderer/+onRenderClient.js +++ b/renderer/+onRenderClient.js @@ -1,12 +1,17 @@ // https://vike.dev/onRenderClient -import { createApp } from './app'; +import { createApp } from './app.js'; // This onRenderClient() hook only supports SSR, see https://vike.dev/render-modes for how to modify onRenderClient() // to support SPA async function onRenderClient(pageContext) { const { Page, pageProps } = pageContext; - if (!Page) throw new Error('Client-side render() hook expects pageContext.Page to be defined'); + + if (!Page) { + throw new Error('Client-side render() hook expects pageContext.Page to be defined'); + } + const app = createApp(Page, pageProps, pageContext); + app.mount('#app'); } diff --git a/renderer/app.js b/renderer/app.js index 18f973d..8ca79ce 100644 --- a/renderer/app.js +++ b/renderer/app.js @@ -1,4 +1,5 @@ import { createSSRApp, h } from 'vue'; +import VueVirtualScroller from 'vue-virtual-scroller'; import { setPageContext } from './usePageContext.js'; @@ -30,6 +31,8 @@ function createApp(Page, pageProps, pageContext) { app.provide('pageContext', pageContext); + app.use(VueVirtualScroller); + app.component('Link', Link); app.component('Icon', Icon); diff --git a/renderer/container.vue b/renderer/container.vue index 8ebd27b..491e7bc 100644 --- a/renderer/container.vue +++ b/renderer/container.vue @@ -32,6 +32,20 @@ onMounted(() => { }); + +