local p=
function getParam(frame) -- This is a longwinded way to return all the args (first choice) or parent.args (second choice) in an array. local parent, pargs, args local param= parent = frame['parent'] if (parent) then pargs = parent['args'] end if (pargs) then for k,v in pairs(args) do param[k] = v end end args = frame['args'] if (args) then for k,v in pairs(args) do param[k] = v end end return paramend
function getIndexpage(page) -- get the contents of either the current page (inadvisable...) or a specified page -- returns either a title object or an error string, and a boolean true for successful completion local indexpage if (page) then indexpage = mw.title.new(page) if (not(indexpage)) then return '
error: failed to access page: ' + tostring(page) + '',false end else indexpage = mw.title.getCurrentTitle if (not(indexpage)) then return ' bug: failed to access getCurrentTitle!',false end end return indexpage, trueendfunction getLinks(frame,indexpage) local index = indexpage:getContent or "" -- indexpage should exist, so no further checking for errors, just return blank local nextLink = mw.ustring.gmatch(index,"%[%[([^%]|]+)[^%]]-%]%]") local linklist = for link in nextLink do local linkval = frame:callParserFunction('REVISIONTIMESTAMP', link) if (mw.ustring.len(linkval) > 8) then -- don't even index pages that don't get meaningful results linklist[tostring(link)] = linkval .. '|' .. frame:callParserFunction('REVISIONUSER', link) end end return linklistend
function display(linklist, options) if (not(options)) then options = 'd-' end local sorttype = mw.ustring.match(options,'([%l%u])') local sortdir = mw.ustring.match(options,'([%+%-])') if (sorttype
'-') then sortdir = 'descending' else sortdir = 'ascending' end else sorttype = 'date' if (sortdir
function filter(linklist, action) -- passend
function p.main(frame)
local param = getParam(frame) -- get all parameters in param tabel; args override parent.args local indexpage = getIndexpage(param.page) local linklist = getLinks(frame,indexpage) for operation = 1, #param do filter(linklist, param[operation]) end if param.nowiki then return frame:preprocess(''..display(linklist)..'') else return display(linklist,param.options) endend
return p