Apply TNCSC favicon through frontend and backend assets
Replace rendered favicon and Apple touch icon links with the official PNG using a versioned URL, including layouts whose database template overrides have not taken effect. Create an icon link when absent without duplicates. Validated injected script on live homepage and login HTML, PNG response, repeated execution, JavaScript syntax, and manifest completeness. Production still requires loading the updated assets.
This commit is contained in:
parent
191b12b0cd
commit
df80bc9560
@ -57,10 +57,12 @@ that applies to the community_* product modules.
|
|||||||
'tncsc_deployment/static/src/scss/primary_variables.scss',
|
'tncsc_deployment/static/src/scss/primary_variables.scss',
|
||||||
],
|
],
|
||||||
'web.assets_frontend': [
|
'web.assets_frontend': [
|
||||||
|
'tncsc_deployment/static/src/js/favicon.js',
|
||||||
'tncsc_deployment/static/src/scss/login_theme.scss',
|
'tncsc_deployment/static/src/scss/login_theme.scss',
|
||||||
'tncsc_deployment/static/src/scss/website_navigation.scss',
|
'tncsc_deployment/static/src/scss/website_navigation.scss',
|
||||||
],
|
],
|
||||||
'web.assets_backend': [
|
'web.assets_backend': [
|
||||||
|
'tncsc_deployment/static/src/js/favicon.js',
|
||||||
'tncsc_deployment/static/src/scss/tncsc_backend_theme.scss',
|
'tncsc_deployment/static/src/scss/tncsc_backend_theme.scss',
|
||||||
'tncsc_deployment/static/src/scss/event_kanban.scss',
|
'tncsc_deployment/static/src/scss/event_kanban.scss',
|
||||||
'tncsc_deployment/static/src/scss/community_dashboard.scss',
|
'tncsc_deployment/static/src/scss/community_dashboard.scss',
|
||||||
|
|||||||
27
addons/tncsc_deployment/static/src/js/favicon.js
Normal file
27
addons/tncsc_deployment/static/src/js/favicon.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/** @odoo-module **/
|
||||||
|
|
||||||
|
// Apply branding to rendered layouts too, including website-specific copies.
|
||||||
|
// A versioned URL avoids reusing a previously cached database favicon.
|
||||||
|
function setTncscFavicon() {
|
||||||
|
const href = "/tncsc_deployment/static/src/img/brand/logo.png?v=tncsc-1";
|
||||||
|
const icons = [...document.head.querySelectorAll(
|
||||||
|
'link[rel~="icon"], link[rel="apple-touch-icon"], link[rel="apple-touch-icon-precomposed"]'
|
||||||
|
)];
|
||||||
|
if (!icons.some((icon) => icon.rel.split(/\s+/).includes("icon"))) {
|
||||||
|
const icon = document.createElement("link");
|
||||||
|
icon.rel = "icon";
|
||||||
|
document.head.appendChild(icon);
|
||||||
|
icons.push(icon);
|
||||||
|
}
|
||||||
|
for (const icon of icons) {
|
||||||
|
icon.type = "image/png";
|
||||||
|
icon.href = href;
|
||||||
|
icon.removeAttribute("sizes");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.readyState === "loading") {
|
||||||
|
document.addEventListener("DOMContentLoaded", setTncscFavicon, { once: true });
|
||||||
|
} else {
|
||||||
|
setTncscFavicon();
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user