Add license information

This commit is contained in:
Luca Bosin
2023-08-28 22:47:55 +02:00
parent ec6d44531b
commit 7dcb27eede
8 changed files with 133 additions and 34 deletions

View File

@ -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";
</script>
<header>
@ -53,12 +67,12 @@
<dt>{displayAuthorsTitle}</dt>
<dd>{displayAuthors}</dd>
<dt>{$str('license')}</dt>
<dd><a href={`${base}/license`} tabindex="0">{album.license}</a></dd>
<dd><a href={hrefLicense} tabindex="0">{displayLicense}</a></dd>
</dl>
<menu>
{#if album.allowDownload !== false}
<li>
<a href={`${base}/download`} tabindex="0">{$str('download-all')}</a>
<a data-sveltekit-reload href={`${base}/download`} tabindex="0">{$str('download-all')}</a>
</li>
{/if}
</menu>

View File

@ -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];

View File

@ -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, <b>ohne um weitere Erlaubnis bitten zu müssen</b>.",
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, <strong>ohne um weitere Erlaubnis bitten zu müssen</strong>.",
"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, <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."
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, <strong>wenn Sie den Namen des Autors nennen</strong>, 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, <strong>if you give appropriate credit</strong>, 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, <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."
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, <strong>wenn Sie den Namen des Autors nennen</strong>, 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 <strong>unter derselben Lizenz</strong> verbreiten.",
"en": "You can copy, modify, distribute and perform the work, even for commercial purposes, <strong>if you give appropriate credit</strong>, mention the license and indicate if changes were made. If you remix, transform, or build upon the material, you must distribute your contributions <strong>under the same license</strong> 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, <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>."
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, <strong>wenn Sie den Namen des Autors nennen</strong>, die Lizenz erwähnen und ggf. angeben, ob Veränderungen vorgenommen wurden. Sie dürfen das Werk <strong>nicht für kommerzielle Zwecke</strong> nutzen.",
"en": "You can copy, modify, distribute and perform the work, <strong>if you give appropriate credit</strong>, mention the license and indicate if changes were made. You may use the material only for <strong>non commercial purposes</strong>."
},
"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, <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."
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verändern, verbreiten und aufzuführen, <strong>wenn Sie den Namen des Autors nennen</strong>, die Lizenz erwähnen und ggf. angeben, ob Veränderungen vorgenommen wurden. Sie dürfen das Werk <strong>nicht für kommerzielle Zwecke</strong> nutzen. Wenn Sie das Werk verändern, dürfen Sie das veränderte Werk nur <strong>unter derselben Lizenz</strong> verbreiten.",
"en": "You can copy, modify, distribute and perform the work, <strong>if you give appropriate credit</strong>, mention the license and indicate if changes were made. You may use the material only for <strong>non commercial purposes</strong>. If you remix, transform, or build upon the material, you must distribute your contributions <strong>under the same license</strong> 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, <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."
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verbreiten und aufzuführen, selbst für kommerzielle Zwecke, <strong>wenn Sie den Namen des Autors nennen</strong> und die Lizenz erwähnen. Sie dürfen das Werk <strong>nicht verändern</strong>.",
"en": "You can copy, distribute and perform the work, even for commercial purposes, <strong>if you give appropriate credit</strong> and mention the license. You may <strong>not alter</strong> 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, <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>."
"de": "Sie sind berechtigt, dieses Werk zu kopieren, verbreiten und aufzuführen, <strong>wenn Sie den Namen des Autors nennen</strong> und die Lizenz erwähnen. Sie dürfen das Werk <strong>nicht verändern</strong> und <strong>nicht für kommerzielle Zwecke</strong> nutzen.",
"en": "You can copy, distribute and perform the work, <strong>if you give appropriate credit</strong> and mention the license. You may <strong>not alter</strong> the work in any way and may use the material only for <strong>non commercial purposes</strong>."
},
"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 <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."
"de": "Alle Rechte vorbehalten. Dieses Werk darf ohne Erlaubnis des Autors <strong>nicht kopiert, verändert, verbreitet oder aufgeführt</strong> werden.",
"en": "All rights reserved. This work <strong>may not be copied, modified, distributed or performed</strong> without the permission of the author."
}
}
]

View File

@ -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; */
}
}

37
src/lib/types.d.ts vendored
View File

@ -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<License, 'type'>;
}
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;

View File

@ -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');
}

View File

@ -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
};
}

View File

@ -0,0 +1,34 @@
<script lang="ts">
import Header from '$lib/components/Header.svelte';
import type { PageData } from './$types';
import Footer from '$lib/components/Footer.svelte';
export let data: PageData;
</script>
<main>
<Header title={data.title} description={data.subtitle} />
<section>
{@html data.description}
</section>
<Footer />
</main>
<style>
section {
display: block;
padding-right: 1.5rem;
padding-bottom: 1.5rem;
padding-left: 1.5rem;
margin: 0 auto;
max-width: 80rem;
letter-spacing: .02em;
}
section :global(strong) {
font-weight: 900;
letter-spacing: .04em;
padding: 0 .25em;
color: var(--strong-color);
}
</style>