-
Notifications
You must be signed in to change notification settings - Fork 7
MIR-1449 Erroneous association of some file extensions with icons in user interface #1157
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: main
Are you sure you want to change the base?
Conversation
- Added Jersey resource to serve external MIME type mapping JSON - Improved file type detection logic in derivate-fileList.js - Updated Handlebars template and mycore.properties accordingly
…oint behavior and config usage
…oint behavior and config usage
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.
The json file and the resource can be replaced by MCRConfigHelperServlet
.
<servlet>
<servlet-name>MimeTypeIconMappingConfigHelper</servlet-name>
<servlet-class>org.mycore.frontend.servlets.MCRConfigHelperServlet</servlet-class>
<init-param>
<param-name>Properties</param-name>
<param-value>MIR.Mimetype.IconMapping.*</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>MimeTypeIconMappingConfigHelper</servlet-name>
<url-pattern>/mime-type-icons.json</url-pattern>
</servlet-mapping>
Property example:
MIR.Mimetype.IconMapping.fa-file-code=application/vnd.wolfram.mathematica.package
or
Property example:
MIR.Mimetype.IconMapping.application/vnd.wolfram.mathematica.package=fa-file-code
This does not require a new additional json configuration file and a java resource for fixing a bug.
This does not require a new additional json configuration file and a java resource for fixing a bug. -> Yes, that's true. But what if the user needs to change/add a lot of icon mappings and contentType(s)? Will they have to add a lot of MIR.Mimetype.IconMapping.* variables? Wouldn't it be easier to just add/change the data in the JSON configuration file? The idea was to allow the user to simply and easily change the mapping icon -> contentType if needed and not just fix a bug. |
You can also inverse your argument. If the User just wants to change a single icon, then he needs to copy the json file, just to change one icon. With my approach, you just need to change one property. In MyCoRe we already use properties to configure the application behaviour. It is well a well documented feature and every MyCoRe user knows it. We add additional code to avoid secondary configuration files like persistence.xml. Adding extra code to support a new undocumented configuration file, seems like big step backward. |
I agree with your arguments. I'll rework it to read variables from mycore.properties, as you advised. |
…g., 'Code') instead of icon class names, simplify config via MCRConfigHelperServlet
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.
Sorry, for the late response. I would prefer another change. Currently there is a mapping from the property to a icon definition e.G. from MIR.Mimetype.IconMapping.Code=application/vnd.wolfram.mathematica.package
But Code is not directly the fontawesome icon, its just a entry in the predefined table fileIcons
. This allows only to use icons defined in the table and it also increases the code complexity, because its another mapping. I would prefer to not have this mapping and just have a property like:
MIR.Mimetype.IconMapping.fa-file-code=application/vnd.wolfram.mathematica.package
This has the following advantages:
- easier to understand
- you can use other icons not present in the js file
- all icons would be in the mycore.properties file
ok, and how should we determine which tooltip (label) to use? At the moment we have const fileIcons in derivate-fileList.js with JSON structure, which uses following definitions as keys: "PDF", "Archive", "Image"... These keys are currently used as tooltips (labels). |
- Fixed some file type detections using exact extension matching - Added full JSDoc documentation for all helpers - Refactored to use object keys as labels - Improved robustness with trim() and strict checks
- Added Jersey resource to serve external MIME type mapping JSON - Improved file type detection logic in derivate-fileList.js - Updated Handlebars template and mycore.properties accordingly
…oint behavior and config usage
…oint behavior and config usage
…g., 'Code') instead of icon class names, simplify config via MCRConfigHelperServlet
3f21db0
to
4298fde
Compare
The labels are wrong now anyway. If i open the site as a german user i get the label "Image". The best way would be to load all keys with a prefix e.G |
New PR #1195 addresses the correct mapping of files to icons. Maybe this PR should go into main? |
please rebase branch to main |
In the user interface, when viewing a document in the Files section of the derivative, some extension files are incorrectly associated with icons. Example: the .m extension is associated with an icon for audio files.
Link to jira.