diff --git a/static/play-template.xml b/src/lib/assets/play-template.xml similarity index 77% rename from static/play-template.xml rename to src/lib/assets/play-template.xml index 50ec896..6c5151c 100644 --- a/static/play-template.xml +++ b/src/lib/assets/play-template.xml @@ -6,10 +6,10 @@ - <!-- generated title --> + <!-- generated title --> - <!-- generated subtitle --> + <!-- generated subtitle --> Simplicius @@ -21,7 +21,7 @@ Q1505487 107968169 - + Du @@ -44,12 +44,9 @@ - - »999 und noch etliche [mehr]«: Web app for Georg Nikolaus Bärmann’s Würfelalmanach from 1829 - - - - + »999 und noch etliche [mehr]«: Web app for Georg Nikolaus Bärmann’s Würfelalmanach + from 1829 +

In the public domain.

@@ -61,16 +58,16 @@ Zwickau: Gebrüder Schumann 1829.
- - + + - - + +
- + file generated @@ -80,13 +77,13 @@ - + - + - + „– Dans l’art dangereux de rimer et d’écrire, Il n’est point de degrés du médiocre au pire.“ @@ -94,21 +91,10 @@ Boileau. - -
- -
+
- - - diff --git a/src/lib/tei.ts b/src/lib/tei.ts index f070630..cae0134 100644 --- a/src/lib/tei.ts +++ b/src/lib/tei.ts @@ -1,18 +1,6 @@ +import xmlTemplate from "$lib/assets/play-template.xml?raw" import { Almanac } from "./almanac" -const TEINS = "http://www.tei-c.org/ns/1.0" - -function generateIdFromSequence(sequence: number[]): string { - return sequence.join("-") // this is a temporary solution -} - -async function fetchTemplate(): Promise { - const res = await fetch("/play-template.xml") - const xmlText = await res.text() - const parser = new DOMParser() - return parser.parseFromString(xmlText, "text/xml") -} - function getSegment(almanacDoc: Document, roll: number, pips: number): Element | null { const segmentId = Almanac.getSegmentId(roll, pips).toString() const segment = almanacDoc.querySelector(`div[type="segment"][n="${segmentId}"]`) @@ -59,8 +47,8 @@ function collectSegments(sequence: number[], almanacDoc: Document): DocumentFrag export async function createTEIDoc( sequence: number[] ): Promise<{ doc: string; timestamp: string }> { - const almanacDoc = Almanac.getDom() // parse almanac text XML into dom document - const templateDoc = await fetchTemplate() // get xml file template as dom document + const almanacDoc = Almanac.getDom() + const templateDoc = new window.DOMParser().parseFromString(xmlTemplate, "text/xml") const segments = collectSegments(sequence, almanacDoc) @@ -119,32 +107,5 @@ export async function downloadTEIDoc(sequence: number[]) { a.href = url a.download = file.name a.click() - // window.open(url, "_blank") // open file in new window setTimeout(() => URL.revokeObjectURL(url), 10000) } - -// NOTES -// improve and complete download function -// wann endet letzte szene? bevor der vorhang fällt oder danach? oder direkt vor Ende des Vorspiels? - -// 1. Wurf: Titel + Untertitel -// 2. Wurf: Personen -// 3. Wurf: Szene 1 -// 4. Wurf: Szene 2 -// 13. Wurf: Szene 3 // WENN 2 GEWÜRFELT WIRD, FEHLT HEADER FÜR SZENE 3 -// 18. Wurf: Szene 4 -// 27. Wurf: Szene 5 -// 28. Wurf: Szene 6 -// 29. Wurf: Szene 7 -// 57. Wurf: Szene 8 -// 61. Wurf: Szene 9 -// 96. Wurf: Szene 10 -// 112. Wurf: Szene 11 -// 114. Wurf: Szene 12 -// 131. Wurf: Szene 13 -// 145. Wurf: Szene 14 // WENN 2 ODER 6 GEWÜRFELT WIRD, FEHLT HEADER FÜR SZENE 14 -// 170. Wurf: Szene 15 -// 184. Wurf: Szene 16 -// 191. Wurf: Szene 17 (Letzter Auftritt) -// 199. Wurf: (Der Vorhang fällt.) -// 200. Wurf: Ende des Vorspiels.