Module:Administrators' noticeboard archives and Module:Administrators' noticeboard archives/sandbox: Difference between pages
(Difference between pages)
imported>CanonNi tweak for dark mode |
self-rv to Izno's version |
||
Line 1: | Line 1: | ||
local archiveList = require( 'Module:Archive list' ) | local archiveList = require( 'Module:Archive list' ) | ||
-- Gets wikitable rows filled with archive links, using [[Module:Archive list]]. | |||
-- Gets wikitable rows filled with archive links, using | |||
local function getLinks( funcArgs ) | local function getLinks( funcArgs ) | ||
if type( funcArgs ) ~= 'table' then | if type( funcArgs ) ~= 'table' then | ||
error( 'Invalid input to getLinks', 2 ) | error( 'Invalid input to getLinks', 2 ) | ||
end | end | ||
funcArgs.sep = ' | funcArgs.sep = '</li><li>' | ||
funcArgs.linesep = ' | funcArgs.links = 20 | ||
funcArgs.linesep = ' ' -- hacking around the wrapper to remove lineseparators | |||
return mw.ustring.format( | return mw.ustring.format( | ||
' | '<ol class="an-archives-list"><li>%s</li></ol>', | ||
archiveList.main( funcArgs ) | archiveList.main( funcArgs ) | ||
) | ) | ||
end | end | ||
-- Returns a Lua table with value being a list of archive links | -- 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 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 = {} | local t = {} | ||
for board, archive in pairs( archives ) do | for board, archive in pairs( archives ) do | ||
Line 60: | Line 59: | ||
end | end | ||
return t | return t | ||
end | |||
local function group (main_page, search, list) | |||
local ret = mw.html.create('li') | |||
ret:tag('div') | |||
:addClass('an-archives-header') | |||
:wikitext(main_page .. " ") | |||
:tag('span') | |||
:wikitext(search) | |||
:done() | |||
:done() | |||
ret:wikitext(list) | |||
:allDone() | |||
return ret | |||
end | end | ||
-- Build the wikitable using mw.ustring.format. | -- Build the wikitable using mw.ustring.format. | ||
local function buildWikitable( args ) | local function buildWikitable( args ) | ||
local t = getLinksTable( args.all ) | |||
local frame = mw.getCurrentFrame() | |||
local lists = { | |||
group( | |||
"[[Wikipedia:Administrators' noticeboard|Administrators']]", | |||
"([[Wikipedia:Administrators' noticeboard/Archives|archives]], [[Template:Administrators' noticeboard archives/Search|search]])", | |||
t.an | |||
), | |||
group( | |||
"[[Wikipedia:Administrators' noticeboard/Incidents|Incidents]]", | |||
"([[Wikipedia:Administrators' noticeboard/IncidentArchives|archives]], [[Template:Administrators' noticeboard archives/Search|search]])", | |||
t.ani | |||
), | |||
group( | |||
"[[Wikipedia:Administrators' noticeboard/Edit warring|Edit-warring/3RR]]", | |||
"([[Wikipedia:Administrators' noticeboard/3RRArchives|archives]], [[Template:Administrators' noticeboard archives/Search|search]])", | |||
t['3rr'] | |||
), | |||
group( | |||
"[[Wikipedia:Arbitration/Requests/Enforcement|Arbitration enforcement]]", | |||
"([[Wikipedia:Arbitration/Requests/Enforcement/Archive|archives]])", | |||
t.ae | |||
) | |||
} | |||
-- optional since these haven't been used in a while | |||
if args.csn == 'yes' then | |||
table.insert(lists, group( | |||
"Community sanction archives", | |||
"([[Template:Administrators\' noticeboard archives/Search|search]])", | |||
t.csn | |||
)) | |||
end | |||
local other_links = mw.html.create('li') | |||
other_links:tag('div') | |||
:addClass('an-archives-header') | |||
:wikitext('Other links') | |||
:done() | |||
:wikitext(require('Module:List').horizontal({ | |||
"[[Wikipedia talk:Administrators' noticeboard|Talk]]", | |||
'[[Wikipedia:Sockpuppet investigations|Sockpuppet investigations]]', | |||
'[[:Category:Administrative backlog|Backlog]]' | |||
})) | |||
:allDone() | |||
table.insert(lists, other_links) | |||
local list = mw.html.create('ul') | |||
for _, group in ipairs(lists) do | |||
list:node(group) | |||
end | |||
list:allDone() | |||
local box = mw.html.create('div') | |||
box:addClass('an-archives') | |||
:tag('div') | |||
:addClass('an-archives-caption') | |||
:wikitext('Noticeboard archives') | |||
:done() | |||
:node(list) | |||
if args.search == 'yes' then | if args.search == 'yes' then | ||
box:tag('div') | |||
:addClass('an-archives-search') | |||
:wikitext(frame:preprocess( | |||
[==[ | [==[ | ||
<inputbox> | <inputbox> | ||
Line 102: | Line 153: | ||
placeholder=Search noticeboards archives | placeholder=Search noticeboards archives | ||
</inputbox>]==] | </inputbox>]==] | ||
)) | |||
end | |||
box:allDone() | |||
return frame:extensionTag { | |||
name = 'templatestyles', args = { src = 'Module:Administrators\' noticeboard archives/styles.css' } | |||
} .. '__NOINDEX__' .. tostring(box) | |||
end | end | ||