default stylua formatting
This commit is contained in:
1258
lib/dkjson.lua
1258
lib/dkjson.lua
File diff suppressed because it is too large
Load Diff
79
lib/fes.lua
79
lib/fes.lua
@@ -4,25 +4,26 @@ local M = {}
|
||||
M.__index = M
|
||||
|
||||
function M.fes(header, footer)
|
||||
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 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
|
||||
|
||||
if site_config.favicon then
|
||||
site_config.favicon = '<link rel="icon" type="image/x-icon" href="' .. site_config.favicon .. '">'
|
||||
end
|
||||
if site_config.favicon then
|
||||
site_config.favicon = '<link rel="icon" type="image/x-icon" href="' .. site_config.favicon .. '">'
|
||||
end
|
||||
|
||||
local self = {
|
||||
version = site_config.version,
|
||||
title = site_config.title,
|
||||
copyright = site_config.copyright,
|
||||
favicon = site_config.favicon,
|
||||
header = header or [[
|
||||
local self = {
|
||||
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>
|
||||
@@ -300,7 +301,7 @@ em, i { font-style: italic; }
|
||||
<body>
|
||||
<div class="container">
|
||||
]],
|
||||
footer = footer or [[
|
||||
footer = footer or [[
|
||||
<footer class="footer">
|
||||
<a href="https://git.vxserver.dev/fSD/fes" target="_blank">Fes Powered</a>
|
||||
<a href="https://www.lua.org/" target="_blank">Lua Powered</a>
|
||||
@@ -311,38 +312,42 @@ em, i { font-style: italic; }
|
||||
</body>
|
||||
</html>
|
||||
]],
|
||||
parts = {}
|
||||
}
|
||||
parts = {},
|
||||
}
|
||||
|
||||
return setmetatable(self, M)
|
||||
return setmetatable(self, M)
|
||||
end
|
||||
|
||||
function M:custom(str)
|
||||
table.insert(self.parts, str)
|
||||
return self
|
||||
table.insert(self.parts, str)
|
||||
return self
|
||||
end
|
||||
|
||||
for name, func in pairs(std) do
|
||||
if type(func) == "function" then
|
||||
M[name] = function(self, ...)
|
||||
local result = func(...)
|
||||
table.insert(self.parts, result)
|
||||
return self
|
||||
end
|
||||
end
|
||||
if type(func) == "function" then
|
||||
M[name] = function(self, ...)
|
||||
local result = func(...)
|
||||
table.insert(self.parts, result)
|
||||
return self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M:build()
|
||||
local header = self.header
|
||||
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
|
||||
local header = self.header
|
||||
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
|
||||
|
||||
M.__tostring = function(self)
|
||||
return self:build()
|
||||
return self:build()
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
15
lib/std.lua
15
lib/std.lua
@@ -19,29 +19,29 @@ end
|
||||
function M.a(link, str)
|
||||
link = link or "https://example.com"
|
||||
str = str or link
|
||||
return "<a href=\"" .. link .. "\">" .. str .. "</a>"
|
||||
return '<a href="' .. link .. '">' .. str .. "</a>"
|
||||
end
|
||||
|
||||
function M.ha(link, str)
|
||||
link = link or "https://example.com"
|
||||
str = str or link
|
||||
return "<a class=\"hidden\" href=\"" .. link .. "\">" .. str .. "</a>"
|
||||
return '<a class="hidden" href="' .. link .. '">' .. str .. "</a>"
|
||||
end
|
||||
|
||||
function M.external(link, str)
|
||||
return "<a target=\"_blank\" href=\"" .. link .. "\">" .. str .. "</a>"
|
||||
return '<a target="_blank" href="' .. link .. '">' .. str .. "</a>"
|
||||
end
|
||||
|
||||
function M.note(str)
|
||||
return '<div class="note">' .. str .. '</div>'
|
||||
return '<div class="note">' .. str .. "</div>"
|
||||
end
|
||||
|
||||
function M.muted(str)
|
||||
return '<div class="muted">' .. str .. '</div>'
|
||||
return '<div class="muted">' .. str .. "</div>"
|
||||
end
|
||||
|
||||
function M.callout(str)
|
||||
return '<div class="callout">' .. str .. '</div>'
|
||||
return '<div class="callout">' .. str .. "</div>"
|
||||
end
|
||||
|
||||
function M.h1(str)
|
||||
@@ -55,7 +55,8 @@ end
|
||||
function M.h3(str)
|
||||
return "<h3>" .. (str or "") .. "</h3>"
|
||||
end
|
||||
function M.h4(str) return "<h4>" .. (str or "") .. "</h4>"
|
||||
function M.h4(str)
|
||||
return "<h4>" .. (str or "") .. "</h4>"
|
||||
end
|
||||
|
||||
function M.h5(str)
|
||||
|
||||
Reference in New Issue
Block a user