Mercurial Hosting > freedit
comparison src/thread.html.luan @ 12:ad1604c72156
fix bbcode
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 03 Jul 2022 22:01:23 -0600 |
parents | 3ed1e3f3a53a |
children | 0edde02b908c |
comparison
equal
deleted
inserted
replaced
11:3ed1e3f3a53a | 12:ad1604c72156 |
---|---|
1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local ipairs = Luan.ipairs or error() | 3 local ipairs = Luan.ipairs or error() |
4 local Html = require "luan:Html.luan" | |
5 local html_encode = Html.encode or error() | |
6 local Parsers = require "luan:Parsers.luan" | |
7 local bbcode_to_html = Parsers.bbcode_to_html or error() | |
8 local Io = require "luan:Io.luan" | 4 local Io = require "luan:Io.luan" |
9 local output_of = Io.output_of or error() | |
10 local Http = require "luan:http/Http.luan" | 5 local Http = require "luan:http/Http.luan" |
11 local Shared = require "site:/lib/Shared.luan" | 6 local Shared = require "site:/lib/Shared.luan" |
12 local head = Shared.head or error() | 7 local head = Shared.head or error() |
13 local header = Shared.header or error() | 8 local header = Shared.header or error() |
14 local footer = Shared.footer or error() | 9 local footer = Shared.footer or error() |
15 local Forum = require "site:/lib/Forum.luan" | 10 local Forum = require "site:/lib/Forum.luan" |
16 local forum_title = Forum.title or error() | 11 local forum_title = Forum.title or error() |
17 local Db = require "site:/lib/Db.luan" | 12 local Db = require "site:/lib/Db.luan" |
18 local Post = require "site:/lib/Post.luan" | 13 local Post = require "site:/lib/Post.luan" |
19 local User = require "site:/lib/User.luan" | 14 local Bbcode = require "site:/lib/Bbcode.luan" |
15 local bbcode_to_html = Bbcode.to_html or error() | |
20 | 16 |
21 | |
22 local function quoter(content,user_name) | |
23 return output_of( function() | |
24 %><blockquote><% | |
25 if user_name ~= nil then | |
26 local user = User.get_by_name(user_name) | |
27 if user == nil then | |
28 %><%= html_encode(user_name) %> wrote:<% | |
29 else | |
30 %><a href="/user_somthing"><%= html_encode(user_name) %></a> wrote:<% | |
31 end | |
32 end | |
33 %><%= content %><% | |
34 %></blockquote><% | |
35 end_function ) | |
36 end | |
37 | 17 |
38 return function() | 18 return function() |
39 local root_id = Http.request.parameters.root or error() | 19 local root_id = Http.request.parameters.root or error() |
40 local docs, total_hits = Db.search("post_root_id:"..root_id,1,1000,{sort="id"}) | 20 local docs, total_hits = Db.search("post_root_id:"..root_id,1,1000,{sort="id"}) |
41 local posts = Post.from_docs(docs) | 21 local posts = Post.from_docs(docs) |
57 <% header() %> | 37 <% header() %> |
58 <div content> | 38 <div content> |
59 <h1><%=subject_html%></h1> | 39 <h1><%=subject_html%></h1> |
60 <% for _, post in ipairs(posts) do %> | 40 <% for _, post in ipairs(posts) do %> |
61 <hr> | 41 <hr> |
62 <div post><%=bbcode_to_html(post.content,quoter)%></div> | 42 <% bbcode_to_html(post.content) %> |
63 <p> | 43 <p> |
64 <a href="/reply.html?parent=<%=post.id%>">reply</a> | 44 <a href="/reply.html?parent=<%=post.id%>">reply</a> |
65 - <a href="/edit.html?post=<%=post.id%>">edit</a> | 45 - <a href="/edit.html?post=<%=post.id%>">edit</a> |
66 </p> | 46 </p> |
67 <% end %> | 47 <% end %> |