structure changes
This commit is contained in:
@@ -6,7 +6,7 @@ local site = fes.fes()
|
||||
|
||||
local title = "Free Software Distributions"
|
||||
|
||||
site.title = title .. " - Site news"
|
||||
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))
|
||||
@@ -17,38 +17,6 @@ local function url_encode(s)
|
||||
return s
|
||||
end
|
||||
|
||||
local function list_files_in_dir(dir)
|
||||
local files = {}
|
||||
local ok, lfs = pcall(require, "lfs")
|
||||
if ok and lfs then
|
||||
for name in lfs.dir(dir) do
|
||||
if name ~= "." and name ~= ".." then
|
||||
local attr = lfs.attributes(dir .. "/" .. name)
|
||||
if attr and attr.mode == "file" then
|
||||
table.insert(files, name)
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(files)
|
||||
return files
|
||||
end
|
||||
local p = io.popen('ls -1 "' .. dir:gsub('"', '\"') .. '" 2>/dev/null')
|
||||
if not p then return files end
|
||||
for line in p:lines() do
|
||||
if line ~= "." and line ~= ".." then
|
||||
local f = dir .. "/" .. line
|
||||
local fh = io.open(f, "r")
|
||||
if fh then
|
||||
fh:close()
|
||||
table.insert(files, line)
|
||||
end
|
||||
end
|
||||
end
|
||||
p:close()
|
||||
table.sort(files)
|
||||
return files
|
||||
end
|
||||
|
||||
local function read_file(path)
|
||||
local f = io.open(path, "r")
|
||||
if not f then return nil end
|
||||
@@ -57,8 +25,8 @@ local function read_file(path)
|
||||
return data
|
||||
end
|
||||
|
||||
local dir = "news"
|
||||
local files = list_files_in_dir(dir)
|
||||
local dir = "article"
|
||||
local files = u.ls(dir)
|
||||
|
||||
local params = fes.bus.params or {}
|
||||
local article = params.article
|
||||
@@ -76,7 +44,8 @@ if article then
|
||||
end
|
||||
site.title = article
|
||||
if body then
|
||||
site:custom(fes.markdown_to_html(body))
|
||||
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),
|
||||
@@ -91,7 +60,7 @@ local articles = {}
|
||||
local n = 0
|
||||
for _, v in ipairs(files) do
|
||||
local display = v:gsub("%.[^%.]+$", "")
|
||||
local link = "/news?article=" .. url_encode(display)
|
||||
local link = "/article?article=" .. url_encode(display)
|
||||
table.insert(articles, std.a(link, display))
|
||||
n = n + 1
|
||||
end
|
||||
@@ -101,7 +70,7 @@ table.sort(articles, function (x, y)
|
||||
end)
|
||||
|
||||
if n > 0 then
|
||||
site:h1("Site news")
|
||||
site:h1("Articles")
|
||||
site:note(std.ul(articles))
|
||||
else
|
||||
site:h1("No articles")
|
||||
@@ -12,7 +12,7 @@ site.favicon = "/static/favicon.ico"
|
||||
|
||||
site:banner(fes.app.header.render(std))
|
||||
|
||||
site:custom(fes.markdown_to_html([[
|
||||
site:g(fes.markdown_to_html([[
|
||||
News
|
||||
===
|
||||
2026-03-01
|
||||
|
||||
@@ -14,16 +14,60 @@ site:h2("Fes")
|
||||
site:muted("fes is a lightweight, static, and optionated microframework.")
|
||||
|
||||
site:h2("Development")
|
||||
site:p("You can " .. std.external("https://git.vxserver.dev/fSD/fes", "browse") .. " its source code or get a copy using the following command:")
|
||||
site:p("You can " ..
|
||||
std.external("https://git.vxserver.dev/fSD/fes", "browse") ..
|
||||
" its source code or get a copy using the following command:")
|
||||
site:code("git clone https://git.vxserver.dev/fSD/fes")
|
||||
|
||||
site:h2("Docker")
|
||||
site:p("You can deploy websites using the " .. std.external("https://git.vxserver.dev/fSD/-/packages/container/fes/latest", "docker") .. " image:")
|
||||
site:p("You can deploy websites using the " ..
|
||||
std.external("https://git.vxserver.dev/fSD/-/packages/container/fes/latest", "docker") .. " image:")
|
||||
site:code("docker pull git.vxserver.dev/fsd/fes:latest")
|
||||
|
||||
local tars = u.ls("archive")
|
||||
|
||||
local function parseVersion(pkg)
|
||||
local version = pkg:match("-(.+)$")
|
||||
local parts = {}
|
||||
for n in version:gmatch("%d+") do
|
||||
parts[#parts + 1] = tonumber(n)
|
||||
end
|
||||
return parts
|
||||
end
|
||||
|
||||
local function isNewer(a, b)
|
||||
local va, vb = parseVersion(a), parseVersion(b)
|
||||
local len = math.max(#va, #vb)
|
||||
|
||||
for i = 1, len do
|
||||
local na, nb = va[i] or 0, vb[i] or 0
|
||||
if na ~= nb then
|
||||
return na > nb
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function latestRelease(packages, name)
|
||||
local latest = nil
|
||||
local prefix = "^" .. name .. "%-"
|
||||
|
||||
for _, pkg in ipairs(packages) do
|
||||
if pkg:match(prefix) then
|
||||
if not latest or isNewer(pkg, latest) then
|
||||
latest = pkg
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return latest
|
||||
end
|
||||
|
||||
local latest = latestRelease(tars, "fes")
|
||||
|
||||
site:h2("Download")
|
||||
site:ul {
|
||||
std.p(std.a("/archive/fes/fes-0.3.0.tar.gz", "fes-0.3.0") .. " (2026-04-1)"),
|
||||
std.p(std.a("/archive/" .. latest, latest) .. " (2026-04-1)"),
|
||||
std.a("/archive/fes", "Looking for specific version?")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user