Mercurial Hosting > freedit
comparison src/edit.html.luan @ 9:9674275019bb
reply and edit
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 30 Jun 2022 00:02:28 -0600 |
parents | |
children | 24668255cede |
comparison
equal
deleted
inserted
replaced
8:be36282b556a | 9:9674275019bb |
---|---|
1 local Luan = require "luan:Luan.luan" | |
2 local error = Luan.error | |
3 local Html = require "luan:Html.luan" | |
4 local html_encode = Html.encode or error() | |
5 local Io = require "luan:Io.luan" | |
6 local Http = require "luan:http/Http.luan" | |
7 local Shared = require "site:/lib/Shared.luan" | |
8 local head = Shared.head or error() | |
9 local header = Shared.header or error() | |
10 local footer = Shared.footer or error() | |
11 local Forum = require "site:/lib/Forum.luan" | |
12 local forum_title = Forum.title or error() | |
13 local Post = require "site:/lib/Post.luan" | |
14 local User = require "site:/lib/User.luan" | |
15 | |
16 | |
17 return function() | |
18 local user = User.current_required() | |
19 if user==nil then return end | |
20 local post_id = Http.request.parameters.post or error() | |
21 local post = Post.get_by_id(post_id) or error() | |
22 if Http.request.method == "POST" then | |
23 post.content = Http.request.parameters.content or error() | |
24 post.save() | |
25 Http.response.send_redirect("/thread.html?root="..post.root_id) | |
26 return | |
27 end | |
28 Io.stdout = Http.response.text_writer() | |
29 %> | |
30 <!doctype html> | |
31 <html> | |
32 <head> | |
33 <% head() %> | |
34 <title><%=forum_title%>: edit</title> | |
35 </head> | |
36 <body> | |
37 <% header() %> | |
38 <div content> | |
39 <h1>edit: <%=post.root.subject_html%></h1> | |
40 <p>This page will almost certainly be replaced by ajax, but whatever. Hack for now.</p> | |
41 <form method=post> | |
42 <p><textarea name=content><%=html_encode(post.content)%></textarea></p> | |
43 <p><input type=submit></p> | |
44 </form> | |
45 </div> | |
46 <% footer() %> | |
47 </body> | |
48 </html> | |
49 <% | |
50 end |