diff --git a/src/lua/endpoints/delete_post.lua b/src/lua/endpoints/delete_post.lua index d0f8b44..152059c 100644 --- a/src/lua/endpoints/delete_post.lua +++ b/src/lua/endpoints/delete_post.lua @@ -7,6 +7,7 @@ local db = require("db") local queries = require("queries") local sql = require("lsqlite3") local cache = require("cache") +local api = require("hooks") local oldconfigure = configure local stmnt_delete @@ -15,6 +16,18 @@ function configure(...) return oldconfigure(...) end +local oldspec = api.get.page_owner +function api.get.page_owner = function(env) + local ret = oldspec() + table.insert(oldret,{ + endpoint = string.format("https://%s/_delete",env.domain), + method = "POST", + fields = {story = env.short}, + text = "Delete" + }) + return ret +end + local function delete_post(req) local host = http_request_get_host(req) local path = http_request_get_path(req) diff --git a/src/lua/endpoints/edit_get.lua b/src/lua/endpoints/edit_get.lua index 7f0a174..ba92fad 100644 --- a/src/lua/endpoints/edit_get.lua +++ b/src/lua/endpoints/edit_get.lua @@ -8,6 +8,7 @@ local pages = require("pages") local tags = require("tags") local session = require("session") local config = require("config") +local api = require("hooks") local stmnt_edit local oldconfigure = configure @@ -16,6 +17,18 @@ function configure(...) return oldconfigure(...) end +local oldspec = api.get.page_owner +function api.get.page_owner = function(env) + local ret = oldspec() + table.insert(oldret,{ + endpoint = string.format("https://%s/_edit",env.domain), + method = "GET", + fields = {story = env.short}, + text = "Edit" + }) + return ret +end + local function edit_get(req) local host = http_request_get_host(req) local path = http_request_get_path(req) diff --git a/src/lua/init.lua b/src/lua/init.lua index 71faccf..7e696c2 100644 --- a/src/lua/init.lua +++ b/src/lua/init.lua @@ -10,6 +10,7 @@ print("Really fast print from init.lua") local et = require("etlua") local sql = require("lsqlite3") local zlib = require("zlib") +local api = require("hooks") --stubs for detouring function configure(...) end @@ -105,7 +106,9 @@ for funcname, spec in pairs({ else log(LOG_DEBUG,string.format("Endpoint %s called with method %s",funcname,method)) end + api.pre_request(req) spec[method](req) + api.post_request(req) end log(LOG_INFO,string.format("Associateing endpoint %q", funcname)) end @@ -118,7 +121,9 @@ function teardown() if cache then cache.close() end + api.worker_shutdown() print("Finished lua teardown") end +api.worker_init() print("Done with init.lua") diff --git a/src/pages/read.etlua.in b/src/pages/read.etlua.in index 6bf0d25..feb7b74 100644 --- a/src/pages/read.etlua.in +++ b/src/pages/read.etlua.in @@ -4,14 +4,14 @@ <% if owner then -%>
-
- - -
-
- - -
+ <% for _, spec in ipairs(api.get.page_owner(_ENV)) do %> +
+ <% for key, value in pairs(spec.fields) %> + + <% end %> + +
+ <% end %>
<% end -%>