comparison src/edit.html.luan @ 13:24668255cede

preprocess urls
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 03 Jul 2022 23:59:41 -0600
parents 9674275019bb
children
comparison
equal deleted inserted replaced
12:ad1604c72156 13:24668255cede
10 local footer = Shared.footer or error() 10 local footer = Shared.footer or error()
11 local Forum = require "site:/lib/Forum.luan" 11 local Forum = require "site:/lib/Forum.luan"
12 local forum_title = Forum.title or error() 12 local forum_title = Forum.title or error()
13 local Post = require "site:/lib/Post.luan" 13 local Post = require "site:/lib/Post.luan"
14 local User = require "site:/lib/User.luan" 14 local User = require "site:/lib/User.luan"
15 local Bbcode = require "site:/lib/Bbcode.luan"
16 local bbcode_preprocess = Bbcode.preprocess or error()
15 17
16 18
17 return function() 19 return function()
18 local user = User.current_required() 20 local user = User.current_required()
19 if user==nil then return end 21 if user==nil then return end
20 local post_id = Http.request.parameters.post or error() 22 local post_id = Http.request.parameters.post or error()
21 local post = Post.get_by_id(post_id) or error() 23 local post = Post.get_by_id(post_id) or error()
22 if Http.request.method == "POST" then 24 if Http.request.method == "POST" then
23 post.content = Http.request.parameters.content or error() 25 local content = Http.request.parameters.content or error()
26 content = bbcode_preprocess(content)
27 post.content = content
24 post.save() 28 post.save()
25 Http.response.send_redirect("/thread.html?root="..post.root_id) 29 Http.response.send_redirect("/thread.html?root="..post.root_id)
26 return 30 return
27 end 31 end
28 Io.stdout = Http.response.text_writer() 32 Io.stdout = Http.response.text_writer()