-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Default favicon #406
Default favicon #406
Conversation
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.
Added some comments, but no real issues. Good to see this getting attended to!
💃
dash/dash.py
Outdated
@@ -216,6 +216,9 @@ def add_url(name, view_func, methods=('GET',)): | |||
'{}<path:path>'.format(self.config['routes_pathname_prefix']), | |||
self.index) | |||
|
|||
add_url('{}_favicon'.format(self.config['routes_pathname_prefix']), |
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.
Could this route be {}_favicon.ico
? I feel like this would make it clearer that the route is serving a .ico file directly
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.
Yes probably clearer thanks.
dash/dash.py
Outdated
favicon = '' | ||
favicon = '<link rel="icon" type="image/x-icon" href="{}">'.format( | ||
self.get_asset_url(self._favicon) if self._favicon | ||
else '{}_favicon'.format(self.config.requests_pathname_prefix)) |
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.
I found this logic with the nested formats and conditional expression a little hard to parse initially. I'd have a preference for something more verbose but easier to read, like:
if self._favicon:
favicon_url = self.get_asset_url(self._favicon)
else:
favicon_url = '{}_favicon'.format(self.config.requests_pathname_prefix)
favicon = '<link rel="icon" type="image/x-icon" href="{}">'.format(favicon_url)
This looks good. I found it a bit difficult to change the Do you think we can implement a cache-busting mechanism when users have custom
This should bust the cache every time the I'm 💃 with or without this change, but I think this will help save people a lot of time who can't figure out why their |
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.
Looks good, tested it with a bunch of different favicons. Would be nice to have cache busting if it works.
@rmarren1 good point, I will add cache busting for the assets favicon. |
ac42f96
to
d2a2752
Compare
Adds a default favicon if no favicon is found in the assets folder.
To override the default favicon, you just need to put a
favicon.ico
file in the assets folder.Resolves #152.