diff --git a/TODO b/TODO index 2922f0f..515b8af 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,2 @@ Add an interval element Add a way to pass data to sites on load via fes.bus -Fire emoji default favicon diff --git a/core/builtin.lua b/core/builtin.lua index 3479946..71a28af 100644 --- a/core/builtin.lua +++ b/core/builtin.lua @@ -3,24 +3,29 @@ local std = require("core.std") local M = {} M.__index = M +local function encode(str) + return str:gsub("([^%w%-%_%.%~])", function(c) + return string.format("%%%02X", string.byte(c)) end) end + function M.fes(header, footer) - local config = {} - local site_config = {} + local config = {} + local site_config = {} + local fes_mod = package.loaded.fes + if fes_mod and fes_mod.config then + config = fes_mod.config + if config.site then + site_config = config.site + end + end - local fes_mod = package.loaded.fes - if fes_mod and fes_mod.config then - config = fes_mod.config - if config.site then - site_config = config.site - end - end + local raw_favicon = site_config.favicon or [[🔥]] - local self = { - version = site_config.version or "", - title = site_config.title or "Document", - copyright = site_config.copyright or "© The Copyright Holder", - favicon = "/image/favicon.ico", - header = header or [[ + local self = { + version = site_config.version or "", + title = site_config.title or "Document", + copyright = site_config.copyright or "© The Copyright Holder", + favicon = "data:image/svg+xml," .. encode(raw_favicon), + header = header or [[ @@ -29,357 +34,71 @@ function M.fes(header, footer) {{TITLE}}
]], - footer = footer or [[ + footer = footer or [[