Skip to content
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

Use a static path for the icon/logo #159

Open
tdulcet opened this issue May 24, 2023 · 2 comments
Open

Use a static path for the icon/logo #159

tdulcet opened this issue May 24, 2023 · 2 comments

Comments

@tdulcet
Copy link

tdulcet commented May 24, 2023

This was originally proposed in #15 (comment)

This is needed for my "FileLink provider for Send" Thunderbird add-on. As of Thunderbird 91.4.1, extensions can provide a URL for the icon of the service after uploading a file, which is added to the message instead of using the extension's icon. Some of the Send service instances of course use different icons/logos and this would allow the correct one to be added to the message. However, there does not currently seem to be a consistent path/filename for the icon.

Of the 19 public Send instances:

  • 11 use /icon.718f87fb.svg
  • 4 use /icon.26e159f8.svg
  • 1 uses /icon.fd04d81a.svg
  • 1 uses /Chapril-banner/v2/chapril-banner-logo.png
  • 1 uses /portailpro-logo.bff132c0.png
  • 1 uses /logo_acted_full.1d533b41.svg.

Note that the file for the default icon is here: https://github.com/timvisee/send/blob/master/assets/icon.svg, but Webpack adds those pesky hashes:

When included from the frontend (via webpack) the export will
be an object mapping file names to hashed file names. Example:
"send_logo.svg": "send_logo.5fcfdf0e.svg"
which seem to change after each version. Some Send instances also use a custom icon/logo with a different filename.

I propose something like a new /__icon__ endpoint which returns the icon, either directly or by an HTTP 301 redirect. An alternative would be to include a favicon.svg file, which is already a standard supported by many browsers, but some Send instances may not want to use an SVG icon. The existing favicon.ico file is too small and still uses the old Firefox Send logo for 16 of the 19 public Send instances due to #158.

@timvisee
Copy link
Owner

but Webpack adds those pesky hashes which seem to change after each version

That is intended, so on reach new release all assets are force-reloaded. That prevents inconsistency issues with partial caches.

I guess we can simply disable the hash for the favicon assets, because those aren't mission critical (to be up-to-date). Would that be fine?

That way we have a static URL without a new route and/or redirect.

@tdulcet
Copy link
Author

tdulcet commented May 25, 2023

Yeah, I figured it was for cache busting, but it is of course problematic when one needs to reference the files externally.

Yes, that would be great! As you know, Send already has the UI_CUSTOM_ASSETS_ICON environment variable for the icon, so when that is set maybe we could additionally create a symbolic link to the icon.svg file, so that the filename would then always be the same for all Send instances without needing to add that new route or redirect on the server:

[[ -n "${UI_CUSTOM_ASSETS_ICON}" ]] && ln -sf "${UI_CUSTOM_ASSETS_ICON}" assets/icon.svg

The only potential issue with this approach is that the .svg extension would obviously be misleading for Send instances that have a PNG icon.

This code could then also be simplified by removing the ternary operator:

send/app/ui/header.js

Lines 25 to 28 in 9f09a79

icon:
this.state.WEB_UI.CUSTOM_ASSETS.icon !== ''
? this.state.WEB_UI.CUSTOM_ASSETS.icon
: assets.get('icon.svg'),

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

No branches or pull requests

2 participants