alpha p6
This commit is contained in:
@@ -3,13 +3,8 @@ 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
|
||||
@@ -18,20 +13,18 @@ function M.fes(header, footer)
|
||||
end
|
||||
end
|
||||
|
||||
local raw_favicon = site_config.favicon or [[<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y=".9em" font-size="90">🔥</text></svg>]]
|
||||
|
||||
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),
|
||||
version = site_config.version,
|
||||
title = site_config.title,
|
||||
copyright = site_config.copyright,
|
||||
favicon = site_config.favicon,
|
||||
header = header or [[
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="{{FAVICON}}">
|
||||
{{FAVICON}}
|
||||
<title>{{TITLE}}</title>
|
||||
<style>
|
||||
html, body { min-height: 100%; margin: 0; padding: 0; background: #0f1113; color: #e6eef3; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; line-height: 1.5; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
|
||||
@@ -132,10 +125,9 @@ end
|
||||
|
||||
function M:build()
|
||||
local header = self.header
|
||||
local safe_title = self.title or "Document"
|
||||
local safe_favicon = self.favicon:gsub("%%", "%%%%")
|
||||
header = header:gsub("{{TITLE}}", safe_title)
|
||||
header = header:gsub("{{FAVICON}}", safe_favicon)
|
||||
header = header:gsub("{{TITLE}}", self.title or "Document")
|
||||
local favicon_html = self.favicon and ('<link rel="icon" type="image/x-icon" href="' .. self.favicon .. '">')
|
||||
header = header:gsub("{{FAVICON}}", favicon_html or [[<link rel="icon" href="data:image/svg+xml,<svg xmlns=%%22http://www.w3.org/2000/svg%%22 viewBox=%%220 0 100 100%%22><text y=%%22.9em%%22 font-size=%%2290%%22>🔥</text></svg>">]])
|
||||
local footer = self.footer:gsub("{{COPYRIGHT}}", self.copyright or "© The Copyright Holder")
|
||||
return header .. table.concat(self.parts, "\n") .. footer
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user