comparison src/save_edit.js.luan @ 21:33731231093a

fix bbcode editing
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 17 Jul 2022 08:24:52 -0600
parents da006d1c1eba
children 66fd3784e60e
comparison
equal deleted inserted replaced
20:3ea49246d6a7 21:33731231093a
5 local Io = require "luan:Io.luan" 5 local Io = require "luan:Io.luan"
6 local output_of = Io.output_of or error() 6 local output_of = Io.output_of or error()
7 local Http = require "luan:http/Http.luan" 7 local Http = require "luan:http/Http.luan"
8 local Post = require "site:/lib/Post.luan" 8 local Post = require "site:/lib/Post.luan"
9 local Bbcode = require "site:/lib/Bbcode.luan" 9 local Bbcode = require "site:/lib/Bbcode.luan"
10 local bbcode_preprocess = Bbcode.preprocess or error() 10 local remove_html = Bbcode.remove_html or error()
11 local bbcode_to_html = Bbcode.to_html or error() 11 local bbcode_to_html = Bbcode.to_html or error()
12 local Db = require "site:/lib/Db.luan" 12 local Db = require "site:/lib/Db.luan"
13 13
14 14
15 return function() 15 return function()
16 local post = Http.request.parameters.post or error() 16 local post = Http.request.parameters.post or error()
17 local text = Http.request.parameters.text or error() 17 local text = Http.request.parameters.text or error()
18 text = bbcode_preprocess(text) 18 text = remove_html(text)
19 Db.run_in_transaction( function() 19 Db.run_in_transaction( function()
20 post = Post.get_by_id(post) or error() 20 post = Post.get_by_id(post) or error()
21 post.author_is_current() or error() 21 post.author_is_current() or error()
22 post.content = text 22 post.content = text
23 post.save() 23 post.save()