comparison mod_pastebin/mod_pastebin.lua @ 3034:6e9096b66704

mod_pastebin: Add an OOB tag pointing to the pastebin URL
author Kim Alvefur <zash@zash.se>
date Mon, 21 May 2018 00:54:27 +0200
parents b2b129f699ed
children 60ca0d03f3e3
comparison
equal deleted inserted replaced
3033:b2b129f699ed 3034:6e9096b66704
121 local summary = (body:sub(1, max_summary_length):gsub(utf8_pattern, drop_invalid_utf8) or ""):match("[^\n]+") or ""; 121 local summary = (body:sub(1, max_summary_length):gsub(utf8_pattern, drop_invalid_utf8) or ""):match("[^\n]+") or "";
122 summary = summary:match("^%s*(.-)%s*$"); 122 summary = summary:match("^%s*(.-)%s*$");
123 local summary_prefixed = summary:match("[,:]$"); 123 local summary_prefixed = summary:match("[,:]$");
124 replace_tag(stanza, st.stanza("body"):text(summary)); 124 replace_tag(stanza, st.stanza("body"):text(summary));
125 125
126 stanza:add_child(st.stanza("query", { xmlns = "jabber:iq:oob" }):tag("url"):text(url));
127
126 if html_preview then 128 if html_preview then
127 local line_count = select(2, body:gsub("\n", "%0")) + 1; 129 local line_count = select(2, body:gsub("\n", "%0")) + 1;
128 local link_text = ("[view %spaste (%d line%s)]"):format(summary_prefixed and "" or "rest of ", line_count, line_count == 1 and "" or "s"); 130 local link_text = ("[view %spaste (%d line%s)]"):format(summary_prefixed and "" or "rest of ", line_count, line_count == 1 and "" or "s");
129 local html = st.stanza("html", { xmlns = xmlns_xhtmlim }):tag("body", { xmlns = xmlns_xhtml }); 131 local html = st.stanza("html", { xmlns = xmlns_xhtmlim }):tag("body", { xmlns = xmlns_xhtml });
130 html:tag("p"):text(summary.." "):up(); 132 html:tag("p"):text(summary.." "):up();