annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Io = require "luan:Io.luan"
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
4 local output_of = Io.output_of or error()
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Http = require "luan:http/Http.luan"
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local Post = require "site:/lib/Post.luan"
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
7 local Shared = require "site:/lib/Shared.luan"
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
8 local base_url = Shared.base_url or error()
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 return function()
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local post = Http.request.parameters.post or error()
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
13 post = Post.get_by_id(post) or error()
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
14 local root_id = post.root_id
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
15 post.delete()
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
16 local js = output_of(function()
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 %>
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
18 deleted( '<%=post.id%>', <%=Post.thread_size(root_id)%> );
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 <%
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
20 end)
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
21 local url = base_url().."/thread.html?root="..root_id
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
22 Http.push(url,js)
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 end