Release 0.5.0
This commit is contained in:
1 parent
4042fe6a64
commit
5a9d7735d4
26 files changed
+1855
-113
No files matched your search
@@ -0,0 +1,9 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { getPresentationView } from '#lib/server/live.js';
|
||||
|
||||
export const load: PageServerLoad = ({ params }) => {
|
||||
const view = getPresentationView(params.token);
|
||||
if (!view) error(404, 'Präsentationsausgabe nicht gefunden');
|
||||
return { view };
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import { onMount, untrack } from 'svelte';
|
||||
import type { PageProps } from './$types';
|
||||
|
||||
let { data }: PageProps = $props();
|
||||
let view = $state(untrack(() => data.view));
|
||||
let connection = $state<'connected' | 'waiting' | 'interrupted'>('connected');
|
||||
|
||||
onMount(() => {
|
||||
let stopped = false;
|
||||
let timer: ReturnType<typeof setTimeout>;
|
||||
async function refresh() {
|
||||
try {
|
||||
const response = await fetch(`/heinzlive/${page.params.token}/state`, {
|
||||
headers: { Accept: 'application/json' },
|
||||
cache: 'no-store'
|
||||
});
|
||||
if (!response.ok) throw new Error('STATE_UNAVAILABLE');
|
||||
const next = await response.json();
|
||||
if (next.revision !== view.revision) view = next;
|
||||
connection = 'connected';
|
||||
} catch {
|
||||
connection = 'interrupted';
|
||||
}
|
||||
if (!stopped) timer = setTimeout(refresh, connection === 'interrupted' ? 3000 : 1000);
|
||||
}
|
||||
connection = 'waiting';
|
||||
timer = setTimeout(refresh, 500);
|
||||
return () => {
|
||||
stopped = true;
|
||||
clearTimeout(timer);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>heinzlive</title>
|
||||
<meta name="robots" content="noindex, nofollow, noarchive" />
|
||||
</svelte:head>
|
||||
|
||||
<main class="heinzlive-output">
|
||||
<div class="output-connection" class:problem={connection === 'interrupted'} role="status">
|
||||
<span></span>{connection === 'interrupted' ? 'Verbindung unterbrochen' : 'Verbunden'}
|
||||
</div>
|
||||
{#if view.content}
|
||||
<article class="output-content">
|
||||
<p class="output-kicker">heinzlive</p>
|
||||
<h1>{view.content.title}</h1>
|
||||
<!-- HTML is produced exclusively by the server-side allowlist sanitizer. -->
|
||||
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||
<div class="output-copy">{@html view.content.html}</div>
|
||||
{#if view.content.images.length}<div class="output-images">
|
||||
{#each view.content.images as image (image.id)}
|
||||
<img src={`/heinzlive/${page.params.token}/media/${image.id}`} alt={image.altText} />
|
||||
{/each}
|
||||
</div>{/if}
|
||||
{#if view.content.sources.length}<footer class="output-sources">
|
||||
<span>Quellen</span>
|
||||
{#each view.content.sources as source, index (`${index}-${source.url}`)}
|
||||
<!-- Source URLs are validated as absolute HTTP(S) URLs when the Piece is saved. -->
|
||||
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
|
||||
<a href={source.url} target="_blank" rel="noopener noreferrer">{source.label}</a>
|
||||
{/each}
|
||||
</footer>{/if}
|
||||
</article>
|
||||
{:else}
|
||||
<section class="output-idle">
|
||||
<div class="brand-mark" aria-hidden="true"><i></i><i></i><i></i></div>
|
||||
<h1>Bereit für den nächsten Inhalt</h1>
|
||||
<p>Die Moderation wählt ausdrücklich aus, was hier erscheint.</p>
|
||||
</section>
|
||||
{/if}
|
||||
</main>
|
||||
@@ -0,0 +1,18 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { getPresentationMedia } from '#lib/server/live.js';
|
||||
|
||||
export const GET: RequestHandler = async ({ params }) => {
|
||||
const media = await getPresentationMedia(params.token, params.id);
|
||||
if (!media) error(404, 'Bild nicht gefunden');
|
||||
return new Response(media.data, {
|
||||
headers: {
|
||||
'Content-Type': media.mimeType,
|
||||
'Content-Length': String(media.byteSize),
|
||||
'Cache-Control': 'no-store',
|
||||
'Content-Security-Policy': "default-src 'none'; sandbox",
|
||||
'Cross-Origin-Resource-Policy': 'same-origin',
|
||||
'X-Content-Type-Options': 'nosniff'
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { error, json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { getPresentationView } from '#lib/server/live.js';
|
||||
|
||||
export const GET: RequestHandler = ({ params }) => {
|
||||
const view = getPresentationView(params.token);
|
||||
if (!view) error(404, 'Präsentationsausgabe nicht gefunden');
|
||||
return json(view, { headers: { 'Cache-Control': 'no-store' } });
|
||||
};
|
||||
Reference in new issue
Block a user