Skip to content

Commit

Permalink
initialize diplomatic transcripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kepper committed Oct 16, 2023
1 parent a80c246 commit b7141ea
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 3 deletions.
206 changes: 206 additions & 0 deletions public/assets/diplomaticTranscriptTemplate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../../../../rng/bw_module4_complete.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="../../../../rng/bw_module4_complete.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.music-encoding.org/ns/mei"
meiversion="5.0.0-dev"
xml:id="%NEW-ID%">
<meiHead meiversion="5.0.0-dev" xml:id="%NEW-ID%">
<fileDesc xml:id="%NEW-ID%">
<titleStmt xml:id="%NEW-ID%">
<title xml:id="%NEW-ID%">
Ludwig van Beethoven, Skizzenbuch "Engelmann" zu den Diabelli-Variationen op. 120 und der 9. Sinfonie op. 125, Autograph
</title>
<composer xml:id="%NEW-ID%">
<persName xml:id="%NEW-ID%">Beethoven, Ludwig van</persName>
</composer>
<editor xml:id="%NEW-ID%">
<corpName auth.uri="https://beethovens-werkstatt.de" xml:id="%NEW-ID%">Beethovens Werkstatt</corpName>
</editor>
<funder xml:id="%NEW-ID%">
<corpName auth.uri="http://www.adwmainz.de/" xml:id="%NEW-ID%">Akademie der Wissenschaften und der Literatur Mainz</corpName>
</funder>
</titleStmt>
<pubStmt xml:id="%NEW-ID%"/>
<seriesStmt xml:id="%NEW-ID%">
<title xml:lang="de" level="s" xml:id="%NEW-ID%">
Skizzenbuchedition
</title>
<identifier auth.uri="https://beethovens-werkstatt.de/modul-4/" xml:id="%NEW-ID%">sk</identifier>
</seriesStmt>
<sourceDesc xml:id="%NEW-ID%">
<source n="1"
target="%FILEPATH%#%GENDESCWZ-ID%"
xml:id="%NEW-ID%"/>
</sourceDesc>
</fileDesc>
<encodingDesc class="#bw_diplomatic_transcript #bw_document_file #bw_module4" xml:id="%NEW-ID%">
<appInfo xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="%NEW-ID%">
<application version="%APP-VERSION%" xml:id="facsimileExplorer">
<name>Facsimile Explorer</name>
</application>
</appInfo>
<classDecls xml:id="%NEW-ID%">
<taxonomy label="availableTaxonomies"
xml:id="%NEW-ID%">
<category xml:id="document_type"/>
<category xml:id="bw_observation_type"/>
<category xml:id="bw_implementation_completeness"/>
<!--<category xml:id="bw_monitum_category"/>-->
<category xml:id="bw_file_type"/>
<category xml:id="bw_monitum_comment"/>
<category xml:id="bw_monitum_classification"/>
<category xml:id="bw_monitum_textoperation"/>
<category xml:id="bw_monitum_object"/>
<category xml:id="bw_monitum_kontext"/>
<category xml:id="bw_monitum_konkordanz"/>
<category xml:id="bw_transcription_type"/>
<category xml:id="xb8206fdc-e421-4ac0-b78d-3bee06b54f93"/>
<category xml:id="bw_geneticOrder"/>
</taxonomy>
<taxonomy xml:id="%NEW-ID%">
<category xml:id="geneticOrder_documentLevel" class="#bw_geneticOrder"/>
<category xml:id="geneticOrder_pageLevel" class="#bw_geneticOrder"/>
<category xml:id="geneticOrder_writingZoneLevel" class="#bw_geneticOrder"/>
<category xml:id="geneticOrder_writingLayerLevel" class="#bw_geneticOrder"/>
<category xml:id="geneticOrder_finalState" class="#bw_geneticOrder"/>
</taxonomy>
<taxonomy xml:id="%NEW-ID%">
<category xml:id="music.print" class="#document_type"/>
<category xml:id="music.manuscript" class="#document_type"/>
<category xml:id="letter.manuscript" class="#document_type"/>
<category xml:id="music.sketchbook" class="#document_type"/>
</taxonomy>
<taxonomy xml:id="%NEW-ID%">
<category xml:id="bw_monitum_context" class="#bw_observation_type"/>
<category xml:id="bw_monitum_effect" class="#bw_observation_type"/>
</taxonomy>
<taxonomy xml:id="%NEW-ID%">
<category xml:id="bw_fully_implemented" class="#bw_implementation_completeness"/>
<category xml:id="bw_partially_implemented"
class="#bw_implementation_completeness"/>
<category xml:id="bw_not_implemented" class="#bw_implementation_completeness"/>
</taxonomy>
<taxonomy xml:id="%NEW-ID%">
<!-- Klassifizierung -->
<category xml:id="bw_classification_korrektur"
label="Korrektur"
class="#bw_monitum_classification"/>
<category xml:id="bw_classification_variante"
label="Variante"
class="#bw_monitum_classification"/>
<category xml:id="bw_classification_textpraezisierung"
label="Textpräzisierung"
class="#bw_monitum_classification"/>
<category xml:id="bw_classification_schriftbildliche_verbesserung"
label="Schriftbildliche Verbesserung"
class="#bw_monitum_classification"/>
<category xml:id="bw_classification_paratextliche_eingriffe"
label="Paratextliche Eingriffe"
class="#bw_monitum_classification"/>
</taxonomy>
<taxonomy xml:id="%NEW-ID%">
<!-- Textoperation -->
<category xml:id="bw_textoperation_einfuegung"
label="Einfuegung"
class="#bw_monitum_textoperation"/>
<!--oder erweiterung-->
<category xml:id="bw_textoperation_tilgung"
label="Tilgung"
class="#bw_monitum_textoperation"/>
<category xml:id="bw_textoperation_ersetzung"
label="Ersetzung"
class="#bw_monitum_textoperation"/>
<category xml:id="bw_textoperation_umstellung"
label="Umstellung"
class="#bw_monitum_textoperation"/>
</taxonomy>
<taxonomy xml:id="%NEW-ID%">
<!-- Revisionsobjekt -->
<category xml:id="bw_object_dynamic"
label="Dynamik"
class="#bw_monitum_object"/>
<category xml:id="bw_object_pitch"
label="Tonbuchstabe"
class="#bw_monitum_object"/>
<category xml:id="bw_object_bogensetzung"
label="Bogensetzung"
class="#bw_monitum_object"/>
<category xml:id="bw_object_rhythm"
label="Rhythmus"
class="#bw_monitum_object"/>
<category xml:id="bw_object_ornament"
label="Verzierung"
class="#bw_monitum_object"/>
<category xml:id="bw_object_octave"
label="Oktavierung"
class="#bw_monitum_object"/>
<category xml:id="bw_object_pedal" label="Pedal" class="#bw_monitum_object"/>
<category xml:id="bw_object_articulation"
label="Artikulation"
class="#bw_monitum_object"/>
<category xml:id="bw_object_clef"
label="Notenschlüssel"
class="#bw_monitum_object"/>
<category xml:id="bw_object_arpeggio"
label="Arpeggiozeichen"
class="#bw_monitum_object"/>
<category xml:id="bw_object_rest" label="Pause" class="#bw_monitum_object"/>
<category xml:id="bw_object_fingering"
label="Fingersatz"
class="#bw_monitum_object"/>
</taxonomy>
<taxonomy xml:id="%NEW-ID%">
<!-- kontextzitat -->
<category xml:id="bw_kontext_korrekt"
label="korrekt"
class="#bw_monitum_kontext"/>
<category xml:id="bw_kontext_unvollstaendig"
label="unvollständig"
class="#bw_monitum_kontext"/>
<category xml:id="bw_kontext_korrumpiert"
label="korrumpiert"
class="#bw_monitum_kontext"/>
</taxonomy>
<taxonomy xml:id="%NEW-ID%">
<!-- konkordanz -->
<category xml:id="bw_konkordanz"
label="konkordanz"
class="#bw_monitum_konkordanz"/>
</taxonomy>
<taxonomy xml:id="%NEW-ID%">
<category xml:id="bw_module3_corpusFile" class="#bw_file_type"/>
<category xml:id="bw_module3_textFile" class="#bw_file_type"/>
<category xml:id="bw_module3_linkingFile" class="#bw_file_type"/>
<category xml:id="bw_module3_documentFile" class="#bw_file_type"/>
<category xml:id="bw_document_file" class="#bw_file_type"/>
<category xml:id="bw_work_file" class="#bw_file_type"/>
<category xml:id="bw_document_reconstruction" class="#bw_file_type"/>
</taxonomy>
<taxonomy xml:id="%NEW-ID%">
<category class="#bw_module" xml:id="bw_module4"/>
</taxonomy>
<taxonomy xml:id="%NEW-ID%">
<category xml:id="bw_diplomatic_transcript" class="#bw_transcription_type"/>
<category xml:id="bw_annotated_transcript" class="#bw_transcription_type"/>
</taxonomy>
</classDecls>
</encodingDesc>
<revisionDesc xml:id="%NEW-ID%">
<change
n="1"
resp="#bw_jk"
isodate="%CURRENT-DATE%"
xml:id="%NEW-ID%">
<changeDesc xml:id="%NEW-ID%">
<p xml:id="%NEW-ID%">Generated file for diplomatic transcription with <ptr target="#facsimileExplorer"/> using template file.</p>
</changeDesc>
</change>
</revisionDesc>
</meiHead>
<music>
<body>

</body>
</music>
</mei>
5 changes: 4 additions & 1 deletion src/components/DiploTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</button>
</div>
<div class="menuItem" v-if="showInitializeButton">
<button class="btn">Initialize Diplomatic Transcription</button>
<button class="btn" @click="initializeDiploTrans">Initialize Diplomatic Transcription</button>
</div>
<div class="osdButtons">
<div class="osdButton" id="zoomOut"><i class="icon icon-minus"></i></div>
Expand Down Expand Up @@ -98,6 +98,9 @@ export default {
path: dtPath
})
}
},
initializeDiploTrans () {
this.$store.dispatch('initializeDiploTrans')
}
},
computed: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/WritingZoneDirectory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<span class="hasTrans float-right">
<template v-if="this.availableDiplomaticTranscripts.indexOf(wz.diploTrans) !== -1">
<span class="desc">Diplo<br/>Trans</span>
<i class="icon icon-check" :title="wz.annotTrans.file"></i>
<i class="icon icon-check" :title="wz.diploTrans.file"></i>
<!--<template v-if="wz.annotTrans.firstZone">
</template>
Expand Down
39 changes: 38 additions & 1 deletion src/store/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { uuid } from '@/tools/uuid.js'
import OpenSeadragon from 'openseadragon'
// import { rotatePoint, getOuterBoundingRect } from '@/tools/trigonometry.js'
import { getOsdRects } from '@/tools/facsimileHelpers.js'
import { /* convertRectUnits, */ sortRastrumsByVerticalPosition } from '@/tools/mei.js'
import { /* convertRectUnits, */ sortRastrumsByVerticalPosition, initializeDiploTrans } from '@/tools/mei.js'
import { rotatePoint } from '@/tools/trigonometry'
// import { getRectFromFragment } from '@/tools/trigonometry.js'
// import { Base64 } from 'js-base64'
Expand Down Expand Up @@ -1202,6 +1202,43 @@ const dataModule = {

dispatch('loadDocumentIntoStore', { path: path, dom: modifiedDom })
dispatch('logChange', { path: path, baseMessage, param, xmlIDs: [rastrum.getAttribute('xml:id')], isNewDocument: false })
},

/**
* initializes a new diplomatic transcript for the current writing zone, if none exists yet
* @param {*} param0
* @returns
*/
initializeDiploTrans ({ commit, getters, dispatch }) {
const existingDt = getters.diplomaticTranscriptForCurrentWz
if (existingDt !== null) {
console.log('…current writing zone already has a diplomatic transcription')
return null
}
fetch('../assets/diplomaticTranscriptTemplate.xml')
.then(response => response.text())
.then(xmlString => {
const diploTemplate = parser.parseFromString(xmlString, 'application/xml')
console.log('Got a new diplomatic transcript: ', diploTemplate)

const diploTrans = initializeDiploTrans(diploTemplate, 'filename', 'wzId')

const dtPath = getters.currentWzDtPath
const writingZoneId = getters.activeWritingZone

const path = getters.currentDocPath
const docName = getters.documentNameByPath(path)

const pageNum = getters.currentSurfaceIndexForCurrentDoc
const baseMessage = 'add diplomatic transcript for ' + docName + ', p.' + pageNum + ', writingZone '

const param = writingZoneId

console.log(diploTrans, dtPath)
commit('ADD_AVAILABLE_DIPLOMATIC_TRANSCRIPT', dtPath)
dispatch('loadDocumentIntoStore', { path: dtPath, dom: diploTrans })
dispatch('logChange', { path: dtPath, baseMessage, param, xmlIDs: [], isNewDocument: true })
})
}
},

Expand Down
5 changes: 5 additions & 0 deletions src/store/octokit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ const mutations = {
SET_AVAILABLE_DIPLOMATIC_TRANSCRIPTS (state, diplomaticTranscripts) {
state.availableDiplomaticTranscripts = diplomaticTranscripts
},
ADD_AVAILABLE_DIPLOMATIC_TRANSCRIPT (state, diplomaticTranscript) {
if (state.availableDiplomaticTranscripts.indexOf(diplomaticTranscript) === -1) {
state.availableDiplomaticTranscripts.push(diplomaticTranscript)
}
},
SET_CONTENT_DATA (state, { repo, owner, ref, path, name, sha, doc }) {
if (!doc) console.warn(`no document '${path}'`)
state.documents[path] = { repo, owner, ref, path, name, sha, doc }
Expand Down
24 changes: 24 additions & 0 deletions src/tools/mei.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
import { uuid } from '@/tools/uuid.js'

export function initializeDiploTrans (diploTemplate, filename, genDescWzId, appVersion) {
diploTemplate.querySelectorAll('*[*|id]').forEach(elem => {
const id = elem.localName.substring(0, 1) + uuid()
if (elem.getAttribute('xml:id') === '%NEW-ID%') {
elem.setAttribute('xml:id', id)
}
})

const date = new Date().toISOString().split('T')[0]
const datePlaceholder = '%CURRENT-DATE%'
diploTemplate.querySelectorAll('change').forEach(change => {
if (change.getAttribute('isodate') === datePlaceholder) {
change.setAttribute('isodate', date)
}
})

diploTemplate.querySelector('application').setAttribute('version', appVersion)

const target = '../' + filename + '#' + genDescWzId
diploTemplate.querySelector('source').setAttribute('target', target)

return diploTemplate
}

export function initializePageIfNecessary (page, height) {
const hasScoreDef = page.querySelector('score')
if (hasScoreDef === null) {
Expand Down

0 comments on commit b7141ea

Please sign in to comment.