diff 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
line wrap: on
line diff
--- a/src/new_post.js.luan	Tue Nov 22 22:57:43 2022 -0700
+++ b/src/new_post.js.luan	Wed Nov 23 23:29:16 2022 -0700
@@ -15,6 +15,8 @@
 local Shared = require "site:/lib/Shared.luan"
 local base_url = Shared.base_url or error()
 local show_post = Shared.show_post or error()
+local Bbcode = require "site:/bbcode/Bbcode.luan"
+local preprocess = Bbcode.preprocess or error()
 local Logging = require "luan:logging/Logging.luan"
 local logger = Logging.logger "new_post.js"
 
@@ -23,6 +25,10 @@
 	local user = User.current() or error()
 	local root_id = Http.request.parameters.root or error()
 	local text = Http.request.parameters.text or error()
+	local convert_urls = Http.request.parameters.convert_urls or error()
+	if convert_urls == "true" then
+		text = preprocess(text)
+	end
 	local post = Post.new{
 		root_id = to_number(root_id) or error()
 		content = text
@@ -35,7 +41,6 @@
 	local js = output_of(function()
 %>
 added( '<%=post.id%>', <%= json_string(html) %>, <%=Post.thread_size(root_id)%> );
-console.log(<%=post.id%>);
 <%
 	end)
 	local url = base_url().."/thread.html?root="..root_id