-
Notifications
You must be signed in to change notification settings - Fork 10
Port Hufnagel font switching to production Verovio worker #1376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
55a5367
807715c
f01c66f
8cfa1a8
c158db3
5fc7449
5602d3a
7e8da31
b373d5f
d114fa1
4190021
696c13e
12ff298
82a1841
2545e1a
723b52c
a1ce921
063e038
7a95714
4e52519
3028e60
e7887ad
1e40fb5
44e3334
4717177
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?xml version='1.0' encoding='UTF-8'?> | ||
| <bounding-boxes font-family="Hufnagel" units-per-em="1000"> | ||
| <g c="E990" x="1.0" y="-84.0" w="159.0" h="168.0" h-a-x="160" n="chantPunctum" /> | ||
| <g c="EA06" x="1.0" y="-84.0" w="265.0" h="169.0" h-a-x="160" n="chantCustosStemUpPosMiddle" /> | ||
| <g c="E996" x="1.0" y="-315.0" w="159.0" h="399.0" h-a-x="160" n="chantPunctumVirga" /> | ||
| <g c="E997" x="-0.0" y="-84.7" w="158.99" h="398.54" h-a-x="160" n="chantPunctumVirgaReversed" /> | ||
| <g c="E906" x="-0.1" y="-211.0" w="252.1" h="347.89" h-a-x="160" n="chantCclef" /> | ||
| <g c="E902" x="0.29" y="-181.65" w="170.71" h="327.65" h-a-x="160" n="chantFclef" /> | ||
| <g c="E9B4" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="0" n="chantEntryLineAsc2nd" /> | ||
| <g c="E9B5" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="0" n="chantEntryLineAsc3rd" /> | ||
| <g c="E9B6" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="0" n="chantEntryLineAsc4th" /> | ||
| <g c="E9B7" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="0" n="chantEntryLineAsc5th" /> | ||
| <g c="E9B8" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="440" n="chantEntryLineAsc6th" /> | ||
| <g c="E9B9" x="-0.0" y="-247.0" w="260.0" h="301.03" h-a-x="460" n="chantLigaturaDesc2nd" /> | ||
| <g c="E9BA" x="-0.0" y="-377.0" w="260.0" h="431.03" h-a-x="460" n="chantLigaturaDesc3rd" /> | ||
| <g c="E9BB" x="-0.0" y="-496.0" w="260.0" h="550.03" h-a-x="463" n="chantLigaturaDesc4th" /> | ||
| <g c="E9BE" x="0.0" y="0.0" w="0.0" h="0.0" h-a-x="0" n="chantConnectingLineAsc3rd" /> | ||
| <g c="E994" x="-15.0" y="-173.15" w="259.29" h="345.92" h-a-x="140" n="chantAuctumAsc" /> | ||
| <g c="E995" x="-67.0" y="-169.0" w="205.0" h="432.0" h-a-x="138" n="chantAuctumDesc" /> | ||
| <g c="E9BC" x="-0.0" y="-621.0" w="260.0" h="675.03" h-a-x="481" n="chantLigaturaDesc5th" /> | ||
| </bounding-boxes> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { v4 as uuidv4 } from 'uuid'; | |
| import PouchDB from 'pouchdb'; | ||
| import { AllDocs, Doc, uploadsInfo } from '../Types'; | ||
| import * as localManifest from '../../assets/manifest.json'; | ||
| import { restoreHufnagelForStorage } from '../utils/ConvertMei'; | ||
|
|
||
| export const db = new PouchDB('Neon-User-Storage'); | ||
|
|
||
|
|
@@ -31,19 +32,20 @@ export function createManifest( | |
| title: string, | ||
| mei: File, | ||
| bg: File, | ||
| notationType: string, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you still need |
||
| ): Promise<string> { | ||
| return new Promise(async (resolve) => { | ||
| const manifest = JSON.parse(JSON.stringify(localManifest)); | ||
| manifest['@id'] = id; | ||
| manifest['title'] = title; | ||
| manifest['timestamp'] = new Date().toISOString(); | ||
|
|
||
| const meiPromise = new Promise((resolve) => { | ||
| const meiTextPromise = new Promise<string>((resolve) => { | ||
| const meiReader = new FileReader(); | ||
| meiReader.addEventListener('load', () => { | ||
| resolve(meiReader.result); | ||
| resolve(meiReader.result as string); | ||
| }); | ||
| meiReader.readAsDataURL(mei); | ||
| meiReader.readAsText(mei); | ||
| }); | ||
|
|
||
| const bgPromise = new Promise((resolve) => { | ||
|
|
@@ -54,9 +56,22 @@ export function createManifest( | |
| bgReader.readAsDataURL(bg); | ||
| }); | ||
|
|
||
| const meiUri = await meiPromise; | ||
| const meiText = await meiTextPromise; | ||
| const meiUri = | ||
| 'data:application/mei+xml;base64,' + | ||
| window.btoa(restoreHufnagelForStorage(meiText, notationType)); | ||
| const bgUri = await bgPromise; | ||
|
|
||
| // Pre-seed this folio's LocalSettings entry (keyed by id, same format | ||
| // LocalSettings itself writes) so the Editing page's notation type | ||
| // dropdown reflects this choice on first open. The Editing page never | ||
| // reads @notationtype back out of the MEI to initialize the dropdown - | ||
| // it relies solely on this per-folio localStorage entry - and by the | ||
| // time it's loaded there, the MEI's real notationtype has already been | ||
| // stripped to a generic value for Verovio (see ConvertMei.ts), so it | ||
| // can't be recovered from the MEI at that point either. | ||
| window.localStorage.setItem(id, JSON.stringify({ notationType })); | ||
|
|
||
| manifest['image'] = bgUri; | ||
| manifest['mei_annotations'] = [ | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,12 @@ async function handleUploadUpdate( | |
| const spinner = document.querySelector('#uploading_spinner'); | ||
| spinner.classList.add('visible'); | ||
|
|
||
| handleUploadAllDocuments(currentFolder) | ||
| const selectedNotationType: HTMLInputElement = document.querySelector( | ||
| 'input[name="upload_notation_type"]:checked', | ||
| ); | ||
| const notationType = selectedNotationType?.value ?? 'square'; | ||
|
|
||
| handleUploadAllDocuments(currentFolder, notationType) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need notation type during upload? |
||
| .then((results) => { | ||
| setTimeout(async () => { | ||
| await updateDashboard(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,12 +178,13 @@ function createPairedFolio( | |
|
|
||
| export async function handleUploadAllDocuments( | ||
| currentFolder: IFolder, | ||
| notationType: string, | ||
| ): Promise<{ status: string; value?: string; reason?: any }[]> { | ||
| const folioPromises = fm | ||
| .getFolios() | ||
| .map(async ([name, mei, image]: [string, File, File]) => { | ||
| const id = uuidv4(); | ||
| return await uploadFolio(id, name, mei, image, currentFolder); | ||
| return await uploadFolio(id, name, mei, image, currentFolder, notationType); | ||
| }); | ||
|
|
||
| const manuscriptPromises = []; //fm.getManuscripts() | ||
|
|
@@ -208,13 +209,14 @@ async function uploadFolio( | |
| mei: File, | ||
| image: File, | ||
| currentFolder: IFolder, | ||
| notationType: string, | ||
| ): Promise<string | null> { | ||
| const newName = fnConflictHandler( | ||
| name, | ||
| FileSystemTools.getAllNames(currentFolder), | ||
| ); | ||
| return ( | ||
| createManifest(id, newName, mei, image) | ||
| createManifest(id, newName, mei, image, notationType) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. Why do you need notation type in manifest? |
||
| .then((manifest) => { | ||
| const manifestBlob = new Blob([JSON.stringify(manifest, null, 2)], { | ||
| type: 'application/ld+json', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -491,6 +491,48 @@ function setBurgerControls(): void { | |
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Set click listeners for Notation Type dropdown (Square / Hufnagel). | ||
| * Update the stored setting and notify the active view when the type changes. | ||
| */ | ||
| export function setNotationTypeControls(): void { | ||
| const dropdown = document.getElementById('notation-type-dropdown'); | ||
| const label = document.getElementById('notation-type-label'); | ||
|
|
||
| function applyNotationType(type: string): void { | ||
| label.textContent = `\xA0- ${type[0].toUpperCase() + type.slice(1)}`; | ||
| setSettings({ notationType: type }); | ||
| document.dispatchEvent( | ||
| new CustomEvent('notationtypechange', { detail: { type } }), | ||
| ); | ||
| } | ||
|
|
||
| function notationTypeClickaway(): void { | ||
| document.body.removeEventListener('click', notationTypeClickaway); | ||
| dropdown.classList.remove('is-active'); | ||
| } | ||
|
|
||
| document.getElementById('notation-type-button').addEventListener('click', (evt) => { | ||
| evt.stopPropagation(); | ||
| dropdown.classList.toggle('is-active'); | ||
| if (dropdown.classList.contains('is-active')) { | ||
| document.body.addEventListener('click', notationTypeClickaway); | ||
| } else { | ||
| document.body.removeEventListener('click', notationTypeClickaway); | ||
| } | ||
| }); | ||
|
|
||
| ['square', 'hufnagel'].forEach((type) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks weird. I recommend you make notation type a type. |
||
| document.getElementById(`notation-type-${type}`).addEventListener('click', () => { | ||
| dropdown.classList.remove('is-active'); | ||
| document.body.removeEventListener('click', notationTypeClickaway); | ||
| applyNotationType(type); | ||
| }); | ||
| }); | ||
|
|
||
| applyNotationType(getSettings().notationType ?? 'square'); | ||
| } | ||
|
|
||
| /** | ||
| * Set listener for "Display All" button in Display panel. | ||
| */ | ||
|
|
@@ -583,6 +625,7 @@ export function initDisplayControls( | |
| setHighlightKeyControls(); | ||
| setDisplayAllListener(); | ||
| loadHighlightSettings(); | ||
| setNotationTypeControls(); | ||
|
|
||
| const displayContents = document.getElementById('displayContents'); | ||
| const toggleDisplay = document.getElementById('toggleDisplay'); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this specific version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.jsonreferenced#master, but that branch no longer exists, so installs that resolve the dependency afresh fail. The existingyarn.lockpointed to commit5f530483, which was already known to work with Neon, so I pinnedpackage.jsonto that commit as the temporary workaround described in issue #1365 .