Skip to content

Implemented XML Downloads/Export via API for Future Automation in Mermeid #263 #267

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

Merged
merged 3 commits into from
Aug 13, 2025

Conversation

imranasif87
Copy link

I replaced the link button with an image button and added a tooltip to clarify its function.

@peterstadler
Copy link
Member

peterstadler commented Jul 4, 2025

Hi @imranasif87 , that's is really great work and worked out of the box for me!

I'm only a little bit hesitant about the endpoint "download-xml" since I do think what it actually implements is the missing "list" functionality of our CRUD module. Hence, my proposal would be to
a) move the logic of collecting the filenames into a function crud:list in modules/crud.xqm
b) add an endpoint "/data/list" to the controller at data/controller.xql and call the new function crud:list from there (cf the "/data/read" endpoint)

I'm happy to do these backend changes if you do not have the time?!

progressLabel.textContent = `Downloading file ${i + 1} of ${totalFiles}`;
currentFileLabel.textContent = `Currently downloading: ${file}`;

let resp = await fetch(`http://localhost:8080/data/${encodeURIComponent(file)}`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the server name etc. should not be hard coded.
Can you get this information from some existing resource or should we add this information to the response of the backend endpoint?

@imranasif87
Copy link
Author

Hi @peterstadler, I've updated the solution based on your feedback—please review it when you get a chance.

Additionally, I have a suggestion for enhancing MerMEId: since users can now download all the files, we could consider supporting a re-upload mechanism. Currently, if a user updates the MerMEId version and re-runs or rebuilds the image without a cache, all previously stored files are lost.

To address this, we could allow users to upload a ZIP archive containing all the XML files after logging in. The front-end could then extract and back-end has methods like crud:create into the eXist-db. This functionality could also support automated uploads via local bash scripts in the future. Just an idea for discussion—happy to hear your thoughts on this.

Copy link
Member

@peterstadler peterstadler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for all the work. I have some proposals which I added as suggestions so it's hopefully not too much hassle?!

for (let i = 0; i < totalFiles; i++) {
const file = filteredFiles[i];

if (!file.endsWith(".xml"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's worth a discussion ;)

a) I have also seen the file extension ".mei" which should not be excluded here.
b) what about letting the backend decide what a MerMEId data file is?

In general, it's probably not that easy. You would probably need to look into the file to tell whether it's an MEI file or not – and that could get get expensive for large databases.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterstadler, To address this, I added a code snippet that filters and returns only the files where the root element is . While this approach may not be suitable for very large data files, it performs efficiently for reasonably sized datasets. Moving forward, we should consider implementing indexing or caching to improve scalability.

  • Preprocess the collection to tag or index files with roots
  • Store valid MEI filenames in a metadata file or use custom indexes
  • Avoids runtime parsing for every request

@peterstadler
Copy link
Member

Many thanks for all the great work and your patience @imranasif87 !

@peterstadler peterstadler merged commit b7ca26a into Edirom:develop Aug 13, 2025
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🔧📤 Implemented XML Downloads/Export via API for Future Automation in Mermeid
2 participants