Mercurial Hosting > freedit
comparison src/lib/Bbcode.luan @ 23:cdcd1b70c15e
tinymce work
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 18 Jul 2022 23:50:48 -0600 |
| parents | 33731231093a |
| children | 6871eec2cf4c |
comparison
equal
deleted
inserted
replaced
| 22:d87a8f9f43d7 | 23:cdcd1b70c15e |
|---|---|
| 14 local is_list = Table.is_list or error() | 14 local is_list = Table.is_list or error() |
| 15 local concat = Table.concat or error() | 15 local concat = Table.concat or error() |
| 16 local String = require "luan:String.luan" | 16 local String = require "luan:String.luan" |
| 17 local gsub = String.gsub or error() | 17 local gsub = String.gsub or error() |
| 18 local matches = String.matches or error() | 18 local matches = String.matches or error() |
| 19 local match = String.match or error() | |
| 19 local User = require "site:/lib/User.luan" | 20 local User = require "site:/lib/User.luan" |
| 20 local Shared = require "site:/lib/Shared.luan" | 21 local Shared = require "site:/lib/Shared.luan" |
| 21 local list_to_set = Shared.list_to_set or error() | 22 local list_to_set = Shared.list_to_set or error() |
| 22 local to_list = Shared.to_list or error() | 23 local to_list = Shared.to_list or error() |
| 23 local Logging = require "luan:logging/Logging.luan" | 24 local Logging = require "luan:logging/Logging.luan" |
| 77 function html.color(bbcode,options) | 78 function html.color(bbcode,options) |
| 78 %><span style="color:<%=bbcode.param%>"><% to_html(bbcode.contents,options) %></span><% | 79 %><span style="color:<%=bbcode.param%>"><% to_html(bbcode.contents,options) %></span><% |
| 79 end | 80 end |
| 80 | 81 |
| 81 function html.size(bbcode,options) | 82 function html.size(bbcode,options) |
| 82 %><span style="font-size:<%=bbcode.param%>%"><% to_html(bbcode.contents,options) %></span><% | 83 %><span style="font-size:<%=bbcode.param%>"><% to_html(bbcode.contents,options) %></span><% |
| 83 end | 84 end |
| 84 | 85 |
| 85 function html.quote(bbcode,options) | 86 function html.quote(bbcode,options) |
| 86 %><blockquote><% | 87 %><blockquote><% |
| 87 local user_name = bbcode.param | 88 local user_name = bbcode.param |
| 98 to_html(bbcode.contents,options) | 99 to_html(bbcode.contents,options) |
| 99 %></blockquote><% | 100 %></blockquote><% |
| 100 options.strip_newline = true | 101 options.strip_newline = true |
| 101 end | 102 end |
| 102 | 103 |
| 104 local youtube_ptn1 = [[https://youtu.be/([a-zA-Z0-9_-]+)(?:\?t=([0-9]+))?]] | |
| 105 local youtube_ptn2 = [[https://www.youtube.com/watch\?v=([a-zA-Z0-9_-]+)(?:&t=([0-9]+)s)?]] | |
| 106 local bitchute_ptn = [[https://www.bitchute.com/video/([a-zA-Z0-9]+)/]] | |
| 107 | |
| 103 function html.video(bbcode,options) | 108 function html.video(bbcode,options) |
| 104 local url = html_encode(bbcode.contents) | 109 local url = bbcode.contents |
| 105 local site = bbcode.site | 110 local id, start = match(url,youtube_ptn1) |
| 106 if site == "youtube" then | 111 if id == nil then |
| 107 %><iframe width="420" height="315" src="https://www.youtube.com/embed/<%=bbcode.id%><% | 112 id, start = match(url,youtube_ptn2) |
| 108 local start = bbcode.start | 113 end |
| 114 if id ~= nil then | |
| 115 %><iframe width="560" height="315" src="https://www.youtube.com/embed/<%=id%><% | |
| 109 if start ~= nil then | 116 if start ~= nil then |
| 110 %>?start=<%=start%><% | 117 %>?start=<%=start%><% |
| 111 end | 118 end |
| 112 %>" frameborder="0" allowfullscreen></iframe><% | 119 %>" frameborder="0" allowfullscreen></iframe><% |
| 113 elseif site == "bitchute" then | 120 return |
| 114 %><iframe width="420" height="315" scrolling="no" frameborder="0" style="border: none;" src="https://www.bitchute.com/embed/<%=bbcode.id%>/"></iframe><% | 121 end |
| 115 else | 122 id = match(url,bitchute_ptn) |
| 116 %><a href="<%=url%>"><%=url%></a><% | 123 if id ~= nil then |
| 117 end | 124 %><iframe width="560" height="315" scrolling="no" frameborder="0" style="border: none;" src="https://www.bitchute.com/embed/<%=id%>/"></iframe><% |
| 125 return | |
| 126 end | |
| 127 url = html_encode(url) | |
| 128 %><a href="<%=url%>"><%=url%></a><% | |
| 118 end | 129 end |
| 119 | 130 |
| 120 local function list_to_html(bbcode,options) | 131 local function list_to_html(bbcode,options) |
| 121 local list = to_list(bbcode.contents) | 132 local list = to_list(bbcode.contents) |
| 122 for _, item in ipairs(list) do | 133 for _, item in ipairs(list) do |
