Module:Sandbox/Smalljim/DiscussionIndexTest explained

--

p = ;pp = require('Module:Sandbox/Smalljim/ParsePageTest'); --a set of page parsing functions

function p.summary(frame) local target = frame.args[1] or frame.args.target or ; --the page to parse local exc = frame.args.excerpts or false; --opt to show an excerpt from start of each section if type(exc)

'string' then --deal with optional ways of specifying show excerpt exc = exc:lower; if exc

'false' or exc

or exc

'0' or exc

'no' then exc = false; else exc = true; --anything but 'false', , '0' or 'no' (case insensitive) end end local rt = (tonumber(frame.args.recent) or 120)*60; --green cell if < 120 min or use "recent" to specify local ot = (tonumber(frame.args.old) or 60*24*2)*60; --red cell if > 2 days or use "old" to specify

if target

then --no target page specified return ; end local text = frame:preprocess(''); --does this expand templates in target page?

return frame:preprocess(p._summary(text, target, exc, rt, ot));end function p._summary(text, target, exc, rt, ot) local lang = mw.getContentLanguage; local now = lang:formatDate('U'); local sections, headings = pp.getSections(text, 2); --2 is header level local result; result = '

\n\n' result = result .. 'This is an automated summary of the discussions occurring on ' .. target .. '.\n\n' .. 'It was last generated at ' .. lang:formatDate('l, j F Y, H:i:s') .. ' UTC ' .. '([{{fullurl:{{FULLPAGENAME}}|action=purge}} update now]).\n\n' .. 'The current version of this report is still experimental and may contain ' .. 'significant inaccuracies.\n\n' if exc then result = result .. '

' .. tv_string; --green cell elseif tv > ot then tv_string = ' style="background:#FEE" ' .. tv_string; --red cell end return tv_string;end

return p;