Mercurial Hosting > freedit
view src/edit.html.luan @ 33:4fdc4ec0050b
upload with uploadcare
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 01 Aug 2022 22:50:16 -0600 |
parents | 24668255cede |
children |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local Html = require "luan:Html.luan" local html_encode = Html.encode or error() local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local Shared = require "site:/lib/Shared.luan" local head = Shared.head or error() local header = Shared.header or error() local footer = Shared.footer or error() local Forum = require "site:/lib/Forum.luan" local forum_title = Forum.title or error() local Post = require "site:/lib/Post.luan" local User = require "site:/lib/User.luan" local Bbcode = require "site:/lib/Bbcode.luan" local bbcode_preprocess = Bbcode.preprocess or error() return function() local user = User.current_required() if user==nil then return end local post_id = Http.request.parameters.post or error() local post = Post.get_by_id(post_id) or error() if Http.request.method == "POST" then local content = Http.request.parameters.content or error() content = bbcode_preprocess(content) post.content = content post.save() Http.response.send_redirect("/thread.html?root="..post.root_id) return end Io.stdout = Http.response.text_writer() %> <!doctype html> <html> <head> <% head() %> <title><%=forum_title%>: edit</title> </head> <body> <% header() %> <div content> <h1>edit: <%=post.root.subject_html%></h1> <p>This page will almost certainly be replaced by ajax, but whatever. Hack for now.</p> <form method=post> <p><textarea name=content><%=html_encode(post.content)%></textarea></p> <p><input type=submit></p> </form> </div> <% footer() %> </body> </html> <% end