diff --git a/src/lib/components/Header.svelte b/src/lib/components/Header.svelte index 576bd52..1360352 100644 --- a/src/lib/components/Header.svelte +++ b/src/lib/components/Header.svelte @@ -35,6 +35,20 @@ $str('author'): "unknown author"): $str('author'); + $: hrefLicense = album && album.license ? ( + typeof album.license === 'object' ? + `${base}/license`: + typeof album.license === 'string' ? + `${galleryBase}/license/${album.license}`: + null): + null; + $: displayLicense = album && album.license ? ( + typeof album.license === 'object' ? + album.license.title: + typeof album.license === 'string' ? + ((l: any) => l ? $strf(l.titleShort || l.title) : album?.license)(licenses.find(l => l.type === album?.license)): + "All rights reserved"): + "All rights reserved";
@@ -53,12 +67,12 @@
{displayAuthorsTitle}
{displayAuthors}
{$str('license')}
-
{album.license}
+
{displayLicense}
{#if album.allowDownload !== false}
  • - {$str('download-all')} + {$str('download-all')}
  • {/if}
    diff --git a/src/lib/data/language.ts b/src/lib/data/language.ts index 16f9493..bd59001 100644 --- a/src/lib/data/language.ts +++ b/src/lib/data/language.ts @@ -59,7 +59,7 @@ export const str = derived(language, $language => { }); export const strf = derived(language, $language => { - function translate(translations: Translation | string, ...args: any[]) { + function translate(translations: Translation | string | undefined, ...args: any[]) { if (translations === undefined) return undefined; if (typeof translations === 'string') return translations; const str = translations[$language]; diff --git a/src/lib/data/licenses.json b/src/lib/data/licenses.json index 97e2a60..ca32b9b 100644 --- a/src/lib/data/licenses.json +++ b/src/lib/data/licenses.json @@ -2,8 +2,9 @@ { "type": "cc0", "title": "CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", + "titleShort": "CC0 1.0", "text": { - "de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, ohne um weitere Erlaubnis bitten zu müssen.", + "de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, ohne um weitere Erlaubnis bitten zu müssen.", "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/" @@ -11,63 +12,72 @@ { "type": "cc-by", "title": "Creative Commons Attribution 4.0 International (CC BY 4.0)", + "titleShort": "CC BY 4.0", "text": { - "de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, wenn Sie den Namen des Autors nennen, 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, if you give appropriate credit, mention the license and indicate if changes were made." + "de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, wenn Sie den Namen des Autors nennen, 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, if you give appropriate credit, 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)", + "titleShort": "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, wenn Sie den Namen des Autors nennen, 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 unter derselben Lizenz verbreiten.", - "en": "You can copy, modify, distribute and perform the work, even for commercial purposes, if you give appropriate credit, mention the license and indicate if changes were made. If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original." + "de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, wenn Sie den Namen des Autors nennen, 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 unter derselben Lizenz verbreiten.", + "en": "You can copy, modify, distribute and perform the work, even for commercial purposes, if you give appropriate credit, mention the license and indicate if changes were made. If you remix, transform, or build upon the material, you must distribute your contributions under the same license 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)", + "titleShort": "CC BY-NC 4.0", "text": { - "de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, wenn Sie den Namen des Autors nennen, die Lizenz erwähnen und ggf. angeben, ob Veränderungen vorgenommen wurden. Sie dürfen das Werk nicht für kommerzielle Zwecke nutzen.", - "en": "You can copy, modify, distribute and perform the work, if you give appropriate credit, mention the license and indicate if changes were made. You may use the material only for non commercial purposes." + "de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, wenn Sie den Namen des Autors nennen, die Lizenz erwähnen und ggf. angeben, ob Veränderungen vorgenommen wurden. Sie dürfen das Werk nicht für kommerzielle Zwecke nutzen.", + "en": "You can copy, modify, distribute and perform the work, if you give appropriate credit, mention the license and indicate if changes were made. You may use the material only for non commercial purposes." }, "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)", + "titleShort": "CC BY-NC-SA 4.0", "text": { - "de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, wenn Sie den Namen des Autors nennen, die Lizenz erwähnen und ggf. angeben, ob Veränderungen vorgenommen wurden. Sie dürfen das Werk nicht für kommerzielle Zwecke nutzen. Wenn Sie das Werk verändern, dürfen Sie das veränderte Werk nur unter derselben Lizenz verbreiten.", - "en": "You can copy, modify, distribute and perform the work, if you give appropriate credit, mention the license and indicate if changes were made. You may use the material only for non commercial purposes. If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original." + "de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, wenn Sie den Namen des Autors nennen, die Lizenz erwähnen und ggf. angeben, ob Veränderungen vorgenommen wurden. Sie dürfen das Werk nicht für kommerzielle Zwecke nutzen. Wenn Sie das Werk verändern, dürfen Sie das veränderte Werk nur unter derselben Lizenz verbreiten.", + "en": "You can copy, modify, distribute and perform the work, if you give appropriate credit, mention the license and indicate if changes were made. You may use the material only for non commercial purposes. If you remix, transform, or build upon the material, you must distribute your contributions under the same license 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)", + "titleShort": "CC BY-ND 4.0", "text": { - "de": "Sie sind berechtigt, dieses Werk zu kopieren, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, wenn Sie den Namen des Autors nennen und die Lizenz erwähnen. Sie dürfen das Werk nicht verändern.", - "en": "You can copy, distribute and perform the work, even for commercial purposes, if you give appropriate credit and mention the license. You may not alter the work in any way." + "de": "Sie sind berechtigt, dieses Werk zu kopieren, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, wenn Sie den Namen des Autors nennen und die Lizenz erwähnen. Sie dürfen das Werk nicht verändern.", + "en": "You can copy, distribute and perform the work, even for commercial purposes, if you give appropriate credit and mention the license. You may not alter 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)", + "titleShort": "CC BY-NC-ND 4.0", "text": { - "de": "Sie sind berechtigt, dieses Werk zu kopieren, verbreiten und aufzuführen, wenn Sie den Namen des Autors nennen und die Lizenz erwähnen. Sie dürfen das Werk nicht verändern und nicht für kommerzielle Zwecke nutzen.", - "en": "You can copy, distribute and perform the work, if you give appropriate credit and mention the license. You may not alter the work in any way and may use the material only for non commercial purposes." + "de": "Sie sind berechtigt, dieses Werk zu kopieren, verbreiten und aufzuführen, wenn Sie den Namen des Autors nennen und die Lizenz erwähnen. Sie dürfen das Werk nicht verändern und nicht für kommerzielle Zwecke nutzen.", + "en": "You can copy, distribute and perform the work, if you give appropriate credit and mention the license. You may not alter the work in any way and may use the material only for non commercial purposes." }, "url": "https://creativecommons.org/licenses/by-nc-nd/4.0/" }, { "type": "all-rights-reserved", - "title": "All rights reserved", + "title": { + "de": "Alle Rechte vorbehalten", + "en": "All rights reserved" + }, "text": { - "de": "Alle Rechte vorbehalten. Dieses Werk darf ohne Erlaubnis des Autors nicht kopiert, verändert, verbreitet oder aufgeführt werden.", - "en": "All rights reserved. This work may not be copied, modified, distributed or performed without the permission of the author." + "de": "Alle Rechte vorbehalten. Dieses Werk darf ohne Erlaubnis des Autors nicht kopiert, verändert, verbreitet oder aufgeführt werden.", + "en": "All rights reserved. This work may not be copied, modified, distributed or performed without the permission of the author." } } ] diff --git a/src/lib/styles/base.css b/src/lib/styles/base.css index 3d7f007..8b306cf 100644 --- a/src/lib/styles/base.css +++ b/src/lib/styles/base.css @@ -9,6 +9,8 @@ --interactive-bg-color: #d4d4d4; --interactive-bg-hover-color: var(--main-text-color); + --strong-color: #8f0000; + --primary-color: #1a1a1a; } @@ -24,6 +26,8 @@ --interactive-bg-color: #272727; --interactive-bg-hover-color: #353535; + --strong-color: #ffb0b0; + /* --primary-color: #1a1a1a; */ } } diff --git a/src/lib/types.d.ts b/src/lib/types.d.ts index 9c3b8ba..95cbb5f 100644 --- a/src/lib/types.d.ts +++ b/src/lib/types.d.ts @@ -7,33 +7,40 @@ type LicenseType = 'cc0' | 'cc-by' | 'cc-by-sa' | 'cc-by-nc' | 'cc-by-nc-sa' | ' type License = { type: LicenseType; title: Translation | string; + titleShort?: Translation | string; text: Translation | string; url?: string; } -type Metadata = { - description?: Translation | string; - authors?: string[] | string; - place?: string; - tags?: string[]; - license?: License; +type UrlInfo = { + url: string; + title?: Translation | string; + icon?: string; } -type AlbumMetadata = Metadata & { - title: Translation | string; - date: string; // ISO 8601, e.g. 2020-12-24, used for sorting - cover?: string; -}; +type Author = { + name: string; + urls?: UrlInfo[]; +} -type ItemMetadata = Metadata & { +type Metadata = { + description?: Translation | string; + authors?: string[] | string | Author | Author[]; + place?: string; + tags?: string[]; + license?: LicenseType | Omit; +} + +type Item = Metadata & { title?: Translation | string; item: string; timestamp?: string; // ISO 8601, e.g. 2020-12-24T12:00:00Z }; -type Item = ItemMetadata; - -type Album = AlbumMetadata & { +type Album = Metadata & { + title: Translation | string; + date: string; // ISO 8601, e.g. 2020-12-24, used for sorting + cover?: string; slug: string; uriTimestamp?: string; allowDownload?: boolean; diff --git a/src/routes/license/+page.server.ts b/src/routes/license/+page.server.ts new file mode 100644 index 0000000..79f1a73 --- /dev/null +++ b/src/routes/license/+page.server.ts @@ -0,0 +1,6 @@ +import { error } from '@sveltejs/kit'; +import type { PageServerLoad } from './$types'; + +export const load: PageServerLoad = async () => { + throw error(400, 'No license specified'); +} diff --git a/src/routes/license/[license]/+page.server.ts b/src/routes/license/[license]/+page.server.ts new file mode 100644 index 0000000..7297f77 --- /dev/null +++ b/src/routes/license/[license]/+page.server.ts @@ -0,0 +1,24 @@ +import { error } from '@sveltejs/kit'; +import { get } from 'svelte/store'; +import { strf } from '$lib/data/language'; +import licenses from "$lib/data/licenses.json"; +import type { PageServerLoad } from './$types'; + +export const load: PageServerLoad = async ({ params }) => { + const license = licenses.find(l => l.type === params.license); + if (!license) { + throw error(404, 'License not found'); + } + const $strf = get(strf); + + const title = $strf(license.titleShort ?? license.title); + const subtitle = $strf(license.titleShort ? license.title : undefined) || ''; + const description = $strf(license.text); + + return { + license, + title, + subtitle, + description + }; +} diff --git a/src/routes/license/[license]/+page.svelte b/src/routes/license/[license]/+page.svelte new file mode 100644 index 0000000..49ad87e --- /dev/null +++ b/src/routes/license/[license]/+page.svelte @@ -0,0 +1,34 @@ + + +
    +
    +
    + {@html data.description} +
    +
    +
    + +