Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 15 additions & 29 deletions static/play-template.xml → src/lib/assets/play-template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<fileDesc>
<titleStmt>
<title type="main">
<!-- generated title -->
<!-- generated title -->
</title>
<title type="sub">
<!-- generated subtitle -->
<!-- generated subtitle -->
</title>
<author>
<persName type="pseudo">Simplicius</persName>
Expand All @@ -21,7 +21,7 @@
<idno type="wikidata">Q1505487</idno>
<idno type="pnd">107968169</idno>
</author>
<author>
<author>
<persName type="pseudo">Du</persName>
</author>
<respStmt>
Expand All @@ -44,12 +44,9 @@
<sourceDesc>
<bibl type="digitalSource">
<!-- Name of the app -->
<name>
»999 und noch etliche [mehr]«: Web app for Georg Nikolaus Bärmann’s Würfelalmanach from 1829
</name>
<!-- insert URL to the generated play -->
<idno type="URL">
</idno>
<name> »999 und noch etliche [mehr]«: Web app for Georg Nikolaus Bärmann’s Würfelalmanach
from 1829 </name>
<idno type="URL"> </idno>
<availability status="free">
<p>In the public domain.</p>
</availability>
Expand All @@ -61,16 +58,16 @@
<pubPlace>Zwickau</pubPlace>: <publisher>Gebrüder Schumann</publisher>
<date>1829</date>.</bibl>
</bibl>
<bibl type="edition">
<edition>
<bibl type="edition">
<edition>
<!-- dice sequence goes here -->
<idno type="sequence"></idno>
</edition>
<idno type="sequence"/>
</edition>
</bibl>
</sourceDesc>
</fileDesc>
<revisionDesc>
<listChange> <!-- TODO: use iso8601, add atrribute when=<datetime> -->
<listChange>
<change>file generated</change>
</listChange>
</revisionDesc>
Expand All @@ -80,35 +77,24 @@
<titlePage>
<docTitle>
<titlePart type="main">
<!-- generated title -->
<!-- generated title -->
</titlePart>
<titlePart type="sub">
<!-- generated subtitle -->
<!-- generated subtitle -->
</titlePart>
</docTitle>
<epigraph>
<epigraph>
<quote>
<l>„– Dans l’art dangereux de rimer et d’écrire,</l>
<l>Il n’est point de degrés du médiocre au pire.“</l>
</quote>
<bibl>Boileau.</bibl>
</epigraph>
</titlePage>
<!-- insert cast list and set here (roll 2) -->
</front>
<pb/>
<body>
<div type="main">
<!-- play segments will be inserted here (leave out roll 1 and 2) -->
</div>
<div type="main"/>
</body>
</text>
</TEI>


<!-- TODO
- fill url tag with url to generated play
- use timestamp as filename (iso8601)
- add atrribute when=<datetime>
- don't add title and cast/set (roll 1, 2) to segments section
- add cast/set below title page tag -->
45 changes: 3 additions & 42 deletions src/lib/tei.ts
Original file line number Diff line number Diff line change
@@ -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<Document> {
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}"]`)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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.