latest.json endpoint

This commit is contained in:
dreamer 2025-12-16 16:23:59 +01:00
parent 13a25eab94
commit d14bcb8d20
2 changed files with 28 additions and 0 deletions

View File

@ -34,6 +34,11 @@ app:get("/", function(self)
return handlers.Roothandler(self) return handlers.Roothandler(self)
end) end)
app:get("/latest.json", function(self)
self.titles = page_titles
return handlers.Latesthandler(self)
end)
app:get("/*", function(self) app:get("/*", function(self)
self.titles = page_titles self.titles = page_titles
return handlers.Roothandler(self) return handlers.Roothandler(self)

View File

@ -0,0 +1,23 @@
local to_json = require("lapis.util").to_json
local escape = require("lapis.util").escape
local autoload = require("lapis.util").autoload
local config = require("lapis.config")
local hotmixes = autoload("hotmixes")
local function Latesthandler(self)
local path = config.get().mount .. self.titles.url
local latest_path, latest_name = hotmixes.utils.these_latest( path )
data_path = 'https://' .. self.titles.url .. '/data/' .. self.titles.url .. '/'
latest_json = {}
for i, file in ipairs(latest_path) do
latest_json[latest_name[i]] = data_path .. escape(file)
end
return { json = latest_json }
end
return Latesthandler