view src/delete.js.luan @ 52:9f8ebc757814

add convert urls
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 23 Nov 2022 23:29:16 -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