structure changes

This commit is contained in:
2026-01-06 15:45:56 -05:00
parent ef53232fca
commit f3114b38a8
14 changed files with 123 additions and 95 deletions

View File

@@ -0,0 +1,81 @@
local fes = require("fes")
local std = fes.std
local u = fes.util
local site = fes.fes()
local title = "Free Software Distributions"
site.title = title .. " - Site articles"
site.copyright = u.copyright("[https://git.vxserver.dev/fSD](https://git.vxserver.dev/fSD)", "fSD")
site.favicon = "/static/favicon.ico"
site:banner(fes.app.header.render(std))
local function url_encode(s)
if not s then return "" end
s = s:gsub("([^%w%-_.~])", function(c) return string.format("%%%02X", string.byte(c)) end)
return s
end
local function read_file(path)
local f = io.open(path, "r")
if not f then return nil end
local data = f:read("*a")
f:close()
return data
end
local dir = "article"
local files = u.ls(dir)
local params = fes.bus.params or {}
local article = params.article
if type(article) == "table" then
article = article[1]
end
if article then
local candidates = { article, article .. ".txt", article .. ".md", article .. ".html" }
local body
for _, c in ipairs(candidates) do
local p = dir .. "/" .. c
body = read_file(p)
if body then break end
end
site.title = article
if body then
site:g("<style>h1, h2, h3, h4, h5, h6 { text-align: center; }</style>")
site:g(fes.markdown_to_html(body))
else
site:note(u.cc {
std.h1(article),
std.p("article not found"),
})
end
site:note(fes.app.footer.render(std))
return site
end
local articles = {}
local n = 0
for _, v in ipairs(files) do
local display = v:gsub("%.[^%.]+$", "")
local link = "/article?article=" .. url_encode(display)
table.insert(articles, std.a(link, display))
n = n + 1
end
table.sort(articles, function (x, y)
return x > y
end)
if n > 0 then
site:h1("Articles")
site:note(std.ul(articles))
else
site:h1("No articles")
end
site:note(fes.app.footer.render(std))
return site