Change many lines
This commit is contained in:
@ -1,11 +0,0 @@
|
||||
<script>
|
||||
|
||||
</script>
|
||||
|
||||
<section class="gallery">
|
||||
<slot />
|
||||
</section>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@ -1,29 +0,0 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
7
src/lib/components/Footer.svelte
Normal file
7
src/lib/components/Footer.svelte
Normal file
@ -0,0 +1,7 @@
|
||||
<footer>
|
||||
|
||||
</footer>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
36
src/lib/components/Gallery.svelte
Normal file
36
src/lib/components/Gallery.svelte
Normal file
@ -0,0 +1,36 @@
|
||||
<script>
|
||||
import { strf } from '$lib/data/language.js';
|
||||
|
||||
function sortItems() {
|
||||
items.sort((a, b) => {
|
||||
if (a.item < b.item) return -1;
|
||||
if (a.item > b.item) return 1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
/** @type {Item[]} */
|
||||
export let items = [];
|
||||
|
||||
export let base = '';
|
||||
</script>
|
||||
|
||||
<section class="gallery">
|
||||
<ul>
|
||||
{#each items as item (item.item)}
|
||||
<!-- <Photo src={`${uriBase}&item=${item.item}`} alt={$strf(item.title)} /> -->
|
||||
<li>
|
||||
<h3>{item.item}</h3>
|
||||
<p>
|
||||
<b>Title:</b> {$strf(item.title)}<br />
|
||||
<b>Description:</b> {#if item.description}{$strf(item.description)}{:else}<i>no description</i>{/if}
|
||||
</p>
|
||||
<img src={`${base}&item=${item.item}`} alt={$strf(item.title)} />
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
20
src/lib/components/Header.svelte
Normal file
20
src/lib/components/Header.svelte
Normal file
@ -0,0 +1,20 @@
|
||||
<script>
|
||||
import Icon from "./Icon.svelte";
|
||||
|
||||
export let title = 'Galerie';
|
||||
export let description = '';
|
||||
/** @type {string | undefined} */
|
||||
export let back = undefined;
|
||||
</script>
|
||||
|
||||
<header>
|
||||
<section class="title">
|
||||
{#if back}
|
||||
<a href={back}>
|
||||
<Icon name="arrow-left" />
|
||||
</a>
|
||||
{/if}
|
||||
<h1>{title}</h1>
|
||||
<p>{description}</p>
|
||||
</section>
|
||||
</header>
|
||||
@ -1,5 +1,6 @@
|
||||
<script>
|
||||
|
||||
export let name = '';
|
||||
name;
|
||||
</script>
|
||||
|
||||
|
||||
5
src/lib/data/album.js
Normal file
5
src/lib/data/album.js
Normal file
@ -0,0 +1,5 @@
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
const album = {error: "Not found"};
|
||||
/** @type {import('svelte/store').Writable<ApiError | Album>} */
|
||||
export default writable(album);
|
||||
69
src/lib/data/language.js
Normal file
69
src/lib/data/language.js
Normal file
@ -0,0 +1,69 @@
|
||||
import { writable, derived } from "svelte/store";
|
||||
|
||||
/** @type {import('svelte/store').Writable<TranslationKey>} */
|
||||
export const language = writable('de');
|
||||
|
||||
/**
|
||||
* @type {Record<TranslationKey, Record<String, String>>}
|
||||
*/
|
||||
const translations = {
|
||||
de: {
|
||||
'gallery': 'Galerie',
|
||||
'album': 'Album',
|
||||
'albums': 'Alben',
|
||||
'photo': 'Foto',
|
||||
'photos': 'Fotos',
|
||||
'video': 'Video',
|
||||
'videos': 'Videos',
|
||||
'back': 'Zurück',
|
||||
'small': 'Klein',
|
||||
'medium': 'Mittel',
|
||||
'large': 'Groß',
|
||||
'open': 'Öffnen',
|
||||
'download': 'Herunterladen',
|
||||
'download-all': 'Alle herunterladen',
|
||||
},
|
||||
en: {
|
||||
'gallery': 'Gallery',
|
||||
'album': 'Album',
|
||||
'albums': 'Albums',
|
||||
'photo': 'Photo',
|
||||
'photos': 'Photos',
|
||||
'video': 'Video',
|
||||
'videos': 'Videos',
|
||||
'back': 'Back',
|
||||
'small': 'Small',
|
||||
'medium': 'Medium',
|
||||
'large': 'Large',
|
||||
'open': 'Open',
|
||||
'download': 'Download',
|
||||
'download-all': 'Download all',
|
||||
}
|
||||
};
|
||||
|
||||
export const str = derived(language, $language => {
|
||||
/**
|
||||
* @param {string} key
|
||||
* @param {...any} args
|
||||
*/
|
||||
function translate(key, ...args) {
|
||||
const str = translations[$language][key];
|
||||
if (str === undefined) return key;
|
||||
return str.replace(/\{(\d+)\}/g, (_, i) => args[i]);
|
||||
}
|
||||
return translate;
|
||||
});
|
||||
|
||||
export const strf = derived(language, $language => {
|
||||
/**
|
||||
* @param {Translation | string} translations
|
||||
* @param {...any} args
|
||||
*/
|
||||
function translate(translations, ...args) {
|
||||
if (typeof translations === 'string') return translations;
|
||||
const str = translations[$language];
|
||||
if (str === undefined) return translations.de;
|
||||
return str.replace(/\{(\w+)\}/g, (_, i) => args[i]);
|
||||
}
|
||||
return translate;
|
||||
});
|
||||
73
src/lib/data/licenses.json
Normal file
73
src/lib/data/licenses.json
Normal file
@ -0,0 +1,73 @@
|
||||
[
|
||||
{
|
||||
"type": "cc0",
|
||||
"title": "CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
|
||||
"text": {
|
||||
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, <b>ohne um weitere Erlaubnis bitten zu müssen</b>.",
|
||||
"en": "You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission."
|
||||
},
|
||||
"url": "https://creativecommons.org/publicdomain/zero/1.0/"
|
||||
},
|
||||
{
|
||||
"type": "cc-by",
|
||||
"title": "Creative Commons Attribution 4.0 International (CC BY 4.0)",
|
||||
"text": {
|
||||
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, <b>wenn Sie den Namen des Autors nennen</b>, die Lizenz erwähnen und ggf. angeben, ob Veränderungen vorgenommen wurden.",
|
||||
"en": "You can copy, modify, distribute and perform the work, even for commercial purposes, <b>if you give appropriate credit</b>, mention the license and indicate if changes were made."
|
||||
},
|
||||
"url": "https://creativecommons.org/licenses/by/4.0/"
|
||||
},
|
||||
{
|
||||
"type": "cc-by-sa",
|
||||
"title": "Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)",
|
||||
"text": {
|
||||
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, <b>wenn Sie den Namen des Autors nennen</b>, die Lizenz erwähnen und ggf. angeben, ob Veränderungen vorgenommen wurden. Wenn Sie das Werk verändern, dürfen Sie das veränderte Werk nur <b>unter derselben Lizenz</b> verbreiten.",
|
||||
"en": "You can copy, modify, distribute and perform the work, even for commercial purposes, <b>if you give appropriate credit</b>, mention the license and indicate if changes were made. If you remix, transform, or build upon the material, you must distribute your contributions <b>under the same license</b> as the original."
|
||||
},
|
||||
"url": "https://creativecommons.org/licenses/by-sa/4.0/"
|
||||
},
|
||||
{
|
||||
"type": "cc-by-nc",
|
||||
"title": "Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)",
|
||||
"text": {
|
||||
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, <b>wenn Sie den Namen des Autors nennen</b>, die Lizenz erwähnen und ggf. angeben, ob Veränderungen vorgenommen wurden. Sie dürfen das Werk <b>nicht für kommerzielle Zwecke</b> nutzen.",
|
||||
"en": "You can copy, modify, distribute and perform the work, <b>if you give appropriate credit</b>, mention the license and indicate if changes were made. You may use the material only for <b>non commercial purposes</b>."
|
||||
},
|
||||
"url": "https://creativecommons.org/licenses/by-nc/4.0/"
|
||||
},
|
||||
{
|
||||
"type": "cc-by-nc-sa",
|
||||
"title": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)",
|
||||
"text": {
|
||||
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, <b>wenn Sie den Namen des Autors nennen</b>, die Lizenz erwähnen und ggf. angeben, ob Veränderungen vorgenommen wurden. Sie dürfen das Werk <b>nicht für kommerzielle Zwecke</b> nutzen. Wenn Sie das Werk verändern, dürfen Sie das veränderte Werk nur <b>unter derselben Lizenz</b> verbreiten.",
|
||||
"en": "You can copy, modify, distribute and perform the work, <b>if you give appropriate credit</b>, mention the license and indicate if changes were made. You may use the material only for <b>non commercial purposes</b>. If you remix, transform, or build upon the material, you must distribute your contributions <b>under the same license</b> as the original."
|
||||
},
|
||||
"url": "https://creativecommons.org/licenses/by-nc-sa/4.0/"
|
||||
},
|
||||
{
|
||||
"type": "cc-by-nd",
|
||||
"title": "Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0)",
|
||||
"text": {
|
||||
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, <b>wenn Sie den Namen des Autors nennen</b> und die Lizenz erwähnen. Sie dürfen das Werk <b>nicht verändern</b>.",
|
||||
"en": "You can copy, distribute and perform the work, even for commercial purposes, <b>if you give appropriate credit</b> and mention the license. You may <b>not alter</b> the work in any way."
|
||||
},
|
||||
"url": "https://creativecommons.org/licenses/by-nd/4.0/"
|
||||
},
|
||||
{
|
||||
"type": "cc-by-nc-nd",
|
||||
"title": "Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)",
|
||||
"text": {
|
||||
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verbreiten und aufzuführen, <b>wenn Sie den Namen des Autors nennen</b> und die Lizenz erwähnen. Sie dürfen das Werk <b>nicht verändern</b> und <b>nicht für kommerzielle Zwecke</b> nutzen.",
|
||||
"en": "You can copy, distribute and perform the work, <b>if you give appropriate credit</b> and mention the license. You may <b>not alter</b> the work in any way and may use the material only for <b>non commercial purposes</b>."
|
||||
},
|
||||
"url": "https://creativecommons.org/licenses/by-nc-nd/4.0/"
|
||||
},
|
||||
{
|
||||
"type": "all-rights-reserved",
|
||||
"title": "All rights reserved",
|
||||
"text": {
|
||||
"de": "Alle Rechte vorbehalten. Dieses Werk darf ohne Erlaubnis des Autors <b>nicht kopiert, verändert, verbreitet oder aufgeführt</b> werden.",
|
||||
"en": "All rights reserved. This work <b>may not be copied, modified, distributed or performed</b> without the permission of the author."
|
||||
}
|
||||
}
|
||||
]
|
||||
43
src/lib/types.d.ts
vendored
Normal file
43
src/lib/types.d.ts
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
type TranslationKey = 'de' | 'en';
|
||||
|
||||
type Translation = Record<TranslationKey, string>;
|
||||
|
||||
type LicenseType = 'cc0' | 'cc-by' | 'cc-by-sa' | 'cc-by-nc' | 'cc-by-nc-sa' | 'cc-by-nd' | 'cc-by-nc-nd' | 'all-rights-reserved';
|
||||
|
||||
type License = {
|
||||
type: LicenseType;
|
||||
title: Translation | string;
|
||||
text: Translation | string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
type Metadata = {
|
||||
title: Translation | string;
|
||||
description?: Translation | string;
|
||||
authors?: string[] | string;
|
||||
place?: string;
|
||||
tags?: string[];
|
||||
license?: License;
|
||||
}
|
||||
|
||||
type AlbumMetadata = Metadata & {
|
||||
date: string; // ISO 8601, e.g. 2020-12-24, used for sorting
|
||||
cover?: string;
|
||||
};
|
||||
|
||||
type ItemMetadata = Metadata & {
|
||||
item: string;
|
||||
timestamp?: string; // ISO 8601, e.g. 2020-12-24T12:00:00Z
|
||||
};
|
||||
|
||||
type Item = ItemMetadata;
|
||||
|
||||
type Album = AlbumMetadata & {
|
||||
slug: string;
|
||||
uriTimestamp?: string;
|
||||
items: Item[];
|
||||
};
|
||||
|
||||
type ApiError = {
|
||||
error: string;
|
||||
};
|
||||
Reference in New Issue
Block a user