Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Galobtter/Related changes
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
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 param end 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 '<span style="color:red">[[Module:Related changes]] error: failed to access page: [[' + tostring(page) + ']]</span>',false end else indexpage = mw.title.getCurrentTitle() if (not(indexpage)) then return '<span style="color:red">[[Module:Related changes]] bug: failed to access getCurrentTitle!</span>',false end end return indexpage, true end function 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 linklist end 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 == 'n') then sorttype = 'name' if (sortdir == '-') then sortdir = 'descending' else sortdir = 'ascending' end else sorttype = 'date' if (sortdir == '+') then sortdir = 'ascending' else sortdir = 'descending' end end local outsort, outarray = {}, {'{| class="wikitable sortable"\n!Name\n!Last edited\n!Last editor'} for k,v in pairs(linklist) do if sorttype == 'name' then table.insert(outsort, k..'|'..v) else table.insert(outsort, v..'|'..k) end end table.sort(outsort) for i = 1,#outsort do local n, d, u, split split = mw.text.split(outsort[i],'|',true) if sorttype == 'name' then n, d, u= split[3], split[1], split[2] else d, u, n = split[1], split[2], split[3] end if ((mw.ustring.sub(n, 1, 5) == 'File:') or (mw.ustring.sub(n, 1, 6) == 'Image:')) then n = ':' .. n end table.insert(outarray,'\n|-\n|[['..(n or '[[Module:Related changes]] bug: missing name') .. ']]\n|' .. (d or '[[Module:Related changes]] bug: missing date') .. '\n|[[User:' .. u .. ']]') end table.insert(outarray,'\n|}') return table.concat(outarray) end function filter(linklist, action) -- pass end 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('<nowiki>'..display(linklist)..'</nowiki>') else return display(linklist,param.options) end end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Further
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Module:Arguments
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Sandbox/Galobtter
(
edit
)
Module:Sandbox/Galobtter/Related changes/doc
(
edit
)
Module:Yesno
(
edit
)