From ebd80b4750fc14212462a32fd61ec6c67f165105 Mon Sep 17 00:00:00 2001
From: Viktor Illmer <1476338+v-ji@users.noreply.github.com>
Date: Wed, 17 Sep 2025 15:33:44 +0200
Subject: [PATCH 1/3] Move XML template
---
{static => src/lib/assets}/play-template.xml | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename {static => src/lib/assets}/play-template.xml (100%)
diff --git a/static/play-template.xml b/src/lib/assets/play-template.xml
similarity index 100%
rename from static/play-template.xml
rename to src/lib/assets/play-template.xml
From b0109e7a3a7506807adc5b120e1786be1e6181c0 Mon Sep 17 00:00:00 2001
From: Viktor Illmer <1476338+v-ji@users.noreply.github.com>
Date: Wed, 17 Sep 2025 15:34:08 +0200
Subject: [PATCH 2/3] Format XML template and remove TODOs
---
src/lib/assets/play-template.xml | 44 +++++++++++---------------------
1 file changed, 15 insertions(+), 29 deletions(-)
diff --git a/src/lib/assets/play-template.xml b/src/lib/assets/play-template.xml
index 50ec896..6c5151c 100644
--- a/src/lib/assets/play-template.xml
+++ b/src/lib/assets/play-template.xml
@@ -6,10 +6,10 @@
-
+
-
+
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.
-
-
-
-
+
-
-
-
From 1346d6d4ba55a082642dbbca1eb3ac04027a1a51 Mon Sep 17 00:00:00 2001
From: Viktor Illmer <1476338+v-ji@users.noreply.github.com>
Date: Wed, 17 Sep 2025 15:34:23 +0200
Subject: [PATCH 3/3] Use asset import for XML template
---
src/lib/tei.ts | 45 +++------------------------------------------
1 file changed, 3 insertions(+), 42 deletions(-)
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.