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
|
M.__index = M
|
||||||
|
|
||||||
function M.fes(header, footer)
|
function M.fes(header, footer)
|
||||||
local config = {} local site_config = {}
|
local config = {}
|
||||||
local fes_mod = package.loaded.fes
|
local site_config = {}
|
||||||
if fes_mod and fes_mod.config then
|
local fes_mod = package.loaded.fes
|
||||||
config = fes_mod.config
|
if fes_mod and fes_mod.config then
|
||||||
if config.site then
|
config = fes_mod.config
|
||||||
site_config = config.site
|
if config.site then
|
||||||
end
|
site_config = config.site
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if site_config.favicon then
|
if site_config.favicon then
|
||||||
site_config.favicon = '<link rel="icon" type="image/x-icon" href="' .. site_config.favicon .. '">'
|
site_config.favicon = '<link rel="icon" type="image/x-icon" href="' .. site_config.favicon .. '">'
|
||||||
end
|
end
|
||||||
|
|
||||||
local self = {
|
local self = {
|
||||||
version = site_config.version,
|
version = site_config.version,
|
||||||
title = site_config.title,
|
title = site_config.title,
|
||||||
copyright = site_config.copyright,
|
copyright = site_config.copyright,
|
||||||
favicon = site_config.favicon,
|
favicon = site_config.favicon,
|
||||||
header = header or [[
|
header = header or [[
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
@@ -300,7 +301,7 @@ em, i { font-style: italic; }
|
|||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
]],
|
]],
|
||||||
footer = footer or [[
|
footer = footer or [[
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<a href="https://git.vxserver.dev/fSD/fes" target="_blank">Fes Powered</a>
|
<a href="https://git.vxserver.dev/fSD/fes" target="_blank">Fes Powered</a>
|
||||||
<a href="https://www.lua.org/" target="_blank">Lua Powered</a>
|
<a href="https://www.lua.org/" target="_blank">Lua Powered</a>
|
||||||
@@ -311,38 +312,42 @@ em, i { font-style: italic; }
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
]],
|
]],
|
||||||
parts = {}
|
parts = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
return setmetatable(self, M)
|
return setmetatable(self, M)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:custom(str)
|
function M:custom(str)
|
||||||
table.insert(self.parts, str)
|
table.insert(self.parts, str)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, func in pairs(std) do
|
for name, func in pairs(std) do
|
||||||
if type(func) == "function" then
|
if type(func) == "function" then
|
||||||
M[name] = function(self, ...)
|
M[name] = function(self, ...)
|
||||||
local result = func(...)
|
local result = func(...)
|
||||||
table.insert(self.parts, result)
|
table.insert(self.parts, result)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:build()
|
function M:build()
|
||||||
local header = self.header
|
local header = self.header
|
||||||
header = header:gsub("{{TITLE}}", self.title or "Document")
|
header = header:gsub("{{TITLE}}", self.title or "Document")
|
||||||
local favicon_html = self.favicon and ('<link rel="icon" type="image/x-icon" href="' .. self.favicon .. '">')
|
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>">]])
|
header = header:gsub(
|
||||||
local footer = self.footer:gsub("{{COPYRIGHT}}", self.copyright or "© The Copyright Holder")
|
"{{FAVICON}}",
|
||||||
return header .. table.concat(self.parts, "\n") .. footer
|
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
|
end
|
||||||
|
|
||||||
M.__tostring = function(self)
|
M.__tostring = function(self)
|
||||||
return self:build()
|
return self:build()
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
15
lib/std.lua
15
lib/std.lua
@@ -19,29 +19,29 @@ end
|
|||||||
function M.a(link, str)
|
function M.a(link, str)
|
||||||
link = link or "https://example.com"
|
link = link or "https://example.com"
|
||||||
str = str or link
|
str = str or link
|
||||||
return "<a href=\"" .. link .. "\">" .. str .. "</a>"
|
return '<a href="' .. link .. '">' .. str .. "</a>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.ha(link, str)
|
function M.ha(link, str)
|
||||||
link = link or "https://example.com"
|
link = link or "https://example.com"
|
||||||
str = str or link
|
str = str or link
|
||||||
return "<a class=\"hidden\" href=\"" .. link .. "\">" .. str .. "</a>"
|
return '<a class="hidden" href="' .. link .. '">' .. str .. "</a>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.external(link, str)
|
function M.external(link, str)
|
||||||
return "<a target=\"_blank\" href=\"" .. link .. "\">" .. str .. "</a>"
|
return '<a target="_blank" href="' .. link .. '">' .. str .. "</a>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.note(str)
|
function M.note(str)
|
||||||
return '<div class="note">' .. str .. '</div>'
|
return '<div class="note">' .. str .. "</div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.muted(str)
|
function M.muted(str)
|
||||||
return '<div class="muted">' .. str .. '</div>'
|
return '<div class="muted">' .. str .. "</div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.callout(str)
|
function M.callout(str)
|
||||||
return '<div class="callout">' .. str .. '</div>'
|
return '<div class="callout">' .. str .. "</div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.h1(str)
|
function M.h1(str)
|
||||||
@@ -55,7 +55,8 @@ end
|
|||||||
function M.h3(str)
|
function M.h3(str)
|
||||||
return "<h3>" .. (str or "") .. "</h3>"
|
return "<h3>" .. (str or "") .. "</h3>"
|
||||||
end
|
end
|
||||||
function M.h4(str) return "<h4>" .. (str or "") .. "</h4>"
|
function M.h4(str)
|
||||||
|
return "<h4>" .. (str or "") .. "</h4>"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.h5(str)
|
function M.h5(str)
|
||||||
|
|||||||
Reference in New Issue
Block a user