kitodo / kitodo-presentation

Kitodo.Presentation is a feature-rich framework for building a METS- or IIIF-based digital library. It is part of the Kitodo Digital Library Suite.
https://kitodo.github.io/kitodo-presentation/
GNU General Public License v3.0
39 stars 45 forks source link

[BUG] Resource wildwebmidi.data not found in Composer-based installations #1367

Open markusweigelt opened 1 month ago

markusweigelt commented 1 month ago

Description

wildwebmidi.js references an incorrect file location.

A significant change in TYPO3 12 is to load public resources from the _assets folder, where the public resource folders of extensions are symlinked.

A clear and concise description of what the bug is.

Reproduction

Steps to reproduce the behaviour:

  1. Install dlf extension in Composer-based Typo3 12 installation

Expected Behavior

wildwebmidi.data loads without 404 from _assets folder

Solution

Use path of caller file wildwebmidi.js maybe with document.currentScript.

Because it looks like a library that is also used in other projects, I didn't fix it.

markusweigelt commented 1 month ago

Does not work with document.currentScript.src because the current script is a merged version of all JavaScript files and is located in a different directory than the extension's assets.

Since I was interested in finding a solution, I discovered a satisfactory approach that works in both and next TYPO3 versions out of the box.

[typo3.branch=="11.5"]
  page.inlineSettings {
    dlfAssets = /typo3conf/ext/dlf/Resources/Public/
  }
[else]
  page.inlineSettings {
    dlfAssets = /_assets/007831ab53eafe3f6be2b9b1baf2a8d6/
  }
[end]

https://github.com/markusweigelt/kitodo-presentation/blob/c2534ae53a65c8f95a8d81db234b2038eaa4ae40/Configuration/TypoScript/setup.typoscript#L72-L80

After adding this to TypoScript and clearing the cache, the URL can be correctly built with this inline setting.

var REMOTE_PACKAGE_BASE= TYPO3.settings.TS.dlfAssets+"JavaScript/WildWebMidi/wildwebmidi.data";

https://github.com/markusweigelt/kitodo-presentation/blob/c2534ae53a65c8f95a8d81db234b2038eaa4ae40/Resources/Public/JavaScript/WildWebMidi/wildwebmidi.js#L4