comparison src/save_edit.js.luan @ 25:66fd3784e60e

back to textarea for bbcode
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 19 Jul 2022 22:24:24 -0600
parents 33731231093a
children 0c1b820fff34
comparison
equal deleted inserted replaced
24:fccbe5554fcc 25:66fd3784e60e
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 remove_html = Bbcode.remove_html or error()
11 local bbcode_to_html = Bbcode.to_html or error() 10 local bbcode_to_html = Bbcode.to_html or error()
12 local Db = require "site:/lib/Db.luan" 11 local Db = require "site:/lib/Db.luan"
13 12
14 13
15 return function() 14 return function()
16 local post = Http.request.parameters.post or error() 15 local post = Http.request.parameters.post or error()
17 local text = Http.request.parameters.text or error() 16 local text = Http.request.parameters.text or error()
18 text = remove_html(text)
19 Db.run_in_transaction( function() 17 Db.run_in_transaction( function()
20 post = Post.get_by_id(post) or error() 18 post = Post.get_by_id(post) or error()
21 post.author_is_current() or error() 19 post.author_is_current() or error()
22 post.content = text 20 post.content = text
23 post.save() 21 post.save()