1.0 fsd main

This commit is contained in:
2025-12-07 12:58:55 -05:00
parent 76eb4809e2
commit 66fa060e2f
8 changed files with 71 additions and 64 deletions

Binary file not shown.

Submodule fsd.vxserver.dev/archive/releases/yait/yait added at 54db089b71

View File

@@ -0,0 +1 @@
djasjkdjaslkdjaskl

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -7,6 +7,7 @@ local site = fes.fes()
local title = "Free Software Distributions" local title = "Free Software Distributions"
site.title = title site.title = title
site.favicon = "/static/image/favicon.ico"
site.copyright = u.copyright("https://git.vxserver.dev/fSD", "fSD") site.copyright = u.copyright("https://git.vxserver.dev/fSD", "fSD")
site:banner(fes.app.header.render(std)) site:banner(fes.app.header.render(std))

View File

@@ -11,49 +11,49 @@ site.copyright = u.copyright("[https://git.vxserver.dev/fSD](https://git.vxserve
site:banner(fes.app.header.render(std)) site:banner(fes.app.header.render(std))
local function url_encode(s) local function url_encode(s)
if not s then return "" end if not s then return "" end
s = s:gsub("([^%w%-_.~])", function(c) return string.format("%%%02X", string.byte(c)) end) s = s:gsub("([^%w%-_.~])", function(c) return string.format("%%%02X", string.byte(c)) end)
return s return s
end end
local function list_files_in_dir(dir) local function list_files_in_dir(dir)
local files = {} local files = {}
local ok, lfs = pcall(require, "lfs") local ok, lfs = pcall(require, "lfs")
if ok and lfs then if ok and lfs then
for name in lfs.dir(dir) do for name in lfs.dir(dir) do
if name ~= "." and name ~= ".." then if name ~= "." and name ~= ".." then
local attr = lfs.attributes(dir .. "/" .. name) local attr = lfs.attributes(dir .. "/" .. name)
if attr and attr.mode == "file" then if attr and attr.mode == "file" then
table.insert(files, name) table.insert(files, name)
end end
end end
end end
table.sort(files) table.sort(files)
return files return files
end end
local p = io.popen('ls -1 "' .. dir:gsub('"','\"') .. '" 2>/dev/null') local p = io.popen('ls -1 "' .. dir:gsub('"', '\"') .. '" 2>/dev/null')
if not p then return files end if not p then return files end
for line in p:lines() do for line in p:lines() do
if line ~= "." and line ~= ".." then if line ~= "." and line ~= ".." then
local f = dir .. "/" .. line local f = dir .. "/" .. line
local fh = io.open(f, "r") local fh = io.open(f, "r")
if fh then if fh then
fh:close() fh:close()
table.insert(files, line) table.insert(files, line)
end end
end end
end end
p:close() p:close()
table.sort(files) table.sort(files)
return files return files
end end
local function read_file(path) local function read_file(path)
local f = io.open(path, "r") local f = io.open(path, "r")
if not f then return nil end if not f then return nil end
local data = f:read("*a") local data = f:read("*a")
f:close() f:close()
return data return data
end end
local dir = "news" local dir = "news"
@@ -62,44 +62,48 @@ local files = list_files_in_dir(dir)
local params = fes.bus.params or {} local params = fes.bus.params or {}
local article = params.article local article = params.article
if type(article) == "table" then if type(article) == "table" then
article = article[1] article = article[1]
end end
if article then if article then
local candidates = {article, article .. ".txt", article .. ".md", article .. ".html"} local candidates = { article, article .. ".txt", article .. ".md", article .. ".html" }
local body local body
for _, c in ipairs(candidates) do for _, c in ipairs(candidates) do
local p = dir .. "/" .. c local p = dir .. "/" .. c
body = read_file(p) body = read_file(p)
if body then break end if body then break end
end end
site.title = article site.title = article
if body then if body then
site:custom(fes.markdown_to_html(body)) site:custom(fes.markdown_to_html(body))
else else
site:note(u.cc { site:note(u.cc {
std.h1(article), std.h1(article),
std.p("article not found"), std.p("article not found"),
}) })
end end
site:note(fes.app.footer.render(std)) site:note(fes.app.footer.render(std))
return site return site
end end
local articles = {} local articles = {}
local n = 0 local n = 0
for _, v in ipairs(files) do for _, v in ipairs(files) do
local display = v:gsub("%.[^%.]+$", "") local display = v:gsub("%.[^%.]+$", "")
local link = "/news?article=" .. url_encode(display) local link = "/news?article=" .. url_encode(display)
table.insert(articles, std.a(link, display)) table.insert(articles, std.a(link, display))
n = n + 1 n = n + 1
end end
table.sort(articles, function (x, y)
return x > y
end)
if n > 0 then if n > 0 then
site:h1("Site news") site:h1("Site news")
site:note(std.ul(articles)) site:note(std.ul(articles))
else else
site:h1("No articles") site:h1("No articles")
end end
site:note(fes.app.footer.render(std)) site:note(fes.app.footer.render(std))

View File

@@ -22,7 +22,7 @@ for i, pkg in pairs(pkgs) do
std.muted(pkg[2] or "Could not find a description."), std.muted(pkg[2] or "Could not find a description."),
std.br(), std.br(),
std.ul({ std.ul({
std.rl(pkg[1], std.external("https://git.vxserver.dev/fSD/" .. pkg[1], "Download")), std.rl(pkg[1], std.external("/archive/releases/" .. pkg[1], "Download")),
}), }),
})) }))
end end