From 495483814061ef96fef0acada279d56c11648888 Mon Sep 17 00:00:00 2001 From: Niels Date: Tue, 24 Dec 2024 16:37:09 +0100 Subject: [PATCH 1/6] feat: redirect to /home instead of /auth --- src/lib/server/auth/authorization.ts | 4 ++-- src/routes/(public)/home/+page.svelte | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 src/routes/(public)/home/+page.svelte diff --git a/src/lib/server/auth/authorization.ts b/src/lib/server/auth/authorization.ts index 6e69448e..da50aa97 100644 --- a/src/lib/server/auth/authorization.ts +++ b/src/lib/server/auth/authorization.ts @@ -38,11 +38,11 @@ const handleAuthorization = (async ({ event, resolve }) => { if (event.route.id?.includes('(public)')) { // Resolve normally return await resolve(event) - } else if (!url.startsWith('/auth')) { + } else if (!url.startsWith('/home')) { // If the path is something other than /auth, check if the user is logged in if (!user) { - return redirect(303, '/auth') + return redirect(301, '/home') } if (user.accessDisabled) { diff --git a/src/routes/(public)/home/+page.svelte b/src/routes/(public)/home/+page.svelte new file mode 100644 index 00000000..80d49a8f --- /dev/null +++ b/src/routes/(public)/home/+page.svelte @@ -0,0 +1,23 @@ + + +
+
+ invictus logo +
+
+ + From c20d93160c198bf99dcfdf9748b4d9a4e22af0ac Mon Sep 17 00:00:00 2001 From: Niels Date: Tue, 24 Dec 2024 20:56:08 +0100 Subject: [PATCH 2/6] bug: fix redirecting to /home --- src/lib/server/auth/authorization.ts | 4 ++-- src/lib/server/auth/index.ts | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/lib/server/auth/authorization.ts b/src/lib/server/auth/authorization.ts index da50aa97..6d5c4631 100644 --- a/src/lib/server/auth/authorization.ts +++ b/src/lib/server/auth/authorization.ts @@ -38,11 +38,11 @@ const handleAuthorization = (async ({ event, resolve }) => { if (event.route.id?.includes('(public)')) { // Resolve normally return await resolve(event) - } else if (!url.startsWith('/home')) { + } else if (!url.startsWith('/home') || !url.startsWith('/auth')) { // If the path is something other than /auth, check if the user is logged in if (!user) { - return redirect(301, '/home') + return redirect(303, '/home') } if (user.accessDisabled) { diff --git a/src/lib/server/auth/index.ts b/src/lib/server/auth/index.ts index 04c43783..b9a7a884 100644 --- a/src/lib/server/auth/index.ts +++ b/src/lib/server/auth/index.ts @@ -32,11 +32,8 @@ const { }, callbacks: { async redirect({ url, baseUrl }) { - if (url.startsWith('/auth')) { - throw redirect(303, '/') - } - - return baseUrl + // Redirect to / after signin + return '/' }, }, }) From 5e90edacccfb6e6904313c46ea2f95a6dda4c1da Mon Sep 17 00:00:00 2001 From: Niels Date: Tue, 24 Dec 2024 20:56:33 +0100 Subject: [PATCH 3/6] feat: add first part of landing page, slides not done yet --- src/routes/(public)/home/+page.server.ts | 13 ++ src/routes/(public)/home/+page.svelte | 243 ++++++++++++++++++++++- src/routes/(public)/home/+page.ts | 2 + 3 files changed, 255 insertions(+), 3 deletions(-) create mode 100644 src/routes/(public)/home/+page.server.ts create mode 100644 src/routes/(public)/home/+page.ts diff --git a/src/routes/(public)/home/+page.server.ts b/src/routes/(public)/home/+page.server.ts new file mode 100644 index 00000000..2d098edf --- /dev/null +++ b/src/routes/(public)/home/+page.server.ts @@ -0,0 +1,13 @@ +import type { PageServerLoad } from './$types' + +export const load = (async ({ locals }) => { + if (locals.user) { + return { + name: locals.user.firstName, + } + } + + return { + name: null, + } +}) satisfies PageServerLoad diff --git a/src/routes/(public)/home/+page.svelte b/src/routes/(public)/home/+page.svelte index 80d49a8f..046ec474 100644 --- a/src/routes/(public)/home/+page.svelte +++ b/src/routes/(public)/home/+page.svelte @@ -1,23 +1,260 @@
-
+
invictus logo + +
+

Wij zijn O.D.D. Invictus

+

Onafhankelijk dispuut uit Enschede

+
+ +
+ + {#if currentElem < elements.length - 1} + + {:else} + + {/if} + +
+
+ +
+
+ invictus logo + Groep +
+ +
+ invictus logo + lichtingen +
+ +
+ invictus logo + deze zo van de zijkant is nice Contact +
diff --git a/src/routes/(public)/home/+page.ts b/src/routes/(public)/home/+page.ts new file mode 100644 index 00000000..b82babe8 --- /dev/null +++ b/src/routes/(public)/home/+page.ts @@ -0,0 +1,2 @@ +export const prerender = true +export const csr = true From 16775a2cac7818a851ab5d769c3ca97157a16dc7 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 1 Jan 2025 14:07:05 +0100 Subject: [PATCH 4/6] wip: change frontpage from admin panel --- README.md | 2 +- prisma/schema.prisma | 32 +++++++++++++++++++++ src/lib/server/settings/settings.ts | 1 + src/routes/(app)/admin/+page.svelte | 11 +++++++ src/routes/(app)/admin/home/+page.server.ts | 10 +++++++ src/routes/(app)/admin/home/+page.svelte | 24 ++++++++++++++++ src/routes/(app)/admin/home/+server.ts | 5 ++++ 7 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 src/routes/(app)/admin/home/+page.server.ts create mode 100644 src/routes/(app)/admin/home/+page.svelte create mode 100644 src/routes/(app)/admin/home/+server.ts diff --git a/README.md b/README.md index 536792da..ed90b0fb 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Invictus Bier Systeem is _het_ websysteem voor O.D.D. Invictus. ## Ontwikkelen -IBS3 gebruikt node 22.4.0 +IBS3 gebruikt node 22.11.0 Om te beginnen met ontwikkelen moet je eerst de repository clonen met diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 818c0a37..1f0548e0 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -96,6 +96,8 @@ model User { File File[] AccessToken AccessToken[] Activity Activity[] + + FrontPageItem FrontPageItem[] } model Account { @@ -915,6 +917,8 @@ model File { Photo Photo[] Journal Journal? @relation(fields: [journalId], references: [id]) journalId Int? + + FrontPageImage FrontPageItem[] } // @@ -933,3 +937,31 @@ model Job { completedAt DateTime? result String? } + +// +// Dit moet natuurlijk in de database +// +model FrontPageItem { + id Int @id @default(autoincrement()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + // HTML ID waar deze foto komt + key String + // Titel (staat bij een foto) + // bijv. Lichting 1 + title String + // Bijbehordende beschrijving + description String + visible Boolean @default(false) + + // verwijst dit item naar een andere pagina? + link String? + + changedBy User? @relation(fields: [userId], references: [id], onDelete: NoAction) + userId Int? + + // Photo + file File @relation(fields: [fileId], references: [id], onDelete: Cascade) + fileId String +} diff --git a/src/lib/server/settings/settings.ts b/src/lib/server/settings/settings.ts index 735a58e3..a9515f7c 100644 --- a/src/lib/server/settings/settings.ts +++ b/src/lib/server/settings/settings.ts @@ -25,6 +25,7 @@ export enum Setting { DEFAULT_SALE_FOOD_LEDGER = 'DEFAULT_SALE_FOOD_LEDGER', DEFAULT_SALE_OTHER_LEDGER = 'DEFAULT_SALE_OTHER_LEDGER', STRAFBAKKEN_VERDUBBELAAR_ENABLED = 'STRAFBAKKEN_VERDUBBELAAR_ENABLED', + DESCRIPTION_INVICTUS = 'DESCRIPTION_INVICTUS', } export const settings = { diff --git a/src/routes/(app)/admin/+page.svelte b/src/routes/(app)/admin/+page.svelte index a8d33e2f..7bd8f8fb 100644 --- a/src/routes/(app)/admin/+page.svelte +++ b/src/routes/(app)/admin/+page.svelte @@ -9,6 +9,7 @@ import TablerFiles from '~icons/tabler/files' import TablerAdjustmentsCog from '~icons/tabler/adjustments-cog' import TablerListNumbers from '~icons/tabler/list-numbers' + import TablerHome from '~icons/tabler/home' import TablerBeer from '~icons/tabler/beer' import TablerBackhoe from '~icons/tabler/backhoe' import { toast } from '$lib/notification' @@ -53,6 +54,16 @@ + + + + + + + Verander publieke homepage + + + diff --git a/src/routes/(app)/admin/home/+page.server.ts b/src/routes/(app)/admin/home/+page.server.ts new file mode 100644 index 00000000..03434ece --- /dev/null +++ b/src/routes/(app)/admin/home/+page.server.ts @@ -0,0 +1,10 @@ +import type { PageServerLoad } from './$types' +import db from '$lib/server/db' +import { Setting, settings } from '$lib/server/settings' + +export const load = (async () => { + const photos = await db.frontPageItem.findMany() + const description = settings.get(Setting.DESCRIPTION_INVICTUS) + + return { photos, description } +}) satisfies PageServerLoad diff --git a/src/routes/(app)/admin/home/+page.svelte b/src/routes/(app)/admin/home/+page.svelte new file mode 100644 index 00000000..891b5c15 --- /dev/null +++ b/src/routes/(app)/admin/home/+page.svelte @@ -0,0 +1,24 @@ + + + + +<h2>Groepsfoto</h2> + +<hr /> + +<h2>Tijdelijke foto</h2> + +<hr /> + +<h2>Omschrijving Invictus</h2> + +<hr /> + +<h2>Lichtingen</h2> + +<hr /> diff --git a/src/routes/(app)/admin/home/+server.ts b/src/routes/(app)/admin/home/+server.ts new file mode 100644 index 00000000..40a03e73 --- /dev/null +++ b/src/routes/(app)/admin/home/+server.ts @@ -0,0 +1,5 @@ +import type { RequestHandler } from './$types' + +export const GET: RequestHandler = async () => { + return new Response() +} From d3cc5384e48e057b498411736644c0c775d43125 Mon Sep 17 00:00:00 2001 From: Niels <git@nierot.com> Date: Wed, 1 Jan 2025 14:07:51 +0100 Subject: [PATCH 5/6] chore: remove old code --- .../(app)/activiteit/nieuw/+page.server.ts | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/routes/(app)/activiteit/nieuw/+page.server.ts b/src/routes/(app)/activiteit/nieuw/+page.server.ts index 2ca23600..3cf2c55a 100644 --- a/src/routes/(app)/activiteit/nieuw/+page.server.ts +++ b/src/routes/(app)/activiteit/nieuw/+page.server.ts @@ -239,23 +239,6 @@ export const actions = { if (image.size > 0) { const filename = await uploadPhoto(image, event.locals.user, false) - // const buf = Buffer.from(await image.arrayBuffer()) - - // const photo = await uploadPhoto( - // { - // creator, - // uploader: event.locals.user, - // runProcessingJob: false, - // additionalName: 'Activiteit', - // invisible: true, - // upload: { - // buf, - // filename: image.name, - // }, - // }, - // tx, - // ) - await tx.activity.update({ where: { id: activity.id, From 2ea75c65324167965b1fff5436a1d07678d24e03 Mon Sep 17 00:00:00 2001 From: Niels <git@nierot.com> Date: Wed, 1 Jan 2025 14:08:14 +0100 Subject: [PATCH 6/6] feat: store pictures of frontpage --- src/routes/(public)/home/+page.server.ts | 22 ++++++++++++++++------ src/routes/(public)/home/+page.svelte | 21 +++++++++++++++++++-- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/routes/(public)/home/+page.server.ts b/src/routes/(public)/home/+page.server.ts index 2d098edf..1b49c513 100644 --- a/src/routes/(public)/home/+page.server.ts +++ b/src/routes/(public)/home/+page.server.ts @@ -1,13 +1,23 @@ +import db from '$lib/server/db' import type { PageServerLoad } from './$types' export const load = (async ({ locals }) => { - if (locals.user) { - return { - name: locals.user.firstName, - } - } + const name = locals.user?.firstName ?? null + + const photos = await db.frontPageItem.findMany({ + where: { + visible: true, + }, + }) + + const temp = photos.find(p => p.key === 'temp') + const group = photos.find(p => p.key === 'group') + const lichtingen = photos.find(p => p.key.includes('lichting')) return { - name: null, + name, + group, + lichtingen, + temp, } }) satisfies PageServerLoad diff --git a/src/routes/(public)/home/+page.svelte b/src/routes/(public)/home/+page.svelte index 046ec474..ed7a9491 100644 --- a/src/routes/(public)/home/+page.svelte +++ b/src/routes/(public)/home/+page.svelte @@ -8,7 +8,7 @@ export let data: PageData let currentElem = 0 - const elements = ['main', 'group', 'lichtingen', 'contact'] + const elements = ['main', 'temp', 'group', 'lichtingen', 'contact'] function scroll() { const scrollButton = document.querySelector('.scroll') @@ -38,8 +38,15 @@ signIn('authentik') } } + + function getPhoto(photo) {} </script> +<!-- heerlijke hack --> +<!-- de laatste css regel die geladen wordt is een display:none, die haalt dit weg --> +<!-- Voorkomt een content flash --> +<div id="overlay" style="position:absolute;top:0px;left:0px;background-color:#551b8a;width:100vw;height:100vh;z-index:9999;"></div> + <main> <section class="center first" id="main"> <img src="logo.png" alt="invictus logo" /> @@ -63,6 +70,13 @@ </section> <div class="rest"> + {#if data.temp} + <section id="temp"> + <img src="no-activity.jpeg" alt="invictus logo" /> + Temp + </section> + {/if} + <section id="group"> <img src="no-activity.jpeg" alt="invictus logo" /> Groep @@ -124,7 +138,6 @@ display: flex; flex-direction: column; - // Animate these h1, h3 { overflow: hidden; @@ -257,4 +270,8 @@ transform: translate(0); } } + + #overlay { + display: none; + } </style>