Mercurial Hosting > freedit
comparison src/new_thread.html.luan @ 46:289718f121e4
use bbcode editor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 14 Nov 2022 18:43:38 -0700 |
parents | 0c1b820fff34 |
children | 78b2d6995244 |
comparison
equal
deleted
inserted
replaced
45:2d4f00755092 | 46:289718f121e4 |
---|---|
15 return function() | 15 return function() |
16 local user = User.current_required() | 16 local user = User.current_required() |
17 if user==nil then return end | 17 if user==nil then return end |
18 if Http.request.method == "POST" then | 18 if Http.request.method == "POST" then |
19 local subject = Http.request.parameters.subject or error() | 19 local subject = Http.request.parameters.subject or error() |
20 local content = Http.request.parameters.content or error() | 20 local content = Http.request.parameters.bbcode or error() |
21 local post = Post.new_thread(user,subject,content) | 21 local post = Post.new_thread(user,subject,content) |
22 Http.response.send_redirect("/thread.html?root="..post.id) | 22 Http.response.send_redirect("/thread.html?root="..post.id) |
23 return | 23 return |
24 end | 24 end |
25 Io.stdout = Http.response.text_writer() | 25 Io.stdout = Http.response.text_writer() |
28 <html> | 28 <html> |
29 <head> | 29 <head> |
30 <% head() %> | 30 <% head() %> |
31 <title><%=forum_title%>: new thread</title> | 31 <title><%=forum_title%>: new thread</title> |
32 <style> | 32 <style> |
33 textarea { | 33 @import "/bbcode/bbcode.css"; |
34 width: 100%; | |
35 } | |
36 </style> | 34 </style> |
37 <script> | 35 <script src="/bbcode/bbcode.js"></script> |
38 function uploaded(input,url,filename) { | |
39 let textarea = document.querySelector('textarea'); | |
40 textarea.focus(); | |
41 textarea.setRangeText(url,textarea.selectionStart,textarea.selectionEnd,'select'); | |
42 } | |
43 </script> | |
44 </head> | |
45 <body> | 36 <body> |
46 <% header() %> | 37 <% header() %> |
47 <div content> | 38 <div content> |
48 <h1>New Thread</h1> | 39 <h1>New Thread</h1> |
49 <form method=post> | 40 <form method=post> |
50 <p> | 41 <p> |
51 <label>Subject</label> | 42 <label>Subject</label> |
52 <input name=subject required> | 43 <input name=subject required> |
53 </p> | 44 </p> |
54 <p><textarea name=content oninput="fixTextarea(this)"></textarea></p> | 45 <p editor></p> |
55 <p> | |
56 <input type=file onchange="upload(this,uploaded)"> | |
57 <button type=button onclick="fileButtonClick(this)">Upload File</button> | |
58 </p> | |
59 <p><input type=submit></p> | 46 <p><input type=submit></p> |
60 </form> | 47 </form> |
61 </div> | 48 </div> |
62 <% footer() %> | 49 <% footer() %> |
63 </body> | 50 </body> |
51 <script> | |
52 bbcodeCreate('p[editor]'); | |
53 </script> | |
64 </html> | 54 </html> |
65 <% | 55 <% |
66 end | 56 end |