-
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 22 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,5 @@ | |
| /cypress/downloads | ||
|
|
||
| .idea | ||
|
|
||
| scripts/gen-hufnagel-grouping/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,9 +54,10 @@ | |
| }, | ||
| "dependencies": { | ||
| "d3": "^5.11.0", | ||
| "diva.js": "github:DDMAL/diva.js#master", | ||
| "diva.js": "github:DDMAL/diva.js#5f530483f653db68af1cbb92bc8cc967b51763c3", | ||
|
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 this specific version?
Author
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.
|
||
| "http-server": "^14.1.1", | ||
| "jsonschema": "^1.2.4", | ||
| "jszip": "^3.10.1", | ||
|
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 can be dropped. See comments above.
Author
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. Dropped. |
||
| "pouchdb": "^7.1.1", | ||
| "vkbeautify": "^0.99.3" | ||
| }, | ||
|
|
@@ -66,6 +67,7 @@ | |
| "@types/elementtree": "^0.1.0", | ||
| "@types/fs-extra": "^9.0.1", | ||
| "@types/jest": "^26.0.8", | ||
| "@types/jszip": "^3.4.1", | ||
| "@types/pouchdb": "^6.4.0", | ||
| "@types/request": "^2.48.2", | ||
| "@types/selenium-webdriver": "^4.0.2", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,24 +26,39 @@ export async function fetchUploads(): Promise<uploadsInfo> { | |
| } | ||
| } | ||
|
|
||
| // Sets <staffDef notationtype="neume.square"/"neume.hufnagel"> on the given | ||
| // MEI text. This is the only place a freshly-uploaded/created MEI file gets | ||
| // its notation type recorded - the Edit page's notation type dropdown does | ||
| // not lock or otherwise depend on this; it can still be changed afterward. | ||
|
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. Can you not set
Author
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. Yes. |
||
| function setMeiNotationType(meiText: string, notationType: string): string { | ||
| const parser = new DOMParser(); | ||
| const serializer = new XMLSerializer(); | ||
| const meiDoc = parser.parseFromString(meiText, 'text/xml'); | ||
| meiDoc.documentElement | ||
| .querySelector('staffDef') | ||
| ?.setAttribute('notationtype', `neume.${notationType}`); | ||
| return serializer.serializeToString(meiDoc); | ||
| } | ||
|
|
||
| export function createManifest( | ||
| id: string, | ||
| 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 +69,22 @@ export function createManifest( | |
| bgReader.readAsDataURL(bg); | ||
| }); | ||
|
|
||
| const meiUri = await meiPromise; | ||
| const meiText = await meiTextPromise; | ||
| const meiUri = | ||
| 'data:application/mei+xml;base64,' + | ||
| window.btoa(setMeiNotationType(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 |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ZoomHandler from '../SingleView/Zoom'; | |
| import { GroupingType } from '../Types'; | ||
| import { getSettings, setSettings } from '../utils/LocalSettings'; | ||
| import * as d3 from 'd3'; | ||
| import NeonView from '../NeonView'; | ||
|
|
||
| let lastGlyphOpacity: number, lastImageOpacity: number, lastCircleSize: number; | ||
|
|
||
|
|
@@ -491,6 +492,47 @@ function setBurgerControls(): void { | |
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Set click listeners for Notation Type dropdown (Square / Hufnagel). | ||
| * Currently only updates the label and logs to console; engine wiring is next. | ||
| */ | ||
| export function setNotationTypeControls(neonView: NeonView): void { | ||
|
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. You do not need
Author
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. Fixed. |
||
| 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 }); | ||
| neonView.setNotationType(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. | ||
| */ | ||
|
|
@@ -575,6 +617,7 @@ export function loadHighlightSettings(): void { | |
| export function initDisplayControls( | ||
| meiClassName: string, | ||
| background: string, | ||
| neonView: NeonView, | ||
| ): void { | ||
| setGlyphOpacityControls(meiClassName); | ||
| setBgOpacityControls(background); | ||
|
|
@@ -583,6 +626,7 @@ export function initDisplayControls( | |
| setHighlightKeyControls(); | ||
| setDisplayAllListener(); | ||
| loadHighlightSettings(); | ||
| setNotationTypeControls(neonView); | ||
|
|
||
| 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.
What is this for?
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.
Removed. It was only for a local glyph-generation scratch directory and is not needed by Neon.