colors
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
let
|
||||
serverCfg = config.syscfg.server;
|
||||
mediaCfg = config.syscfg.media;
|
||||
palette = serverCfg.colorScheme.palette or { };
|
||||
port = 8080;
|
||||
assetSize = 64;
|
||||
cacheControl = containerCfg.extra.cacheControl or "public, max-age=86400";
|
||||
@@ -9,10 +10,32 @@ let
|
||||
logoSvgFileName = builtins.baseNameOf (toString mediaCfg.logo.svg);
|
||||
logoSvgMount = "/assets/${logoSvgFileName}";
|
||||
borderRadius = toString (containerCfg.extra.borderRadius or 32);
|
||||
resolveColor = value:
|
||||
if value == null then null
|
||||
else if !builtins.isString value then
|
||||
throw "favicon color values must be strings"
|
||||
else if lib.hasPrefix "#" value then
|
||||
value
|
||||
else
|
||||
lib.attrByPath [ value ] (throw "Unknown favicon color reference `${value}`") palette;
|
||||
normalizeProfile = profile:
|
||||
let
|
||||
bg =
|
||||
if profile ? bg then resolveColor profile.bg
|
||||
else if profile ? background then resolveColor profile.background
|
||||
else null;
|
||||
fg =
|
||||
if profile ? fg then resolveColor profile.fg
|
||||
else if profile ? foreground then resolveColor profile.foreground
|
||||
else null;
|
||||
in
|
||||
(lib.filterAttrs (name: _: !(builtins.elem name [ "bg" "background" "fg" "foreground" ])) profile)
|
||||
// lib.optionalAttrs (bg != null) { bg = bg; }
|
||||
// lib.optionalAttrs (fg != null) { fg = fg; };
|
||||
hostMappings = lib.mapAttrs' (mapping: profile:
|
||||
lib.nameValuePair
|
||||
(if lib.hasInfix "." mapping then mapping else "${mapping}.${serverCfg.domain}")
|
||||
profile
|
||||
(normalizeProfile profile)
|
||||
) (containerCfg.extra.mappings or {});
|
||||
traefikAssetPathRegexp =
|
||||
"^/(.*/)?"
|
||||
@@ -26,7 +49,9 @@ let
|
||||
inherit cacheControl;
|
||||
borderRadius = borderRadius;
|
||||
mappings = hostMappings;
|
||||
default = containerCfg.extra.default or null;
|
||||
default =
|
||||
if containerCfg.extra ? default then normalizeProfile containerCfg.extra.default
|
||||
else null;
|
||||
});
|
||||
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
|
||||
cairosvg
|
||||
@@ -104,8 +129,8 @@ let
|
||||
return f"{text}px"
|
||||
|
||||
def _render_svg(profile):
|
||||
bg = _color(profile.get("background"), "#111827")
|
||||
fg = _color(profile.get("foreground"), "#f8fafc")
|
||||
bg = _color(profile.get("bg") or profile.get("background"), "#111827")
|
||||
fg = _color(profile.get("fg") or profile.get("foreground"), "#f8fafc")
|
||||
border_radius = _border_radius()
|
||||
logo_data_uri = _tinted_logo_data_uri(fg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user