latest.json endpoint
This commit is contained in:
parent
13a25eab94
commit
d14bcb8d20
@ -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)
|
||||||
|
|||||||
23
code/handlers/latesthandler.lua
Normal file
23
code/handlers/latesthandler.lua
Normal 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
|
||||||
Loading…
Reference in New Issue
Block a user