Module:Administrators' noticeboard archives/sandbox
MyWikiBiz, Author Your Legacy — Monday November 25, 2024
Jump to navigationJump to searchDocumentation for this module may be created at Module:Administrators' noticeboard archives/sandbox/doc
-- This module is a replacement for {{Administrators' noticeboard navbox}} -- and {{Administrators' noticeboard navbox all}}. local archiveList = require( 'Module:Archive list' ) -- A table of the archives to display. local archives = { an = { header = "[[Wikipedia:Administrators' noticeboard|Administrators']]", link = "[[Wikipedia:Administrators' noticeboard/Archives|archives]]", root = "Wikipedia:Administrators' noticeboard", prefix = "Archive" }, ani = { header = "[[Wikipedia:Administrators' noticeboard/Incidents|Incidents]]", link = "[[Wikipedia:Administrators' noticeboard/IncidentArchives|archives]]", root = "Wikipedia:Administrators' noticeboard", prefix = "IncidentArchive" }, ew = { header = "[[Wikipedia:Administrators' noticeboard/Edit warring|Edit-warring/3RR]]", link = "[[Wikipedia:Administrators' noticeboard/3RRArchives|archives]]", root = "Wikipedia:Administrators' noticeboard", prefix = "3RRArchive" }, ae = { header = "[[Wikipedia:Arbitration/Requests/Enforcement|Arbitration enforcement]]", link = "[[Wikipedia:Arbitration/Requests/Enforcement/Archive|archives]]", root = "Wikipedia:Arbitration/Requests/Enforcement", prefix = "Archive" }, csn = { header = 'Community sanction archives', link = nil, root = "Wikipedia:Administrators' noticeboard/Community sanction", prefix = "Archive" } } -- 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 = '\n| ' funcArgs.linesep = '\n|-\n| ' return mw.ustring.format( '|-\n| %s', archiveList.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 ) local t = {} for board, archive in pairs( archives ) do local funcArgs = {} funcArgs.root = archive.root funcArgs.prefix = archive.prefix 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 local function inputbox(builder, has_search) if has_search ~= 'yes' then return '' end builder:tag('div') :css('white-space', 'nowrap') :wikitext(mw.getCurrentFrame():extensionTag{ name = 'inputbox' , args = { bgcolor = 'transparent', ['type'] = 'fulltext', prefix = "Wikipedia:Administrators' noticeboard", ['break'] = 'yes', width = '32', searchbuttonlabel = 'Search', placeholder = 'Search noticeboards archives' }}) end -- Build the wikitable using mw.ustring.format. local function buildWikitable( args ) local links = getLinksTable( args.all ) local frame = mw.getCurrentFrame() -- The following are defined here for convenience, as they recur frequently -- in the wikitable. local openSpan = '<span style="font-size: smaller;">' local closeSpan = '</span>' local searchLink = "[[Template:Administrators' noticeboard archives/Search|search]]" if args.csn == 'yes' then -- build the csn div end local noindex = '__NOINDEX__' local function other_links(builder) builder = builder:tag('div') :addClass('an-archives-header') :wikitext('Other links') :done() :tag('ul') -- padding: 0.125em 0; on hlist in navbox :addClass('hlist') :tag('li') :wikitext("[[Wikipedia talk:Administrators' noticeboard|Talk]]") :tag('li') :wikitext('[[Wikipedia:Sockpuppet investigations|Sockpuppet investigations]]') :tag('li') :wikitext('[[Wikipedia:Sockpuppet investigations|Sockpuppet investigations]]') :done() :done() end local templatestyles = frame:extensionTag{ name = 'templatestyles', args = { src = "Module:Administrators' noticeboard archives/styles.css" } } local builder = mw.html.create('div') :addClass('an-archives') :addClass('noprint') :tag('div') :addClass('an-archives-caption') :wikitext('Noticeboard archives') :done() for board, link_table in pairs(links) do builder = builder:tag('div') :addClass('an-archives-header') :wikitext(archives.board.header) :tag('span') :css('font-size', 'smaller') :wikitext(archives[board].archives) end return 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 ) }