-- Gets wikitable rows filled with archive links, using
-- [[Module:Archive list]].
local function getLinks( funcArgs )
if type( funcArgs ) ~= 'table' then
error( 'Invalid input to getLinks', 2 )
end
funcArgs.sep = '</li><li>'
-- funcArgs.linesep = '\n|-\n| '
return mw.ustring.format(
'|-\n|<ol><li>%s</li></ol>',
require( 'Module:Archive list/sandbox' ).main( funcArgs )
)
end
-- Returns a Lua table with value being a list of archive links for one of the
-- noticeboards listed in the archives table at the top of the module.
local function getLinksTable( all )
-- A table of the archives to display.
local archives = {
an = {
root = "Wikipedia:Administrators' noticeboard",
prefix = "Archive"
},
ani = {
root = "Wikipedia:Administrators' noticeboard",
prefix = "IncidentArchive"
},
['3rr'] = {
root = "Wikipedia:Administrators' noticeboard",
prefix = "3RRArchive"
},
ae = {
root = "Wikipedia:Arbitration/Requests/Enforcement",
prefix = "Archive"
},
csn = {
root = "Wikipedia:Administrators' noticeboard/Community sanction",
prefix = "Archive"
}
}
local t = {}
for board, archive in pairs( archives ) do
local funcArgs = archive
if not all then
local archiveMax = archiveList.count( funcArgs )
if type( archiveMax ) == 'number' and archiveMax >= 0 then
funcArgs.max = math.floor( archiveMax )
local start = funcArgs.max -19
if start < 1 then
start = 1
end
funcArgs.start = start
end
end
t[board] = getLinks( funcArgs )
end
return t
end
-- Build the wikitable using mw.ustring.format.
local function buildWikitable( args )
local t = getLinksTable( args.all )
local frame = mw.getCurrentFrame()
-- Community sanction archive links plus header. We define it here as it is optional.
local csn = ''
if args.csn == 'yes' then
csn = '\n|-\n! class="an-archives-header" colspan="10" | Community sanction archives <span>([[Template:Administrators\' noticeboard archives/Search|search]])</span>\n'
.. t.csn
end
-- The inputbox plus header. We define it here as it is optional.
local inputbox = ''
if args.search == 'yes' then
inputbox = '\n|-\n! class="an-archives-search" colspan="10" | '
.. frame:preprocess(
[==[
<inputbox>
bgcolor=transparent
type=fulltext
prefix=Wikipedia:Administrators' noticeboard
break=no
width=32
searchbuttonlabel=Search
placeholder=Search noticeboards archives
</inputbox>]==]
)
end
local bottom_list = require('Module:List').horizontal({
"[[Wikipedia talk:Administrators' noticeboard|Talk]]",
'[[Wikipedia:Sockpuppet investigations|Sockpuppet investigations]]',
'[[:Category:Administrative backlog|Backlog]]'
})
return mw.ustring.format(
[==[
%s
{| class="an-archives"
|+ Noticeboard archives
|-
! class="an-archives-header" colspan="10" | [[Wikipedia:Administrators' noticeboard|Administrators']] <span>([[Wikipedia:Administrators' noticeboard/Archives|archives]], [[Template:Administrators' noticeboard archives/Search|search]])</span>
%s
|-
! class="an-archives-header" colspan="10" | [[Wikipedia:Administrators' noticeboard/Incidents|Incidents]] <span>([[Wikipedia:Administrators' noticeboard/IncidentArchives|archives]], [[Template:Administrators' noticeboard archives/Search|search]])</span>
%s
|-
! class="an-archives-header" colspan="10" | [[Wikipedia:Administrators' noticeboard/Edit warring|Edit-warring/3RR]] <span>([[Wikipedia:Administrators' noticeboard/3RRArchives|archives]], [[Template:Administrators' noticeboard archives/Search|search]])</span>
%s
|-
! class="an-archives-header" colspan="10" | [[Wikipedia:Arbitration/Requests/Enforcement|Arbitration enforcement]] <span>([[Wikipedia:Arbitration/Requests/Enforcement/Archive|archives]])</span>
%s%s
|-
! class="an-archives-header" colspan="10" |Other links
|-
| class="an-archives-below" colspan="10" | %s%s
|}
__NOINDEX__]==],
frame:extensionTag {
name = 'templatestyles', args = { src = 'Module:Administrators\' noticeboard archives/styles.css' }
},
t.an, t.ani, t['3rr'], t.ae, csn,
bottom_list, inputbox
)
end
function makeWrapper( all )
return function( frame )
-- If we are being called from #invoke, get the args from #invoke
-- if they exist, or else get the arguments passed to the parent
-- frame. Otherwise, assume the arguments are being passed directly
-- in from another module or from the debug console.
local origArgs
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
for k, v in pairs( frame.args ) do
origArgs = frame.args
break
end
else
origArgs = frame
end
-- Ignore blank values for parameters.
local args = {}
for k, v in pairs( origArgs ) do
if v ~= '' then
args[k] = v
end
end
-- Find whether we are getting all the links or just the
-- last 20 links.
args.all = all
return buildWikitable( args )
end
end
return {
compact = makeWrapper(),
all = makeWrapper( true )
}