Add trick to access.lua to be able to inject custom/theme css and js when in apps as well

This commit is contained in:
Alexandre Aubin 2019-02-23 04:20:01 +01:00
parent ac3dc39f9a
commit 2f24e82f38
2 changed files with 19 additions and 0 deletions

View file

@ -315,6 +315,14 @@ if hlp.is_logged_in() then
if string.match(ngx.var.uri, "^/ynhpanel.json$") then
hlp.serve("/yunohost/sso/assets/js/ynhpanel.json")
end
-- TODO : don't forget to open a PR to enable access to those
-- in yunohost_panel.conf.inc
if string.match(ngx.var.uri, "^/ynhpanel_custom.js$") then
hlp.serve("/yunohost/sso/assets/themes/"..conf.theme.."/custom.js")
end
if string.match(ngx.var.uri, "^/ynhpanel_custom.css$") then
hlp.serve("/yunohost/sso/assets/themes/"..conf.theme.."/custom.css")
end
-- If user has no access to this URL, redirect him to the portal
if not hlp.has_access() then

View file

@ -262,6 +262,17 @@ function init_portal_button_and_overlay()
portalStyle.setAttribute("type", "text/css");
portalStyle.setAttribute("href", '/ynhpanel.css');
document.getElementsByTagName("head")[0].insertBefore(portalStyle, null);
// Inject custom / theme css
var customStyle = document.createElement("link");
customStyle.setAttribute("rel", "stylesheet");
customStyle.setAttribute("type", "text/css");
customStyle.setAttribute("href", '/ynhpanel_custom.css');
document.getElementsByTagName("head")[0].insertBefore(customStyle, null);
// Inject custom / theme js
var customScript = document.createElement("script");
customScript.setAttribute("type", "text/javascript");
customScript.setAttribute("src", '/ynhpanel_custom.js');
document.getElementsByTagName("head")[0].insertBefore(customScript, null);
// Bind portal button
// FIXME : this somehow prevent the portalButton