favicons
¶
Derives raster favicon assets from light-logo.svg, for browser/OS chrome that can't use an SVG favicon at all.
Mirrors the approach used by the (separate) flask-website project for the same problem:
- Safari's tab bar, bookmarks, and iOS's "Add to Home Screen" only read a
raster
apple-touch-icon, never an SVG favicon. GET /favicon.icoat the site root is still probed by a lot of browser/OS UI (bookmarks, tab switchers) independent of any<link rel="icon">in the page at all.- Some browser chrome still only understands PNG favicons, at the conventional 32x32/16x16 sizes.
Rendered from light-logo.svg specifically, not dark-logo.svg -- these
derivatives are static files and can't respond to Dojo's manual dark-mode
toggle the way the primary SVG <link> does (see base.html), so they mirror
that link's own default, pre-toggle state instead of trying to track it.
:func:ensure_favicons regenerates each derivative once, only when the
source SVG has actually changed since the last time it ran (see main.py
for where this gets called, and CACHE_DIR for where the results land).
ensure_favicons
¶
(Re)generates every favicon derivative that's missing or stale.
Covers every PNG in _FAVICON_TARGETS plus favicon.ico. Each is handled
independently -- one failing to render (a corrupt SVG, a read-only cache
directory) is logged and skipped rather than raised, so it can't block
the others or take down app startup over what's ultimately a cosmetic
asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
static_dir
|
Path
|
Dojo's |
required |
cache_dir
|
Path
|
Where derived PNG/ICO files are written. Defaults to |
CACHE_DIR
|