Editing
Module:DPL
Jump to navigation
Jump to search
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!
-- From [[w:c:dev:Module:Sandbox/Dorumin/DPL]] local p = {} local arguments = require('Module:Arguments') -- ExtDynamicPageList::$maxResultCount p.COUNT = 500 -- Generates dpl parser function from a key-value table function p.tag(tag, tbl) local buffer = {'{{#' .. tag .. '\n'} for key, val in pairs(tbl) do if type(val) == 'table' then for _, value in ipairs(val) do table.insert(buffer, '| ' .. key .. ' = ' .. value .. '\n') end else table.insert(buffer, '| ' .. key .. ' = ' .. val .. '\n') end end table.insert(buffer, '}}') return table.concat(buffer, '') end -- Gets a forum parser function and returns its wikitext function p.forum(tbl) local frame = mw.getCurrentFrame() return frame:preprocess(p.tag('tag: forum', tbl)) end -- Gets the DPL parser function and returns its wikitext after parsing function p.parse(tbl) local frame = mw.getCurrentFrame() return frame:preprocess(p.tag('dpl:', tbl)) end -- Returns all DPL results concatenated -- The count parameter doesn't take effect function p.recursive(tbl) tbl['noresultsheader'] = tbl['noresultsheader'] or '<no-results>' tbl['count'] = p.COUNT local offset = tbl['offset'] or 0 local buffer = {} local parsed = p.parse(tbl) if parsed == tbl['noresultsheader'] then if tbl['noresultsheader'] == '<no-results>' then return '' else return tbl['noresultsheader'] end end while parsed ~= tbl['noresultsheader'] do table.insert(buffer, parsed) offset = offset + p.COUNT tbl['offset'] = offset parsed = p.parse(tbl) end return table.concat(buffer) end -- Returns an array (really just a table) of all pages that match a query -- The format parameter doesn't take effect function p.list(tbl) tbl['format'] = ',,%PAGE%#,' local content = p.recursive(tbl) local results = {} for page in content:gmatch("[^#]+") do table.insert(results, page) end return results end function p.getArgs(frame) local args = arguments.getArgs(frame) local ret = {} for k, v in pairs(args) do ret[k] = {} for w in v:gmatch("([^Β¦]+)") do table.insert(ret[k], w) end end return ret end -- For usage in #invoke function p.main(frame) return p.parse(p.getArgs(frame)) end -- For usage in #invoke function p.all(frame) return p.recursive(p.getArgs(frame)) end return p
Summary:
Please note that all contributions to nUSA Wiki Archive 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
NUSA Wiki Archive:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:DPL/doc
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Tools
What links here
Related changes
Special pages
Page information