Mercurial Hosting > freedit
comparison src/new_post.js.luan @ 52:9f8ebc757814
add convert urls
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Wed, 23 Nov 2022 23:29:16 -0700 |
| parents | 0c1b820fff34 |
| children | 7ce54f6d93f2 |
comparison
equal
deleted
inserted
replaced
| 51:78b2d6995244 | 52:9f8ebc757814 |
|---|---|
| 13 local Post = require "site:/lib/Post.luan" | 13 local Post = require "site:/lib/Post.luan" |
| 14 local Db = require "site:/lib/Db.luan" | 14 local Db = require "site:/lib/Db.luan" |
| 15 local Shared = require "site:/lib/Shared.luan" | 15 local Shared = require "site:/lib/Shared.luan" |
| 16 local base_url = Shared.base_url or error() | 16 local base_url = Shared.base_url or error() |
| 17 local show_post = Shared.show_post or error() | 17 local show_post = Shared.show_post or error() |
| 18 local Bbcode = require "site:/bbcode/Bbcode.luan" | |
| 19 local preprocess = Bbcode.preprocess or error() | |
| 18 local Logging = require "luan:logging/Logging.luan" | 20 local Logging = require "luan:logging/Logging.luan" |
| 19 local logger = Logging.logger "new_post.js" | 21 local logger = Logging.logger "new_post.js" |
| 20 | 22 |
| 21 | 23 |
| 22 return function() | 24 return function() |
| 23 local user = User.current() or error() | 25 local user = User.current() or error() |
| 24 local root_id = Http.request.parameters.root or error() | 26 local root_id = Http.request.parameters.root or error() |
| 25 local text = Http.request.parameters.text or error() | 27 local text = Http.request.parameters.text or error() |
| 28 local convert_urls = Http.request.parameters.convert_urls or error() | |
| 29 if convert_urls == "true" then | |
| 30 text = preprocess(text) | |
| 31 end | |
| 26 local post = Post.new{ | 32 local post = Post.new{ |
| 27 root_id = to_number(root_id) or error() | 33 root_id = to_number(root_id) or error() |
| 28 content = text | 34 content = text |
| 29 author_name = user.name | 35 author_name = user.name |
| 30 } | 36 } |
| 33 end ) | 39 end ) |
| 34 local html = output_of(function() show_post(post,time_now()) end) | 40 local html = output_of(function() show_post(post,time_now()) end) |
| 35 local js = output_of(function() | 41 local js = output_of(function() |
| 36 %> | 42 %> |
| 37 added( '<%=post.id%>', <%= json_string(html) %>, <%=Post.thread_size(root_id)%> ); | 43 added( '<%=post.id%>', <%= json_string(html) %>, <%=Post.thread_size(root_id)%> ); |
| 38 console.log(<%=post.id%>); | |
| 39 <% | 44 <% |
| 40 end) | 45 end) |
| 41 local url = base_url().."/thread.html?root="..root_id | 46 local url = base_url().."/thread.html?root="..root_id |
| 42 Http.push(url,js) | 47 Http.push(url,js) |
| 43 end | 48 end |
