63 lines
1.2 KiB
Lua
63 lines
1.2 KiB
Lua
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 news"
|
|
site.copyright = u.copyright("https://git.vxserver.dev/fSD", "fSD")
|
|
|
|
site:banner(fes.app.header.render(std))
|
|
|
|
local articles_dir = "article"
|
|
local files = {}
|
|
|
|
local p = io.popen("ls -1 " .. articles_dir)
|
|
if p then
|
|
for file in p:lines() do
|
|
if file:match("%.md$") then
|
|
files[#files + 1] = file
|
|
end
|
|
end
|
|
p:close()
|
|
end
|
|
|
|
table.sort(files, function(a, b) return a > b end)
|
|
|
|
local news_html = {}
|
|
local news_titles = {}
|
|
|
|
for _, file in ipairs(files) do
|
|
local path = articles_dir .. "/" .. file
|
|
local f = io.open(path, "r")
|
|
if f then
|
|
local content = f:read("*a")
|
|
f:close()
|
|
news_html[#news_html + 1] = fes.markdown_to_html(content)
|
|
local title_line = content:match("^#+%s*(.-)%s*\n") or ""
|
|
news_titles[#news_titles + 1] = std.h3(title_line)
|
|
end
|
|
end
|
|
|
|
site:note(u.cc({
|
|
std.h1("Site news - Latest"),
|
|
std.blockquote(std.p(news_html[1] or "")),
|
|
}))
|
|
|
|
local other_titles = {}
|
|
|
|
for i = 2, #news_titles do
|
|
other_titles[#other_titles + 1] = news_titles[i]
|
|
end
|
|
|
|
site:note(u.cc({
|
|
std.center(std.h2("Other")),
|
|
table.concat(other_titles, "")
|
|
}))
|
|
|
|
site:note(fes.app.footer.render(std))
|
|
|
|
return site
|