Add route structure
This commit is contained in:
11
src/lib/Gallery.svelte
Normal file
11
src/lib/Gallery.svelte
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<section class="gallery">
|
||||||
|
<slot />
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
9
src/lib/Icon.svelte
Normal file
9
src/lib/Icon.svelte
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<script>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
32
src/lib/Photo.svelte
Normal file
32
src/lib/Photo.svelte
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* The source of the image.
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export let src;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alternative text for the image. Used for accessibility.
|
||||||
|
* @type {string | undefined}
|
||||||
|
*/
|
||||||
|
export let alt = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The click handler for the image.
|
||||||
|
* @param {MouseEvent} event
|
||||||
|
*/
|
||||||
|
async function clickHandler(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<a href="{src}" on:click={clickHandler}>
|
||||||
|
<figure class="photo">
|
||||||
|
<img src="{src}" alt="{alt}" />
|
||||||
|
</figure>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
29
src/lib/albums.json
Normal file
29
src/lib/albums.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"slug": "sts",
|
||||||
|
"title": "Testgalerie",
|
||||||
|
"description": "Das ist eine Testgalerie",
|
||||||
|
"timestamp": "2023-08-04T00:00:00.000Z",
|
||||||
|
"place": "Berlin",
|
||||||
|
"tags": [
|
||||||
|
"Berlin",
|
||||||
|
"Test"
|
||||||
|
],
|
||||||
|
"license": "CC BY-NC-ND 4.0",
|
||||||
|
"items": "img.zip",
|
||||||
|
"itemsMeta": [
|
||||||
|
{
|
||||||
|
"item": "cover.jpg",
|
||||||
|
"title": "Cover",
|
||||||
|
"description": "Das ist das Cover",
|
||||||
|
"timestamp": "2023-08-04T00:00:00.000Z",
|
||||||
|
"place": "Berlin",
|
||||||
|
"tags": [
|
||||||
|
"Berlin",
|
||||||
|
"Cover"
|
||||||
|
],
|
||||||
|
"license": "CC BY-NC-ND 4.0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
@ -1 +0,0 @@
|
|||||||
// place files you want to import through the `$lib` alias in this folder.
|
|
||||||
6
src/routes/+error.svelte
Normal file
6
src/routes/+error.svelte
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<script>
|
||||||
|
import { page } from '$app/stores';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1>{$page.status}</h1>
|
||||||
|
<p>{$page.error?.message}</p>
|
||||||
@ -1,2 +0,0 @@
|
|||||||
<h1>Welcome to SvelteKit</h1>
|
|
||||||
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
|
|
||||||
0
src/routes/g/+page.svelte
Normal file
0
src/routes/g/+page.svelte
Normal file
0
src/routes/g/.gallery
Normal file
0
src/routes/g/.gallery
Normal file
16
src/routes/g/[slug]/[[timestamp]]/+page.js
Normal file
16
src/routes/g/[slug]/[[timestamp]]/+page.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
import albums from '$lib/albums.json';
|
||||||
|
|
||||||
|
/** @type {import('./$types').PageLoad} */
|
||||||
|
export function load({ params }) {
|
||||||
|
const album = albums.find((album) => album.slug === params.slug);
|
||||||
|
if (album) {
|
||||||
|
return {
|
||||||
|
title: album.title,
|
||||||
|
content: album.description,
|
||||||
|
image: '/s/lga/?i=LFB04128-Enhanced-NR.jpg'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
throw error(404, 'Not found');
|
||||||
|
}
|
||||||
8
src/routes/g/[slug]/[[timestamp]]/+page.svelte
Normal file
8
src/routes/g/[slug]/[[timestamp]]/+page.svelte
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<script>
|
||||||
|
/** @type {import('./$types').PageData} */
|
||||||
|
export let data;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1>{data.title}</h1>
|
||||||
|
<div>{@html data.content}</div>
|
||||||
|
<img src={data.image} alt={data.title} />
|
||||||
0
src/routes/g/[slug]/[[timestamp]]/.album
Normal file
0
src/routes/g/[slug]/[[timestamp]]/.album
Normal file
17
src/routes/g/[slug]/[[timestamp]]/d/+server.js
Normal file
17
src/routes/g/[slug]/[[timestamp]]/d/+server.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
/** @type {import('./$types').RequestHandler} */
|
||||||
|
export function GET({ url }) {
|
||||||
|
const min = Number(url.searchParams.get('min') ?? '0');
|
||||||
|
const max = Number(url.searchParams.get('max') ?? '1');
|
||||||
|
|
||||||
|
const d = max - min;
|
||||||
|
|
||||||
|
if (isNaN(d) || d < 0) {
|
||||||
|
throw error(400, 'min and max must be numbers, and min must be less than max');
|
||||||
|
}
|
||||||
|
|
||||||
|
const random = min + Math.random() * d;
|
||||||
|
|
||||||
|
return new Response(String(random));
|
||||||
|
}
|
||||||
0
src/routes/g/[slug]/[[timestamp]]/d/.download
Normal file
0
src/routes/g/[slug]/[[timestamp]]/d/.download
Normal file
0
src/routes/g/[slug]/[[timestamp]]/i/[item]/+page.js
Normal file
0
src/routes/g/[slug]/[[timestamp]]/i/[item]/+page.js
Normal file
26
src/routes/g/[slug]/[[timestamp]]/i/[item]/d/+server.js
Normal file
26
src/routes/g/[slug]/[[timestamp]]/i/[item]/d/+server.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
/** @type {import('./$types').RequestHandler} */
|
||||||
|
export function GET({ url }) {
|
||||||
|
const noAttachment = url.searchParams.has('r');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const min = Number(url.searchParams.get('min') ?? '0');
|
||||||
|
const max = Number(url.searchParams.get('max') ?? '1');
|
||||||
|
|
||||||
|
const d = max - min;
|
||||||
|
|
||||||
|
if (isNaN(d) || d < 0) {
|
||||||
|
throw error(400, 'min and max must be numbers, and min must be less than max');
|
||||||
|
}
|
||||||
|
|
||||||
|
const random = min + Math.random() * d;
|
||||||
|
|
||||||
|
return new Response(String(random), {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'text/plain',
|
||||||
|
'Content-Disposition': noAttachment ? 'inline' : 'attachment'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
17
src/routes/g/[slug]/[[timestamp]]/i/[item]/t/+server.js
Normal file
17
src/routes/g/[slug]/[[timestamp]]/i/[item]/t/+server.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
/** @type {import('./$types').RequestHandler} */
|
||||||
|
export function GET({ url }) {
|
||||||
|
const min = Number(url.searchParams.get('min') ?? '0');
|
||||||
|
const max = Number(url.searchParams.get('max') ?? '1');
|
||||||
|
|
||||||
|
const d = max - min;
|
||||||
|
|
||||||
|
if (isNaN(d) || d < 0) {
|
||||||
|
throw error(400, 'min and max must be numbers, and min must be less than max');
|
||||||
|
}
|
||||||
|
|
||||||
|
const random = min + Math.random() * d;
|
||||||
|
|
||||||
|
return new Response(String(random));
|
||||||
|
}
|
||||||
26
src/routes/g/[slug]/[[timestamp]]/j/+server.js
Normal file
26
src/routes/g/[slug]/[[timestamp]]/j/+server.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
/** @type {import('./$types').RequestHandler} */
|
||||||
|
export function GET({ url }) {
|
||||||
|
const noAttachment = url.searchParams.has('r');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const min = Number(url.searchParams.get('min') ?? '0');
|
||||||
|
const max = Number(url.searchParams.get('max') ?? '1');
|
||||||
|
|
||||||
|
const d = max - min;
|
||||||
|
|
||||||
|
if (isNaN(d) || d < 0) {
|
||||||
|
throw error(400, 'min and max must be numbers, and min must be less than max');
|
||||||
|
}
|
||||||
|
|
||||||
|
const random = min + Math.random() * d;
|
||||||
|
|
||||||
|
return new Response(String(random), {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'text/plain',
|
||||||
|
'Content-Disposition': noAttachment ? 'inline' : 'attachment'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
0
src/routes/g/[slug]/[[timestamp]]/j/.json
Normal file
0
src/routes/g/[slug]/[[timestamp]]/j/.json
Normal file
Reference in New Issue
Block a user