Software /
code /
prosody-modules
Comparison
mod_pastebin/mod_pastebin.lua @ 513:5e8843a869a3
mod_pastebin: Fix off-by-one in line counting (display issue only)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 19 Dec 2011 11:38:57 +0000 |
parent | 512:c819365ac6ab |
child | 514:46e1983486e9 |
comparison
equal
deleted
inserted
replaced
512:c819365ac6ab | 513:5e8843a869a3 |
---|---|
98 summary = summary:match("^%s*(.-)%s*$"); | 98 summary = summary:match("^%s*(.-)%s*$"); |
99 local summary_prefixed = summary:match("[,:]$"); | 99 local summary_prefixed = summary:match("[,:]$"); |
100 stanza[bodyindex][1] = (summary_prefixed and (summary.." ") or "")..url; | 100 stanza[bodyindex][1] = (summary_prefixed and (summary.." ") or "")..url; |
101 | 101 |
102 if html_preview then | 102 if html_preview then |
103 local line_count = select(2, body:gsub("\n", "%0")); | 103 local line_count = select(2, body:gsub("\n", "%0")) + 1; |
104 local link_text = ("[view %spaste (%d line%s)]"):format(summary_prefixed and "" or "rest of ", line_count, line_count == 1 and "" or "s"); | 104 local link_text = ("[view %spaste (%d line%s)]"):format(summary_prefixed and "" or "rest of ", line_count, line_count == 1 and "" or "s"); |
105 local html = st.stanza("html", { xmlns = xmlns_xhtmlim }):tag("body", { xmlns = xmlns_xhtml }); | 105 local html = st.stanza("html", { xmlns = xmlns_xhtmlim }):tag("body", { xmlns = xmlns_xhtml }); |
106 html:tag("p"):text(summary.." "):up(); | 106 html:tag("p"):text(summary.." "):up(); |
107 html:tag("a", { href = url }):text(link_text):up(); | 107 html:tag("a", { href = url }):text(link_text):up(); |
108 stanza[htmlindex or #stanza+1] = html; | 108 stanza[htmlindex or #stanza+1] = html; |