view src/delete.js.luan @ 60:8b5b1bce7d6b

bcode menus
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 30 Nov 2022 23:50:52 -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