Mercurial Hosting > freedit
comparison src/save_edit.js.luan @ 52:9f8ebc757814
add convert urls
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Wed, 23 Nov 2022 23:29:16 -0700 |
| parents | 96f0c3d65698 |
| children |
comparison
equal
deleted
inserted
replaced
| 51:78b2d6995244 | 52:9f8ebc757814 |
|---|---|
| 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:/bbcode/Bbcode.luan" | 9 local Bbcode = require "site:/bbcode/Bbcode.luan" |
| 10 local preprocess = Bbcode.preprocess or error() | |
| 10 local bbcode_to_html = Bbcode.to_html or error() | 11 local bbcode_to_html = Bbcode.to_html or error() |
| 11 local Db = require "site:/lib/Db.luan" | 12 local Db = require "site:/lib/Db.luan" |
| 12 local Shared = require "site:/lib/Shared.luan" | 13 local Shared = require "site:/lib/Shared.luan" |
| 13 local base_url = Shared.base_url or error() | 14 local base_url = Shared.base_url or error() |
| 14 local Logging = require "luan:logging/Logging.luan" | 15 local Logging = require "luan:logging/Logging.luan" |
| 16 | 17 |
| 17 | 18 |
| 18 return function() | 19 return function() |
| 19 local post = Http.request.parameters.post or error() | 20 local post = Http.request.parameters.post or error() |
| 20 local text = Http.request.parameters.text or error() | 21 local text = Http.request.parameters.text or error() |
| 22 local convert_urls = Http.request.parameters.convert_urls or error() | |
| 23 if convert_urls == "true" then | |
| 24 text = preprocess(text) | |
| 25 end | |
| 21 Db.run_in_transaction( function() | 26 Db.run_in_transaction( function() |
| 22 post = Post.get_by_id(post) or error() | 27 post = Post.get_by_id(post) or error() |
| 23 post.author_is_current() or error() | 28 post.author_is_current() or error() |
| 24 post.content = text | 29 post.content = text |
| 25 post.save() | 30 post.save() |
