view src/delete.js.luan @ 47:7ef9222474e2

add more button
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 14 Nov 2022 23:01:29 -0700
parents 0c1b820fff34
children
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local Io = require "luan:Io.luan"
local output_of = Io.output_of or error()
local Http = require "luan:http/Http.luan"
local Post = require "site:/lib/Post.luan"
local Shared = require "site:/lib/Shared.luan"
local base_url = Shared.base_url or error()


return function()
	local post = Http.request.parameters.post or error()
	post = Post.get_by_id(post) or error()
	local root_id = post.root_id
	post.delete()
	local js = output_of(function()
%>
deleted( '<%=post.id%>', <%=Post.thread_size(root_id)%> );
<%
	end)
	local url = base_url().."/thread.html?root="..root_id
	Http.push(url,js)
end