view src/delete.js.luan @ 48:4e1a01db19ec

add lists
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 17 Nov 2022 00:11:44 -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