Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <mediawiki xmlns="http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-0.10.xsd" version="0.10" xml:lang="en">
- <siteinfo>
- <sitename>Wikipedia</sitename>
- <dbname>enwiki</dbname>
- <base>https://en.wikipedia.org/wiki/Main_Page</base>
- <generator>MediaWiki 1.38.0-wmf.21</generator>
- <case>first-letter</case>
- <namespaces>
- <namespace key="-2" case="first-letter">Media</namespace>
- <namespace key="-1" case="first-letter">Special</namespace>
- <namespace key="0" case="first-letter" />
- <namespace key="1" case="first-letter">Talk</namespace>
- <namespace key="2" case="first-letter">User</namespace>
- <namespace key="3" case="first-letter">User talk</namespace>
- <namespace key="4" case="first-letter">Wikipedia</namespace>
- <namespace key="5" case="first-letter">Wikipedia talk</namespace>
- <namespace key="6" case="first-letter">File</namespace>
- <namespace key="7" case="first-letter">File talk</namespace>
- <namespace key="8" case="first-letter">MediaWiki</namespace>
- <namespace key="9" case="first-letter">MediaWiki talk</namespace>
- <namespace key="10" case="first-letter">Template</namespace>
- <namespace key="11" case="first-letter">Template talk</namespace>
- <namespace key="12" case="first-letter">Help</namespace>
- <namespace key="13" case="first-letter">Help talk</namespace>
- <namespace key="14" case="first-letter">Category</namespace>
- <namespace key="15" case="first-letter">Category talk</namespace>
- <namespace key="100" case="first-letter">Portal</namespace>
- <namespace key="101" case="first-letter">Portal talk</namespace>
- <namespace key="118" case="first-letter">Draft</namespace>
- <namespace key="119" case="first-letter">Draft talk</namespace>
- <namespace key="710" case="first-letter">TimedText</namespace>
- <namespace key="711" case="first-letter">TimedText talk</namespace>
- <namespace key="828" case="first-letter">Module</namespace>
- <namespace key="829" case="first-letter">Module talk</namespace>
- <namespace key="2300" case="first-letter">Gadget</namespace>
- <namespace key="2301" case="first-letter">Gadget talk</namespace>
- <namespace key="2302" case="case-sensitive">Gadget definition</namespace>
- <namespace key="2303" case="case-sensitive">Gadget definition talk</namespace>
- </namespaces>
- </siteinfo>
- <page>
- <title>Module:Navboxes</title>
- <ns>828</ns>
- <id>49336059</id>
- <revision>
- <id>880025066</id>
- <parentid>863560331</parentid>
- <timestamp>2019-01-24T21:20:05Z</timestamp>
- <contributor>
- <username>MusikAnimal</username>
- <id>14882394</id>
- </contributor>
- <minor/>
- <comment>Protected "[[Module:Navboxes]]": [[Wikipedia:High-risk templates|High-risk module]] ([Edit=Require template editor access] (indefinite))</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="1513" xml:space="preserve">-- This implements Template:navboxes
- local p = {}
- local Navbox = require('Module:Navbox')
- local function isnotempty(s)
- return s and s:match( '^%s*(.-)%s*$' ) ~= ''
- end
- local function navboxes(args, list)
- local navbar = (args['state'] and args['state'] == 'off') and 'off' or 'plain'
- local title = args['title'] or 'Links to related articles'
- local titlestyle = 'background:' .. (args['bg'] or '#e8e8ff') .. ';'
- .. (isnotempty(args['fg']) and ('color:' .. args['fg'] .. ';') or '')
- .. (isnotempty(args['bordercolor']) and ('border: 1px solid ' .. args['bordercolor'] .. ';') or '')
- .. (args['titlestyle'] or '')
- return Navbox._navbox({
- navbar = navbar, title = title,
- list1 = list,
- state = args['state'] or 'collapsed',
- titlestyle = titlestyle,
- liststyle = 'font-size:114%',
- listpadding = '0px',
- tracking = 'no'
- })
- end
- function p.top(frame)
- local args = frame:getParent().args
- local parts = mw.text.split(navboxes(args, '<ADD LIST HERE>'), '<ADD LIST HERE>')
- return parts[1]
- end
- function p.bottom(frame)
- local args = {}
- local parts = mw.text.split(navboxes(args, '<ADD LIST HERE>'), '<ADD LIST HERE>')
- return parts[2]
- end
- function p.navbox(frame)
- local args = frame:getParent().args
- local list = args['list1'] or args['list'] or ''
- local track_cats = ''
- if list == '' then
- if mw.title.getCurrentTitle().namespace == 0 then
- track_cats = '[[Category:Navboxes template with no content]]'
- end
- end
- return navboxes(args, list) .. track_cats
- end
- return p</text>
- <sha1>9bbm2wredpidaz4k9qxoggz4ma1wrtb</sha1>
- </revision>
- </page>
- <page>
- <title>Template:High-use</title>
- <ns>10</ns>
- <id>17406187</id>
- <revision>
- <id>1051188483</id>
- <parentid>1016519090</parentid>
- <timestamp>2021-10-22T01:54:41Z</timestamp>
- <contributor>
- <username>MusikBot II</username>
- <id>29539620</id>
- </contributor>
- <minor/>
- <comment>Changed protection settings for "[[Template:High-use]]": [[Wikipedia:High-risk templates|High-risk template or module]]: 3343 transclusions ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Require extended confirmed access] (indefinite) [Move=Require extended confirmed access] (indefinite))</comment>
- <model>wikitext</model>
- <format>text/x-wiki</format>
- <text bytes="297" xml:space="preserve">{{#invoke:High-use|main|1={{{1|}}}|2={{{2|}}}|all-pages={{{all-pages|}}}|info={{{info|}}}|demo={{{demo|}}}|form={{{form|}}}|expiry={{{expiry|}}}|system={{{system|}}}}}<noinclude>
- {{Documentation}}
- <!-- Add categories to the /doc subpage; interwiki links go to Wikidata, thank you! -->
- </noinclude></text>
- <sha1>pqp5tan0gkp2stociv4f3zgylzoarl5</sha1>
- </revision>
- </page>
- <page>
- <title>Template:Template link</title>
- <ns>10</ns>
- <id>1487430</id>
- <revision>
- <id>1014201710</id>
- <parentid>1012903429</parentid>
- <timestamp>2021-03-25T19:03:22Z</timestamp>
- <contributor>
- <username>Izno</username>
- <id>2927383</id>
- </contributor>
- <comment>[[Wikipedia:Templates for discussion/Log/2021 March 18#Template:Tlu]] closed as keep ([[WP:XFDC#4.0.11|XFDcloser]])</comment>
- <model>wikitext</model>
- <format>text/x-wiki</format>
- <text bytes="167" xml:space="preserve">&#123;&#123;[[Template:{{{1}}}|{{{1}}}]]&#125;&#125;<noinclude>{{documentation}}
- <!-- Categories go on the /doc subpage and interwikis go on Wikidata. -->
- </noinclude></text>
- <sha1>rf3qx5cilaxlnjqq9fivevkah92ncil</sha1>
- </revision>
- </page>
- <page>
- <title>Template:Tl</title>
- <ns>10</ns>
- <id>66733012</id>
- <redirect title="Template:Template link" />
- <revision>
- <id>1006436965</id>
- <timestamp>2021-02-12T22:03:00Z</timestamp>
- <contributor>
- <username>Anthony Appleyard</username>
- <id>119438</id>
- </contributor>
- <comment>Anthony Appleyard moved page [[Template:Tl]] to [[Template:Template link]]: [[Special:Permalink/1006428669|Requested]] by Buidhe at [[WP:RM/TR]]: RM closed as move</comment>
- <model>wikitext</model>
- <format>text/x-wiki</format>
- <text bytes="83" xml:space="preserve">#REDIRECT [[Template:Template link]]
- {{Redirect category shell|
- {{R from move}}
- }}</text>
- <sha1>p1dn3i2ckb7gtckkrbn0xh6ckx8nei1</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Arguments</title>
- <ns>828</ns>
- <id>41298065</id>
- <revision>
- <id>948472485</id>
- <parentid>948472482</parentid>
- <timestamp>2020-04-01T06:12:40Z</timestamp>
- <contributor>
- <username>MusikAnimal</username>
- <id>14882394</id>
- </contributor>
- <minor/>
- <comment>1 revision imported</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="10054" xml:space="preserve">-- This module provides easy processing of arguments passed to Scribunto from
- -- #invoke. It is intended for use by other Lua modules, and should not be
- -- called from #invoke directly.
- local libraryUtil = require('libraryUtil')
- local checkType = libraryUtil.checkType
- local arguments = {}
- -- Generate four different tidyVal functions, so that we don't have to check the
- -- options every time we call it.
- local function tidyValDefault(key, val)
- if type(val) == 'string' then
- val = val:match('^%s*(.-)%s*$')
- if val == '' then
- return nil
- else
- return val
- end
- else
- return val
- end
- end
- local function tidyValTrimOnly(key, val)
- if type(val) == 'string' then
- return val:match('^%s*(.-)%s*$')
- else
- return val
- end
- end
- local function tidyValRemoveBlanksOnly(key, val)
- if type(val) == 'string' then
- if val:find('%S') then
- return val
- else
- return nil
- end
- else
- return val
- end
- end
- local function tidyValNoChange(key, val)
- return val
- end
- local function matchesTitle(given, title)
- local tp = type( given )
- return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title
- end
- local translate_mt = { __index = function(t, k) return k end }
- function arguments.getArgs(frame, options)
- checkType('getArgs', 1, frame, 'table', true)
- checkType('getArgs', 2, options, 'table', true)
- frame = frame or {}
- options = options or {}
- --[[
- -- Set up argument translation.
- --]]
- options.translate = options.translate or {}
- if getmetatable(options.translate) == nil then
- setmetatable(options.translate, translate_mt)
- end
- if options.backtranslate == nil then
- options.backtranslate = {}
- for k,v in pairs(options.translate) do
- options.backtranslate[v] = k
- end
- end
- if options.backtranslate and getmetatable(options.backtranslate) == nil then
- setmetatable(options.backtranslate, {
- __index = function(t, k)
- if options.translate[k] ~= k then
- return nil
- else
- return k
- end
- end
- })
- end
- --[[
- -- Get the argument tables. If we were passed a valid frame object, get the
- -- frame arguments (fargs) and the parent frame arguments (pargs), depending
- -- on the options set and on the parent frame's availability. If we weren't
- -- passed a valid frame object, we are being called from another Lua module
- -- or from the debug console, so assume that we were passed a table of args
- -- directly, and assign it to a new variable (luaArgs).
- --]]
- local fargs, pargs, luaArgs
- if type(frame.args) == 'table' and type(frame.getParent) == 'function' then
- if options.wrappers then
- --[[
- -- The wrappers option makes Module:Arguments look up arguments in
- -- either the frame argument table or the parent argument table, but
- -- not both. This means that users can use either the #invoke syntax
- -- or a wrapper template without the loss of performance associated
- -- with looking arguments up in both the frame and the parent frame.
- -- Module:Arguments will look up arguments in the parent frame
- -- if it finds the parent frame's title in options.wrapper;
- -- otherwise it will look up arguments in the frame object passed
- -- to getArgs.
- --]]
- local parent = frame:getParent()
- if not parent then
- fargs = frame.args
- else
- local title = parent:getTitle():gsub('/sandbox$', '')
- local found = false
- if matchesTitle(options.wrappers, title) then
- found = true
- elseif type(options.wrappers) == 'table' then
- for _,v in pairs(options.wrappers) do
- if matchesTitle(v, title) then
- found = true
- break
- end
- end
- end
- -- We test for false specifically here so that nil (the default) acts like true.
- if found or options.frameOnly == false then
- pargs = parent.args
- end
- if not found or options.parentOnly == false then
- fargs = frame.args
- end
- end
- else
- -- options.wrapper isn't set, so check the other options.
- if not options.parentOnly then
- fargs = frame.args
- end
- if not options.frameOnly then
- local parent = frame:getParent()
- pargs = parent and parent.args or nil
- end
- end
- if options.parentFirst then
- fargs, pargs = pargs, fargs
- end
- else
- luaArgs = frame
- end
- -- Set the order of precedence of the argument tables. If the variables are
- -- nil, nothing will be added to the table, which is how we avoid clashes
- -- between the frame/parent args and the Lua args.
- local argTables = {fargs}
- argTables[#argTables + 1] = pargs
- argTables[#argTables + 1] = luaArgs
- --[[
- -- Generate the tidyVal function. If it has been specified by the user, we
- -- use that; if not, we choose one of four functions depending on the
- -- options chosen. This is so that we don't have to call the options table
- -- every time the function is called.
- --]]
- local tidyVal = options.valueFunc
- if tidyVal then
- if type(tidyVal) ~= 'function' then
- error(
- "bad value assigned to option 'valueFunc'"
- .. '(function expected, got '
- .. type(tidyVal)
- .. ')',
- 2
- )
- end
- elseif options.trim ~= false then
- if options.removeBlanks ~= false then
- tidyVal = tidyValDefault
- else
- tidyVal = tidyValTrimOnly
- end
- else
- if options.removeBlanks ~= false then
- tidyVal = tidyValRemoveBlanksOnly
- else
- tidyVal = tidyValNoChange
- end
- end
- --[[
- -- Set up the args, metaArgs and nilArgs tables. args will be the one
- -- accessed from functions, and metaArgs will hold the actual arguments. Nil
- -- arguments are memoized in nilArgs, and the metatable connects all of them
- -- together.
- --]]
- local args, metaArgs, nilArgs, metatable = {}, {}, {}, {}
- setmetatable(args, metatable)
- local function mergeArgs(tables)
- --[[
- -- Accepts multiple tables as input and merges their keys and values
- -- into one table. If a value is already present it is not overwritten;
- -- tables listed earlier have precedence. We are also memoizing nil
- -- values, which can be overwritten if they are 's' (soft).
- --]]
- for _, t in ipairs(tables) do
- for key, val in pairs(t) do
- if metaArgs[key] == nil and nilArgs[key] ~= 'h' then
- local tidiedVal = tidyVal(key, val)
- if tidiedVal == nil then
- nilArgs[key] = 's'
- else
- metaArgs[key] = tidiedVal
- end
- end
- end
- end
- end
- --[[
- -- Define metatable behaviour. Arguments are memoized in the metaArgs table,
- -- and are only fetched from the argument tables once. Fetching arguments
- -- from the argument tables is the most resource-intensive step in this
- -- module, so we try and avoid it where possible. For this reason, nil
- -- arguments are also memoized, in the nilArgs table. Also, we keep a record
- -- in the metatable of when pairs and ipairs have been called, so we do not
- -- run pairs and ipairs on the argument tables more than once. We also do
- -- not run ipairs on fargs and pargs if pairs has already been run, as all
- -- the arguments will already have been copied over.
- --]]
- metatable.__index = function (t, key)
- --[[
- -- Fetches an argument when the args table is indexed. First we check
- -- to see if the value is memoized, and if not we try and fetch it from
- -- the argument tables. When we check memoization, we need to check
- -- metaArgs before nilArgs, as both can be non-nil at the same time.
- -- If the argument is not present in metaArgs, we also check whether
- -- pairs has been run yet. If pairs has already been run, we return nil.
- -- This is because all the arguments will have already been copied into
- -- metaArgs by the mergeArgs function, meaning that any other arguments
- -- must be nil.
- --]]
- if type(key) == 'string' then
- key = options.translate[key]
- end
- local val = metaArgs[key]
- if val ~= nil then
- return val
- elseif metatable.donePairs or nilArgs[key] then
- return nil
- end
- for _, argTable in ipairs(argTables) do
- local argTableVal = tidyVal(key, argTable[key])
- if argTableVal ~= nil then
- metaArgs[key] = argTableVal
- return argTableVal
- end
- end
- nilArgs[key] = 'h'
- return nil
- end
- metatable.__newindex = function (t, key, val)
- -- This function is called when a module tries to add a new value to the
- -- args table, or tries to change an existing value.
- if type(key) == 'string' then
- key = options.translate[key]
- end
- if options.readOnly then
- error(
- 'could not write to argument table key "'
- .. tostring(key)
- .. '"; the table is read-only',
- 2
- )
- elseif options.noOverwrite and args[key] ~= nil then
- error(
- 'could not write to argument table key "'
- .. tostring(key)
- .. '"; overwriting existing arguments is not permitted',
- 2
- )
- elseif val == nil then
- --[[
- -- If the argument is to be overwritten with nil, we need to erase
- -- the value in metaArgs, so that __index, __pairs and __ipairs do
- -- not use a previous existing value, if present; and we also need
- -- to memoize the nil in nilArgs, so that the value isn't looked
- -- up in the argument tables if it is accessed again.
- --]]
- metaArgs[key] = nil
- nilArgs[key] = 'h'
- else
- metaArgs[key] = val
- end
- end
- local function translatenext(invariant)
- local k, v = next(invariant.t, invariant.k)
- invariant.k = k
- if k == nil then
- return nil
- elseif type(k) ~= 'string' or not options.backtranslate then
- return k, v
- else
- local backtranslate = options.backtranslate[k]
- if backtranslate == nil then
- -- Skip this one. This is a tail call, so this won't cause stack overflow
- return translatenext(invariant)
- else
- return backtranslate, v
- end
- end
- end
- metatable.__pairs = function ()
- -- Called when pairs is run on the args table.
- if not metatable.donePairs then
- mergeArgs(argTables)
- metatable.donePairs = true
- end
- return translatenext, { t = metaArgs }
- end
- local function inext(t, i)
- -- This uses our __index metamethod
- local v = t[i + 1]
- if v ~= nil then
- return i + 1, v
- end
- end
- metatable.__ipairs = function (t)
- -- Called when ipairs is run on the args table.
- return inext, t, 0
- end
- return args
- end
- return arguments</text>
- <sha1>5qx9tzlul9ser30uxj9nbasjt92cevn</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Documentation</title>
- <ns>828</ns>
- <id>40256557</id>
- <revision>
- <id>1065934020</id>
- <parentid>1061447122</parentid>
- <timestamp>2022-01-16T01:32:10Z</timestamp>
- <contributor>
- <username>Matt Fitzpatrick</username>
- <id>291848</id>
- </contributor>
- <comment>sync from sandbox, add aria role and label to container</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="35027" xml:space="preserve">-- This module implements {{documentation}}.
- -- Get required modules.
- local getArgs = require('Module:Arguments').getArgs
- -- Get the config table.
- local cfg = mw.loadData('Module:Documentation/config')
- local p = {}
- -- Often-used functions.
- local ugsub = mw.ustring.gsub
- ----------------------------------------------------------------------------
- -- Helper functions
- --
- -- These are defined as local functions, but are made available in the p
- -- table for testing purposes.
- ----------------------------------------------------------------------------
- local function message(cfgKey, valArray, expectType)
- --[[
- -- Gets a message from the cfg table and formats it if appropriate.
- -- The function raises an error if the value from the cfg table is not
- -- of the type expectType. The default type for expectType is 'string'.
- -- If the table valArray is present, strings such as $1, $2 etc. in the
- -- message are substituted with values from the table keys [1], [2] etc.
- -- For example, if the message "foo-message" had the value 'Foo $2 bar $1.',
- -- message('foo-message', {'baz', 'qux'}) would return "Foo qux bar baz."
- --]]
- local msg = cfg[cfgKey]
- expectType = expectType or 'string'
- if type(msg) ~= expectType then
- error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)
- end
- if not valArray then
- return msg
- end
- local function getMessageVal(match)
- match = tonumber(match)
- return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)
- end
- return ugsub(msg, '$([1-9][0-9]*)', getMessageVal)
- end
- p.message = message
- local function makeWikilink(page, display)
- if display then
- return mw.ustring.format('[[%s|%s]]', page, display)
- else
- return mw.ustring.format('[[%s]]', page)
- end
- end
- p.makeWikilink = makeWikilink
- local function makeCategoryLink(cat, sort)
- local catns = mw.site.namespaces[14].name
- return makeWikilink(catns .. ':' .. cat, sort)
- end
- p.makeCategoryLink = makeCategoryLink
- local function makeUrlLink(url, display)
- return mw.ustring.format('[%s %s]', url, display)
- end
- p.makeUrlLink = makeUrlLink
- local function makeToolbar(...)
- local ret = {}
- local lim = select('#', ...)
- if lim < 1 then
- return nil
- end
- for i = 1, lim do
- ret[#ret + 1] = select(i, ...)
- end
- -- 'documentation-toolbar'
- return '<span class="' .. message('toolbar-class') .. '">('
- .. table.concat(ret, ' &#124; ') .. ')</span>'
- end
- p.makeToolbar = makeToolbar
- ----------------------------------------------------------------------------
- -- Argument processing
- ----------------------------------------------------------------------------
- local function makeInvokeFunc(funcName)
- return function (frame)
- local args = getArgs(frame, {
- valueFunc = function (key, value)
- if type(value) == 'string' then
- value = value:match('^%s*(.-)%s*$') -- Remove whitespace.
- if key == 'heading' or value ~= '' then
- return value
- else
- return nil
- end
- else
- return value
- end
- end
- })
- return p[funcName](args)
- end
- end
- ----------------------------------------------------------------------------
- -- Entry points
- ----------------------------------------------------------------------------
- function p.nonexistent(frame)
- if mw.title.getCurrentTitle().subpageText == 'testcases' then
- return frame:expandTemplate{title = 'module test cases notice'}
- else
- return p.main(frame)
- end
- end
- p.main = makeInvokeFunc('_main')
- function p._main(args)
- --[[
- -- This function defines logic flow for the module.
- -- @args - table of arguments passed by the user
- --]]
- local env = p.getEnvironment(args)
- local root = mw.html.create()
- root
- :wikitext(p._getModuleWikitext(args, env))
- :wikitext(p.protectionTemplate(env))
- :wikitext(p.sandboxNotice(args, env))
- :tag('div')
- -- 'documentation-container'
- :addClass(message('container'))
- :attr('role', 'complementary')
- :attr('aria-labelledby', args.heading ~= '' and 'documentation-heading' or nil)
- :attr('aria-label', args.heading == '' and 'Documentation' or nil)
- :newline()
- :tag('div')
- -- 'documentation'
- :addClass(message('main-div-classes'))
- :newline()
- :wikitext(p._startBox(args, env))
- :wikitext(p._content(args, env))
- :tag('div')
- -- 'documentation-clear'
- :addClass(message('clear'))
- :done()
- :newline()
- :done()
- :wikitext(p._endBox(args, env))
- :done()
- :wikitext(p.addTrackingCategories(env))
- -- 'Module:Documentation/styles.css'
- return mw.getCurrentFrame():extensionTag (
- 'templatestyles', '', {src=cfg['templatestyles']
- }) .. tostring(root)
- end
- ----------------------------------------------------------------------------
- -- Environment settings
- ----------------------------------------------------------------------------
- function p.getEnvironment(args)
- --[[
- -- Returns a table with information about the environment, including title
- -- objects and other namespace- or path-related data.
- -- @args - table of arguments passed by the user
- --
- -- Title objects include:
- -- env.title - the page we are making documentation for (usually the current title)
- -- env.templateTitle - the template (or module, file, etc.)
- -- env.docTitle - the /doc subpage.
- -- env.sandboxTitle - the /sandbox subpage.
- -- env.testcasesTitle - the /testcases subpage.
- --
- -- Data includes:
- -- env.protectionLevels - the protection levels table of the title object.
- -- env.subjectSpace - the number of the title's subject namespace.
- -- env.docSpace - the number of the namespace the title puts its documentation in.
- -- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.
- -- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.
- --
- -- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value
- -- returned will be nil.
- --]]
- local env, envFuncs = {}, {}
- -- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value
- -- returned by that function is memoized in the env table so that we don't call any of the functions
- -- more than once. (Nils won't be memoized.)
- setmetatable(env, {
- __index = function (t, key)
- local envFunc = envFuncs[key]
- if envFunc then
- local success, val = pcall(envFunc)
- if success then
- env[key] = val -- Memoise the value.
- return val
- end
- end
- return nil
- end
- })
- function envFuncs.title()
- -- The title object for the current page, or a test page passed with args.page.
- local title
- local titleArg = args.page
- if titleArg then
- title = mw.title.new(titleArg)
- else
- title = mw.title.getCurrentTitle()
- end
- return title
- end
- function envFuncs.templateTitle()
- --[[
- -- The template (or module, etc.) title object.
- -- Messages:
- -- 'sandbox-subpage' --> 'sandbox'
- -- 'testcases-subpage' --> 'testcases'
- --]]
- local subjectSpace = env.subjectSpace
- local title = env.title
- local subpage = title.subpageText
- if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then
- return mw.title.makeTitle(subjectSpace, title.baseText)
- else
- return mw.title.makeTitle(subjectSpace, title.text)
- end
- end
- function envFuncs.docTitle()
- --[[
- -- Title object of the /doc subpage.
- -- Messages:
- -- 'doc-subpage' --> 'doc'
- --]]
- local title = env.title
- local docname = args[1] -- User-specified doc page.
- local docpage
- if docname then
- docpage = docname
- else
- docpage = env.docpageBase .. '/' .. message('doc-subpage')
- end
- return mw.title.new(docpage)
- end
- function envFuncs.sandboxTitle()
- --[[
- -- Title object for the /sandbox subpage.
- -- Messages:
- -- 'sandbox-subpage' --> 'sandbox'
- --]]
- return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage'))
- end
- function envFuncs.testcasesTitle()
- --[[
- -- Title object for the /testcases subpage.
- -- Messages:
- -- 'testcases-subpage' --> 'testcases'
- --]]
- return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
- end
- function envFuncs.protectionLevels()
- -- The protection levels table of the title object.
- return env.title.protectionLevels
- end
- function envFuncs.subjectSpace()
- -- The subject namespace number.
- return mw.site.namespaces[env.title.namespace].subject.id
- end
- function envFuncs.docSpace()
- -- The documentation namespace number. For most namespaces this is the
- -- same as the subject namespace. However, pages in the Article, File,
- -- MediaWiki or Category namespaces must have their /doc, /sandbox and
- -- /testcases pages in talk space.
- local subjectSpace = env.subjectSpace
- if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then
- return subjectSpace + 1
- else
- return subjectSpace
- end
- end
- function envFuncs.docpageBase()
- -- The base page of the /doc, /sandbox, and /testcases subpages.
- -- For some namespaces this is the talk page, rather than the template page.
- local templateTitle = env.templateTitle
- local docSpace = env.docSpace
- local docSpaceText = mw.site.namespaces[docSpace].name
- -- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon.
- return docSpaceText .. ':' .. templateTitle.text
- end
- function envFuncs.compareUrl()
- -- Diff link between the sandbox and the main template using [[Special:ComparePages]].
- local templateTitle = env.templateTitle
- local sandboxTitle = env.sandboxTitle
- if templateTitle.exists and sandboxTitle.exists then
- local compareUrl = mw.uri.fullUrl(
- 'Special:ComparePages',
- { page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
- )
- return tostring(compareUrl)
- else
- return nil
- end
- end
- return env
- end
- ----------------------------------------------------------------------------
- -- Auxiliary templates
- ----------------------------------------------------------------------------
- p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext')
- function p._getModuleWikitext(args, env)
- local currentTitle = mw.title.getCurrentTitle()
- if currentTitle.contentModel ~= 'Scribunto' then return end
- pcall(require, currentTitle.prefixedText) -- if it fails, we don't care
- local moduleWikitext = package.loaded["Module:Module wikitext"]
- if moduleWikitext then
- return moduleWikitext.main()
- end
- end
- function p.sandboxNotice(args, env)
- --[=[
- -- Generates a sandbox notice for display above sandbox pages.
- -- @args - a table of arguments passed by the user
- -- @env - environment table containing title objects, etc., generated with p.getEnvironment
- --
- -- Messages:
- -- 'sandbox-notice-image' --> '[[Image:Sandbox.svg|50px|alt=|link=]]'
- -- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'
- -- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'
- -- 'sandbox-notice-pagetype-template' --> '[[Wikipedia:Template test cases|template sandbox]] page'
- -- 'sandbox-notice-pagetype-module' --> '[[Wikipedia:Template test cases|module sandbox]] page'
- -- 'sandbox-notice-pagetype-other' --> 'sandbox page'
- -- 'sandbox-notice-compare-link-display' --> 'diff'
- -- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.'
- -- 'sandbox-notice-testcases-link-display' --> 'test cases'
- -- 'sandbox-category' --> 'Template sandboxes'
- --]=]
- local title = env.title
- local sandboxTitle = env.sandboxTitle
- local templateTitle = env.templateTitle
- local subjectSpace = env.subjectSpace
- if not (subjectSpace and title and sandboxTitle and templateTitle
- and mw.title.equals(title, sandboxTitle)) then
- return nil
- end
- -- Build the table of arguments to pass to {{ombox}}. We need just two fields, "image" and "text".
- local omargs = {}
- omargs.image = message('sandbox-notice-image')
- -- Get the text. We start with the opening blurb, which is something like
- -- "This is the template sandbox for [[Template:Foo]] (diff)."
- local text = ''
- local pagetype
- if subjectSpace == 10 then
- pagetype = message('sandbox-notice-pagetype-template')
- elseif subjectSpace == 828 then
- pagetype = message('sandbox-notice-pagetype-module')
- else
- pagetype = message('sandbox-notice-pagetype-other')
- end
- local templateLink = makeWikilink(templateTitle.prefixedText)
- local compareUrl = env.compareUrl
- if compareUrl then
- local compareDisplay = message('sandbox-notice-compare-link-display')
- local compareLink = makeUrlLink(compareUrl, compareDisplay)
- text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
- else
- text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
- end
- -- Get the test cases page blurb if the page exists. This is something like
- -- "See also the companion subpage for [[Template:Foo/testcases|test cases]]."
- local testcasesTitle = env.testcasesTitle
- if testcasesTitle and testcasesTitle.exists then
- if testcasesTitle.contentModel == "Scribunto" then
- local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
- local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
- local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
- local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
- text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink})
- else
- local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
- local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
- text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink})
- end
- end
- -- Add the sandbox to the sandbox category.
- omargs.text = text .. makeCategoryLink(message('sandbox-category'))
- -- 'documentation-clear'
- return '<div class="' .. message('clear') .. '"></div>'
- .. require('Module:Message box').main('ombox', omargs)
- end
- function p.protectionTemplate(env)
- -- Generates the padlock icon in the top right.
- -- @env - environment table containing title objects, etc., generated with p.getEnvironment
- -- Messages:
- -- 'protection-template' --> 'pp-template'
- -- 'protection-template-args' --> {docusage = 'yes'}
- local protectionLevels = env.protectionLevels
- if not protectionLevels then
- return nil
- end
- local editProt = protectionLevels.edit and protectionLevels.edit[1]
- local moveProt = protectionLevels.move and protectionLevels.move[1]
- if editProt then
- -- The page is edit-protected.
- return require('Module:Protection banner')._main{
- message('protection-reason-edit'), small = true
- }
- elseif moveProt and moveProt ~= 'autoconfirmed' then
- -- The page is move-protected but not edit-protected. Exclude move
- -- protection with the level "autoconfirmed", as this is equivalent to
- -- no move protection at all.
- return require('Module:Protection banner')._main{
- action = 'move', small = true
- }
- else
- return nil
- end
- end
- ----------------------------------------------------------------------------
- -- Start box
- ----------------------------------------------------------------------------
- p.startBox = makeInvokeFunc('_startBox')
- function p._startBox(args, env)
- --[[
- -- This function generates the start box.
- -- @args - a table of arguments passed by the user
- -- @env - environment table containing title objects, etc., generated with p.getEnvironment
- --
- -- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make
- -- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox
- -- which generate the box HTML.
- --]]
- env = env or p.getEnvironment(args)
- local links
- local content = args.content
- if not content or args[1] then
- -- No need to include the links if the documentation is on the template page itself.
- local linksData = p.makeStartBoxLinksData(args, env)
- if linksData then
- links = p.renderStartBoxLinks(linksData)
- end
- end
- -- Generate the start box html.
- local data = p.makeStartBoxData(args, env, links)
- if data then
- return p.renderStartBox(data)
- else
- -- User specified no heading.
- return nil
- end
- end
- function p.makeStartBoxLinksData(args, env)
- --[[
- -- Does initial processing of data to make the [view] [edit] [history] [purge] links.
- -- @args - a table of arguments passed by the user
- -- @env - environment table containing title objects, etc., generated with p.getEnvironment
- --
- -- Messages:
- -- 'view-link-display' --> 'view'
- -- 'edit-link-display' --> 'edit'
- -- 'history-link-display' --> 'history'
- -- 'purge-link-display' --> 'purge'
- -- 'module-preload' --> 'Template:Documentation/preload-module-doc'
- -- 'docpage-preload' --> 'Template:Documentation/preload'
- -- 'create-link-display' --> 'create'
- --]]
- local subjectSpace = env.subjectSpace
- local title = env.title
- local docTitle = env.docTitle
- if not title or not docTitle then
- return nil
- end
- if docTitle.isRedirect then
- docTitle = docTitle.redirectTarget
- end
- local data = {}
- data.title = title
- data.docTitle = docTitle
- -- View, display, edit, and purge links if /doc exists.
- data.viewLinkDisplay = message('view-link-display')
- data.editLinkDisplay = message('edit-link-display')
- data.historyLinkDisplay = message('history-link-display')
- data.purgeLinkDisplay = message('purge-link-display')
- -- Create link if /doc doesn't exist.
- local preload = args.preload
- if not preload then
- if subjectSpace == 828 then -- Module namespace
- preload = message('module-preload')
- else
- preload = message('docpage-preload')
- end
- end
- data.preload = preload
- data.createLinkDisplay = message('create-link-display')
- return data
- end
- function p.renderStartBoxLinks(data)
- --[[
- -- Generates the [view][edit][history][purge] or [create][purge] links from the data table.
- -- @data - a table of data generated by p.makeStartBoxLinksData
- --]]
- local function escapeBrackets(s)
- -- Escapes square brackets with HTML entities.
- s = s:gsub('%[', '&#91;') -- Replace square brackets with HTML entities.
- s = s:gsub('%]', '&#93;')
- return s
- end
- local ret
- local docTitle = data.docTitle
- local title = data.title
- local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay)
- if docTitle.exists then
- local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
- local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay)
- local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay)
- ret = '[%s] [%s] [%s] [%s]'
- ret = escapeBrackets(ret)
- ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink)
- else
- local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
- ret = '[%s] [%s]'
- ret = escapeBrackets(ret)
- ret = mw.ustring.format(ret, createLink, purgeLink)
- end
- return ret
- end
- function p.makeStartBoxData(args, env, links)
- --[=[
- -- Does initial processing of data to pass to the start-box render function, p.renderStartBox.
- -- @args - a table of arguments passed by the user
- -- @env - environment table containing title objects, etc., generated with p.getEnvironment
- -- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error.
- --
- -- Messages:
- -- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
- -- 'template-namespace-heading' --> 'Template documentation'
- -- 'module-namespace-heading' --> 'Module documentation'
- -- 'file-namespace-heading' --> 'Summary'
- -- 'other-namespaces-heading' --> 'Documentation'
- -- 'testcases-create-link-display' --> 'create'
- --]=]
- local subjectSpace = env.subjectSpace
- if not subjectSpace then
- -- Default to an "other namespaces" namespace, so that we get at least some output
- -- if an error occurs.
- subjectSpace = 2
- end
- local data = {}
- -- Heading
- local heading = args.heading -- Blank values are not removed.
- if heading == '' then
- -- Don't display the start box if the heading arg is defined but blank.
- return nil
- end
- if heading then
- data.heading = heading
- elseif subjectSpace == 10 then -- Template namespace
- data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading')
- elseif subjectSpace == 828 then -- Module namespace
- data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading')
- elseif subjectSpace == 6 then -- File namespace
- data.heading = message('file-namespace-heading')
- else
- data.heading = message('other-namespaces-heading')
- end
- -- Heading CSS
- local headingStyle = args['heading-style']
- if headingStyle then
- data.headingStyleText = headingStyle
- else
- -- 'documentation-heading'
- data.headingClass = message('main-div-heading-class')
- end
- -- Data for the [view][edit][history][purge] or [create] links.
- if links then
- -- 'mw-editsection-like plainlinks'
- data.linksClass = message('start-box-link-classes')
- data.links = links
- end
- return data
- end
- function p.renderStartBox(data)
- -- Renders the start box html.
- -- @data - a table of data generated by p.makeStartBoxData.
- local sbox = mw.html.create('div')
- sbox
- -- 'documentation-startbox'
- :addClass(message('start-box-class'))
- :newline()
- :tag('span')
- :addClass(data.headingClass)
- :attr('id', 'documentation-heading')
- :cssText(data.headingStyleText)
- :wikitext(data.heading)
- local links = data.links
- if links then
- sbox:tag('span')
- :addClass(data.linksClass)
- :attr('id', data.linksId)
- :wikitext(links)
- end
- return tostring(sbox)
- end
- ----------------------------------------------------------------------------
- -- Documentation content
- ----------------------------------------------------------------------------
- p.content = makeInvokeFunc('_content')
- function p._content(args, env)
- -- Displays the documentation contents
- -- @args - a table of arguments passed by the user
- -- @env - environment table containing title objects, etc., generated with p.getEnvironment
- env = env or p.getEnvironment(args)
- local docTitle = env.docTitle
- local content = args.content
- if not content and docTitle and docTitle.exists then
- content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}
- end
- -- The line breaks below are necessary so that "=== Headings ===" at the start and end
- -- of docs are interpreted correctly.
- return '\n' .. (content or '') .. '\n'
- end
- p.contentTitle = makeInvokeFunc('_contentTitle')
- function p._contentTitle(args, env)
- env = env or p.getEnvironment(args)
- local docTitle = env.docTitle
- if not args.content and docTitle and docTitle.exists then
- return docTitle.prefixedText
- else
- return ''
- end
- end
- ----------------------------------------------------------------------------
- -- End box
- ----------------------------------------------------------------------------
- p.endBox = makeInvokeFunc('_endBox')
- function p._endBox(args, env)
- --[=[
- -- This function generates the end box (also known as the link box).
- -- @args - a table of arguments passed by the user
- -- @env - environment table containing title objects, etc., generated with p.getEnvironment
- --
- --]=]
- -- Get environment data.
- env = env or p.getEnvironment(args)
- local subjectSpace = env.subjectSpace
- local docTitle = env.docTitle
- if not subjectSpace or not docTitle then
- return nil
- end
- -- Check whether we should output the end box at all. Add the end
- -- box by default if the documentation exists or if we are in the
- -- user, module or template namespaces.
- local linkBox = args['link box']
- if linkBox == 'off'
- or not (
- docTitle.exists
- or subjectSpace == 2
- or subjectSpace == 828
- or subjectSpace == 10
- )
- then
- return nil
- end
- -- Assemble the link box.
- local text = ''
- if linkBox then
- text = text .. linkBox
- else
- text = text .. (p.makeDocPageBlurb(args, env) or '') -- "This documentation is transcluded from [[Foo]]."
- if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then
- -- We are in the user, template or module namespaces.
- -- Add sandbox and testcases links.
- -- "Editors can experiment in this template's sandbox and testcases pages."
- text = text .. (p.makeExperimentBlurb(args, env) or '') .. '<br />'
- if not args.content and not args[1] then
- -- "Please add categories to the /doc subpage."
- -- Don't show this message with inline docs or with an explicitly specified doc page,
- -- as then it is unclear where to add the categories.
- text = text .. (p.makeCategoriesBlurb(args, env) or '')
- end
- text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template"
- end
- end
- local box = mw.html.create('div')
- -- 'documentation-metadata'
- box:attr('role', 'note')
- :addClass(message('end-box-class'))
- -- 'plainlinks'
- :addClass(message('end-box-plainlinks'))
- :wikitext(text)
- :done()
- return '\n' .. tostring(box)
- end
- function p.makeDocPageBlurb(args, env)
- --[=[
- -- Makes the blurb "This documentation is transcluded from [[Template:Foo]] (edit, history)".
- -- @args - a table of arguments passed by the user
- -- @env - environment table containing title objects, etc., generated with p.getEnvironment
- --
- -- Messages:
- -- 'edit-link-display' --> 'edit'
- -- 'history-link-display' --> 'history'
- -- 'transcluded-from-blurb' -->
- -- 'The above [[Wikipedia:Template documentation|documentation]]
- -- is [[Help:Transclusion|transcluded]] from $1.'
- -- 'module-preload' --> 'Template:Documentation/preload-module-doc'
- -- 'create-link-display' --> 'create'
- -- 'create-module-doc-blurb' -->
- -- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'
- --]=]
- local docTitle = env.docTitle
- if not docTitle then
- return nil
- end
- local ret
- if docTitle.exists then
- -- /doc exists; link to it.
- local docLink = makeWikilink(docTitle.prefixedText)
- local editUrl = docTitle:fullUrl{action = 'edit'}
- local editDisplay = message('edit-link-display')
- local editLink = makeUrlLink(editUrl, editDisplay)
- local historyUrl = docTitle:fullUrl{action = 'history'}
- local historyDisplay = message('history-link-display')
- local historyLink = makeUrlLink(historyUrl, historyDisplay)
- ret = message('transcluded-from-blurb', {docLink})
- .. ' '
- .. makeToolbar(editLink, historyLink)
- .. '<br />'
- elseif env.subjectSpace == 828 then
- -- /doc does not exist; ask to create it.
- local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')}
- local createDisplay = message('create-link-display')
- local createLink = makeUrlLink(createUrl, createDisplay)
- ret = message('create-module-doc-blurb', {createLink})
- .. '<br />'
- end
- return ret
- end
- function p.makeExperimentBlurb(args, env)
- --[[
- -- Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages."
- -- @args - a table of arguments passed by the user
- -- @env - environment table containing title objects, etc., generated with p.getEnvironment
- --
- -- Messages:
- -- 'sandbox-link-display' --> 'sandbox'
- -- 'sandbox-edit-link-display' --> 'edit'
- -- 'compare-link-display' --> 'diff'
- -- 'module-sandbox-preload' --> 'Template:Documentation/preload-module-sandbox'
- -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'
- -- 'sandbox-create-link-display' --> 'create'
- -- 'mirror-edit-summary' --> 'Create sandbox version of $1'
- -- 'mirror-link-display' --> 'mirror'
- -- 'mirror-link-preload' --> 'Template:Documentation/mirror'
- -- 'sandbox-link-display' --> 'sandbox'
- -- 'testcases-link-display' --> 'testcases'
- -- 'testcases-edit-link-display'--> 'edit'
- -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'
- -- 'testcases-create-link-display' --> 'create'
- -- 'testcases-link-display' --> 'testcases'
- -- 'testcases-edit-link-display' --> 'edit'
- -- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases'
- -- 'template-testcases-preload' --> 'Template:Documentation/preload-testcases'
- -- 'experiment-blurb-module' --> 'Editors can experiment in this module's $1 and $2 pages.'
- -- 'experiment-blurb-template' --> 'Editors can experiment in this template's $1 and $2 pages.'
- --]]
- local subjectSpace = env.subjectSpace
- local templateTitle = env.templateTitle
- local sandboxTitle = env.sandboxTitle
- local testcasesTitle = env.testcasesTitle
- local templatePage = templateTitle.prefixedText
- if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then
- return nil
- end
- -- Make links.
- local sandboxLinks, testcasesLinks
- if sandboxTitle.exists then
- local sandboxPage = sandboxTitle.prefixedText
- local sandboxDisplay = message('sandbox-link-display')
- local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
- local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'}
- local sandboxEditDisplay = message('sandbox-edit-link-display')
- local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay)
- local compareUrl = env.compareUrl
- local compareLink
- if compareUrl then
- local compareDisplay = message('compare-link-display')
- compareLink = makeUrlLink(compareUrl, compareDisplay)
- end
- sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
- else
- local sandboxPreload
- if subjectSpace == 828 then
- sandboxPreload = message('module-sandbox-preload')
- else
- sandboxPreload = message('template-sandbox-preload')
- end
- local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload}
- local sandboxCreateDisplay = message('sandbox-create-link-display')
- local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
- local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
- local mirrorPreload = message('mirror-link-preload')
- local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
- if subjectSpace == 828 then
- mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
- end
- local mirrorDisplay = message('mirror-link-display')
- local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
- sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink)
- end
- if testcasesTitle.exists then
- local testcasesPage = testcasesTitle.prefixedText
- local testcasesDisplay = message('testcases-link-display')
- local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
- local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'}
- local testcasesEditDisplay = message('testcases-edit-link-display')
- local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
- -- for Modules, add testcases run link if exists
- if testcasesTitle.contentModel == "Scribunto" and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
- local testcasesRunLinkDisplay = message('testcases-run-link-display')
- local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
- testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink)
- else
- testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
- end
- else
- local testcasesPreload
- if subjectSpace == 828 then
- testcasesPreload = message('module-testcases-preload')
- else
- testcasesPreload = message('template-testcases-preload')
- end
- local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload}
- local testcasesCreateDisplay = message('testcases-create-link-display')
- local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
- testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink)
- end
- local messageName
- if subjectSpace == 828 then
- messageName = 'experiment-blurb-module'
- else
- messageName = 'experiment-blurb-template'
- end
- return message(messageName, {sandboxLinks, testcasesLinks})
- end
- function p.makeCategoriesBlurb(args, env)
- --[[
- -- Generates the text "Please add categories to the /doc subpage."
- -- @args - a table of arguments passed by the user
- -- @env - environment table containing title objects, etc., generated with p.getEnvironment
- -- Messages:
- -- 'doc-link-display' --> '/doc'
- -- 'add-categories-blurb' --> 'Please add categories to the $1 subpage.'
- --]]
- local docTitle = env.docTitle
- if not docTitle then
- return nil
- end
- local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))
- return message('add-categories-blurb', {docPathLink})
- end
- function p.makeSubpagesBlurb(args, env)
- --[[
- -- Generates the "Subpages of this template" link.
- -- @args - a table of arguments passed by the user
- -- @env - environment table containing title objects, etc., generated with p.getEnvironment
- -- Messages:
- -- 'template-pagetype' --> 'template'
- -- 'module-pagetype' --> 'module'
- -- 'default-pagetype' --> 'page'
- -- 'subpages-link-display' --> 'Subpages of this $1'
- --]]
- local subjectSpace = env.subjectSpace
- local templateTitle = env.templateTitle
- if not subjectSpace or not templateTitle then
- return nil
- end
- local pagetype
- if subjectSpace == 10 then
- pagetype = message('template-pagetype')
- elseif subjectSpace == 828 then
- pagetype = message('module-pagetype')
- else
- pagetype = message('default-pagetype')
- end
- local subpagesLink = makeWikilink(
- 'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',
- message('subpages-link-display', {pagetype})
- )
- return message('subpages-blurb', {subpagesLink})
- end
- ----------------------------------------------------------------------------
- -- Tracking categories
- ----------------------------------------------------------------------------
- function p.addTrackingCategories(env)
- --[[
- -- Check if {{documentation}} is transcluded on a /doc or /testcases page.
- -- @env - environment table containing title objects, etc., generated with p.getEnvironment
- -- Messages:
- -- 'display-strange-usage-category' --> true
- -- 'doc-subpage' --> 'doc'
- -- 'testcases-subpage' --> 'testcases'
- -- 'strange-usage-category' --> 'Wikipedia pages with strange ((documentation)) usage'
- --
- -- /testcases pages in the module namespace are not categorised, as they may have
- -- {{documentation}} transcluded automatically.
- --]]
- local title = env.title
- local subjectSpace = env.subjectSpace
- if not title or not subjectSpace then
- return nil
- end
- local subpage = title.subpageText
- local ret = ''
- if message('display-strange-usage-category', nil, 'boolean')
- and (
- subpage == message('doc-subpage')
- or subjectSpace ~= 828 and subpage == message('testcases-subpage')
- )
- then
- ret = ret .. makeCategoryLink(message('strange-usage-category'))
- end
- return ret
- end
- return p</text>
- <sha1>hhe6rl9gdvqywjk6r1tbi4ymwotbf24</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Documentation/config</title>
- <ns>828</ns>
- <id>41520829</id>
- <revision>
- <id>1067946425</id>
- <parentid>1061447213</parentid>
- <timestamp>2022-01-25T23:46:11Z</timestamp>
- <contributor>
- <username>Ianblair23</username>
- <id>145927</id>
- </contributor>
- <comment>link</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="17433" xml:space="preserve">----------------------------------------------------------------------------------------------------
- --
- -- Configuration for Module:Documentation
- --
- -- Here you can set the values of the parameters and messages used in Module:Documentation to
- -- localise it to your wiki and your language. Unless specified otherwise, values given here
- -- should be string values.
- ----------------------------------------------------------------------------------------------------
- local cfg = {} -- Do not edit this line.
- ----------------------------------------------------------------------------------------------------
- -- Protection template configuration
- ----------------------------------------------------------------------------------------------------
- -- cfg['protection-reason-edit']
- -- The protection reason for edit-protected templates to pass to
- -- [[Module:Protection banner]].
- cfg['protection-reason-edit'] = 'template'
- --[[
- ----------------------------------------------------------------------------------------------------
- -- Sandbox notice configuration
- --
- -- On sandbox pages the module can display a template notifying users that the current page is a
- -- sandbox, and the location of test cases pages, etc. The module decides whether the page is a
- -- sandbox or not based on the value of cfg['sandbox-subpage']. The following settings configure the
- -- messages that the notices contains.
- ----------------------------------------------------------------------------------------------------
- --]]
- -- cfg['sandbox-notice-image']
- -- The image displayed in the sandbox notice.
- cfg['sandbox-notice-image'] = '[[File:Sandbox.svg|50px|alt=|link=]]'
- --[[
- -- cfg['sandbox-notice-pagetype-template']
- -- cfg['sandbox-notice-pagetype-module']
- -- cfg['sandbox-notice-pagetype-other']
- -- The page type of the sandbox page. The message that is displayed depends on the current subject
- -- namespace. This message is used in either cfg['sandbox-notice-blurb'] or
- -- cfg['sandbox-notice-diff-blurb'].
- --]]
- cfg['sandbox-notice-pagetype-template'] = '[[Wikipedia:Template test cases|template sandbox]] page'
- cfg['sandbox-notice-pagetype-module'] = '[[Wikipedia:Template test cases|module sandbox]] page'
- cfg['sandbox-notice-pagetype-other'] = 'sandbox page'
- --[[
- -- cfg['sandbox-notice-blurb']
- -- cfg['sandbox-notice-diff-blurb']
- -- cfg['sandbox-notice-diff-display']
- -- Either cfg['sandbox-notice-blurb'] or cfg['sandbox-notice-diff-blurb'] is the opening sentence
- -- of the sandbox notice. The latter has a diff link, but the former does not. $1 is the page
- -- type, which is either cfg['sandbox-notice-pagetype-template'],
- -- cfg['sandbox-notice-pagetype-module'] or cfg['sandbox-notice-pagetype-other'] depending what
- -- namespace we are in. $2 is a link to the main template page, and $3 is a diff link between
- -- the sandbox and the main template. The display value of the diff link is set by
- -- cfg['sandbox-notice-compare-link-display'].
- --]]
- cfg['sandbox-notice-blurb'] = 'This is the $1 for $2.'
- cfg['sandbox-notice-diff-blurb'] = 'This is the $1 for $2 ($3).'
- cfg['sandbox-notice-compare-link-display'] = 'diff'
- --[[
- -- cfg['sandbox-notice-testcases-blurb']
- -- cfg['sandbox-notice-testcases-link-display']
- -- cfg['sandbox-notice-testcases-run-blurb']
- -- cfg['sandbox-notice-testcases-run-link-display']
- -- cfg['sandbox-notice-testcases-blurb'] is a sentence notifying the user that there is a test cases page
- -- corresponding to this sandbox that they can edit. $1 is a link to the test cases page.
- -- cfg['sandbox-notice-testcases-link-display'] is the display value for that link.
- -- cfg['sandbox-notice-testcases-run-blurb'] is a sentence notifying the user that there is a test cases page
- -- corresponding to this sandbox that they can edit, along with a link to run it. $1 is a link to the test
- -- cases page, and $2 is a link to the page to run it.
- -- cfg['sandbox-notice-testcases-run-link-display'] is the display value for the link to run the test
- -- cases.
- --]]
- cfg['sandbox-notice-testcases-blurb'] = 'See also the companion subpage for $1.'
- cfg['sandbox-notice-testcases-link-display'] = 'test cases'
- cfg['sandbox-notice-testcases-run-blurb'] = 'See also the companion subpage for $1 ($2).'
- cfg['sandbox-notice-testcases-run-link-display'] = 'run'
- -- cfg['sandbox-category']
- -- A category to add to all template sandboxes.
- cfg['sandbox-category'] = 'Template sandboxes'
- ----------------------------------------------------------------------------------------------------
- -- Start box configuration
- ----------------------------------------------------------------------------------------------------
- -- cfg['documentation-icon-wikitext']
- -- The wikitext for the icon shown at the top of the template.
- cfg['documentation-icon-wikitext'] = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
- -- cfg['template-namespace-heading']
- -- The heading shown in the template namespace.
- cfg['template-namespace-heading'] = 'Template documentation'
- -- cfg['module-namespace-heading']
- -- The heading shown in the module namespace.
- cfg['module-namespace-heading'] = 'Module documentation'
- -- cfg['file-namespace-heading']
- -- The heading shown in the file namespace.
- cfg['file-namespace-heading'] = 'Summary'
- -- cfg['other-namespaces-heading']
- -- The heading shown in other namespaces.
- cfg['other-namespaces-heading'] = 'Documentation'
- -- cfg['view-link-display']
- -- The text to display for "view" links.
- cfg['view-link-display'] = 'view'
- -- cfg['edit-link-display']
- -- The text to display for "edit" links.
- cfg['edit-link-display'] = 'edit'
- -- cfg['history-link-display']
- -- The text to display for "history" links.
- cfg['history-link-display'] = 'history'
- -- cfg['purge-link-display']
- -- The text to display for "purge" links.
- cfg['purge-link-display'] = 'purge'
- -- cfg['create-link-display']
- -- The text to display for "create" links.
- cfg['create-link-display'] = 'create'
- ----------------------------------------------------------------------------------------------------
- -- Link box (end box) configuration
- ----------------------------------------------------------------------------------------------------
- -- cfg['transcluded-from-blurb']
- -- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page.
- cfg['transcluded-from-blurb'] = 'The above [[Wikipedia:Template documentation|documentation]] is [[Help:Transclusion|transcluded]] from $1.'
- --[[
- -- cfg['create-module-doc-blurb']
- -- Notice displayed in the module namespace when the documentation subpage does not exist.
- -- $1 is a link to create the documentation page with the preload cfg['module-preload'] and the
- -- display cfg['create-link-display'].
- --]]
- cfg['create-module-doc-blurb'] = 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'
- ----------------------------------------------------------------------------------------------------
- -- Experiment blurb configuration
- ----------------------------------------------------------------------------------------------------
- --[[
- -- cfg['experiment-blurb-template']
- -- cfg['experiment-blurb-module']
- -- The experiment blurb is the text inviting editors to experiment in sandbox and test cases pages.
- -- It is only shown in the template and module namespaces. With the default English settings, it
- -- might look like this:
- --
- -- Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.
- --
- -- In this example, "sandbox", "edit", "diff", "testcases", and "edit" would all be links.
- --
- -- There are two versions, cfg['experiment-blurb-template'] and cfg['experiment-blurb-module'], depending
- -- on what namespace we are in.
- --
- -- Parameters:
- --
- -- $1 is a link to the sandbox page. If the sandbox exists, it is in the following format:
- --
- -- cfg['sandbox-link-display'] (cfg['sandbox-edit-link-display'] | cfg['compare-link-display'])
- --
- -- If the sandbox doesn't exist, it is in the format:
- --
- -- cfg['sandbox-link-display'] (cfg['sandbox-create-link-display'] | cfg['mirror-link-display'])
- --
- -- The link for cfg['sandbox-create-link-display'] link preloads the page with cfg['template-sandbox-preload']
- -- or cfg['module-sandbox-preload'], depending on the current namespace. The link for cfg['mirror-link-display']
- -- loads a default edit summary of cfg['mirror-edit-summary'].
- --
- -- $2 is a link to the test cases page. If the test cases page exists, it is in the following format:
- --
- -- cfg['testcases-link-display'] (cfg['testcases-edit-link-display'] | cfg['testcases-run-link-display'])
- --
- -- If the test cases page doesn't exist, it is in the format:
- --
- -- cfg['testcases-link-display'] (cfg['testcases-create-link-display'])
- --
- -- If the test cases page doesn't exist, the link for cfg['testcases-create-link-display'] preloads the
- -- page with cfg['template-testcases-preload'] or cfg['module-testcases-preload'], depending on the current
- -- namespace.
- --]]
- cfg['experiment-blurb-template'] = "Editors can experiment in this template's $1 and $2 pages."
- cfg['experiment-blurb-module'] = "Editors can experiment in this module's $1 and $2 pages."
- ----------------------------------------------------------------------------------------------------
- -- Sandbox link configuration
- ----------------------------------------------------------------------------------------------------
- -- cfg['sandbox-subpage']
- -- The name of the template subpage typically used for sandboxes.
- cfg['sandbox-subpage'] = 'sandbox'
- -- cfg['template-sandbox-preload']
- -- Preload file for template sandbox pages.
- cfg['template-sandbox-preload'] = 'Template:Documentation/preload-sandbox'
- -- cfg['module-sandbox-preload']
- -- Preload file for Lua module sandbox pages.
- cfg['module-sandbox-preload'] = 'Template:Documentation/preload-module-sandbox'
- -- cfg['sandbox-link-display']
- -- The text to display for "sandbox" links.
- cfg['sandbox-link-display'] = 'sandbox'
- -- cfg['sandbox-edit-link-display']
- -- The text to display for sandbox "edit" links.
- cfg['sandbox-edit-link-display'] = 'edit'
- -- cfg['sandbox-create-link-display']
- -- The text to display for sandbox "create" links.
- cfg['sandbox-create-link-display'] = 'create'
- -- cfg['compare-link-display']
- -- The text to display for "compare" links.
- cfg['compare-link-display'] = 'diff'
- -- cfg['mirror-edit-summary']
- -- The default edit summary to use when a user clicks the "mirror" link. $1 is a wikilink to the
- -- template page.
- cfg['mirror-edit-summary'] = 'Create sandbox version of $1'
- -- cfg['mirror-link-display']
- -- The text to display for "mirror" links.
- cfg['mirror-link-display'] = 'mirror'
- -- cfg['mirror-link-preload']
- -- The page to preload when a user clicks the "mirror" link.
- cfg['mirror-link-preload'] = 'Template:Documentation/mirror'
- ----------------------------------------------------------------------------------------------------
- -- Test cases link configuration
- ----------------------------------------------------------------------------------------------------
- -- cfg['testcases-subpage']
- -- The name of the template subpage typically used for test cases.
- cfg['testcases-subpage'] = 'testcases'
- -- cfg['template-testcases-preload']
- -- Preload file for template test cases pages.
- cfg['template-testcases-preload'] = 'Template:Documentation/preload-testcases'
- -- cfg['module-testcases-preload']
- -- Preload file for Lua module test cases pages.
- cfg['module-testcases-preload'] = 'Template:Documentation/preload-module-testcases'
- -- cfg['testcases-link-display']
- -- The text to display for "testcases" links.
- cfg['testcases-link-display'] = 'testcases'
- -- cfg['testcases-edit-link-display']
- -- The text to display for test cases "edit" links.
- cfg['testcases-edit-link-display'] = 'edit'
- -- cfg['testcases-run-link-display']
- -- The text to display for test cases "run" links.
- cfg['testcases-run-link-display'] = 'run'
- -- cfg['testcases-create-link-display']
- -- The text to display for test cases "create" links.
- cfg['testcases-create-link-display'] = 'create'
- ----------------------------------------------------------------------------------------------------
- -- Add categories blurb configuration
- ----------------------------------------------------------------------------------------------------
- --[[
- -- cfg['add-categories-blurb']
- -- Text to direct users to add categories to the /doc subpage. Not used if the "content" or
- -- "docname fed" arguments are set, as then it is not clear where to add the categories. $1 is a
- -- link to the /doc subpage with a display value of cfg['doc-link-display'].
- --]]
- cfg['add-categories-blurb'] = 'Add categories to the $1 subpage.'
- -- cfg['doc-link-display']
- -- The text to display when linking to the /doc subpage.
- cfg['doc-link-display'] = '/doc'
- ----------------------------------------------------------------------------------------------------
- -- Subpages link configuration
- ----------------------------------------------------------------------------------------------------
- --[[
- -- cfg['subpages-blurb']
- -- The "Subpages of this template" blurb. $1 is a link to the main template's subpages with a
- -- display value of cfg['subpages-link-display']. In the English version this blurb is simply
- -- the link followed by a period, and the link display provides the actual text.
- --]]
- cfg['subpages-blurb'] = '$1.'
- --[[
- -- cfg['subpages-link-display']
- -- The text to display for the "subpages of this page" link. $1 is cfg['template-pagetype'],
- -- cfg['module-pagetype'] or cfg['default-pagetype'], depending on whether the current page is in
- -- the template namespace, the module namespace, or another namespace.
- --]]
- cfg['subpages-link-display'] = 'Subpages of this $1'
- -- cfg['template-pagetype']
- -- The pagetype to display for template pages.
- cfg['template-pagetype'] = 'template'
- -- cfg['module-pagetype']
- -- The pagetype to display for Lua module pages.
- cfg['module-pagetype'] = 'module'
- -- cfg['default-pagetype']
- -- The pagetype to display for pages other than templates or Lua modules.
- cfg['default-pagetype'] = 'page'
- ----------------------------------------------------------------------------------------------------
- -- Doc link configuration
- ----------------------------------------------------------------------------------------------------
- -- cfg['doc-subpage']
- -- The name of the subpage typically used for documentation pages.
- cfg['doc-subpage'] = 'doc'
- -- cfg['docpage-preload']
- -- Preload file for template documentation pages in all namespaces.
- cfg['docpage-preload'] = 'Template:Documentation/preload'
- -- cfg['module-preload']
- -- Preload file for Lua module documentation pages.
- cfg['module-preload'] = 'Template:Documentation/preload-module-doc'
- ----------------------------------------------------------------------------------------------------
- -- HTML and CSS configuration
- ----------------------------------------------------------------------------------------------------
- -- cfg['templatestyles']
- -- The name of the TemplateStyles page where CSS is kept.
- -- Sandbox CSS will be at Module:Documentation/sandbox/styles.css when needed.
- cfg['templatestyles'] = 'Module:Documentation/styles.css'
- -- cfg['container']
- -- Class which can be used to set flex or grid CSS on the
- -- two child divs documentation and documentation-metadata
- cfg['container'] = 'documentation-container'
- -- cfg['main-div-classes']
- -- Classes added to the main HTML "div" tag.
- cfg['main-div-classes'] = 'documentation'
- -- cfg['main-div-heading-class']
- -- Class for the main heading for templates and modules and assoc. talk spaces
- cfg['main-div-heading-class'] = 'documentation-heading'
- -- cfg['start-box-class']
- -- Class for the start box
- cfg['start-box-class'] = 'documentation-startbox'
- -- cfg['start-box-link-classes']
- -- Classes used for the [view][edit][history] or [create] links in the start box.
- -- mw-editsection-like is per [[Wikipedia:Village pump (technical)/Archive 117]]
- cfg['start-box-link-classes'] = 'mw-editsection-like plainlinks'
- -- cfg['end-box-class']
- -- Class for the end box.
- cfg['end-box-class'] = 'documentation-metadata'
- -- cfg['end-box-plainlinks']
- -- Plainlinks
- cfg['end-box-plainlinks'] = 'plainlinks'
- -- cfg['toolbar-class']
- -- Class added for toolbar links.
- cfg['toolbar-class'] = 'documentation-toolbar'
- -- cfg['clear']
- -- Just used to clear things.
- cfg['clear'] = 'documentation-clear'
- ----------------------------------------------------------------------------------------------------
- -- Tracking category configuration
- ----------------------------------------------------------------------------------------------------
- -- cfg['display-strange-usage-category']
- -- Set to true to enable output of cfg['strange-usage-category'] if the module is used on a /doc subpage
- -- or a /testcases subpage. This should be a boolean value (either true or false).
- cfg['display-strange-usage-category'] = true
- -- cfg['strange-usage-category']
- -- Category to output if cfg['display-strange-usage-category'] is set to true and the module is used on a
- -- /doc subpage or a /testcases subpage.
- cfg['strange-usage-category'] = 'Wikipedia pages with strange ((documentation)) usage'
- --[[
- ----------------------------------------------------------------------------------------------------
- -- End configuration
- --
- -- Don't edit anything below this line.
- ----------------------------------------------------------------------------------------------------
- --]]
- return cfg</text>
- <sha1>da6pt1lzpy4z0skaztwblaqnfhizyf7</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Documentation/styles.css</title>
- <ns>828</ns>
- <id>61440006</id>
- <revision>
- <id>989579069</id>
- <parentid>989578481</parentid>
- <timestamp>2020-11-19T20:21:58Z</timestamp>
- <contributor>
- <username>Izno</username>
- <id>2927383</id>
- </contributor>
- <minor/>
- <comment>Changed protection level for "[[Module:Documentation/styles.css]]": actually match module ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))</comment>
- <model>sanitized-css</model>
- <format>text/css</format>
- <text bytes="716" xml:space="preserve">/* {{pp|small=yes}} */
- .documentation,
- .documentation-metadata {
- border: 1px solid #a2a9b1;
- background-color: #ecfcf4;
- clear: both;
- }
- .documentation {
- margin: 1em 0 0 0;
- padding: 1em;
- }
- .documentation-metadata {
- margin: 0.2em 0; /* same margin left-right as .documentation */
- font-style: italic;
- padding: 0.4em 1em; /* same padding left-right as .documentation */
- }
- .documentation-startbox {
- padding-bottom: 3px;
- border-bottom: 1px solid #aaa;
- margin-bottom: 1ex;
- }
- .documentation-heading {
- font-weight: bold;
- font-size: 125%;
- }
- .documentation-clear { /* Don't want things to stick out where they shouldn't. */
- clear: both;
- }
- .documentation-toolbar {
- font-style: normal;
- font-size: 85%;
- }</text>
- <sha1>o2ia525en7wbq32mq4fpdevtl5d6pcb</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Effective protection expiry</title>
- <ns>828</ns>
- <id>48785459</id>
- <revision>
- <id>948472505</id>
- <parentid>948472504</parentid>
- <timestamp>2020-04-01T06:12:42Z</timestamp>
- <contributor>
- <username>MusikAnimal</username>
- <id>14882394</id>
- </contributor>
- <minor/>
- <comment>1 revision imported</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="1494" xml:space="preserve">local p = {}
- -- Returns the expiry of a restriction of an action on a given title, or unknown if it cannot be known.
- -- If no title is specified, the title of the page being displayed is used.
- function p._main(action, pagename)
- local title
- if type(pagename) == 'table' and pagename.prefixedText then
- title = pagename
- elseif pagename then
- title = mw.title.new(pagename)
- else
- title = mw.title.getCurrentTitle()
- end
- pagename = title.prefixedText
- if action == 'autoreview' then
- local stabilitySettings = mw.ext.FlaggedRevs.getStabilitySettings(title)
- return stabilitySettings and stabilitySettings.expiry or 'unknown'
- elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' then
- error( 'First parameter must be one of edit, move, create, upload, autoreview', 2 )
- end
- local rawExpiry = mw.getCurrentFrame():callParserFunction('PROTECTIONEXPIRY', action, pagename)
- if rawExpiry == 'infinity' then
- return 'infinity'
- elseif rawExpiry == '' then
- return 'unknown'
- else
- local year, month, day, hour, minute, second = rawExpiry:match(
- '^(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)$'
- )
- if year then
- return string.format(
- '%s-%s-%sT%s:%s:%s',
- year, month, day, hour, minute, second
- )
- else
- error('internal error in Module:Effective protection expiry; malformed expiry timestamp')
- end
- end
- end
- setmetatable(p, { __index = function(t, k)
- return function(frame)
- return t._main(k, frame.args[1])
- end
- end })
- return p</text>
- <sha1>i1wms02y1w048cq6uttka18a5pjzp63</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Effective protection level</title>
- <ns>828</ns>
- <id>41617327</id>
- <revision>
- <id>980896975</id>
- <parentid>948472507</parentid>
- <timestamp>2020-09-29T03:38:47Z</timestamp>
- <contributor>
- <username>Jackmcbarn</username>
- <id>19285809</id>
- </contributor>
- <comment>bring in changes from sandbox</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="3438" xml:space="preserve">local p = {}
- -- Returns the permission required to perform a given action on a given title.
- -- If no title is specified, the title of the page being displayed is used.
- function p._main(action, pagename)
- local title
- if type(pagename) == 'table' and pagename.prefixedText then
- title = pagename
- elseif pagename then
- title = mw.title.new(pagename)
- else
- title = mw.title.getCurrentTitle()
- end
- pagename = title.prefixedText
- if action == 'autoreview' then
- local level = mw.ext.FlaggedRevs.getStabilitySettings(title)
- level = level and level.autoreview
- if level == 'review' then
- return 'reviewer'
- elseif level ~= '' then
- return level
- else
- return nil -- not '*'. a page not being PC-protected is distinct from it being PC-protected with anyone able to review. also not '', as that would mean PC-protected but nobody can review
- end
- elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' and action ~= 'undelete' then
- error( 'First parameter must be one of edit, move, create, upload, undelete, autoreview', 2 )
- end
- if title.namespace == 8 then -- MediaWiki namespace
- if title.text:sub(-3) == '.js' or title.text:sub(-4) == '.css' or title.contentModel == 'javascript' or title.contentModel == 'css' then -- site JS or CSS page
- return 'interfaceadmin'
- else -- any non-JS/CSS MediaWiki page
- return 'sysop'
- end
- elseif title.namespace == 2 and title.isSubpage then
- if title.contentModel == 'javascript' or title.contentModel == 'css' then -- user JS or CSS page
- return 'interfaceadmin'
- elseif title.contentModel == 'json' then -- user JSON page
- return 'sysop'
- end
- end
- if action == 'undelete' then
- return 'sysop'
- end
- local level = title.protectionLevels[action] and title.protectionLevels[action][1]
- if level == 'sysop' or level == 'editprotected' then
- return 'sysop'
- elseif title.cascadingProtection.restrictions[action] and title.cascadingProtection.restrictions[action][1] then -- used by a cascading-protected page
- return 'sysop'
- elseif level == 'templateeditor' then
- return 'templateeditor'
- elseif action == 'move' then
- local blacklistentry = mw.ext.TitleBlacklist.test('edit', pagename) -- Testing action edit is correct, since this is for the source page. The target page name gets tested with action move.
- if blacklistentry and not blacklistentry.params.autoconfirmed then
- return 'templateeditor'
- elseif title.namespace == 6 then
- return 'filemover'
- elseif level == 'extendedconfirmed' then
- return 'extendedconfirmed'
- else
- return 'autoconfirmed'
- end
- end
- local blacklistentry = mw.ext.TitleBlacklist.test(action, pagename)
- if blacklistentry then
- if not blacklistentry.params.autoconfirmed then
- return 'templateeditor'
- elseif level == 'extendedconfirmed' then
- return 'extendedconfirmed'
- else
- return 'autoconfirmed'
- end
- elseif level == 'editsemiprotected' then -- create-semiprotected pages return this for some reason
- return 'autoconfirmed'
- elseif level then
- return level
- elseif action == 'upload' then
- return 'autoconfirmed'
- elseif action == 'create' and title.namespace % 2 == 0 and title.namespace ~= 118 then -- You need to be registered, but not autoconfirmed, to create non-talk pages other than drafts
- return 'user'
- else
- return '*'
- end
- end
- setmetatable(p, { __index = function(t, k)
- return function(frame)
- return t._main(k, frame.args[1])
- end
- end })
- return p</text>
- <sha1>d3lhy0comfcfe9lnnj8klmrfqm1oxw7</sha1>
- </revision>
- </page>
- <page>
- <title>Module:File link</title>
- <ns>828</ns>
- <id>42903140</id>
- <revision>
- <id>948474149</id>
- <parentid>948472509</parentid>
- <timestamp>2020-04-01T06:31:54Z</timestamp>
- <contributor>
- <username>MusikAnimal</username>
- <id>14882394</id>
- </contributor>
- <comment>Undid revision 948472508 by [[Special:Contributions/w>IPad365|w>IPad365]] ([[User talk:w>IPad365|talk]])</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="2544" xml:space="preserve">-- This module provides a library for formatting file wikilinks.
- local yesno = require('Module:Yesno')
- local checkType = require('libraryUtil').checkType
- local p = {}
- function p._main(args)
- checkType('_main', 1, args, 'table')
- -- This is basically libraryUtil.checkTypeForNamedArg, but we are rolling our
- -- own function to get the right error level.
- local function checkArg(key, val, level)
- if type(val) ~= 'string' then
- error(string.format(
- "type error in '%s' parameter of '_main' (expected string, got %s)",
- key, type(val)
- ), level)
- end
- end
- local ret = {}
- -- Adds a positional parameter to the buffer.
- local function addPositional(key)
- local val = args[key]
- if not val then
- return nil
- end
- checkArg(key, val, 4)
- ret[#ret + 1] = val
- end
- -- Adds a named parameter to the buffer. We assume that the parameter name
- -- is the same as the argument key.
- local function addNamed(key)
- local val = args[key]
- if not val then
- return nil
- end
- checkArg(key, val, 4)
- ret[#ret + 1] = key .. '=' .. val
- end
- -- Filename
- checkArg('file', args.file, 3)
- ret[#ret + 1] = 'File:' .. args.file
- -- Format
- if args.format then
- checkArg('format', args.format)
- if args.formatfile then
- checkArg('formatfile', args.formatfile)
- ret[#ret + 1] = args.format .. '=' .. args.formatfile
- else
- ret[#ret + 1] = args.format
- end
- end
- -- Border
- if yesno(args.border) then
- ret[#ret + 1] = 'border'
- end
- addPositional('location')
- addPositional('alignment')
- addPositional('size')
- addNamed('upright')
- addNamed('link')
- addNamed('alt')
- addNamed('page')
- addNamed('class')
- addNamed('lang')
- addNamed('start')
- addNamed('end')
- addNamed('thumbtime')
- addPositional('caption')
- return string.format('[[%s]]', table.concat(ret, '|'))
- end
- function p.main(frame)
- local origArgs = require('Module:Arguments').getArgs(frame, {
- wrappers = 'Template:File link'
- })
- if not origArgs.file then
- error("'file' parameter missing from [[Template:File link]]", 0)
- end
- -- Copy the arguments that were passed to a new table to avoid looking up
- -- every possible parameter in the frame object.
- local args = {}
- for k, v in pairs(origArgs) do
- -- Make _BLANK a special argument to add a blank parameter. For use in
- -- conditional templates etc. it is useful for blank arguments to be
- -- ignored, but we still need a way to specify them so that we can do
- -- things like [[File:Example.png|link=]].
- if v == '_BLANK' then
- v = ''
- end
- args[k] = v
- end
- return p._main(args)
- end
- return p</text>
- <sha1>bzc22v133v9z5yc4aisazripn6l94p8</sha1>
- </revision>
- </page>
- <page>
- <title>Module:High-use</title>
- <ns>828</ns>
- <id>62062952</id>
- <revision>
- <id>1053091615</id>
- <parentid>1050945202</parentid>
- <timestamp>2021-11-01T21:11:55Z</timestamp>
- <contributor>
- <username>GKFX</username>
- <id>14918984</id>
- </contributor>
- <comment>Link to https://linkcount.toolforge.org/ which is more detailed and mobile-friendly</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="6690" xml:space="preserve">local p = {}
- -- _fetch looks at the "demo" argument.
- local _fetch = require('Module:Transclusion_count').fetch
- local yesno = require('Module:Yesno')
- function p.num(frame, count)
- if count == nil then
- if yesno(frame.args['fetch']) == false then
- if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end
- else
- count = _fetch(frame)
- end
- end
- -- Build output string
- local return_value = ""
- if count == nil then
- if frame.args[1] == "risk" then
- return_value = "a very large number of"
- else
- return_value = "many"
- end
- else
- -- Use 2 significant figures for smaller numbers and 3 for larger ones
- local sigfig = 2
- if count >= 100000 then
- sigfig = 3
- end
- -- Prepare to round to appropriate number of sigfigs
- local f = math.floor(math.log10(count)) - sigfig + 1
- -- Round and insert "approximately" or "+" when appropriate
- if (frame.args[2] == "yes") or (mw.ustring.sub(frame.args[1],-1) == "+") then
- -- Round down
- return_value = string.format("%s+", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) ) * (10^(f))) )
- else
- -- Round to nearest
- return_value = string.format("approximately&#x20;%s", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) + 0.5) * (10^(f))) )
- end
- -- Insert percentage of pages if that is likely to be >= 1% and when |no-percent= not set to yes
- if count and count > 250000 and not yesno (frame:getParent().args['no-percent']) then
- local percent = math.floor( ( (count/frame:callParserFunction('NUMBEROFPAGES', 'R') ) * 100) + 0.5)
- if percent >= 1 then
- return_value = string.format("%s&#x20;pages, or roughly %s%% of all", return_value, percent)
- end
- end
- end
- return return_value
- end
- -- Actions if there is a large (greater than or equal to 100,000) transclusion count
- function p.risk(frame)
- local return_value = ""
- if frame.args[1] == "risk" then
- return_value = "risk"
- else
- local count = _fetch(frame)
- if count and count >= 100000 then return_value = "risk" end
- end
- return return_value
- end
- function p.text(frame, count)
- -- Only show the information about how this template gets updated if someone
- -- is actually editing the page and maybe trying to update the count.
- local bot_text = (frame:preprocess("{{REVISIONID}}") == "") and "\n\n----\n'''Preview message''': Transclusion count updated automatically ([[Template:High-use/doc#Technical details|see documentation]])." or ''
- if count == nil then
- if yesno(frame.args['fetch']) == false then
- if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end
- else
- count = _fetch(frame)
- end
- end
- local title = mw.title.getCurrentTitle()
- if title.subpageText == "doc" or title.subpageText == "sandbox" then
- title = title.basePageTitle
- end
- local systemMessages = frame.args['system']
- if frame.args['system'] == '' then
- systemMessages = nil
- end
- -- This retrieves the project URL automatically to simplify localiation.
- local templateCount = ('on [https://linkcount.toolforge.org/index.php?project=%s&page=%s %s pages]'):format(
- mw.title.getCurrentTitle():fullUrl():gsub('//(.-)/.*', '%1'),
- mw.uri.encode(title.fullText), p.num(frame, count))
- local used_on_text = "'''This " .. (mw.title.getCurrentTitle().namespace == 828 and "Lua module" or "template") .. ' is used ';
- if systemMessages then
- used_on_text = used_on_text .. systemMessages ..
- ((count and count > 2000) and (",''' and " .. templateCount) or ("'''"))
- else
- used_on_text = used_on_text .. templateCount .. "'''"
- end
- local sandbox_text = ("%s's [[%s/sandbox|/sandbox]] or [[%s/testcases|/testcases]] subpages, or in your own [[%s]]. "):format(
- (mw.title.getCurrentTitle().namespace == 828 and "module" or "template"),
- title.fullText, title.fullText,
- mw.title.getCurrentTitle().namespace == 828 and "Module:Sandbox|module sandbox" or "Wikipedia:User pages#SUB|user subpage"
- )
- local infoArg = frame.args["info"] ~= "" and frame.args["info"]
- if (systemMessages or frame.args[1] == "risk" or (count and count >= 100000) ) then
- local info = systemMessages and '.<br/>Changes to it can cause immediate changes to the Wikipedia user interface.' or '.'
- if infoArg then
- info = info .. "<br />" .. infoArg
- end
- sandbox_text = info .. '<br /> To avoid major disruption' ..
- (count and count >= 100000 and ' and server load' or '') ..
- ', any changes should be tested in the ' .. sandbox_text ..
- 'The tested changes can be added to this page in a single edit. '
- else
- sandbox_text = (infoArg and ('.<br />' .. infoArg .. ' C') or ' and c') ..
- 'hanges may be widely noticed. Test changes in the ' .. sandbox_text
- end
- local discussion_text = systemMessages and 'Please discuss changes ' or 'Consider discussing changes '
- if frame.args["2"] and frame.args["2"] ~= "" and frame.args["2"] ~= "yes" then
- discussion_text = string.format("%sat [[%s]]", discussion_text, frame.args["2"])
- else
- discussion_text = string.format("%son the [[%s|talk page]]", discussion_text, title.talkPageTitle.fullText )
- end
- return used_on_text .. sandbox_text .. discussion_text .. " before implementing them." .. bot_text
- end
- function p.main(frame)
- local count = nil
- if yesno(frame.args['fetch']) == false then
- if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end
- else
- count = _fetch(frame)
- end
- local image = "[[File:Ambox warning yellow.svg|40px|alt=Warning|link=]]"
- local type_param = "style"
- local epilogue = ''
- if frame.args['system'] and frame.args['system'] ~= '' then
- image = "[[File:Ambox important.svg|40px|alt=Warning|link=]]"
- type_param = "content"
- local nocat = frame:getParent().args['nocat'] or frame.args['nocat']
- local categorise = (nocat == '' or not yesno(nocat))
- if categorise then
- epilogue = frame:preprocess('{{Sandbox other||{{#switch:{{#invoke:Effective protection level|{{#switch:{{NAMESPACE}}|File=upload|#default=edit}}|{{FULLPAGENAME}}}}|sysop|templateeditor|interfaceadmin=|#default=[[Category:Pages used in system messages needing protection]]}}}}')
- end
- elseif (frame.args[1] == "risk" or (count and count >= 100000)) then
- image = "[[File:Ambox warning orange.svg|40px|alt=Warning|link=]]"
- type_param = "content"
- end
- if frame.args["form"] == "editnotice" then
- return frame:expandTemplate{
- title = 'editnotice',
- args = {
- ["image"] = image,
- ["text"] = p.text(frame, count),
- ["expiry"] = (frame.args["expiry"] or "")
- }
- } .. epilogue
- else
- return require('Module:Message box').main('ombox', {
- type = type_param,
- image = image,
- text = p.text(frame, count),
- expiry = (frame.args["expiry"] or "")
- }) .. epilogue
- end
- end
- return p</text>
- <sha1>sy3y3omwgho4wnukvqxwejjpb2mjh3c</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Message box</title>
- <ns>828</ns>
- <id>40574910</id>
- <revision>
- <id>1027212344</id>
- <parentid>970994177</parentid>
- <timestamp>2021-06-06T18:51:34Z</timestamp>
- <contributor>
- <username>Izno</username>
- <id>2927383</id>
- </contributor>
- <comment>per tper</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="18348" xml:space="preserve">-- This is a meta-module for producing message box templates, including
- -- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}.
- -- Load necessary modules.
- require('Module:No globals')
- local getArgs
- local yesno = require('Module:Yesno')
- -- Get a language object for formatDate and ucfirst.
- local lang = mw.language.getContentLanguage()
- -- Define constants
- local CONFIG_MODULE = 'Module:Message box/configuration'
- local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'}
- --------------------------------------------------------------------------------
- -- Helper functions
- --------------------------------------------------------------------------------
- local function getTitleObject(...)
- -- Get the title object, passing the function through pcall
- -- in case we are over the expensive function count limit.
- local success, title = pcall(mw.title.new, ...)
- if success then
- return title
- end
- end
- local function union(t1, t2)
- -- Returns the union of two arrays.
- local vals = {}
- for i, v in ipairs(t1) do
- vals[v] = true
- end
- for i, v in ipairs(t2) do
- vals[v] = true
- end
- local ret = {}
- for k in pairs(vals) do
- table.insert(ret, k)
- end
- table.sort(ret)
- return ret
- end
- local function getArgNums(args, prefix)
- local nums = {}
- for k, v in pairs(args) do
- local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$')
- if num then
- table.insert(nums, tonumber(num))
- end
- end
- table.sort(nums)
- return nums
- end
- --------------------------------------------------------------------------------
- -- Box class definition
- --------------------------------------------------------------------------------
- local MessageBox = {}
- MessageBox.__index = MessageBox
- function MessageBox.new(boxType, args, cfg)
- args = args or {}
- local obj = {}
- -- Set the title object and the namespace.
- obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()
- -- Set the config for our box type.
- obj.cfg = cfg[boxType]
- if not obj.cfg then
- local ns = obj.title.namespace
- -- boxType is "mbox" or invalid input
- if args.demospace and args.demospace ~= '' then
- -- implement demospace parameter of mbox
- local demospace = string.lower(args.demospace)
- if DEMOSPACES[demospace] then
- -- use template from DEMOSPACES
- obj.cfg = cfg[DEMOSPACES[demospace]]
- elseif string.find( demospace, 'talk' ) then
- -- demo as a talk page
- obj.cfg = cfg.tmbox
- else
- -- default to ombox
- obj.cfg = cfg.ombox
- end
- elseif ns == 0 then
- obj.cfg = cfg.ambox -- main namespace
- elseif ns == 6 then
- obj.cfg = cfg.imbox -- file namespace
- elseif ns == 14 then
- obj.cfg = cfg.cmbox -- category namespace
- else
- local nsTable = mw.site.namespaces[ns]
- if nsTable and nsTable.isTalk then
- obj.cfg = cfg.tmbox -- any talk namespace
- else
- obj.cfg = cfg.ombox -- other namespaces or invalid input
- end
- end
- end
- -- Set the arguments, and remove all blank arguments except for the ones
- -- listed in cfg.allowBlankParams.
- do
- local newArgs = {}
- for k, v in pairs(args) do
- if v ~= '' then
- newArgs[k] = v
- end
- end
- for i, param in ipairs(obj.cfg.allowBlankParams or {}) do
- newArgs[param] = args[param]
- end
- obj.args = newArgs
- end
- -- Define internal data structure.
- obj.categories = {}
- obj.classes = {}
- -- For lazy loading of [[Module:Category handler]].
- obj.hasCategories = false
- return setmetatable(obj, MessageBox)
- end
- function MessageBox:addCat(ns, cat, sort)
- if not cat then
- return nil
- end
- if sort then
- cat = string.format('[[Category:%s|%s]]', cat, sort)
- else
- cat = string.format('[[Category:%s]]', cat)
- end
- self.hasCategories = true
- self.categories[ns] = self.categories[ns] or {}
- table.insert(self.categories[ns], cat)
- end
- function MessageBox:addClass(class)
- if not class then
- return nil
- end
- table.insert(self.classes, class)
- end
- function MessageBox:setParameters()
- local args = self.args
- local cfg = self.cfg
- -- Get type data.
- self.type = args.type
- local typeData = cfg.types[self.type]
- self.invalidTypeError = cfg.showInvalidTypeError
- and self.type
- and not typeData
- typeData = typeData or cfg.types[cfg.default]
- self.typeClass = typeData.class
- self.typeImage = typeData.image
- -- Find if the box has been wrongly substituted.
- self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'
- -- Find whether we are using a small message box.
- self.isSmall = cfg.allowSmall and (
- cfg.smallParam and args.small == cfg.smallParam
- or not cfg.smallParam and yesno(args.small)
- )
- -- Add attributes, classes and styles.
- self.id = args.id
- self.name = args.name
- if self.name then
- self:addClass('box-' .. string.gsub(self.name,' ','_'))
- end
- if yesno(args.plainlinks) ~= false then
- self:addClass('plainlinks')
- end
- for _, class in ipairs(cfg.classes or {}) do
- self:addClass(class)
- end
- if self.isSmall then
- self:addClass(cfg.smallClass or 'mbox-small')
- end
- self:addClass(self.typeClass)
- self:addClass(args.class)
- self.style = args.style
- self.attrs = args.attrs
- -- Set text style.
- self.textstyle = args.textstyle
- -- Find if we are on the template page or not. This functionality is only
- -- used if useCollapsibleTextFields is set, or if both cfg.templateCategory
- -- and cfg.templateCategoryRequireName are set.
- self.useCollapsibleTextFields = cfg.useCollapsibleTextFields
- if self.useCollapsibleTextFields
- or cfg.templateCategory
- and cfg.templateCategoryRequireName
- then
- if self.name then
- local templateName = mw.ustring.match(
- self.name,
- '^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$'
- ) or self.name
- templateName = 'Template:' .. templateName
- self.templateTitle = getTitleObject(templateName)
- end
- self.isTemplatePage = self.templateTitle
- and mw.title.equals(self.title, self.templateTitle)
- end
- -- Process data for collapsible text fields. At the moment these are only
- -- used in {{ambox}}.
- if self.useCollapsibleTextFields then
- -- Get the self.issue value.
- if self.isSmall and args.smalltext then
- self.issue = args.smalltext
- else
- local sect
- if args.sect == '' then
- sect = 'This ' .. (cfg.sectionDefault or 'page')
- elseif type(args.sect) == 'string' then
- sect = 'This ' .. args.sect
- end
- local issue = args.issue
- issue = type(issue) == 'string' and issue ~= '' and issue or nil
- local text = args.text
- text = type(text) == 'string' and text or nil
- local issues = {}
- table.insert(issues, sect)
- table.insert(issues, issue)
- table.insert(issues, text)
- self.issue = table.concat(issues, ' ')
- end
- -- Get the self.talk value.
- local talk = args.talk
- -- Show talk links on the template page or template subpages if the talk
- -- parameter is blank.
- if talk == ''
- and self.templateTitle
- and (
- mw.title.equals(self.templateTitle, self.title)
- or self.title:isSubpageOf(self.templateTitle)
- )
- then
- talk = '#'
- elseif talk == '' then
- talk = nil
- end
- if talk then
- -- If the talk value is a talk page, make a link to that page. Else
- -- assume that it's a section heading, and make a link to the talk
- -- page of the current page with that section heading.
- local talkTitle = getTitleObject(talk)
- local talkArgIsTalkPage = true
- if not talkTitle or not talkTitle.isTalkPage then
- talkArgIsTalkPage = false
- talkTitle = getTitleObject(
- self.title.text,
- mw.site.namespaces[self.title.namespace].talk.id
- )
- end
- if talkTitle and talkTitle.exists then
- local talkText
- if self.isSmall then
- local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk)
- talkText = string.format('([[%s|talk]])', talkLink)
- else
- talkText = 'Relevant discussion may be found on'
- if talkArgIsTalkPage then
- talkText = string.format(
- '%s [[%s|%s]].',
- talkText,
- talk,
- talkTitle.prefixedText
- )
- else
- talkText = string.format(
- '%s the [[%s#%s|talk page]].',
- talkText,
- talkTitle.prefixedText,
- talk
- )
- end
- end
- self.talk = talkText
- end
- end
- -- Get other values.
- self.fix = args.fix ~= '' and args.fix or nil
- local date
- if args.date and args.date ~= '' then
- date = args.date
- elseif args.date == '' and self.isTemplatePage then
- date = lang:formatDate('F Y')
- end
- if date then
- self.date = string.format(" <span class='date-container'>''(<span class='date'>%s</span>)''</span>", date)
- end
- self.info = args.info
- if yesno(args.removalnotice) then
- self.removalNotice = cfg.removalNotice
- end
- end
- -- Set the non-collapsible text field. At the moment this is used by all box
- -- types other than ambox, and also by ambox when small=yes.
- if self.isSmall then
- self.text = args.smalltext or args.text
- else
- self.text = args.text
- end
- -- Set the below row.
- self.below = cfg.below and args.below
- -- General image settings.
- self.imageCellDiv = not self.isSmall and cfg.imageCellDiv
- self.imageEmptyCell = cfg.imageEmptyCell
- if cfg.imageEmptyCellStyle then
- self.imageEmptyCellStyle = 'border:none;padding:0;width:1px'
- end
- -- Left image settings.
- local imageLeft = self.isSmall and args.smallimage or args.image
- if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none'
- or not cfg.imageCheckBlank and imageLeft ~= 'none'
- then
- self.imageLeft = imageLeft
- if not imageLeft then
- local imageSize = self.isSmall
- and (cfg.imageSmallSize or '30x30px')
- or '40x40px'
- self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage
- or 'Imbox notice.png', imageSize)
- end
- end
- -- Right image settings.
- local imageRight = self.isSmall and args.smallimageright or args.imageright
- if not (cfg.imageRightNone and imageRight == 'none') then
- self.imageRight = imageRight
- end
- end
- function MessageBox:setMainspaceCategories()
- local args = self.args
- local cfg = self.cfg
- if not cfg.allowMainspaceCategories then
- return nil
- end
- local nums = {}
- for _, prefix in ipairs{'cat', 'category', 'all'} do
- args[prefix .. '1'] = args[prefix]
- nums = union(nums, getArgNums(args, prefix))
- end
- -- The following is roughly equivalent to the old {{Ambox/category}}.
- local date = args.date
- date = type(date) == 'string' and date
- local preposition = 'from'
- for _, num in ipairs(nums) do
- local mainCat = args['cat' .. tostring(num)]
- or args['category' .. tostring(num)]
- local allCat = args['all' .. tostring(num)]
- mainCat = type(mainCat) == 'string' and mainCat
- allCat = type(allCat) == 'string' and allCat
- if mainCat and date and date ~= '' then
- local catTitle = string.format('%s %s %s', mainCat, preposition, date)
- self:addCat(0, catTitle)
- catTitle = getTitleObject('Category:' .. catTitle)
- if not catTitle or not catTitle.exists then
- self:addCat(0, 'Articles with invalid date parameter in template')
- end
- elseif mainCat and (not date or date == '') then
- self:addCat(0, mainCat)
- end
- if allCat then
- self:addCat(0, allCat)
- end
- end
- end
- function MessageBox:setTemplateCategories()
- local args = self.args
- local cfg = self.cfg
- -- Add template categories.
- if cfg.templateCategory then
- if cfg.templateCategoryRequireName then
- if self.isTemplatePage then
- self:addCat(10, cfg.templateCategory)
- end
- elseif not self.title.isSubpage then
- self:addCat(10, cfg.templateCategory)
- end
- end
- -- Add template error categories.
- if cfg.templateErrorCategory then
- local templateErrorCategory = cfg.templateErrorCategory
- local templateCat, templateSort
- if not self.name and not self.title.isSubpage then
- templateCat = templateErrorCategory
- elseif self.isTemplatePage then
- local paramsToCheck = cfg.templateErrorParamsToCheck or {}
- local count = 0
- for i, param in ipairs(paramsToCheck) do
- if not args[param] then
- count = count + 1
- end
- end
- if count > 0 then
- templateCat = templateErrorCategory
- templateSort = tostring(count)
- end
- if self.categoryNums and #self.categoryNums > 0 then
- templateCat = templateErrorCategory
- templateSort = 'C'
- end
- end
- self:addCat(10, templateCat, templateSort)
- end
- end
- function MessageBox:setAllNamespaceCategories()
- -- Set categories for all namespaces.
- if self.invalidTypeError then
- local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText
- self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort)
- end
- if self.isSubstituted then
- self:addCat('all', 'Pages with incorrectly substituted templates')
- end
- end
- function MessageBox:setCategories()
- if self.title.namespace == 0 then
- self:setMainspaceCategories()
- elseif self.title.namespace == 10 then
- self:setTemplateCategories()
- end
- self:setAllNamespaceCategories()
- end
- function MessageBox:renderCategories()
- if not self.hasCategories then
- -- No categories added, no need to pass them to Category handler so,
- -- if it was invoked, it would return the empty string.
- -- So we shortcut and return the empty string.
- return ""
- end
- -- Convert category tables to strings and pass them through
- -- [[Module:Category handler]].
- return require('Module:Category handler')._main{
- main = table.concat(self.categories[0] or {}),
- template = table.concat(self.categories[10] or {}),
- all = table.concat(self.categories.all or {}),
- nocat = self.args.nocat,
- page = self.args.page
- }
- end
- function MessageBox:export()
- local root = mw.html.create()
- -- Add the subst check error.
- if self.isSubstituted and self.name then
- root:tag('b')
- :addClass('error')
- :wikitext(string.format(
- 'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.',
- mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
- ))
- end
- -- Create the box table.
- local boxTable = root:tag('table')
- boxTable:attr('id', self.id or nil)
- for i, class in ipairs(self.classes or {}) do
- boxTable:addClass(class or nil)
- end
- boxTable
- :cssText(self.style or nil)
- :attr('role', 'presentation')
- if self.attrs then
- boxTable:attr(self.attrs)
- end
- -- Add the left-hand image.
- local row = boxTable:tag('tr')
- if self.imageLeft then
- local imageLeftCell = row:tag('td'):addClass('mbox-image')
- if self.imageCellDiv then
- -- If we are using a div, redefine imageLeftCell so that the image
- -- is inside it. Divs use style="width: 52px;", which limits the
- -- image width to 52px. If any images in a div are wider than that,
- -- they may overlap with the text or cause other display problems.
- imageLeftCell = imageLeftCell:tag('div'):css('width', '52px')
- end
- imageLeftCell:wikitext(self.imageLeft or nil)
- elseif self.imageEmptyCell then
- -- Some message boxes define an empty cell if no image is specified, and
- -- some don't. The old template code in templates where empty cells are
- -- specified gives the following hint: "No image. Cell with some width
- -- or padding necessary for text cell to have 100% width."
- row:tag('td')
- :addClass('mbox-empty-cell')
- :cssText(self.imageEmptyCellStyle or nil)
- end
- -- Add the text.
- local textCell = row:tag('td'):addClass('mbox-text')
- if self.useCollapsibleTextFields then
- -- The message box uses advanced text parameters that allow things to be
- -- collapsible. At the moment, only ambox uses this.
- textCell:cssText(self.textstyle or nil)
- local textCellDiv = textCell:tag('div')
- textCellDiv
- :addClass('mbox-text-span')
- :wikitext(self.issue or nil)
- if (self.talk or self.fix) then
- textCellDiv:tag('span')
- :addClass('hide-when-compact')
- :wikitext(self.talk and (' ' .. self.talk) or nil)
- :wikitext(self.fix and (' ' .. self.fix) or nil)
- end
- textCellDiv:wikitext(self.date and (' ' .. self.date) or nil)
- if self.info and not self.isSmall then
- textCellDiv
- :tag('span')
- :addClass('hide-when-compact')
- :wikitext(self.info and (' ' .. self.info) or nil)
- end
- if self.removalNotice then
- textCellDiv:tag('span')
- :addClass('hide-when-compact')
- :tag('i')
- :wikitext(string.format(" (%s)", self.removalNotice))
- end
- else
- -- Default text formatting - anything goes.
- textCell
- :cssText(self.textstyle or nil)
- :wikitext(self.text or nil)
- end
- -- Add the right-hand image.
- if self.imageRight then
- local imageRightCell = row:tag('td'):addClass('mbox-imageright')
- if self.imageCellDiv then
- -- If we are using a div, redefine imageRightCell so that the image
- -- is inside it.
- imageRightCell = imageRightCell:tag('div'):css('width', '52px')
- end
- imageRightCell
- :wikitext(self.imageRight or nil)
- end
- -- Add the below row.
- if self.below then
- boxTable:tag('tr')
- :tag('td')
- :attr('colspan', self.imageRight and '3' or '2')
- :addClass('mbox-text')
- :cssText(self.textstyle or nil)
- :wikitext(self.below or nil)
- end
- -- Add error message for invalid type parameters.
- if self.invalidTypeError then
- root:tag('div')
- :css('text-align', 'center')
- :wikitext(string.format(
- 'This message box is using an invalid "type=%s" parameter and needs fixing.',
- self.type or ''
- ))
- end
- -- Add categories.
- root:wikitext(self:renderCategories() or nil)
- return tostring(root)
- end
- --------------------------------------------------------------------------------
- -- Exports
- --------------------------------------------------------------------------------
- local p, mt = {}, {}
- function p._exportClasses()
- -- For testing.
- return {
- MessageBox = MessageBox
- }
- end
- function p.main(boxType, args, cfgTables)
- local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE))
- box:setParameters()
- box:setCategories()
- return box:export()
- end
- function mt.__index(t, k)
- return function (frame)
- if not getArgs then
- getArgs = require('Module:Arguments').getArgs
- end
- return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))
- end
- end
- return setmetatable(p, mt)</text>
- <sha1>kshc0gmfnt1xkzycgdb25urt4m770p1</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Message box/configuration</title>
- <ns>828</ns>
- <id>40627038</id>
- <revision>
- <id>948472514</id>
- <parentid>948472513</parentid>
- <timestamp>2020-04-01T06:12:44Z</timestamp>
- <contributor>
- <username>MusikAnimal</username>
- <id>14882394</id>
- </contributor>
- <minor/>
- <comment>1 revision imported</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="6141" xml:space="preserve">--------------------------------------------------------------------------------
- -- Message box configuration --
- -- --
- -- This module contains configuration data for [[Module:Message box]]. --
- --------------------------------------------------------------------------------
- return {
- ambox = {
- types = {
- speedy = {
- class = 'ambox-speedy',
- image = 'Ambox warning pn.svg'
- },
- delete = {
- class = 'ambox-delete',
- image = 'Ambox warning pn.svg'
- },
- content = {
- class = 'ambox-content',
- image = 'Ambox important.svg'
- },
- style = {
- class = 'ambox-style',
- image = 'Edit-clear.svg'
- },
- move = {
- class = 'ambox-move',
- image = 'Merge-split-transwiki default.svg'
- },
- protection = {
- class = 'ambox-protection',
- image = 'Semi-protection-shackle-keyhole.svg'
- },
- notice = {
- class = 'ambox-notice',
- image = 'Information icon4.svg'
- }
- },
- default = 'notice',
- allowBlankParams = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'},
- allowSmall = true,
- smallParam = 'left',
- smallClass = 'mbox-small-left',
- substCheck = true,
- classes = {'metadata', 'ambox'},
- imageEmptyCell = true,
- imageCheckBlank = true,
- imageSmallSize = '20x20px',
- imageCellDiv = true,
- useCollapsibleTextFields = true,
- imageRightNone = true,
- sectionDefault = 'article',
- allowMainspaceCategories = true,
- templateCategory = 'Article message templates',
- templateCategoryRequireName = true,
- templateErrorCategory = 'Article message templates with missing parameters',
- templateErrorParamsToCheck = {'issue', 'fix', 'subst'},
- removalNotice = '[[Help:Maintenance template removal|Learn how and when to remove this template message]]'
- },
- cmbox = {
- types = {
- speedy = {
- class = 'cmbox-speedy',
- image = 'Ambox warning pn.svg'
- },
- delete = {
- class = 'cmbox-delete',
- image = 'Ambox warning pn.svg'
- },
- content = {
- class = 'cmbox-content',
- image = 'Ambox important.svg'
- },
- style = {
- class = 'cmbox-style',
- image = 'Edit-clear.svg'
- },
- move = {
- class = 'cmbox-move',
- image = 'Merge-split-transwiki default.svg'
- },
- protection = {
- class = 'cmbox-protection',
- image = 'Semi-protection-shackle-keyhole.svg'
- },
- notice = {
- class = 'cmbox-notice',
- image = 'Information icon4.svg'
- }
- },
- default = 'notice',
- showInvalidTypeError = true,
- classes = {'cmbox'},
- imageEmptyCell = true
- },
- fmbox = {
- types = {
- warning = {
- class = 'fmbox-warning',
- image = 'Ambox warning pn.svg'
- },
- editnotice = {
- class = 'fmbox-editnotice',
- image = 'Information icon4.svg'
- },
- system = {
- class = 'fmbox-system',
- image = 'Information icon4.svg'
- }
- },
- default = 'system',
- showInvalidTypeError = true,
- classes = {'fmbox'},
- imageEmptyCell = false,
- imageRightNone = false
- },
- imbox = {
- types = {
- speedy = {
- class = 'imbox-speedy',
- image = 'Ambox warning pn.svg'
- },
- delete = {
- class = 'imbox-delete',
- image = 'Ambox warning pn.svg'
- },
- content = {
- class = 'imbox-content',
- image = 'Ambox important.svg'
- },
- style = {
- class = 'imbox-style',
- image = 'Edit-clear.svg'
- },
- move = {
- class = 'imbox-move',
- image = 'Merge-split-transwiki default.svg'
- },
- protection = {
- class = 'imbox-protection',
- image = 'Semi-protection-shackle-keyhole.svg'
- },
- license = {
- class = 'imbox-license licensetpl',
- image = 'Imbox license.png' -- @todo We need an SVG version of this
- },
- featured = {
- class = 'imbox-featured',
- image = 'Cscr-featured.svg'
- },
- notice = {
- class = 'imbox-notice',
- image = 'Information icon4.svg'
- }
- },
- default = 'notice',
- showInvalidTypeError = true,
- classes = {'imbox'},
- imageEmptyCell = true,
- below = true,
- templateCategory = 'File message boxes'
- },
- ombox = {
- types = {
- speedy = {
- class = 'ombox-speedy',
- image = 'Ambox warning pn.svg'
- },
- delete = {
- class = 'ombox-delete',
- image = 'Ambox warning pn.svg'
- },
- content = {
- class = 'ombox-content',
- image = 'Ambox important.svg'
- },
- style = {
- class = 'ombox-style',
- image = 'Edit-clear.svg'
- },
- move = {
- class = 'ombox-move',
- image = 'Merge-split-transwiki default.svg'
- },
- protection = {
- class = 'ombox-protection',
- image = 'Semi-protection-shackle-keyhole.svg'
- },
- notice = {
- class = 'ombox-notice',
- image = 'Information icon4.svg'
- }
- },
- default = 'notice',
- showInvalidTypeError = true,
- classes = {'ombox'},
- allowSmall = true,
- imageEmptyCell = true,
- imageRightNone = true
- },
- tmbox = {
- types = {
- speedy = {
- class = 'tmbox-speedy',
- image = 'Ambox warning pn.svg'
- },
- delete = {
- class = 'tmbox-delete',
- image = 'Ambox warning pn.svg'
- },
- content = {
- class = 'tmbox-content',
- image = 'Ambox important.svg'
- },
- style = {
- class = 'tmbox-style',
- image = 'Edit-clear.svg'
- },
- move = {
- class = 'tmbox-move',
- image = 'Merge-split-transwiki default.svg'
- },
- protection = {
- class = 'tmbox-protection',
- image = 'Semi-protection-shackle-keyhole.svg'
- },
- notice = {
- class = 'tmbox-notice',
- image = 'Information icon4.svg'
- }
- },
- default = 'notice',
- showInvalidTypeError = true,
- classes = {'tmbox'},
- allowSmall = true,
- imageRightNone = true,
- imageEmptyCell = true,
- imageEmptyCellStyle = true,
- templateCategory = 'Talk message boxes'
- }
- }</text>
- <sha1>rz63o9789otb966y0k5pcntqf0bl6te</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Navbar</title>
- <ns>828</ns>
- <id>38827227</id>
- <revision>
- <id>1054994468</id>
- <parentid>1054938041</parentid>
- <timestamp>2021-11-13T05:33:43Z</timestamp>
- <contributor>
- <username>Izno</username>
- <id>2927383</id>
- </contributor>
- <comment>remove unnecessary line</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="5088" xml:space="preserve">local p = {}
- local cfg = mw.loadData('Module:Navbar/configuration')
- local function get_title_arg(is_collapsible, template)
- local title_arg = 1
- if is_collapsible then title_arg = 2 end
- if template then title_arg = 'template' end
- return title_arg
- end
- local function choose_links(template, args)
- -- The show table indicates the default displayed items.
- -- view, talk, edit, hist, move, watch
- -- TODO: Move to configuration.
- local show = {true, true, true, false, false, false}
- if template then
- show[2] = false
- show[3] = false
- local index = {t = 2, d = 2, e = 3, h = 4, m = 5, w = 6,
- talk = 2, edit = 3, hist = 4, move = 5, watch = 6}
- -- TODO: Consider removing TableTools dependency.
- for _, v in ipairs(require ('Module:TableTools').compressSparseArray(args)) do
- local num = index[v]
- if num then show[num] = true end
- end
- end
- local remove_edit_link = args.noedit
- if remove_edit_link then show[3] = false end
- return show
- end
- local function add_link(link_description, ul, is_mini, font_style)
- local l
- if link_description.url then
- l = {'[', '', ']'}
- else
- l = {'[[', '|', ']]'}
- end
- ul:tag('li')
- :addClass('nv-' .. link_description.full)
- :wikitext(l[1] .. link_description.link .. l[2])
- :tag(is_mini and 'abbr' or 'span')
- :attr('title', link_description.html_title)
- :cssText(font_style)
- :wikitext(is_mini and link_description.mini or link_description.full)
- :done()
- :wikitext(l[3])
- :done()
- end
- local function make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
- local title = mw.title.new(mw.text.trim(title_text), cfg.title_namespace)
- if not title then
- error(cfg.invalid_title .. title_text)
- end
- local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ''
- -- TODO: Get link_descriptions and show into the configuration module.
- -- link_descriptions should be easier...
- local link_descriptions = {
- { ['mini'] = 'v', ['full'] = 'view', ['html_title'] = 'View this template',
- ['link'] = title.fullText, ['url'] = false },
- { ['mini'] = 't', ['full'] = 'talk', ['html_title'] = 'Discuss this template',
- ['link'] = talkpage, ['url'] = false },
- { ['mini'] = 'e', ['full'] = 'edit', ['html_title'] = 'Edit this template',
- ['link'] = title:fullUrl('action=edit'), ['url'] = true },
- { ['mini'] = 'h', ['full'] = 'hist', ['html_title'] = 'History of this template',
- ['link'] = title:fullUrl('action=history'), ['url'] = true },
- { ['mini'] = 'm', ['full'] = 'move', ['html_title'] = 'Move this template',
- ['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText), ['url'] = true },
- { ['mini'] = 'w', ['full'] = 'watch', ['html_title'] = 'Watch this template',
- ['link'] = title:fullUrl('action=watch'), ['url'] = true }
- }
- local ul = mw.html.create('ul')
- if has_brackets then
- ul:addClass(cfg.classes.brackets)
- :cssText(font_style)
- end
- for i, _ in ipairs(displayed_links) do
- if displayed_links[i] then add_link(link_descriptions[i], ul, is_mini, font_style) end
- end
- return ul:done()
- end
- function p._navbar(args)
- -- TODO: We probably don't need both fontstyle and fontcolor...
- local font_style = args.fontstyle
- local font_color = args.fontcolor
- local is_collapsible = args.collapsible
- local is_mini = args.mini
- local is_plain = args.plain
- local collapsible_class = nil
- if is_collapsible then
- collapsible_class = cfg.classes.collapsible
- if not is_plain then is_mini = 1 end
- if font_color then
- font_style = (font_style or '') .. '; color: ' .. font_color .. ';'
- end
- end
- local navbar_style = args.style
- local div = mw.html.create():tag('div')
- div
- :addClass(cfg.classes.navbar)
- :addClass(cfg.classes.plainlinks)
- :addClass(cfg.classes.horizontal_list)
- :addClass(collapsible_class) -- we made the determination earlier
- :cssText(navbar_style)
- if is_mini then div:addClass(cfg.classes.mini) end
- local box_text = (args.text or cfg.box_text) .. ' '
- -- the concatenated space guarantees the box text is separated
- if not (is_mini or is_plain) then
- div
- :tag('span')
- :addClass(cfg.classes.box_text)
- :cssText(font_style)
- :wikitext(box_text)
- end
- local template = args.template
- local displayed_links = choose_links(template, args)
- local has_brackets = args.brackets
- local title_arg = get_title_arg(is_collapsible, template)
- local title_text = args[title_arg] or (':' .. mw.getCurrentFrame():getParent():getTitle())
- local list = make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
- div:node(list)
- if is_collapsible then
- local title_text_class
- if is_mini then
- title_text_class = cfg.classes.collapsible_title_mini
- else
- title_text_class = cfg.classes.collapsible_title_full
- end
- div:done()
- :tag('div')
- :addClass(title_text_class)
- :cssText(font_style)
- :wikitext(args[1])
- end
- return mw.getCurrentFrame():extensionTag{
- name = 'templatestyles', args = { src = cfg.templatestyles }
- } .. tostring(div:done())
- end
- function p.navbar(frame)
- return p._navbar(require('Module:Arguments').getArgs(frame))
- end
- return p</text>
- <sha1>jd5no8v1zi4m1e6lvbwo0a9t0kogdvi</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Navbar/configuration</title>
- <ns>828</ns>
- <id>66010105</id>
- <revision>
- <id>1054995103</id>
- <parentid>992950717</parentid>
- <timestamp>2021-11-13T05:39:10Z</timestamp>
- <contributor>
- <username>Izno</username>
- <id>2927383</id>
- </contributor>
- <comment>well, since I edited the other one...</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="867" xml:space="preserve">return {
- ['templatestyles'] = 'Module:Navbar/styles.css',
- ['box_text'] = 'This box: ', -- default text box when not plain or mini
- ['title_namespace'] = 'Template', -- namespace to default to for title
- ['invalid_title'] = 'Invalid title ',
- ['classes'] = { -- set a line to nil if you don't want it
- ['navbar'] = 'navbar',
- ['plainlinks'] = 'plainlinks', -- plainlinks
- ['horizontal_list'] = 'hlist', -- horizontal list class
- ['mini'] = 'navbar-mini', -- class indicating small links in the navbar
- ['this_box'] = 'navbar-boxtext',
- ['brackets'] = 'navbar-brackets',
- -- 'collapsible' is the key for a class to indicate the navbar is
- -- setting up the collapsible element in addition to the normal
- -- navbar.
- ['collapsible'] = 'navbar-collapse',
- ['collapsible_title_mini'] = 'navbar-ct-mini',
- ['collapsible_title_full'] = 'navbar-ct-full'
- }
- }</text>
- <sha1>lydm72m86hfvyzj0u2lqfps9lz9gquk</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Navbox</title>
- <ns>828</ns>
- <id>38634746</id>
- <revision>
- <id>1064341473</id>
- <parentid>1057332100</parentid>
- <timestamp>2022-01-07T21:39:23Z</timestamp>
- <contributor>
- <username>Izno</username>
- <id>2927383</id>
- </contributor>
- <comment>remove titlegroup per templatestyles section on talk page</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="16064" xml:space="preserve">local p = {}
- local navbar = require('Module:Navbar')._navbar
- local cfg = mw.loadData('Module:Navbox/configuration')
- local getArgs -- lazily initialized
- local args
- local format = string.format
- local function striped(wikitext, border)
- -- Return wikitext with markers replaced for odd/even striping.
- -- Child (subgroup) navboxes are flagged with a category that is removed
- -- by parent navboxes. The result is that the category shows all pages
- -- where a child navbox is not contained in a parent navbox.
- local orphanCat = cfg.category.orphan
- if border == cfg.keyword.border_subgroup and args[cfg.arg.orphan] ~= cfg.keyword.orphan_yes then
- -- No change; striping occurs in outermost navbox.
- return wikitext .. orphanCat
- end
- local first, second = cfg.class.navbox_odd_part, cfg.class.navbox_even_part
- if args[cfg.arg.evenodd] then
- if args[cfg.arg.evenodd] == cfg.keyword.evenodd_swap then
- first, second = second, first
- else
- first = args[cfg.arg.evenodd]
- second = first
- end
- end
- local changer
- if first == second then
- changer = first
- else
- local index = 0
- changer = function (code)
- if code == '0' then
- -- Current occurrence is for a group before a nested table.
- -- Set it to first as a valid although pointless class.
- -- The next occurrence will be the first row after a title
- -- in a subgroup and will also be first.
- index = 0
- return first
- end
- index = index + 1
- return index % 2 == 1 and first or second
- end
- end
- local regex = orphanCat:gsub('([%[%]])', '%%%1')
- return (wikitext:gsub(regex, ''):gsub(cfg.marker.regex, changer)) -- () omits gsub count
- end
- local function processItem(item, nowrapitems)
- if item:sub(1, 2) == '{|' then
- -- Applying nowrap to lines in a table does not make sense.
- -- Add newlines to compensate for trim of x in |parm=x in a template.
- return '\n' .. item ..'\n'
- end
- if nowrapitems == cfg.keyword.nowrapitems_yes then
- local lines = {}
- for line in (item .. '\n'):gmatch('([^\n]*)\n') do
- local prefix, content = line:match('^([*:;#]+)%s*(.*)')
- if prefix and not content:match(cfg.pattern.nowrap) then
- line = format(cfg.nowrap_item, prefix, content)
- end
- table.insert(lines, line)
- end
- item = table.concat(lines, '\n')
- end
- if item:match('^[*:;#]') then
- return '\n' .. item ..'\n'
- end
- return item
- end
- -- we will want this later when we want to add tstyles for hlist/plainlist
- local function has_navbar()
- return args[cfg.arg.navbar] ~= cfg.keyword.navbar_off
- and args[cfg.arg.navbar] ~= cfg.keyword.navbar_plain
- and (
- args[cfg.arg.name]
- or mw.getCurrentFrame():getParent():getTitle():gsub(cfg.pattern.sandbox, '')
- ~= cfg.pattern.navbox
- )
- end
- local function renderNavBar(titleCell)
- if has_navbar() then
- titleCell:wikitext(navbar{
- [cfg.navbar.name] = args[cfg.arg.name],
- [cfg.navbar.mini] = 1,
- [cfg.navbar.fontstyle] = (args[cfg.arg.basestyle] or '') .. ';' ..
- (args[cfg.arg.titlestyle] or '') ..
- ';background:none transparent;border:none;box-shadow:none;padding:0;'
- })
- end
- end
- local function renderTitleRow(tbl)
- if not args[cfg.arg.title] then return end
- local titleRow = tbl:tag('tr')
- local titleCell = titleRow:tag('th'):attr('scope', 'col')
- local titleColspan = 2
- if args[cfg.arg.imageleft] then titleColspan = titleColspan + 1 end
- if args[cfg.arg.image] then titleColspan = titleColspan + 1 end
- titleCell
- :cssText(args[cfg.arg.basestyle])
- :cssText(args[cfg.arg.titlestyle])
- :addClass(cfg.class.navbox_title)
- :attr('colspan', titleColspan)
- renderNavBar(titleCell)
- titleCell
- :tag('div')
- -- id for aria-labelledby attribute
- :attr('id', mw.uri.anchorEncode(args[cfg.arg.title]))
- :addClass(args[cfg.arg.titleclass])
- :css('font-size', '114%')
- :css('margin', '0 4em')
- :wikitext(processItem(args[cfg.arg.title]))
- end
- local function getAboveBelowColspan()
- local ret = 2
- if args[cfg.arg.imageleft] then ret = ret + 1 end
- if args[cfg.arg.image] then ret = ret + 1 end
- return ret
- end
- local function renderAboveRow(tbl)
- if not args[cfg.arg.above] then return end
- tbl:tag('tr')
- :tag('td')
- :addClass(cfg.class.navbox_abovebelow)
- :addClass(args[cfg.arg.aboveclass])
- :cssText(args[cfg.arg.basestyle])
- :cssText(args[cfg.arg.abovestyle])
- :attr('colspan', getAboveBelowColspan())
- :tag('div')
- -- id for aria-labelledby attribute, if no title
- :attr('id', args[cfg.arg.title] and nil or mw.uri.anchorEncode(args[cfg.arg.above]))
- :wikitext(processItem(args[cfg.arg.above], args[cfg.arg.nowrapitems]))
- end
- local function renderBelowRow(tbl)
- if not args[cfg.arg.below] then return end
- tbl:tag('tr')
- :tag('td')
- :addClass(cfg.class.navbox_abovebelow)
- :addClass(args[cfg.arg.belowclass])
- :cssText(args[cfg.arg.basestyle])
- :cssText(args[cfg.arg.belowstyle])
- :attr('colspan', getAboveBelowColspan())
- :tag('div')
- :wikitext(processItem(args[cfg.arg.below], args[cfg.arg.nowrapitems]))
- end
- local function renderListRow(tbl, index, listnum, listnums_size)
- local row = tbl:tag('tr')
- if index == 1 and args[cfg.arg.imageleft] then
- row
- :tag('td')
- :addClass(cfg.class.noviewer)
- :addClass(cfg.class.navbox_image)
- :addClass(args[cfg.arg.imageclass])
- :css('width', '1px') -- Minimize width
- :css('padding', '0 2px 0 0')
- :cssText(args[cfg.arg.imageleftstyle])
- :attr('rowspan', listnums_size)
- :tag('div')
- :wikitext(processItem(args[cfg.arg.imageleft]))
- end
- local group_and_num = format(cfg.arg.group_and_num, listnum)
- local groupstyle_and_num = format(cfg.arg.groupstyle_and_num, listnum)
- if args[group_and_num] then
- local groupCell = row:tag('th')
- -- id for aria-labelledby attribute, if lone group with no title or above
- if listnum == 1 and not (args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group2]) then
- groupCell
- :attr('id', mw.uri.anchorEncode(args[cfg.arg.group1]))
- end
- groupCell
- :attr('scope', 'row')
- :addClass(cfg.class.navbox_group)
- :addClass(args[cfg.arg.groupclass])
- :cssText(args[cfg.arg.basestyle])
- -- If groupwidth not specified, minimize width
- :css('width', args[cfg.arg.groupwidth] or '1%')
- groupCell
- :cssText(args[cfg.arg.groupstyle])
- :cssText(args[groupstyle_and_num])
- :wikitext(args[group_and_num])
- end
- local listCell = row:tag('td')
- if args[group_and_num] then
- listCell
- :addClass(cfg.class.navbox_list_with_group)
- else
- listCell:attr('colspan', 2)
- end
- if not args[cfg.arg.groupwidth] then
- listCell:css('width', '100%')
- end
- local rowstyle -- usually nil so cssText(rowstyle) usually adds nothing
- if index % 2 == 1 then
- rowstyle = args[cfg.arg.oddstyle]
- else
- rowstyle = args[cfg.arg.evenstyle]
- end
- local list_and_num = format(cfg.arg.list_and_num, listnum)
- local listText = args[list_and_num]
- local oddEven = cfg.marker.oddeven
- if listText:sub(1, 12) == '</div><table' then
- -- Assume list text is for a subgroup navbox so no automatic striping for this row.
- oddEven = listText:find(cfg.pattern.navbox_title) and cfg.marker.restart or cfg.class.navbox_odd_part
- end
- local liststyle_and_num = format(cfg.arg.liststyle_and_num, listnum)
- local listclass_and_num = format(cfg.arg.listclass_and_num, listnum)
- listCell
- :css('padding', '0')
- :cssText(args[cfg.arg.liststyle])
- :cssText(rowstyle)
- :cssText(args[liststyle_and_num])
- :addClass(cfg.class.navbox_list)
- :addClass(cfg.class.navbox_part .. oddEven)
- :addClass(args[cfg.arg.listclass])
- :addClass(args[listclass_and_num])
- :tag('div')
- :css('padding',
- (index == 1 and args[cfg.arg.list1padding]) or args[cfg.arg.listpadding] or '0 0.25em'
- )
- :wikitext(processItem(listText, args[cfg.arg.nowrapitems]))
- if index == 1 and args[cfg.arg.image] then
- row
- :tag('td')
- :addClass(cfg.class.noviewer)
- :addClass(cfg.class.navbox_image)
- :addClass(args[cfg.arg.imageclass])
- :css('width', '1px') -- Minimize width
- :css('padding', '0 0 0 2px')
- :cssText(args[cfg.arg.imagestyle])
- :attr('rowspan', listnums_size)
- :tag('div')
- :wikitext(processItem(args[cfg.arg.image]))
- end
- end
- -- uses this now to make the needHlistCategory correct
- -- to use later for when we add list styles via navbox
- local function has_list_class(htmlclass)
- local class_args = { -- rough order of probability of use
- cfg.arg.bodyclass, cfg.arg.listclass, cfg.arg.aboveclass,
- cfg.arg.belowclass, cfg.arg.titleclass, cfg.arg.navboxclass,
- cfg.arg.groupclass, cfg.arg.imageclass
- }
- local patterns = {
- '^' .. htmlclass .. '$',
- '%s' .. htmlclass .. '$',
- '^' .. htmlclass .. '%s',
- '%s' .. htmlclass .. '%s'
- }
- for _, arg in ipairs(class_args) do
- for _, pattern in ipairs(patterns) do
- if mw.ustring.find(args[arg] or '', pattern) then
- return true
- end
- end
- end
- return false
- end
- local function needsHorizontalLists(border)
- if border == cfg.keyword.border_subgroup or args[cfg.arg.tracking] == cfg.keyword.tracking_no then
- return false
- end
- return not has_list_class(cfg.pattern.hlist) and not has_list_class(cfg.pattern.plainlist)
- end
- local function hasBackgroundColors()
- for _, key in ipairs({cfg.arg.titlestyle, cfg.arg.groupstyle,
- cfg.arg.basestyle, cfg.arg.abovestyle, cfg.arg.belowstyle}) do
- if tostring(args[key]):find('background', 1, true) then
- return true
- end
- end
- return false
- end
- local function hasBorders()
- for _, key in ipairs({cfg.arg.groupstyle, cfg.arg.basestyle,
- cfg.arg.abovestyle, cfg.arg.belowstyle}) do
- if tostring(args[key]):find('border', 1, true) then
- return true
- end
- end
- return false
- end
- local function isIllegible()
- local styleratio = require('Module:Color contrast')._styleratio
- for key, style in pairs(args) do
- if tostring(key):match(cfg.pattern.style) then
- if styleratio{mw.text.unstripNoWiki(style)} < 4.5 then
- return true
- end
- end
- end
- return false
- end
- local function getTrackingCategories(border)
- local cats = {}
- if needsHorizontalLists(border) then table.insert(cats, cfg.category.horizontal_lists) end
- if hasBackgroundColors() then table.insert(cats, cfg.category.background_colors) end
- if isIllegible() then table.insert(cats, cfg.category.illegible) end
- if hasBorders() then table.insert(cats, cfg.category.borders) end
- return cats
- end
- local function renderTrackingCategories(builder, border)
- local title = mw.title.getCurrentTitle()
- if title.namespace ~= 10 then return end -- not in template space
- local subpage = title.subpageText
- if subpage == cfg.keyword.subpage_doc or subpage == cfg.keyword.subpage_sandbox
- or subpage == cfg.keyword.subpage_testcases then return end
- for _, cat in ipairs(getTrackingCategories(border)) do
- builder:wikitext('[[Category:' .. cat .. ']]')
- end
- end
- local function renderMainTable(border, listnums)
- local tbl = mw.html.create('table')
- :addClass(cfg.class.nowraplinks)
- :addClass(args[cfg.arg.bodyclass])
- local state = args[cfg.arg.state]
- if args[cfg.arg.title] and state ~= cfg.keyword.state_plain and state ~= cfg.keyword.state_off then
- if state == cfg.keyword.state_collapsed then
- state = cfg.class.collapsed
- end
- tbl
- :addClass(cfg.class.collapsible)
- :addClass(state or cfg.class.autocollapse)
- end
- tbl:css('border-spacing', 0)
- if border == cfg.keyword.border_subgroup or border == cfg.keyword.border_none then
- tbl
- :addClass(cfg.class.navbox_subgroup)
- :cssText(args[cfg.arg.bodystyle])
- :cssText(args[cfg.arg.style])
- else -- regular navbox - bodystyle and style will be applied to the wrapper table
- tbl
- :addClass(cfg.class.navbox_inner)
- :css('background', 'transparent')
- :css('color', 'inherit')
- end
- tbl:cssText(args[cfg.arg.innerstyle])
- renderTitleRow(tbl)
- renderAboveRow(tbl)
- local listnums_size = #listnums
- for i, listnum in ipairs(listnums) do
- renderListRow(tbl, i, listnum, listnums_size)
- end
- renderBelowRow(tbl)
- return tbl
- end
- local function add_navbox_styles()
- local frame = mw.getCurrentFrame()
- -- This is a lambda so that it doesn't need the frame as a parameter
- local function add_user_styles(templatestyles)
- if templatestyles and templatestyles ~= '' then
- return frame:extensionTag{
- name = 'templatestyles', args = { src = templatestyles }
- }
- end
- return ''
- end
- -- get templatestyles. load base from config so that Lua only needs to do
- -- the work once of parser tag expansion
- local base_templatestyles = cfg.templatestyles
- local templatestyles = add_user_styles(args[cfg.arg.templatestyles])
- local child_templatestyles = add_user_styles(args[cfg.arg.child_templatestyles])
- -- The 'navbox-styles' div exists for two reasons:
- -- 1. To wrap the styles to work around T200206 more elegantly. Instead
- -- of combinatorial rules, this ends up being linear number of CSS rules.
- -- 2. To allow MobileFrontend to rip the styles out with 'nomobile' such that
- -- they are not dumped into the mobile view.
- return mw.html.create('div')
- :addClass(cfg.class.navbox_styles)
- :addClass(cfg.class.nomobile)
- :wikitext(base_templatestyles .. templatestyles .. child_templatestyles)
- :done()
- end
- function p._navbox(navboxArgs)
- args = navboxArgs
- local listnums = {}
- for k, _ in pairs(args) do
- if type(k) == 'string' then
- local listnum = k:match(cfg.pattern.listnum)
- if listnum then table.insert(listnums, tonumber(listnum)) end
- end
- end
- table.sort(listnums)
- local border = mw.text.trim(args[cfg.arg.border] or args[1] or '')
- if border == cfg.keyword.border_child then
- border = cfg.keyword.border_subgroup
- end
- -- render the main body of the navbox
- local tbl = renderMainTable(border, listnums)
- local res = mw.html.create()
- -- render the appropriate wrapper for the navbox, based on the border param
- if border == cfg.keyword.border_none then
- res:node(add_navbox_styles())
- local nav = res:tag('div')
- :attr('role', 'navigation')
- :node(tbl)
- -- aria-labelledby title, otherwise above, otherwise lone group
- if args[cfg.arg.title] or args[cfg.arg.above] or (args[cfg.arg.group1]
- and not args[cfg.arg.group2]) then
- nav:attr(
- 'aria-labelledby',
- mw.uri.anchorEncode(
- args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group1]
- )
- )
- else
- nav:attr('aria-label', cfg.aria_label)
- end
- elseif border == cfg.keyword.border_subgroup then
- -- We assume that this navbox is being rendered in a list cell of a
- -- parent navbox, and is therefore inside a div with padding:0em 0.25em.
- -- We start with a </div> to avoid the padding being applied, and at the
- -- end add a <div> to balance out the parent's </div>
- res
- :wikitext('</div>')
- :node(tbl)
- :wikitext('<div>')
- else
- res:node(add_navbox_styles())
- local nav = res:tag('div')
- :attr('role', 'navigation')
- :addClass(cfg.class.navbox)
- :addClass(args[cfg.arg.navboxclass])
- :cssText(args[cfg.arg.bodystyle])
- :cssText(args[cfg.arg.style])
- :css('padding', '3px')
- :node(tbl)
- -- aria-labelledby title, otherwise above, otherwise lone group
- if args[cfg.arg.title] or args[cfg.arg.above]
- or (args[cfg.arg.group1] and not args[cfg.arg.group2]) then
- nav:attr(
- 'aria-labelledby',
- mw.uri.anchorEncode(args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group1])
- )
- else
- nav:attr('aria-label', cfg.aria_label)
- end
- end
- if (args[cfg.arg.nocat] or cfg.keyword.nocat_false):lower() == cfg.keyword.nocat_false then
- renderTrackingCategories(res, border)
- end
- return striped(tostring(res), border)
- end
- function p.navbox(frame)
- if not getArgs then
- getArgs = require('Module:Arguments').getArgs
- end
- args = getArgs(frame, {wrappers = {cfg.pattern.navbox}})
- -- Read the arguments in the order they'll be output in, to make references
- -- number in the right order.
- local _
- _ = args[cfg.arg.title]
- _ = args[cfg.arg.above]
- -- Limit this to 20 as covering 'most' cases (that's a SWAG) and because
- -- iterator approach won't work here
- for i = 1, 20 do
- _ = args[format(cfg.arg.group_and_num, i)]
- _ = args[format(cfg.arg.list_and_num, i)]
- end
- _ = args[cfg.arg.below]
- return p._navbox(args)
- end
- return p</text>
- <sha1>aps8opqyleqagctjqmi5zb3x6sq8mux</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Navbox/configuration</title>
- <ns>828</ns>
- <id>67685668</id>
- <revision>
- <id>1064341544</id>
- <parentid>1057330154</parentid>
- <timestamp>2022-01-07T21:39:52Z</timestamp>
- <contributor>
- <username>Izno</username>
- <id>2927383</id>
- </contributor>
- <comment>remove titlegroup</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="3597" xml:space="preserve">return {
- aria_label = 'Navbox',
- nowrap_item = '%s<span class="nowrap">%s</span>',
- templatestyles = mw.getCurrentFrame():extensionTag{
- name = 'templatestyles', args = { src = 'Module:Navbox/styles.css' }
- },
- -- do not localize marker table
- marker = {
- oddeven = '\127_ODDEVEN_\127',
- restart = '\127_ODDEVEN0_\127',
- regex = '\127_ODDEVEN(%d?)_\127'
- },
- category = {
- orphan = '[[Category:Navbox orphans]]',
- horizontal_lists = 'Navigational boxes without horizontal lists',
- background_colors = 'Navboxes using background colours',
- illegible = 'Potentially illegible navboxes',
- borders = 'Navboxes using borders',
- },
- keyword = {
- border_subgroup = 'subgroup',
- border_child = 'child',
- border_none = 'none',
- evenodd_swap = 'swap',
- navbar_off = 'off',
- navbar_plain = 'plain',
- nocat_false = 'false',
- nowrapitems_yes = 'yes',
- orphan_yes = 'yes',
- state_collapsed = 'collapsed',
- state_off = 'off',
- state_plain = 'plain',
- subpage_doc = 'doc',
- subpage_sandbox = 'sandbox',
- subpage_testcases = 'testcases',
- tracking_no = 'no'
- },
- class = {
- autocollapse = 'autocollapse',
- collapsible = 'mw-collapsible',
- collapsed = 'mw-collapsed',
- -- Warning
- navbox = 'navbox', -- WMF currently hides 'navbox' from mobile,
- -- so you probably shouldn't change the navbox class.
- navbox_abovebelow = 'navbox-abovebelow',
- navbox_group = 'navbox-group',
- navbox_image = 'navbox-image',
- navbox_inner = 'navbox-inner',
- navbox_list = 'navbox-list',
- navbox_list_with_group = 'navbox-list-with-group',
- navbox_part = 'navbox-', -- do not l10n
- navbox_styles = 'navbox-styles',
- navbox_subgroup = 'navbox-subgroup',
- navbox_title = 'navbox-title', -- l10n only if you change pattern.navbox_title below
- navbox_odd_part = 'odd', -- do not l10n
- navbox_even_part = 'even', -- do not l10n
- nomobile = 'nomobile',
- nowraplinks = 'nowraplinks',
- noviewer = 'noviewer' -- used to remove images from MediaViewer
- },
- pattern = {
- listnum = '^list(%d+)$',
- sandbox = '/sandbox$',
- navbox = 'Template:Navbox',
- nowrap = '^<span class="nowrap">',
- style = 'style$',
- navbox_title = '<th[^>]*"navbox%-title"',
- hlist = 'hlist',
- plainlist = 'plainlist'
- },
- arg = {
- above = 'above',
- aboveclass = 'aboveclass',
- abovestyle = 'abovestyle',
- basestyle = 'basestyle',
- bodyclass = 'bodyclass',
- bodystyle = 'bodystyle',
- border = 'border',
- below = 'below',
- belowclass = 'belowclass',
- belowstyle = 'belowstyle',
- evenodd = 'evenodd',
- evenstyle = 'evenstyle',
- group1 = 'group1',
- group2 = 'group2',
- group_and_num = 'group%d',
- groupstyle_and_num = 'group%dstyle',
- groupclass = 'groupclass',
- groupstyle = 'groupstyle',
- groupwidth = 'groupwidth',
- innerstyle = 'innerstyle',
- image = 'image',
- imageclass = 'imageclass',
- imageleft = 'imageleft',
- imageleftstyle = 'imageleftstyle',
- imagesetyle = 'imagestyle',
- list_and_num = 'list%d',
- listclass_and_num = 'list%dclass',
- liststyle_and_num = 'list%dstyle',
- list1padding = 'list1padding',
- listclass = 'listclass',
- listpadding = 'listpadding',
- liststyle = 'liststyle',
- name = 'name',
- navbar = 'navbar',
- navboxclass = 'navboxclass',
- nocat = 'nocat',
- nowrapitems = 'nowrapitems',
- oddstyle = 'oddstyle',
- orphan = 'orphan',
- state = 'state',
- style = 'style',
- templatestyles = 'templatestyles',
- child_templatestyles = 'child templatestyles',
- title = 'title',
- titleclass = 'titleclass',
- titlestyle = 'titlestyle',
- tracking = 'tracking'
- },
- -- names of navbar arguments
- navbar = {
- name = 1,
- fontstyle = 'fontstyle',
- mini = 'mini'
- }
- }</text>
- <sha1>8npf15277sgmgep5j2bnmes7i7ktuvo</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Navbox/styles.css</title>
- <ns>828</ns>
- <id>69272159</id>
- <revision>
- <id>1061467846</id>
- <parentid>1057682214</parentid>
- <timestamp>2021-12-21T22:10:10Z</timestamp>
- <contributor>
- <username>Izno</username>
- <id>2927383</id>
- </contributor>
- <comment>remove qualifications on th - this will remove styling from "hand-crafted" navboxes, but there's no other elegant way to deal with it. see talk page</comment>
- <model>sanitized-css</model>
- <format>text/css</format>
- <text bytes="2183" xml:space="preserve">/* {{pp|small=y}} */
- .navbox {
- box-sizing: border-box;
- border: 1px solid #a2a9b1;
- width: 100%;
- clear: both;
- font-size: 88%;
- text-align: center;
- padding: 1px;
- margin: 1em auto 0; /* Prevent preceding content from clinging to navboxes */
- }
- .navbox .navbox {
- margin-top: 0; /* No top margin for nested navboxes */
- }
- .navbox + .navbox, /* TODO: remove first line after transclusions have updated */
- .navbox + .navbox-styles + .navbox {
- margin-top: -1px; /* Single pixel border between adjacent navboxes */
- }
- .navbox-inner,
- .navbox-subgroup {
- width: 100%;
- }
- .navbox-group,
- .navbox-title,
- .navbox-abovebelow {
- padding: 0.25em 1em;
- line-height: 1.5em;
- text-align: center;
- }
- .navbox-group {
- white-space: nowrap;
- /* @noflip */
- text-align: right;
- }
- .navbox,
- .navbox-subgroup {
- background-color: #fdfdfd;
- }
- .navbox-list {
- line-height: 1.5em;
- border-color: #fdfdfd; /* Must match background color */
- }
- .navbox-list-with-group {
- text-align: left;
- border-left-width: 2px;
- border-left-style: solid;
- }
- /* cell spacing for navbox cells */
- /* Borders above 2nd, 3rd, etc. rows */
- /* TODO: figure out how to replace tr as structure;
- * with div structure it should be just a matter of first-child */
- tr + tr > .navbox-abovebelow,
- tr + tr > .navbox-group,
- tr + tr > .navbox-image,
- tr + tr > .navbox-list {
- border-top: 2px solid #fdfdfd; /* Must match background color */
- }
- .navbox-title {
- background-color: #ccf; /* Level 1 color */
- }
- .navbox-abovebelow,
- .navbox-group,
- .navbox-subgroup .navbox-title {
- background-color: #ddf; /* Level 2 color */
- }
- .navbox-subgroup .navbox-group,
- .navbox-subgroup .navbox-abovebelow {
- background-color: #e6e6ff; /* Level 3 color */
- }
- .navbox-even {
- background-color: #f7f7f7;
- }
- .navbox-odd {
- background-color: transparent;
- }
- /* TODO: figure out how to remove reliance on td as structure */
- .navbox .hlist td dl,
- .navbox .hlist td ol,
- .navbox .hlist td ul,
- .navbox td.hlist dl,
- .navbox td.hlist ol,
- .navbox td.hlist ul {
- padding: 0.125em 0;
- }
- .navbox .navbar {
- display: block;
- font-size: 100%;
- }
- .navbox-title .navbar {
- /* @noflip */
- float: left;
- /* @noflip */
- text-align: left;
- /* @noflip */
- margin-right: 0.5em;
- }</text>
- <sha1>r3sdo030s2y37osfqh0rur7i26x9epy</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Navboxes/doc</title>
- <ns>828</ns>
- <id>63365392</id>
- <revision>
- <id>1061627648</id>
- <parentid>945403484</parentid>
- <timestamp>2021-12-22T21:38:23Z</timestamp>
- <contributor>
- <username>GKFX</username>
- <id>14918984</id>
- </contributor>
- <comment>Mark high-use</comment>
- <model>wikitext</model>
- <format>text/x-wiki</format>
- <text bytes="48" xml:space="preserve">{{high-use}}
- Implements most of {{tl|Navboxes}}.</text>
- <sha1>lzmsnzuow65l1zfmr9bkiuvidrg9z4s</sha1>
- </revision>
- </page>
- <page>
- <title>Module:No globals</title>
- <ns>828</ns>
- <id>42567026</id>
- <revision>
- <id>948473889</id>
- <parentid>948472526</parentid>
- <timestamp>2020-04-01T06:28:55Z</timestamp>
- <contributor>
- <username>MusikAnimal</username>
- <id>14882394</id>
- </contributor>
- <comment>Undid revision 948472525 by [[Special:Contributions/w>DiBabelYurikBot|w>DiBabelYurikBot]] ([[User talk:w>DiBabelYurikBot|talk]])</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="307" xml:space="preserve">local mt = getmetatable(_G) or {}
- function mt.__index (t, k)
- if k ~= 'arg' then
- error('Tried to read nil global ' .. tostring(k), 2)
- end
- return nil
- end
- function mt.__newindex(t, k, v)
- if k ~= 'arg' then
- error('Tried to write global ' .. tostring(k), 2)
- end
- rawset(t, k, v)
- end
- setmetatable(_G, mt)</text>
- <sha1>gggsv54pq7f94l3up48hr91qtxnskdm</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Protection banner</title>
- <ns>828</ns>
- <id>42040984</id>
- <revision>
- <id>1033879006</id>
- <parentid>1013845490</parentid>
- <timestamp>2021-07-16T11:59:29Z</timestamp>
- <contributor>
- <username>ProcrastinatingReader</username>
- <id>32939139</id>
- </contributor>
- <comment>add catonly param which hides both the banner and padlock if set to yes. all testcases pass. tested in sandbox.</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="26029" xml:space="preserve">-- This module implements {{pp-meta}} and its daughter templates such as
- -- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}.
- -- Initialise necessary modules.
- require('Module:No globals')
- local makeFileLink = require('Module:File link')._main
- local effectiveProtectionLevel = require('Module:Effective protection level')._main
- local effectiveProtectionExpiry = require('Module:Effective protection expiry')._main
- local yesno = require('Module:Yesno')
- -- Lazily initialise modules and objects we don't always need.
- local getArgs, makeMessageBox, lang
- -- Set constants.
- local CONFIG_MODULE = 'Module:Protection banner/config'
- --------------------------------------------------------------------------------
- -- Helper functions
- --------------------------------------------------------------------------------
- local function makeCategoryLink(cat, sort)
- if cat then
- return string.format(
- '[[%s:%s|%s]]',
- mw.site.namespaces[14].name,
- cat,
- sort
- )
- end
- end
- -- Validation function for the expiry and the protection date
- local function validateDate(dateString, dateType)
- if not lang then
- lang = mw.language.getContentLanguage()
- end
- local success, result = pcall(lang.formatDate, lang, 'U', dateString)
- if success then
- result = tonumber(result)
- if result then
- return result
- end
- end
- error(string.format(
- 'invalid %s: %s',
- dateType,
- tostring(dateString)
- ), 4)
- end
- local function makeFullUrl(page, query, display)
- return string.format(
- '[%s %s]',
- tostring(mw.uri.fullUrl(page, query)),
- display
- )
- end
- -- Given a directed graph formatted as node -> table of direct successors,
- -- get a table of all nodes reachable from a given node (though always
- -- including the given node).
- local function getReachableNodes(graph, start)
- local toWalk, retval = {[start] = true}, {}
- while true do
- -- Can't use pairs() since we're adding and removing things as we're iterating
- local k = next(toWalk) -- This always gets the "first" key
- if k == nil then
- return retval
- end
- toWalk[k] = nil
- retval[k] = true
- for _,v in ipairs(graph[k]) do
- if not retval[v] then
- toWalk[v] = true
- end
- end
- end
- end
- --------------------------------------------------------------------------------
- -- Protection class
- --------------------------------------------------------------------------------
- local Protection = {}
- Protection.__index = Protection
- Protection.supportedActions = {
- edit = true,
- move = true,
- autoreview = true,
- upload = true
- }
- Protection.bannerConfigFields = {
- 'text',
- 'explanation',
- 'tooltip',
- 'alt',
- 'link',
- 'image'
- }
- function Protection.new(args, cfg, title)
- local obj = {}
- obj._cfg = cfg
- obj.title = title or mw.title.getCurrentTitle()
- -- Set action
- if not args.action then
- obj.action = 'edit'
- elseif Protection.supportedActions[args.action] then
- obj.action = args.action
- else
- error(string.format(
- 'invalid action: %s',
- tostring(args.action)
- ), 3)
- end
- -- Set level
- obj.level = args.demolevel or effectiveProtectionLevel(obj.action, obj.title)
- if not obj.level or (obj.action == 'move' and obj.level == 'autoconfirmed') then
- -- Users need to be autoconfirmed to move pages anyway, so treat
- -- semi-move-protected pages as unprotected.
- obj.level = '*'
- end
- -- Set expiry
- local effectiveExpiry = effectiveProtectionExpiry(obj.action, obj.title)
- if effectiveExpiry == 'infinity' then
- obj.expiry = 'indef'
- elseif effectiveExpiry ~= 'unknown' then
- obj.expiry = validateDate(effectiveExpiry, 'expiry date')
- end
- -- Set reason
- if args[1] then
- obj.reason = mw.ustring.lower(args[1])
- if obj.reason:find('|') then
- error('reasons cannot contain the pipe character ("|")', 3)
- end
- end
- -- Set protection date
- if args.date then
- obj.protectionDate = validateDate(args.date, 'protection date')
- end
- -- Set banner config
- do
- obj.bannerConfig = {}
- local configTables = {}
- if cfg.banners[obj.action] then
- configTables[#configTables + 1] = cfg.banners[obj.action][obj.reason]
- end
- if cfg.defaultBanners[obj.action] then
- configTables[#configTables + 1] = cfg.defaultBanners[obj.action][obj.level]
- configTables[#configTables + 1] = cfg.defaultBanners[obj.action].default
- end
- configTables[#configTables + 1] = cfg.masterBanner
- for i, field in ipairs(Protection.bannerConfigFields) do
- for j, t in ipairs(configTables) do
- if t[field] then
- obj.bannerConfig[field] = t[field]
- break
- end
- end
- end
- end
- return setmetatable(obj, Protection)
- end
- function Protection:isUserScript()
- -- Whether the page is a user JavaScript or CSS page.
- local title = self.title
- return title.namespace == 2 and (
- title.contentModel == 'javascript' or title.contentModel == 'css'
- )
- end
- function Protection:isProtected()
- return self.level ~= '*'
- end
- function Protection:shouldShowLock()
- -- Whether we should output a banner/padlock
- return self:isProtected() and not self:isUserScript()
- end
- -- Whether this page needs a protection category.
- Protection.shouldHaveProtectionCategory = Protection.shouldShowLock
- function Protection:isTemporary()
- return type(self.expiry) == 'number'
- end
- function Protection:makeProtectionCategory()
- if not self:shouldHaveProtectionCategory() then
- return ''
- end
- local cfg = self._cfg
- local title = self.title
- -- Get the expiry key fragment.
- local expiryFragment
- if self.expiry == 'indef' then
- expiryFragment = self.expiry
- elseif type(self.expiry) == 'number' then
- expiryFragment = 'temp'
- end
- -- Get the namespace key fragment.
- local namespaceFragment = cfg.categoryNamespaceKeys[title.namespace]
- if not namespaceFragment and title.namespace % 2 == 1 then
- namespaceFragment = 'talk'
- end
- -- Define the order that key fragments are tested in. This is done with an
- -- array of tables containing the value to be tested, along with its
- -- position in the cfg.protectionCategories table.
- local order = {
- {val = expiryFragment, keypos = 1},
- {val = namespaceFragment, keypos = 2},
- {val = self.reason, keypos = 3},
- {val = self.level, keypos = 4},
- {val = self.action, keypos = 5}
- }
- --[[
- -- The old protection templates used an ad-hoc protection category system,
- -- with some templates prioritising namespaces in their categories, and
- -- others prioritising the protection reason. To emulate this in this module
- -- we use the config table cfg.reasonsWithNamespacePriority to set the
- -- reasons for which namespaces have priority over protection reason.
- -- If we are dealing with one of those reasons, move the namespace table to
- -- the end of the order table, i.e. give it highest priority. If not, the
- -- reason should have highest priority, so move that to the end of the table
- -- instead.
- --]]
- table.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] and 2 or 3))
- --[[
- -- Define the attempt order. Inactive subtables (subtables with nil "value"
- -- fields) are moved to the end, where they will later be given the key
- -- "all". This is to cut down on the number of table lookups in
- -- cfg.protectionCategories, which grows exponentially with the number of
- -- non-nil keys. We keep track of the number of active subtables with the
- -- noActive parameter.
- --]]
- local noActive, attemptOrder
- do
- local active, inactive = {}, {}
- for i, t in ipairs(order) do
- if t.val then
- active[#active + 1] = t
- else
- inactive[#inactive + 1] = t
- end
- end
- noActive = #active
- attemptOrder = active
- for i, t in ipairs(inactive) do
- attemptOrder[#attemptOrder + 1] = t
- end
- end
- --[[
- -- Check increasingly generic key combinations until we find a match. If a
- -- specific category exists for the combination of key fragments we are
- -- given, that match will be found first. If not, we keep trying different
- -- key fragment combinations until we match using the key
- -- "all-all-all-all-all".
- --
- -- To generate the keys, we index the key subtables using a binary matrix
- -- with indexes i and j. j is only calculated up to the number of active
- -- subtables. For example, if there were three active subtables, the matrix
- -- would look like this, with 0 corresponding to the key fragment "all", and
- -- 1 corresponding to other key fragments.
- --
- -- j 1 2 3
- -- i
- -- 1 1 1 1
- -- 2 0 1 1
- -- 3 1 0 1
- -- 4 0 0 1
- -- 5 1 1 0
- -- 6 0 1 0
- -- 7 1 0 0
- -- 8 0 0 0
- --
- -- Values of j higher than the number of active subtables are set
- -- to the string "all".
- --
- -- A key for cfg.protectionCategories is constructed for each value of i.
- -- The position of the value in the key is determined by the keypos field in
- -- each subtable.
- --]]
- local cats = cfg.protectionCategories
- for i = 1, 2^noActive do
- local key = {}
- for j, t in ipairs(attemptOrder) do
- if j > noActive then
- key[t.keypos] = 'all'
- else
- local quotient = i / 2 ^ (j - 1)
- quotient = math.ceil(quotient)
- if quotient % 2 == 1 then
- key[t.keypos] = t.val
- else
- key[t.keypos] = 'all'
- end
- end
- end
- key = table.concat(key, '|')
- local attempt = cats[key]
- if attempt then
- return makeCategoryLink(attempt, title.text)
- end
- end
- return ''
- end
- function Protection:isIncorrect()
- local expiry = self.expiry
- return not self:shouldHaveProtectionCategory()
- or type(expiry) == 'number' and expiry < os.time()
- end
- function Protection:isTemplateProtectedNonTemplate()
- local action, namespace = self.action, self.title.namespace
- return self.level == 'templateeditor'
- and (
- (action ~= 'edit' and action ~= 'move')
- or (namespace ~= 10 and namespace ~= 828)
- )
- end
- function Protection:makeCategoryLinks()
- local msg = self._cfg.msg
- local ret = {self:makeProtectionCategory()}
- if self:isIncorrect() then
- ret[#ret + 1] = makeCategoryLink(
- msg['tracking-category-incorrect'],
- self.title.text
- )
- end
- if self:isTemplateProtectedNonTemplate() then
- ret[#ret + 1] = makeCategoryLink(
- msg['tracking-category-template'],
- self.title.text
- )
- end
- return table.concat(ret)
- end
- --------------------------------------------------------------------------------
- -- Blurb class
- --------------------------------------------------------------------------------
- local Blurb = {}
- Blurb.__index = Blurb
- Blurb.bannerTextFields = {
- text = true,
- explanation = true,
- tooltip = true,
- alt = true,
- link = true
- }
- function Blurb.new(protectionObj, args, cfg)
- return setmetatable({
- _cfg = cfg,
- _protectionObj = protectionObj,
- _args = args
- }, Blurb)
- end
- -- Private methods --
- function Blurb:_formatDate(num)
- -- Formats a Unix timestamp into dd Month, YYYY format.
- lang = lang or mw.language.getContentLanguage()
- local success, date = pcall(
- lang.formatDate,
- lang,
- self._cfg.msg['expiry-date-format'] or 'j F Y',
- '@' .. tostring(num)
- )
- if success then
- return date
- end
- end
- function Blurb:_getExpandedMessage(msgKey)
- return self:_substituteParameters(self._cfg.msg[msgKey])
- end
- function Blurb:_substituteParameters(msg)
- if not self._params then
- local parameterFuncs = {}
- parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter
- parameterFuncs.EDITREQUEST = self._makeEditRequestParameter
- parameterFuncs.EXPIRY = self._makeExpiryParameter
- parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter
- parameterFuncs.IMAGELINK = self._makeImageLinkParameter
- parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter
- parameterFuncs.INTROFRAGMENT = self._makeIntroFragmentParameter
- parameterFuncs.PAGETYPE = self._makePagetypeParameter
- parameterFuncs.PROTECTIONBLURB = self._makeProtectionBlurbParameter
- parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter
- parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter
- parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter
- parameterFuncs.TALKPAGE = self._makeTalkPageParameter
- parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter
- parameterFuncs.TOOLTIPFRAGMENT = self._makeTooltipFragmentParameter
- parameterFuncs.VANDAL = self._makeVandalTemplateParameter
- self._params = setmetatable({}, {
- __index = function (t, k)
- local param
- if parameterFuncs[k] then
- param = parameterFuncs[k](self)
- end
- param = param or ''
- t[k] = param
- return param
- end
- })
- end
- msg = msg:gsub('${(%u+)}', self._params)
- return msg
- end
- function Blurb:_makeCurrentVersionParameter()
- -- A link to the page history or the move log, depending on the kind of
- -- protection.
- local pagename = self._protectionObj.title.prefixedText
- if self._protectionObj.action == 'move' then
- -- We need the move log link.
- return makeFullUrl(
- 'Special:Log',
- {type = 'move', page = pagename},
- self:_getExpandedMessage('current-version-move-display')
- )
- else
- -- We need the history link.
- return makeFullUrl(
- pagename,
- {action = 'history'},
- self:_getExpandedMessage('current-version-edit-display')
- )
- end
- end
- function Blurb:_makeEditRequestParameter()
- local mEditRequest = require('Module:Submit an edit request')
- local action = self._protectionObj.action
- local level = self._protectionObj.level
- -- Get the edit request type.
- local requestType
- if action == 'edit' then
- if level == 'autoconfirmed' then
- requestType = 'semi'
- elseif level == 'extendedconfirmed' then
- requestType = 'extended'
- elseif level == 'templateeditor' then
- requestType = 'template'
- end
- end
- requestType = requestType or 'full'
- -- Get the display value.
- local display = self:_getExpandedMessage('edit-request-display')
- return mEditRequest._link{type = requestType, display = display}
- end
- function Blurb:_makeExpiryParameter()
- local expiry = self._protectionObj.expiry
- if type(expiry) == 'number' then
- return self:_formatDate(expiry)
- else
- return expiry
- end
- end
- function Blurb:_makeExplanationBlurbParameter()
- -- Cover special cases first.
- if self._protectionObj.title.namespace == 8 then
- -- MediaWiki namespace
- return self:_getExpandedMessage('explanation-blurb-nounprotect')
- end
- -- Get explanation blurb table keys
- local action = self._protectionObj.action
- local level = self._protectionObj.level
- local talkKey = self._protectionObj.title.isTalkPage and 'talk' or 'subject'
- -- Find the message in the explanation blurb table and substitute any
- -- parameters.
- local explanations = self._cfg.explanationBlurbs
- local msg
- if explanations[action][level] and explanations[action][level][talkKey] then
- msg = explanations[action][level][talkKey]
- elseif explanations[action][level] and explanations[action][level].default then
- msg = explanations[action][level].default
- elseif explanations[action].default and explanations[action].default[talkKey] then
- msg = explanations[action].default[talkKey]
- elseif explanations[action].default and explanations[action].default.default then
- msg = explanations[action].default.default
- else
- error(string.format(
- 'could not find explanation blurb for action "%s", level "%s" and talk key "%s"',
- action,
- level,
- talkKey
- ), 8)
- end
- return self:_substituteParameters(msg)
- end
- function Blurb:_makeImageLinkParameter()
- local imageLinks = self._cfg.imageLinks
- local action = self._protectionObj.action
- local level = self._protectionObj.level
- local msg
- if imageLinks[action][level] then
- msg = imageLinks[action][level]
- elseif imageLinks[action].default then
- msg = imageLinks[action].default
- else
- msg = imageLinks.edit.default
- end
- return self:_substituteParameters(msg)
- end
- function Blurb:_makeIntroBlurbParameter()
- if self._protectionObj:isTemporary() then
- return self:_getExpandedMessage('intro-blurb-expiry')
- else
- return self:_getExpandedMessage('intro-blurb-noexpiry')
- end
- end
- function Blurb:_makeIntroFragmentParameter()
- if self._protectionObj:isTemporary() then
- return self:_getExpandedMessage('intro-fragment-expiry')
- else
- return self:_getExpandedMessage('intro-fragment-noexpiry')
- end
- end
- function Blurb:_makePagetypeParameter()
- local pagetypes = self._cfg.pagetypes
- return pagetypes[self._protectionObj.title.namespace]
- or pagetypes.default
- or error('no default pagetype defined', 8)
- end
- function Blurb:_makeProtectionBlurbParameter()
- local protectionBlurbs = self._cfg.protectionBlurbs
- local action = self._protectionObj.action
- local level = self._protectionObj.level
- local msg
- if protectionBlurbs[action][level] then
- msg = protectionBlurbs[action][level]
- elseif protectionBlurbs[action].default then
- msg = protectionBlurbs[action].default
- elseif protectionBlurbs.edit.default then
- msg = protectionBlurbs.edit.default
- else
- error('no protection blurb defined for protectionBlurbs.edit.default', 8)
- end
- return self:_substituteParameters(msg)
- end
- function Blurb:_makeProtectionDateParameter()
- local protectionDate = self._protectionObj.protectionDate
- if type(protectionDate) == 'number' then
- return self:_formatDate(protectionDate)
- else
- return protectionDate
- end
- end
- function Blurb:_makeProtectionLevelParameter()
- local protectionLevels = self._cfg.protectionLevels
- local action = self._protectionObj.action
- local level = self._protectionObj.level
- local msg
- if protectionLevels[action][level] then
- msg = protectionLevels[action][level]
- elseif protectionLevels[action].default then
- msg = protectionLevels[action].default
- elseif protectionLevels.edit.default then
- msg = protectionLevels.edit.default
- else
- error('no protection level defined for protectionLevels.edit.default', 8)
- end
- return self:_substituteParameters(msg)
- end
- function Blurb:_makeProtectionLogParameter()
- local pagename = self._protectionObj.title.prefixedText
- if self._protectionObj.action == 'autoreview' then
- -- We need the pending changes log.
- return makeFullUrl(
- 'Special:Log',
- {type = 'stable', page = pagename},
- self:_getExpandedMessage('pc-log-display')
- )
- else
- -- We need the protection log.
- return makeFullUrl(
- 'Special:Log',
- {type = 'protect', page = pagename},
- self:_getExpandedMessage('protection-log-display')
- )
- end
- end
- function Blurb:_makeTalkPageParameter()
- return string.format(
- '[[%s:%s#%s|%s]]',
- mw.site.namespaces[self._protectionObj.title.namespace].talk.name,
- self._protectionObj.title.text,
- self._args.section or 'top',
- self:_getExpandedMessage('talk-page-link-display')
- )
- end
- function Blurb:_makeTooltipBlurbParameter()
- if self._protectionObj:isTemporary() then
- return self:_getExpandedMessage('tooltip-blurb-expiry')
- else
- return self:_getExpandedMessage('tooltip-blurb-noexpiry')
- end
- end
- function Blurb:_makeTooltipFragmentParameter()
- if self._protectionObj:isTemporary() then
- return self:_getExpandedMessage('tooltip-fragment-expiry')
- else
- return self:_getExpandedMessage('tooltip-fragment-noexpiry')
- end
- end
- function Blurb:_makeVandalTemplateParameter()
- return mw.getCurrentFrame():expandTemplate{
- title="vandal-m",
- args={self._args.user or self._protectionObj.title.baseText}
- }
- end
- -- Public methods --
- function Blurb:makeBannerText(key)
- -- Validate input.
- if not key or not Blurb.bannerTextFields[key] then
- error(string.format(
- '"%s" is not a valid banner config field',
- tostring(key)
- ), 2)
- end
- -- Generate the text.
- local msg = self._protectionObj.bannerConfig[key]
- if type(msg) == 'string' then
- return self:_substituteParameters(msg)
- elseif type(msg) == 'function' then
- msg = msg(self._protectionObj, self._args)
- if type(msg) ~= 'string' then
- error(string.format(
- 'bad output from banner config function with key "%s"'
- .. ' (expected string, got %s)',
- tostring(key),
- type(msg)
- ), 4)
- end
- return self:_substituteParameters(msg)
- end
- end
- --------------------------------------------------------------------------------
- -- BannerTemplate class
- --------------------------------------------------------------------------------
- local BannerTemplate = {}
- BannerTemplate.__index = BannerTemplate
- function BannerTemplate.new(protectionObj, cfg)
- local obj = {}
- obj._cfg = cfg
- -- Set the image filename.
- local imageFilename = protectionObj.bannerConfig.image
- if imageFilename then
- obj._imageFilename = imageFilename
- else
- -- If an image filename isn't specified explicitly in the banner config,
- -- generate it from the protection status and the namespace.
- local action = protectionObj.action
- local level = protectionObj.level
- local namespace = protectionObj.title.namespace
- local reason = protectionObj.reason
- -- Deal with special cases first.
- if (
- namespace == 10
- or namespace == 828
- or reason and obj._cfg.indefImageReasons[reason]
- )
- and action == 'edit'
- and level == 'sysop'
- and not protectionObj:isTemporary()
- then
- -- Fully protected modules and templates get the special red "indef"
- -- padlock.
- obj._imageFilename = obj._cfg.msg['image-filename-indef']
- else
- -- Deal with regular protection types.
- local images = obj._cfg.images
- if images[action] then
- if images[action][level] then
- obj._imageFilename = images[action][level]
- elseif images[action].default then
- obj._imageFilename = images[action].default
- end
- end
- end
- end
- return setmetatable(obj, BannerTemplate)
- end
- function BannerTemplate:renderImage()
- local filename = self._imageFilename
- or self._cfg.msg['image-filename-default']
- or 'Transparent.gif'
- return makeFileLink{
- file = filename,
- size = (self.imageWidth or 20) .. 'px',
- alt = self._imageAlt,
- link = self._imageLink,
- caption = self.imageCaption
- }
- end
- --------------------------------------------------------------------------------
- -- Banner class
- --------------------------------------------------------------------------------
- local Banner = setmetatable({}, BannerTemplate)
- Banner.__index = Banner
- function Banner.new(protectionObj, blurbObj, cfg)
- local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.
- obj.imageWidth = 40
- obj.imageCaption = blurbObj:makeBannerText('alt') -- Large banners use the alt text for the tooltip.
- obj._reasonText = blurbObj:makeBannerText('text')
- obj._explanationText = blurbObj:makeBannerText('explanation')
- obj._page = protectionObj.title.prefixedText -- Only makes a difference in testing.
- return setmetatable(obj, Banner)
- end
- function Banner:__tostring()
- -- Renders the banner.
- makeMessageBox = makeMessageBox or require('Module:Message box').main
- local reasonText = self._reasonText or error('no reason text set', 2)
- local explanationText = self._explanationText
- local mbargs = {
- page = self._page,
- type = 'protection',
- image = self:renderImage(),
- text = string.format(
- "'''%s'''%s",
- reasonText,
- explanationText and '<br />' .. explanationText or ''
- )
- }
- return makeMessageBox('mbox', mbargs)
- end
- --------------------------------------------------------------------------------
- -- Padlock class
- --------------------------------------------------------------------------------
- local Padlock = setmetatable({}, BannerTemplate)
- Padlock.__index = Padlock
- function Padlock.new(protectionObj, blurbObj, cfg)
- local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.
- obj.imageWidth = 20
- obj.imageCaption = blurbObj:makeBannerText('tooltip')
- obj._imageAlt = blurbObj:makeBannerText('alt')
- obj._imageLink = blurbObj:makeBannerText('link')
- obj._indicatorName = cfg.padlockIndicatorNames[protectionObj.action]
- or cfg.padlockIndicatorNames.default
- or 'pp-default'
- return setmetatable(obj, Padlock)
- end
- function Padlock:__tostring()
- local frame = mw.getCurrentFrame()
- -- The nowiki tag helps prevent whitespace at the top of articles.
- return frame:extensionTag{name = 'nowiki'} .. frame:extensionTag{
- name = 'indicator',
- args = {name = self._indicatorName},
- content = self:renderImage()
- }
- end
- --------------------------------------------------------------------------------
- -- Exports
- --------------------------------------------------------------------------------
- local p = {}
- function p._exportClasses()
- -- This is used for testing purposes.
- return {
- Protection = Protection,
- Blurb = Blurb,
- BannerTemplate = BannerTemplate,
- Banner = Banner,
- Padlock = Padlock,
- }
- end
- function p._main(args, cfg, title)
- args = args or {}
- cfg = cfg or require(CONFIG_MODULE)
- local protectionObj = Protection.new(args, cfg, title)
- local ret = {}
- -- If a page's edit protection is equally or more restrictive than its
- -- protection from some other action, then don't bother displaying anything
- -- for the other action (except categories).
- if not yesno(args.catonly) and (protectionObj.action == 'edit' or
- args.demolevel or
- not getReachableNodes(
- cfg.hierarchy,
- protectionObj.level
- )[effectiveProtectionLevel('edit', protectionObj.title)])
- then
- -- Initialise the blurb object
- local blurbObj = Blurb.new(protectionObj, args, cfg)
- -- Render the banner
- if protectionObj:shouldShowLock() then
- ret[#ret + 1] = tostring(
- (yesno(args.small) and Padlock or Banner)
- .new(protectionObj, blurbObj, cfg)
- )
- end
- end
- -- Render the categories
- if yesno(args.category) ~= false then
- ret[#ret + 1] = protectionObj:makeCategoryLinks()
- end
- return table.concat(ret)
- end
- function p.main(frame, cfg)
- cfg = cfg or require(CONFIG_MODULE)
- -- Find default args, if any.
- local parent = frame.getParent and frame:getParent()
- local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')]
- -- Find user args, and use the parent frame if we are being called from a
- -- wrapper template.
- getArgs = getArgs or require('Module:Arguments').getArgs
- local userArgs = getArgs(frame, {
- parentOnly = defaultArgs,
- frameOnly = not defaultArgs
- })
- -- Build the args table. User-specified args overwrite default args.
- local args = {}
- for k, v in pairs(defaultArgs or {}) do
- args[k] = v
- end
- for k, v in pairs(userArgs) do
- args[k] = v
- end
- return p._main(args, cfg)
- end
- return p</text>
- <sha1>ktral6mmlw9hhlxwgaq85237qklrdx8</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Protection banner/config</title>
- <ns>828</ns>
- <id>42982788</id>
- <revision>
- <id>1069763876</id>
- <parentid>1053458493</parentid>
- <timestamp>2022-02-03T23:49:55Z</timestamp>
- <contributor>
- <username>Andrybak</username>
- <id>23735172</id>
- </contributor>
- <comment>add categorization into [[:Category:Wikipedia extended-confirmed-protected modules]] per [[Special:Diff/1069761256|request]]</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="46228" xml:space="preserve">-- This module provides configuration data for [[Module:Protection banner]].
- return {
- --------------------------------------------------------------------------------
- --
- -- BANNER DATA
- --
- --------------------------------------------------------------------------------
- --[[
- -- Banner data consists of six fields:
- -- * text - the main protection text that appears at the top of protection
- -- banners.
- -- * explanation - the text that appears below the main protection text, used
- -- to explain the details of the protection.
- -- * tooltip - the tooltip text you see when you move the mouse over a small
- -- padlock icon.
- -- * link - the page that the small padlock icon links to.
- -- * alt - the alt text for the small padlock icon. This is also used as tooltip
- -- text for the large protection banners.
- -- * image - the padlock image used in both protection banners and small padlock
- -- icons.
- --
- -- The module checks in three separate tables to find a value for each field.
- -- First it checks the banners table, which has values specific to the reason
- -- for the page being protected. Then the module checks the defaultBanners
- -- table, which has values specific to each protection level. Finally, the
- -- module checks the masterBanner table, which holds data for protection
- -- templates to use if no data has been found in the previous two tables.
- --
- -- The values in the banner data can take parameters. These are specified
- -- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name
- -- enclosed in curly braces).
- --
- -- Available parameters:
- --
- -- ${CURRENTVERSION} - a link to the page history or the move log, with the
- -- display message "current-version-edit-display" or
- -- "current-version-move-display".
- --
- -- ${EDITREQUEST} - a link to create an edit request for the current page.
- --
- -- ${EXPLANATIONBLURB} - an explanation blurb, e.g. "Please discuss any changes
- -- on the talk page; you may submit a request to ask an administrator to make
- -- an edit if it is minor or supported by consensus."
- --
- -- ${IMAGELINK} - a link to set the image to, depending on the protection
- -- action and protection level.
- --
- -- ${INTROBLURB} - the PROTECTIONBLURB parameter, plus the expiry if an expiry
- -- is set. E.g. "Editing of this page by new or unregistered users is currently
- -- disabled until dd Month YYYY."
- --
- -- ${INTROFRAGMENT} - the same as ${INTROBLURB}, but without final punctuation
- -- so that it can be used in run-on sentences.
- --
- -- ${PAGETYPE} - the type of the page, e.g. "article" or "template".
- -- Defined in the cfg.pagetypes table.
- --
- -- ${PROTECTIONBLURB} - a blurb explaining the protection level of the page, e.g.
- -- "Editing of this page by new or unregistered users is currently disabled"
- --
- -- ${PROTECTIONDATE} - the protection date, if it has been supplied to the
- -- template.
- --
- -- ${PROTECTIONLEVEL} - the protection level, e.g. "fully protected" or
- -- "semi-protected".
- --
- -- ${PROTECTIONLOG} - a link to the protection log or the pending changes log,
- -- depending on the protection action.
- --
- -- ${TALKPAGE} - a link to the talk page. If a section is specified, links
- -- straight to that talk page section.
- --
- -- ${TOOLTIPBLURB} - uses the PAGETYPE, PROTECTIONTYPE and EXPIRY parameters to
- -- create a blurb like "This template is semi-protected", or "This article is
- -- move-protected until DD Month YYYY".
- --
- -- ${VANDAL} - links for the specified username (or the root page name)
- -- using Module:Vandal-m.
- --
- -- Functions
- --
- -- For advanced users, it is possible to use Lua functions instead of strings
- -- in the banner config tables. Using functions gives flexibility that is not
- -- possible just by using parameters. Functions take two arguments, the
- -- protection object and the template arguments, and they must output a string.
- --
- -- For example:
- --
- -- text = function (protectionObj, args)
- -- if protectionObj.level == 'autoconfirmed' then
- -- return 'foo'
- -- else
- -- return 'bar'
- -- end
- -- end
- --
- -- Some protection object properties and methods that may be useful:
- -- protectionObj.action - the protection action
- -- protectionObj.level - the protection level
- -- protectionObj.reason - the protection reason
- -- protectionObj.expiry - the expiry. Nil if unset, the string "indef" if set
- -- to indefinite, and the protection time in unix time if temporary.
- -- protectionObj.protectionDate - the protection date in unix time, or nil if
- -- unspecified.
- -- protectionObj.bannerConfig - the banner config found by the module. Beware
- -- of editing the config field used by the function, as it could create an
- -- infinite loop.
- -- protectionObj:isProtected - returns a boolean showing whether the page is
- -- protected.
- -- protectionObj:isTemporary - returns a boolean showing whether the expiry is
- -- temporary.
- -- protectionObj:isIncorrect - returns a boolean showing whether the protection
- -- template is incorrect.
- --]]
- -- The master banner data, used if no values have been found in banners or
- -- defaultBanners.
- masterBanner = {
- text = '${INTROBLURB}',
- explanation = '${EXPLANATIONBLURB}',
- tooltip = '${TOOLTIPBLURB}',
- link = '${IMAGELINK}',
- alt = 'Page ${PROTECTIONLEVEL}'
- },
- -- The default banner data. This holds banner data for different protection
- -- levels.
- -- *required* - this table needs edit, move, autoreview and upload subtables.
- defaultBanners = {
- edit = {},
- move = {},
- autoreview = {
- default = {
- alt = 'Page protected with pending changes',
- tooltip = 'All edits by unregistered and new users are subject to review prior to becoming visible to unregistered users',
- image = 'Pending-protection-shackle.svg'
- }
- },
- upload = {}
- },
- -- The banner data. This holds banner data for different protection reasons.
- -- In fact, the reasons specified in this table control which reasons are
- -- valid inputs to the first positional parameter.
- --
- -- There is also a non-standard "description" field that can be used for items
- -- in this table. This is a description of the protection reason for use in the
- -- module documentation.
- --
- -- *required* - this table needs edit, move, autoreview and upload subtables.
- banners = {
- edit = {
- blp = {
- description = 'For pages protected to promote compliance with the'
- .. ' [[Wikipedia:Biographies of living persons'
- .. '|biographies of living persons]] policy',
- text = '${INTROFRAGMENT} to promote compliance with'
- .. ' [[Wikipedia:Biographies of living persons'
- .. "|Wikipedia's&nbsp;policy on&nbsp;the&nbsp;biographies"
- .. ' of&nbsp;living&nbsp;people]].',
- tooltip = '${TOOLTIPFRAGMENT} to promote compliance with the policy on'
- .. ' biographies of living persons',
- },
- dmca = {
- description = 'For pages protected by the Wikimedia Foundation'
- .. ' due to [[Digital Millennium Copyright Act]] takedown requests',
- explanation = function (protectionObj, args)
- local ret = 'Pursuant to a rights owner notice under the Digital'
- .. ' Millennium Copyright Act (DMCA) regarding some content'
- .. ' in this article, the Wikimedia Foundation acted under'
- .. ' applicable law and took down and restricted the content'
- .. ' in question.'
- if args.notice then
- ret = ret .. ' A copy of the received notice can be found here: '
- .. args.notice .. '.'
- end
- ret = ret .. ' For more information, including websites discussing'
- .. ' how to file a counter-notice, please see'
- .. " [[Wikipedia:Office actions]] and the article's ${TALKPAGE}."
- .. "'''Do not remove this template from the article until the"
- .. " restrictions are withdrawn'''."
- return ret
- end,
- image = 'Office-protection-shackle.svg',
- },
- dispute = {
- description = 'For pages protected due to editing disputes',
- text = function (protectionObj, args)
- -- Find the value of "disputes".
- local display = 'disputes'
- local disputes
- if args.section then
- disputes = string.format(
- '[[%s:%s#%s|%s]]',
- mw.site.namespaces[protectionObj.title.namespace].talk.name,
- protectionObj.title.text,
- args.section,
- display
- )
- else
- disputes = display
- end
- -- Make the blurb, depending on the expiry.
- local msg
- if type(protectionObj.expiry) == 'number' then
- msg = '${INTROFRAGMENT} or until editing %s have been resolved.'
- else
- msg = '${INTROFRAGMENT} until editing %s have been resolved.'
- end
- return string.format(msg, disputes)
- end,
- explanation = "This protection is '''not''' an endorsement of the"
- .. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',
- tooltip = '${TOOLTIPFRAGMENT} due to editing disputes',
- },
- ecp = {
- description = 'For articles in topic areas authorized by'
- .. ' [[Wikipedia:Arbitration Committee|ArbCom]] or'
- .. ' meets the criteria for community use',
- tooltip = 'This ${PAGETYPE} is extended-confirmed protected',
- alt = 'Extended-protected ${PAGETYPE}',
- },
- mainpage = {
- description = 'For pages protected for being displayed on the [[Main Page]]',
- text = 'This file is currently'
- .. ' [[Wikipedia:This page is protected|protected]] from'
- .. ' editing because it is currently or will soon be displayed'
- .. ' on the [[Main Page]].',
- explanation = 'Images on the Main Page are protected due to their high'
- .. ' visibility. Please discuss any necessary changes on the ${TALKPAGE}.'
- .. '<br /><span style="font-size:90%;">'
- .. "'''Administrators:''' Once this image is definitely off the Main Page,"
- .. ' please unprotect this file, or reduce to semi-protection,'
- .. ' as appropriate.</span>',
- },
- office = {
- description = 'For pages protected by the Wikimedia Foundation',
- text = function (protectionObj, args)
- local ret = 'This ${PAGETYPE} is currently under the'
- .. ' scrutiny of the'
- .. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]'
- .. ' and is protected.'
- if protectionObj.protectionDate then
- ret = ret .. ' It has been protected since ${PROTECTIONDATE}.'
- end
- return ret
- end,
- explanation = "If you can edit this page, please discuss all changes and"
- .. " additions on the ${TALKPAGE} first. '''Do not remove protection from this"
- .. " page unless you are authorized by the Wikimedia Foundation to do"
- .. " so.'''",
- image = 'Office-protection-shackle.svg',
- },
- reset = {
- description = 'For pages protected by the Wikimedia Foundation and'
- .. ' "reset" to a bare-bones version',
- text = 'This ${PAGETYPE} is currently under the'
- .. ' scrutiny of the'
- .. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]'
- .. ' and is protected.',
- explanation = function (protectionObj, args)
- local ret = ''
- if protectionObj.protectionDate then
- ret = ret .. 'On ${PROTECTIONDATE} this ${PAGETYPE} was'
- else
- ret = ret .. 'This ${PAGETYPE} has been'
- end
- ret = ret .. ' reduced to a'
- .. ' simplified, "bare bones" version so that it may be completely'
- .. ' rewritten to ensure it meets the policies of'
- .. ' [[WP:NPOV|Neutral Point of View]] and [[WP:V|Verifiability]].'
- .. ' Standard Wikipedia policies will apply to its rewriting—which'
- .. ' will eventually be open to all editors—and will be strictly'
- .. ' enforced. The ${PAGETYPE} has been ${PROTECTIONLEVEL} while'
- .. ' it is being rebuilt.\n\n'
- .. 'Any insertion of material directly from'
- .. ' pre-protection revisions of the ${PAGETYPE} will be removed, as'
- .. ' will any material added to the ${PAGETYPE} that is not properly'
- .. ' sourced. The associated talk page(s) were also cleared on the'
- .. " same date.\n\n"
- .. "If you can edit this page, please discuss all changes and"
- .. " additions on the ${TALKPAGE} first. '''Do not override"
- .. " this action, and do not remove protection from this page,"
- .. " unless you are authorized by the Wikimedia Foundation"
- .. " to do so. No editor may remove this notice.'''"
- return ret
- end,
- image = 'Office-protection-shackle.svg',
- },
- sock = {
- description = 'For pages protected due to'
- .. ' [[Wikipedia:Sock puppetry|sock puppetry]]',
- text = '${INTROFRAGMENT} to prevent [[Wikipedia:Sock puppetry|sock puppets]] of'
- .. ' [[Wikipedia:Blocking policy|blocked]] or'
- .. ' [[Wikipedia:Banning policy|banned users]]'
- .. ' from editing it.',
- tooltip = '${TOOLTIPFRAGMENT} to prevent sock puppets of blocked or banned users from'
- .. ' editing it',
- },
- template = {
- description = 'For [[Wikipedia:High-risk templates|high-risk]]'
- .. ' templates and Lua modules',
- text = 'This is a permanently [[Help:Protection|protected]] ${PAGETYPE},'
- .. ' as it is [[Wikipedia:High-risk templates|high-risk]].',
- explanation = 'Please discuss any changes on the ${TALKPAGE}; you may'
- .. ' ${EDITREQUEST} to ask an'
- .. ' [[Wikipedia:Administrators|administrator]] or'
- .. ' [[Wikipedia:Template editor|template editor]] to make an edit if'
- .. ' it is [[Help:Minor edit#When to mark an edit as a minor edit'
- .. '|uncontroversial]] or supported by'
- .. ' [[Wikipedia:Consensus|consensus]]. You can also'
- .. ' [[Wikipedia:Requests for page protection|request]] that the page be'
- .. ' unprotected.',
- tooltip = 'This high-risk ${PAGETYPE} is permanently ${PROTECTIONLEVEL}'
- .. ' to prevent vandalism',
- alt = 'Permanently protected ${PAGETYPE}',
- },
- usertalk = {
- description = 'For pages protected against disruptive edits by a'
- .. ' particular user',
- text = '${INTROFRAGMENT} to prevent ${VANDAL} from using it to make disruptive edits,'
- .. ' such as abusing the'
- .. ' &#123;&#123;[[Template:unblock|unblock]]&#125;&#125; template.',
- explanation = 'If you cannot edit this user talk page and you need to'
- .. ' make a change or leave a message, you can'
- .. ' [[Wikipedia:Requests for page protection'
- .. '#Current requests for edits to a protected page'
- .. '|request an edit]],'
- .. ' [[Wikipedia:Requests for page protection'
- .. '#Current requests for reduction in protection level'
- .. '|request unprotection]],'
- .. ' [[Special:Userlogin|log in]],'
- .. ' or [[Special:UserLogin/signup|create an account]].',
- },
- vandalism = {
- description = 'For pages protected against'
- .. ' [[Wikipedia:Vandalism|vandalism]]',
- text = '${INTROFRAGMENT} due to [[Wikipedia:Vandalism|vandalism]].',
- explanation = function (protectionObj, args)
- local ret = ''
- if protectionObj.level == 'sysop' then
- ret = ret .. "This protection is '''not''' an endorsement of the"
- .. ' ${CURRENTVERSION}. '
- end
- return ret .. '${EXPLANATIONBLURB}'
- end,
- tooltip = '${TOOLTIPFRAGMENT} due to vandalism',
- }
- },
- move = {
- dispute = {
- description = 'For pages protected against page moves due to'
- .. ' disputes over the page title',
- explanation = "This protection is '''not''' an endorsement of the"
- .. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',
- image = 'Move-protection-shackle.svg'
- },
- vandalism = {
- description = 'For pages protected against'
- .. ' [[Wikipedia:Vandalism#Page-move vandalism'
- .. ' |page-move vandalism]]'
- }
- },
- autoreview = {},
- upload = {}
- },
- --------------------------------------------------------------------------------
- --
- -- GENERAL DATA TABLES
- --
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- -- Protection blurbs
- --------------------------------------------------------------------------------
- -- This table produces the protection blurbs available with the
- -- ${PROTECTIONBLURB} parameter. It is sorted by protection action and
- -- protection level, and is checked by the module in the following order:
- -- 1. page's protection action, page's protection level
- -- 2. page's protection action, default protection level
- -- 3. "edit" protection action, default protection level
- --
- -- It is possible to use banner parameters inside this table.
- -- *required* - this table needs edit, move, autoreview and upload subtables.
- protectionBlurbs = {
- edit = {
- default = 'This ${PAGETYPE} is currently [[Help:Protection|'
- .. 'protected]] from editing',
- autoconfirmed = 'Editing of this ${PAGETYPE} by [[Wikipedia:User access'
- .. ' levels#New users|new]] or [[Wikipedia:User access levels#Unregistered'
- .. ' users|unregistered]] users is currently [[Help:Protection|disabled]]',
- extendedconfirmed = 'This ${PAGETYPE} is currently under extended confirmed protection',
- },
- move = {
- default = 'This ${PAGETYPE} is currently [[Help:Protection|protected]]'
- .. ' from [[Help:Moving a page|page moves]]'
- },
- autoreview = {
- default = 'All edits made to this ${PAGETYPE} by'
- .. ' [[Wikipedia:User access levels#New users|new]] or'
- .. ' [[Wikipedia:User access levels#Unregistered users|unregistered]]'
- .. ' users are currently'
- .. ' [[Wikipedia:Pending changes|subject to review]]'
- },
- upload = {
- default = 'Uploading new versions of this ${PAGETYPE} is currently disabled'
- }
- },
- --------------------------------------------------------------------------------
- -- Explanation blurbs
- --------------------------------------------------------------------------------
- -- This table produces the explanation blurbs available with the
- -- ${EXPLANATIONBLURB} parameter. It is sorted by protection action,
- -- protection level, and whether the page is a talk page or not. If the page is
- -- a talk page it will have a talk key of "talk"; otherwise it will have a talk
- -- key of "subject". The table is checked in the following order:
- -- 1. page's protection action, page's protection level, page's talk key
- -- 2. page's protection action, page's protection level, default talk key
- -- 3. page's protection action, default protection level, page's talk key
- -- 4. page's protection action, default protection level, default talk key
- --
- -- It is possible to use banner parameters inside this table.
- -- *required* - this table needs edit, move, autoreview and upload subtables.
- explanationBlurbs = {
- edit = {
- autoconfirmed = {
- subject = 'See the [[Wikipedia:Protection policy|'
- .. 'protection policy]] and ${PROTECTIONLOG} for more details. If you'
- .. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can'
- .. ' ${EDITREQUEST}, discuss changes on the ${TALKPAGE},'
- .. ' [[Wikipedia:Requests for page protection'
- .. '#Current requests for reduction in protection level'
- .. '|request unprotection]], [[Special:Userlogin|log in]], or'
- .. ' [[Special:UserLogin/signup|create an account]].',
- default = 'See the [[Wikipedia:Protection policy|'
- .. 'protection policy]] and ${PROTECTIONLOG} for more details. If you'
- .. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can'
- .. ' [[Wikipedia:Requests for page protection'
- .. '#Current requests for reduction in protection level'
- .. '|request unprotection]], [[Special:Userlogin|log in]], or'
- .. ' [[Special:UserLogin/signup|create an account]].',
- },
- extendedconfirmed = {
- default = 'Extended confirmed protection prevents edits from all unregistered editors'
- .. ' and registered users with fewer than 30 days tenure and 500 edits.'
- .. ' The [[Wikipedia:Protection policy#extended|policy on community use]]'
- .. ' specifies that extended confirmed protection can be applied to combat'
- .. ' disruption, if semi-protection has proven to be ineffective.'
- .. ' Extended confirmed protection may also be applied to enforce'
- .. ' [[Wikipedia:Arbitration Committee|arbitration sanctions]].'
- .. ' Please discuss any changes on the ${TALKPAGE}; you may'
- .. ' ${EDITREQUEST} to ask for uncontroversial changes supported by'
- .. ' [[Wikipedia:Consensus|consensus]].'
- },
- default = {
- subject = 'See the [[Wikipedia:Protection policy|'
- .. 'protection policy]] and ${PROTECTIONLOG} for more details.'
- .. ' Please discuss any changes on the ${TALKPAGE}; you'
- .. ' may ${EDITREQUEST} to ask an'
- .. ' [[Wikipedia:Administrators|administrator]] to make an edit if it'
- .. ' is [[Help:Minor edit#When to mark an edit as a minor edit'
- .. '|uncontroversial]] or supported by [[Wikipedia:Consensus'
- .. '|consensus]]. You may also [[Wikipedia:Requests for'
- .. ' page protection#Current requests for reduction in protection level'
- .. '|request]] that this page be unprotected.',
- default = 'See the [[Wikipedia:Protection policy|'
- .. 'protection policy]] and ${PROTECTIONLOG} for more details.'
- .. ' You may [[Wikipedia:Requests for page'
- .. ' protection#Current requests for edits to a protected page|request an'
- .. ' edit]] to this page, or [[Wikipedia:Requests for'
- .. ' page protection#Current requests for reduction in protection level'
- .. '|ask]] for it to be unprotected.'
- }
- },
- move = {
- default = {
- subject = 'See the [[Wikipedia:Protection policy|'
- .. 'protection policy]] and ${PROTECTIONLOG} for more details.'
- .. ' The page may still be edited but cannot be moved'
- .. ' until unprotected. Please discuss any suggested moves on the'
- .. ' ${TALKPAGE} or at [[Wikipedia:Requested moves]]. You can also'
- .. ' [[Wikipedia:Requests for page protection|request]] that the page be'
- .. ' unprotected.',
- default = 'See the [[Wikipedia:Protection policy|'
- .. 'protection policy]] and ${PROTECTIONLOG} for more details.'
- .. ' The page may still be edited but cannot be moved'
- .. ' until unprotected. Please discuss any suggested moves at'
- .. ' [[Wikipedia:Requested moves]]. You can also'
- .. ' [[Wikipedia:Requests for page protection|request]] that the page be'
- .. ' unprotected.'
- }
- },
- autoreview = {
- default = {
- default = 'See the [[Wikipedia:Protection policy|'
- .. 'protection policy]] and ${PROTECTIONLOG} for more details.'
- .. ' Edits to this ${PAGETYPE} by new and unregistered users'
- .. ' will not be visible to readers until they are accepted by'
- .. ' a reviewer. To avoid the need for your edits to be'
- .. ' reviewed, you may'
- .. ' [[Wikipedia:Requests for page protection'
- .. '#Current requests for reduction in protection level'
- .. '|request unprotection]], [[Special:Userlogin|log in]], or'
- .. ' [[Special:UserLogin/signup|create an account]].'
- },
- },
- upload = {
- default = {
- default = 'See the [[Wikipedia:Protection policy|'
- .. 'protection policy]] and ${PROTECTIONLOG} for more details.'
- .. ' The page may still be edited but new versions of the file'
- .. ' cannot be uploaded until it is unprotected. You can'
- .. ' request that a new version be uploaded by using a'
- .. ' [[Wikipedia:Edit requests|protected edit request]], or you'
- .. ' can [[Wikipedia:Requests for page protection|request]]'
- .. ' that the file be unprotected.'
- }
- }
- },
- --------------------------------------------------------------------------------
- -- Protection levels
- --------------------------------------------------------------------------------
- -- This table provides the data for the ${PROTECTIONLEVEL} parameter, which
- -- produces a short label for different protection levels. It is sorted by
- -- protection action and protection level, and is checked in the following
- -- order:
- -- 1. page's protection action, page's protection level
- -- 2. page's protection action, default protection level
- -- 3. "edit" protection action, default protection level
- --
- -- It is possible to use banner parameters inside this table.
- -- *required* - this table needs edit, move, autoreview and upload subtables.
- protectionLevels = {
- edit = {
- default = 'protected',
- templateeditor = 'template-protected',
- extendedconfirmed = 'extended-protected',
- autoconfirmed = 'semi-protected',
- },
- move = {
- default = 'move-protected'
- },
- autoreview = {
- },
- upload = {
- default = 'upload-protected'
- }
- },
- --------------------------------------------------------------------------------
- -- Images
- --------------------------------------------------------------------------------
- -- This table lists different padlock images for each protection action and
- -- protection level. It is used if an image is not specified in any of the
- -- banner data tables, and if the page does not satisfy the conditions for using
- -- the ['image-filename-indef'] image. It is checked in the following order:
- -- 1. page's protection action, page's protection level
- -- 2. page's protection action, default protection level
- images = {
- edit = {
- default = 'Full-protection-shackle.svg',
- templateeditor = 'Template-protection-shackle.svg',
- extendedconfirmed = 'Extended-protection-shackle.svg',
- autoconfirmed = 'Semi-protection-shackle.svg'
- },
- move = {
- default = 'Move-protection-shackle.svg',
- },
- autoreview = {
- default = 'Pending-protection-shackle.svg'
- },
- upload = {
- default = 'Upload-protection-shackle.svg'
- }
- },
- -- Pages with a reason specified in this table will show the special "indef"
- -- padlock, defined in the 'image-filename-indef' message, if no expiry is set.
- indefImageReasons = {
- template = true
- },
- --------------------------------------------------------------------------------
- -- Image links
- --------------------------------------------------------------------------------
- -- This table provides the data for the ${IMAGELINK} parameter, which gets
- -- the image link for small padlock icons based on the page's protection action
- -- and protection level. It is checked in the following order:
- -- 1. page's protection action, page's protection level
- -- 2. page's protection action, default protection level
- -- 3. "edit" protection action, default protection level
- --
- -- It is possible to use banner parameters inside this table.
- -- *required* - this table needs edit, move, autoreview and upload subtables.
- imageLinks = {
- edit = {
- default = 'Wikipedia:Protection policy#full',
- templateeditor = 'Wikipedia:Protection policy#template',
- extendedconfirmed = 'Wikipedia:Protection policy#extended',
- autoconfirmed = 'Wikipedia:Protection policy#semi'
- },
- move = {
- default = 'Wikipedia:Protection policy#move'
- },
- autoreview = {
- default = 'Wikipedia:Protection policy#pending'
- },
- upload = {
- default = 'Wikipedia:Protection policy#upload'
- }
- },
- --------------------------------------------------------------------------------
- -- Padlock indicator names
- --------------------------------------------------------------------------------
- -- This table provides the "name" attribute for the <indicator> extension tag
- -- with which small padlock icons are generated. All indicator tags on a page
- -- are displayed in alphabetical order based on this attribute, and with
- -- indicator tags with duplicate names, the last tag on the page wins.
- -- The attribute is chosen based on the protection action; table keys must be a
- -- protection action name or the string "default".
- padlockIndicatorNames = {
- autoreview = 'pp-autoreview',
- default = 'pp-default'
- },
- --------------------------------------------------------------------------------
- -- Protection categories
- --------------------------------------------------------------------------------
- --[[
- -- The protection categories are stored in the protectionCategories table.
- -- Keys to this table are made up of the following strings:
- --
- -- 1. the expiry date
- -- 2. the namespace
- -- 3. the protection reason (e.g. "dispute" or "vandalism")
- -- 4. the protection level (e.g. "sysop" or "autoconfirmed")
- -- 5. the action (e.g. "edit" or "move")
- --
- -- When the module looks up a category in the table, first it will will check to
- -- see a key exists that corresponds to all five parameters. For example, a
- -- user page semi-protected from vandalism for two weeks would have the key
- -- "temp-user-vandalism-autoconfirmed-edit". If no match is found, the module
- -- changes the first part of the key to "all" and checks the table again. It
- -- keeps checking increasingly generic key combinations until it finds the
- -- field, or until it reaches the key "all-all-all-all-all".
- --
- -- The module uses a binary matrix to determine the order in which to search.
- -- This is best demonstrated by a table. In this table, the "0" values
- -- represent "all", and the "1" values represent the original data (e.g.
- -- "indef" or "file" or "vandalism").
- --
- -- expiry namespace reason level action
- -- order
- -- 1 1 1 1 1 1
- -- 2 0 1 1 1 1
- -- 3 1 0 1 1 1
- -- 4 0 0 1 1 1
- -- 5 1 1 0 1 1
- -- 6 0 1 0 1 1
- -- 7 1 0 0 1 1
- -- 8 0 0 0 1 1
- -- 9 1 1 1 0 1
- -- 10 0 1 1 0 1
- -- 11 1 0 1 0 1
- -- 12 0 0 1 0 1
- -- 13 1 1 0 0 1
- -- 14 0 1 0 0 1
- -- 15 1 0 0 0 1
- -- 16 0 0 0 0 1
- -- 17 1 1 1 1 0
- -- 18 0 1 1 1 0
- -- 19 1 0 1 1 0
- -- 20 0 0 1 1 0
- -- 21 1 1 0 1 0
- -- 22 0 1 0 1 0
- -- 23 1 0 0 1 0
- -- 24 0 0 0 1 0
- -- 25 1 1 1 0 0
- -- 26 0 1 1 0 0
- -- 27 1 0 1 0 0
- -- 28 0 0 1 0 0
- -- 29 1 1 0 0 0
- -- 30 0 1 0 0 0
- -- 31 1 0 0 0 0
- -- 32 0 0 0 0 0
- --
- -- In this scheme the action has the highest priority, as it is the last
- -- to change, and the expiry has the least priority, as it changes the most.
- -- The priorities of the expiry, the protection level and the action are
- -- fixed, but the priorities of the reason and the namespace can be swapped
- -- through the use of the cfg.bannerDataNamespaceHasPriority table.
- --]]
- -- If the reason specified to the template is listed in this table,
- -- namespace data will take priority over reason data in the protectionCategories
- -- table.
- reasonsWithNamespacePriority = {
- vandalism = true,
- },
- -- The string to use as a namespace key for the protectionCategories table for each
- -- namespace number.
- categoryNamespaceKeys = {
- [ 2] = 'user',
- [ 3] = 'user',
- [ 4] = 'project',
- [ 6] = 'file',
- [ 8] = 'mediawiki',
- [ 10] = 'template',
- [ 12] = 'project',
- [ 14] = 'category',
- [100] = 'portal',
- [828] = 'module',
- },
- protectionCategories = {
- ['all|all|all|all|all'] = 'Wikipedia fully protected pages',
- ['all|all|office|all|all'] = 'Wikipedia Office-protected pages',
- ['all|all|reset|all|all'] = 'Wikipedia Office-protected pages',
- ['all|all|dmca|all|all'] = 'Wikipedia Office-protected pages',
- ['all|all|mainpage|all|all'] = 'Wikipedia fully-protected main page files',
- ['all|all|all|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages',
- ['all|all|ecp|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages',
- ['all|template|all|all|edit'] = 'Wikipedia fully protected templates',
- ['all|all|all|autoconfirmed|edit'] = 'Wikipedia semi-protected pages',
- ['indef|all|all|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected pages',
- ['all|all|blp|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected biographies of living people',
- ['temp|all|blp|autoconfirmed|edit'] = 'Wikipedia temporarily semi-protected biographies of living people',
- ['all|all|dispute|autoconfirmed|edit'] = 'Wikipedia pages semi-protected due to dispute',
- ['all|all|sock|autoconfirmed|edit'] = 'Wikipedia pages semi-protected from banned users',
- ['all|all|vandalism|autoconfirmed|edit'] = 'Wikipedia pages semi-protected against vandalism',
- ['all|category|all|autoconfirmed|edit'] = 'Wikipedia semi-protected categories',
- ['all|file|all|autoconfirmed|edit'] = 'Wikipedia semi-protected files',
- ['all|portal|all|autoconfirmed|edit'] = 'Wikipedia semi-protected portals',
- ['all|project|all|autoconfirmed|edit'] = 'Wikipedia semi-protected project pages',
- ['all|talk|all|autoconfirmed|edit'] = 'Wikipedia semi-protected talk pages',
- ['all|template|all|autoconfirmed|edit'] = 'Wikipedia semi-protected templates',
- ['all|user|all|autoconfirmed|edit'] = 'Wikipedia semi-protected user and user talk pages',
- ['all|all|all|templateeditor|edit'] = 'Wikipedia template-protected pages other than templates and modules',
- ['all|template|all|templateeditor|edit'] = 'Wikipedia template-protected templates',
- ['all|template|all|templateeditor|move'] = 'Wikipedia template-protected templates', -- move-protected templates
- ['all|all|blp|sysop|edit'] = 'Wikipedia indefinitely protected biographies of living people',
- ['temp|all|blp|sysop|edit'] = 'Wikipedia temporarily protected biographies of living people',
- ['all|all|dispute|sysop|edit'] = 'Wikipedia pages protected due to dispute',
- ['all|all|sock|sysop|edit'] = 'Wikipedia pages protected from banned users',
- ['all|all|vandalism|sysop|edit'] = 'Wikipedia pages protected against vandalism',
- ['all|category|all|sysop|edit'] = 'Wikipedia fully protected categories',
- ['all|file|all|sysop|edit'] = 'Wikipedia fully-protected files',
- ['all|project|all|sysop|edit'] = 'Wikipedia fully-protected project pages',
- ['all|talk|all|sysop|edit'] = 'Wikipedia fully-protected talk pages',
- ['all|template|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed-protected templates',
- ['all|template|all|sysop|edit'] = 'Wikipedia fully protected templates',
- ['all|user|all|sysop|edit'] = 'Wikipedia fully protected user and user talk pages',
- ['all|module|all|all|edit'] = 'Wikipedia fully-protected modules',
- ['all|module|all|templateeditor|edit'] = 'Wikipedia template-protected modules',
- ['all|module|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed-protected modules',
- ['all|module|all|autoconfirmed|edit'] = 'Wikipedia semi-protected modules',
- ['all|all|all|sysop|move'] = 'Wikipedia move-protected pages',
- ['indef|all|all|sysop|move'] = 'Wikipedia indefinitely move-protected pages',
- ['all|all|dispute|sysop|move'] = 'Wikipedia pages move-protected due to dispute',
- ['all|all|vandalism|sysop|move'] = 'Wikipedia pages move-protected due to vandalism',
- ['all|portal|all|sysop|move'] = 'Wikipedia move-protected portals',
- ['all|project|all|sysop|move'] = 'Wikipedia move-protected project pages',
- ['all|talk|all|sysop|move'] = 'Wikipedia move-protected talk pages',
- ['all|template|all|sysop|move'] = 'Wikipedia move-protected templates',
- ['all|user|all|sysop|move'] = 'Wikipedia move-protected user and user talk pages',
- ['all|all|all|autoconfirmed|autoreview'] = 'Wikipedia pending changes protected pages',
- ['all|file|all|all|upload'] = 'Wikipedia upload-protected files',
- },
- --------------------------------------------------------------------------------
- -- Expiry category config
- --------------------------------------------------------------------------------
- -- This table configures the expiry category behaviour for each protection
- -- action.
- -- * If set to true, setting that action will always categorise the page if
- -- an expiry parameter is not set.
- -- * If set to false, setting that action will never categorise the page.
- -- * If set to nil, the module will categorise the page if:
- -- 1) an expiry parameter is not set, and
- -- 2) a reason is provided, and
- -- 3) the specified reason is not blacklisted in the reasonsWithoutExpiryCheck
- -- table.
- expiryCheckActions = {
- edit = nil,
- move = false,
- autoreview = true,
- upload = false
- },
- reasonsWithoutExpiryCheck = {
- blp = true,
- template = true,
- },
- --------------------------------------------------------------------------------
- -- Pagetypes
- --------------------------------------------------------------------------------
- -- This table produces the page types available with the ${PAGETYPE} parameter.
- -- Keys are namespace numbers, or the string "default" for the default value.
- pagetypes = {
- [0] = 'article',
- [6] = 'file',
- [10] = 'template',
- [14] = 'category',
- [828] = 'module',
- default = 'page'
- },
- --------------------------------------------------------------------------------
- -- Strings marking indefinite protection
- --------------------------------------------------------------------------------
- -- This table contains values passed to the expiry parameter that mean the page
- -- is protected indefinitely.
- indefStrings = {
- ['indef'] = true,
- ['indefinite'] = true,
- ['indefinitely'] = true,
- ['infinite'] = true,
- },
- --------------------------------------------------------------------------------
- -- Group hierarchy
- --------------------------------------------------------------------------------
- -- This table maps each group to all groups that have a superset of the original
- -- group's page editing permissions.
- hierarchy = {
- sysop = {},
- reviewer = {'sysop'},
- filemover = {'sysop'},
- templateeditor = {'sysop'},
- extendedconfirmed = {'sysop'},
- autoconfirmed = {'reviewer', 'filemover', 'templateeditor', 'extendedconfirmed'},
- user = {'autoconfirmed'},
- ['*'] = {'user'}
- },
- --------------------------------------------------------------------------------
- -- Wrapper templates and their default arguments
- --------------------------------------------------------------------------------
- -- This table contains wrapper templates used with the module, and their
- -- default arguments. Templates specified in this table should contain the
- -- following invocation, and no other template content:
- --
- -- {{#invoke:Protection banner|main}}
- --
- -- If other content is desired, it can be added between
- -- <noinclude>...</noinclude> tags.
- --
- -- When a user calls one of these wrapper templates, they will use the
- -- default arguments automatically. However, users can override any of the
- -- arguments.
- wrappers = {
- ['Template:Pp'] = {},
- ['Template:Pp-extended'] = {'ecp'},
- ['Template:Pp-blp'] = {'blp'},
- -- we don't need Template:Pp-create
- ['Template:Pp-dispute'] = {'dispute'},
- ['Template:Pp-main-page'] = {'mainpage'},
- ['Template:Pp-move'] = {action = 'move', catonly = 'yes'},
- ['Template:Pp-move-dispute'] = {'dispute', action = 'move', catonly = 'yes'},
- -- we don't need Template:Pp-move-indef
- ['Template:Pp-move-vandalism'] = {'vandalism', action = 'move', catonly = 'yes'},
- ['Template:Pp-office'] = {'office'},
- ['Template:Pp-office-dmca'] = {'dmca'},
- ['Template:Pp-pc'] = {action = 'autoreview', small = true},
- ['Template:Pp-pc1'] = {action = 'autoreview', small = true},
- ['Template:Pp-reset'] = {'reset'},
- ['Template:Pp-semi-indef'] = {small = true},
- ['Template:Pp-sock'] = {'sock'},
- ['Template:Pp-template'] = {'template', small = true},
- ['Template:Pp-upload'] = {action = 'upload'},
- ['Template:Pp-usertalk'] = {'usertalk'},
- ['Template:Pp-vandalism'] = {'vandalism'},
- },
- --------------------------------------------------------------------------------
- --
- -- MESSAGES
- --
- --------------------------------------------------------------------------------
- msg = {
- --------------------------------------------------------------------------------
- -- Intro blurb and intro fragment
- --------------------------------------------------------------------------------
- -- These messages specify what is produced by the ${INTROBLURB} and
- -- ${INTROFRAGMENT} parameters. If the protection is temporary they use the
- -- intro-blurb-expiry or intro-fragment-expiry, and if not they use
- -- intro-blurb-noexpiry or intro-fragment-noexpiry.
- -- It is possible to use banner parameters in these messages.
- ['intro-blurb-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY}.',
- ['intro-blurb-noexpiry'] = '${PROTECTIONBLURB}.',
- ['intro-fragment-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY},',
- ['intro-fragment-noexpiry'] = '${PROTECTIONBLURB}',
- --------------------------------------------------------------------------------
- -- Tooltip blurb
- --------------------------------------------------------------------------------
- -- These messages specify what is produced by the ${TOOLTIPBLURB} parameter.
- -- If the protection is temporary the tooltip-blurb-expiry message is used, and
- -- if not the tooltip-blurb-noexpiry message is used.
- -- It is possible to use banner parameters in these messages.
- ['tooltip-blurb-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY}.',
- ['tooltip-blurb-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}.',
- ['tooltip-fragment-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY},',
- ['tooltip-fragment-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}',
- --------------------------------------------------------------------------------
- -- Special explanation blurb
- --------------------------------------------------------------------------------
- -- An explanation blurb for pages that cannot be unprotected, e.g. for pages
- -- in the MediaWiki namespace.
- -- It is possible to use banner parameters in this message.
- ['explanation-blurb-nounprotect'] = 'See the [[Wikipedia:Protection policy|'
- .. 'protection policy]] and ${PROTECTIONLOG} for more details.'
- .. ' Please discuss any changes on the ${TALKPAGE}; you'
- .. ' may ${EDITREQUEST} to ask an'
- .. ' [[Wikipedia:Administrators|administrator]] to make an edit if it'
- .. ' is [[Help:Minor edit#When to mark an edit as a minor edit'
- .. '|uncontroversial]] or supported by [[Wikipedia:Consensus'
- .. '|consensus]].',
- --------------------------------------------------------------------------------
- -- Protection log display values
- --------------------------------------------------------------------------------
- -- These messages determine the display values for the protection log link
- -- or the pending changes log link produced by the ${PROTECTIONLOG} parameter.
- -- It is possible to use banner parameters in these messages.
- ['protection-log-display'] = 'protection log',
- ['pc-log-display'] = 'pending changes log',
- --------------------------------------------------------------------------------
- -- Current version display values
- --------------------------------------------------------------------------------
- -- These messages determine the display values for the page history link
- -- or the move log link produced by the ${CURRENTVERSION} parameter.
- -- It is possible to use banner parameters in these messages.
- ['current-version-move-display'] = 'current title',
- ['current-version-edit-display'] = 'current version',
- --------------------------------------------------------------------------------
- -- Talk page
- --------------------------------------------------------------------------------
- -- This message determines the display value of the talk page link produced
- -- with the ${TALKPAGE} parameter.
- -- It is possible to use banner parameters in this message.
- ['talk-page-link-display'] = 'talk page',
- --------------------------------------------------------------------------------
- -- Edit requests
- --------------------------------------------------------------------------------
- -- This message determines the display value of the edit request link produced
- -- with the ${EDITREQUEST} parameter.
- -- It is possible to use banner parameters in this message.
- ['edit-request-display'] = 'submit an edit request',
- --------------------------------------------------------------------------------
- -- Expiry date format
- --------------------------------------------------------------------------------
- -- This is the format for the blurb expiry date. It should be valid input for
- -- the first parameter of the #time parser function.
- ['expiry-date-format'] = 'F j, Y "at" H:i e',
- --------------------------------------------------------------------------------
- -- Tracking categories
- --------------------------------------------------------------------------------
- -- These messages determine which tracking categories the module outputs.
- ['tracking-category-incorrect'] = 'Wikipedia pages with incorrect protection templates',
- ['tracking-category-template'] = 'Wikipedia template-protected pages other than templates and modules',
- --------------------------------------------------------------------------------
- -- Images
- --------------------------------------------------------------------------------
- -- These are images that are not defined by their protection action and protection level.
- ['image-filename-indef'] = 'Full-protection-shackle.svg',
- ['image-filename-default'] = 'Transparent.gif',
- --------------------------------------------------------------------------------
- -- End messages
- --------------------------------------------------------------------------------
- }
- --------------------------------------------------------------------------------
- -- End configuration
- --------------------------------------------------------------------------------
- }</text>
- <sha1>eeb6sgpzkp24z3uln44ko8rah6nhotf</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Transclusion count</title>
- <ns>828</ns>
- <id>61792794</id>
- <revision>
- <id>1061635767</id>
- <parentid>1057474521</parentid>
- <timestamp>2021-12-22T22:48:57Z</timestamp>
- <contributor>
- <username>GKFX</username>
- <id>14918984</id>
- </contributor>
- <comment>Correction to tabulate function</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="2174" xml:space="preserve">local p = {}
- function p.fetch(frame)
- local template = nil
- local return_value = nil
- -- Use demo parameter if it exists, otherswise use current template name
- local namespace = mw.title.getCurrentTitle().namespace
- if frame.args["demo"] and frame.args["demo"] ~= "" then
- template = frame.args["demo"]
- elseif namespace == 10 then -- Template namespace
- template = mw.title.getCurrentTitle().text
- elseif namespace == 828 then -- Module namespace
- template = (mw.site.namespaces[828].name .. ":" .. mw.title.getCurrentTitle().text)
- end
- -- If in template or module namespace, look up count in /data
- if template ~= nil then
- namespace = mw.title.new(template, "Template").namespace
- if namespace == 10 or namespace == 828 then
- template = mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end
- local index = mw.ustring.sub(mw.title.new(template).text,1,1)
- local status, data = pcall(function ()
- return(mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other")))
- end)
- if status then
- return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")])
- end
- end
- end
- -- If database value doesn't exist, use value passed to template
- if return_value == nil and frame.args[1] ~= nil then
- local arg1=mw.ustring.match(frame.args[1], '[%d,]+')
- if arg1 and arg1 ~= '' then
- return_value = tonumber(frame:callParserFunction('formatnum', arg1, 'R'))
- end
- end
- return return_value
- end
- -- Tabulate this data for [[Wikipedia:Database reports/Templates transcluded on the most pages]]
- function p.tabulate(frame)
- local list = {}
- for i = 65, 91 do
- local data = mw.loadData('Module:Transclusion count/data/' .. ((i == 91) and 'other' or string.char(i)))
- for name, count in pairs(data) do
- table.insert(list, {mw.title.new(name, "Template").fullText, count})
- end
- end
- table.sort(list, function(a, b)
- return (a[2] == b[2]) and (a[1] < b[1]) or (a[2] > b[2])
- end)
- local lang = mw.getContentLanguage();
- for i = 1, #list do
- list[i] = ('|-\n| %d || [[%s]] || %s\n'):format(i, list[i][1]:gsub('_', ' '), lang:formatNum(list[i][2]))
- end
- return table.concat(list)
- end
- return p</text>
- <sha1>i4hf4ogs2jqprtn91iinnikcxeyynd9</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Transclusion count/data/N</title>
- <ns>828</ns>
- <id>61481068</id>
- <revision>
- <id>1071545058</id>
- <parentid>1070187547</parentid>
- <timestamp>2022-02-13T05:15:36Z</timestamp>
- <contributor>
- <username>Ahechtbot</username>
- <id>26109785</id>
- </contributor>
- <minor/>
- <comment>[[Wikipedia:BOT|Bot]]: Updated page.</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="7724" xml:space="preserve">return {
- ["N"] = 11000,
- ["N/A"] = 20000,
- ["N/a"] = 45000,
- ["NA-Class"] = 14000,
- ["NASTRO_comment"] = 29000,
- ["NBA_Draft_template_list"] = 3200,
- ["NBA_Year"] = 5400,
- ["NBA_color"] = 3600,
- ["NBA_color_cell"] = 4300,
- ["NBA_color_cell2"] = 3400,
- ["NBA_player_statistics_legend"] = 3700,
- ["NBA_player_statistics_start"] = 3300,
- ["NBbox"] = 3400,
- ["NCAA_color_cell"] = 8000,
- ["NCAA_secondary_color_cell"] = 3800,
- ["NED"] = 9500,
- ["NEXTYEAR"] = 6300,
- ["NFLAltPrimaryColor"] = 2100,
- ["NFLAltPrimaryStyle"] = 5700,
- ["NFLAltSecondaryColor"] = 2400,
- ["NFLPrimaryColor"] = 2100,
- ["NFLPrimaryStyle"] = 27000,
- ["NFLSecondaryColor"] = 18000,
- ["NFL_Roster_navbox_template_list"] = 2500,
- ["NFL_Year"] = 21000,
- ["NFL_predraft"] = 4200,
- ["NFL_predraft/check"] = 4200,
- ["NFL_predraft/ftin"] = 4200,
- ["NFT"] = 6200,
- ["NFT_player"] = 30000,
- ["NGA"] = 2900,
- ["NGR"] = 2100,
- ["NHLE"] = 16000,
- ["NHLS_url"] = 2200,
- ["NLD"] = 11000,
- ["NLM_content"] = 2800,
- ["NOINDEX"] = 418000,
- ["NOMIS2011"] = 2200,
- ["NOR"] = 8900,
- ["NRDB_species"] = 5900,
- ["NRHP-PA"] = 2600,
- ["NRHPGoogleMapFootnote"] = 2500,
- ["NRHP_Focus"] = 75000,
- ["NRHP_color"] = 3700,
- ["NRHP_date_for_lists"] = 3100,
- ["NRHP_date_for_lists/dates"] = 3100,
- ["NRHP_header"] = 3300,
- ["NRHP_navigation_box"] = 8000,
- ["NRHP_row"] = 3400,
- ["NRHP_style"] = 69000,
- ["NRHP_url"] = 28000,
- ["NRHP_url/core"] = 30000,
- ["NRISref"] = 72000,
- ["NSWcity"] = 2200,
- ["NSWcity/core"] = 2200,
- ["NUMBEROFSECTIONS"] = 3300,
- ["NYCS_br"] = 2700,
- ["NYCS_time_2"] = 3100,
- ["NZL"] = 6700,
- ["NZ_electorate_link"] = 2200,
- ["Nac"] = 2200,
- ["Namespace_detect"] = 522000,
- ["Namespace_detect_showall"] = 5300,
- ["Nastaliq"] = 9300,
- ["Nat_fs_end"] = 2200,
- ["National_Heritage_List_for_England"] = 20000,
- ["National_Rail_style"] = 5500,
- ["National_Register_of_Historic_Places"] = 29000,
- ["National_Register_of_Historic_Places_in_Massachusetts"] = 4300,
- ["National_Register_of_Historic_Places_in_New_York"] = 5500,
- ["National_Register_of_Historic_Places_in_North_Carolina"] = 2900,
- ["National_Register_of_Historic_Places_in_Pennsylvania"] = 3200,
- ["National_Register_of_Historic_Places_in_Virginia"] = 3100,
- ["National_basketball_squad"] = 3300,
- ["National_field_hockey_squad"] = 3800,
- ["National_football_squad_end"] = 2800,
- ["National_football_squad_start/styles.css"] = 2300,
- ["National_rugby_union_team"] = 3400,
- ["National_squad"] = 39000,
- ["National_squad_no_numbers"] = 16000,
- ["Native_name"] = 13000,
- ["Native_name_checker"] = 76000,
- ["Naval"] = 2100,
- ["Naval/core"] = 2100,
- ["Navbar"] = 939000,
- ["Navbar-collapsible"] = 3400,
- ["Navbar-header"] = 15000,
- ["Navbar-header/styles.css"] = 15000,
- ["Navbox"] = 2940000,
- ["Navbox_GR_munic"] = 3400,
- ["Navbox_Musical_artist"] = 9600,
- ["Navbox_bottom"] = 14000,
- ["Navbox_decade_list"] = 11000,
- ["Navbox_musical_artist"] = 212000,
- ["Navbox_musical_artist/color"] = 212000,
- ["Navbox_rugby_league_squad"] = 5100,
- ["Navbox_season_by_team"] = 3100,
- ["Navbox_top"] = 14000,
- ["Navbox_with_collapsible_groups"] = 130000,
- ["Navbox_with_collapsible_sections"] = 2200,
- ["Navbox_with_columns"] = 23000,
- ["Navboxes"] = 50000,
- ["Navboxes_colour"] = 7200,
- ["Navseasoncats"] = 446000,
- ["Navseasoncats_with_centuries_below_decade"] = 6100,
- ["Navseasoncats_with_decades_below_year"] = 19000,
- ["Navsource"] = 2500,
- ["Navy"] = 18000,
- ["Navy/core"] = 18000,
- ["Nay"] = 13000,
- ["Nbay"] = 5400,
- ["Nbsp"] = 445000,
- ["Nbsp_to_space"] = 17000,
- ["Ndash"] = 17000,
- ["Nee"] = 5300,
- ["NeilBrownPlayers"] = 3100,
- ["New_York_Stock_Exchange"] = 2000,
- ["New_user_bar"] = 57000,
- ["Newbot"] = 4100,
- ["Next_period"] = 19000,
- ["Nfly"] = 2000,
- ["Nihongo"] = 98000,
- ["Nihongo2"] = 12000,
- ["Nihongo_foot"] = 2200,
- ["No"] = 7100,
- ["No."] = 14000,
- ["No2"] = 9100,
- ["NoSpam"] = 4100,
- ["NoSpamEmail"] = 17000,
- ["No_col_break"] = 2100,
- ["No_col_break/styles.css"] = 2100,
- ["No_footnotes"] = 52000,
- ["No_ping"] = 434000,
- ["No_plot"] = 4100,
- ["No_redirect"] = 522000,
- ["No_spam"] = 241000,
- ["No_wrap"] = 2100,
- ["Nobold"] = 360000,
- ["Nobold/styles.css"] = 360000,
- ["Nobr"] = 4000,
- ["Nobreak"] = 28000,
- ["Nochange"] = 2300,
- ["Noflag"] = 2100,
- ["Nofootnotes"] = 2100,
- ["Noindex"] = 4700,
- ["Noitalic"] = 4500,
- ["Noitalic/styles.css"] = 4500,
- ["Nom"] = 33000,
- ["Nominated"] = 5900,
- ["Non-admin_closure"] = 2300,
- ["Non-diffusing_subcategory"] = 12000,
- ["Non-free_2D_art"] = 6300,
- ["Non-free_3D_art"] = 2100,
- ["Non-free_album_cover"] = 192000,
- ["Non-free_audio_sample"] = 8600,
- ["Non-free_biog-pic"] = 21000,
- ["Non-free_book_cover"] = 52000,
- ["Non-free_comic"] = 11000,
- ["Non-free_fair_use"] = 18000,
- ["Non-free_fair_use_in"] = 15000,
- ["Non-free_film_screenshot"] = 5100,
- ["Non-free_game_cover"] = 6500,
- ["Non-free_game_screenshot"] = 4100,
- ["Non-free_historic_image"] = 16000,
- ["Non-free_image_data"] = 8300,
- ["Non-free_image_rationale"] = 9500,
- ["Non-free_in_US"] = 2100,
- ["Non-free_logo"] = 159000,
- ["Non-free_magazine_cover"] = 7400,
- ["Non-free_media"] = 698000,
- ["Non-free_media_data"] = 9400,
- ["Non-free_media_rationale"] = 11000,
- ["Non-free_movie_poster"] = 19000,
- ["Non-free_poster"] = 96000,
- ["Non-free_promotional"] = 9000,
- ["Non-free_school_logo"] = 2300,
- ["Non-free_seal"] = 3500,
- ["Non-free_symbol"] = 6200,
- ["Non-free_television_screenshot"] = 16000,
- ["Non-free_title-card"] = 4700,
- ["Non-free_use_rationale"] = 449000,
- ["Non-free_use_rationale_2"] = 190000,
- ["Non-free_use_rationale_album_cover"] = 127000,
- ["Non-free_use_rationale_book_cover"] = 17000,
- ["Non-free_use_rationale_logo"] = 97000,
- ["Non-free_use_rationale_poster"] = 47000,
- ["Non-free_use_rationale_title-card"] = 2100,
- ["Non-free_use_rationale_video_cover"] = 5600,
- ["Non-free_use_rationale_video_game_cover"] = 9500,
- ["Non-free_video_cover"] = 16000,
- ["Non-free_video_game_cover"] = 20000,
- ["Non-free_video_game_cover/platform"] = 20000,
- ["Non-free_video_game_screenshot"] = 9800,
- ["Non-free_video_game_screenshot/platform"] = 9100,
- ["Non-free_with_permission"] = 2200,
- ["Nonumtoc"] = 2200,
- ["Nonumtoc/styles.css"] = 2200,
- ["Noping"] = 359000,
- ["Noprint"] = 2800,
- ["Noredirect"] = 7900,
- ["Normalwraplink"] = 3100,
- ["NorthAmNative"] = 2600,
- ["North_America_topic"] = 3700,
- ["Northern_Ireland_tasks"] = 19000,
- ["Nospam"] = 13000,
- ["Not-PD-US-expired-min-year"] = 26000,
- ["Not_a_ballot"] = 7400,
- ["Not_a_forum"] = 7300,
- ["Not_a_typo"] = 8200,
- ["Not_around"] = 2700,
- ["Not_done"] = 18000,
- ["Notability"] = 59000,
- ["Notavote"] = 2000,
- ["Notdone"] = 5200,
- ["Note"] = 25000,
- ["NoteFoot"] = 3000,
- ["NoteTag"] = 3000,
- ["Note_label"] = 8600,
- ["Notelist"] = 140000,
- ["Notelist-lr"] = 3000,
- ["Notelist-ua"] = 5500,
- ["Notes"] = 6400,
- ["Noteslist"] = 2800,
- ["Notice"] = 104000,
- ["NovelsWikiProject"] = 19000,
- ["Nowiki_="] = 3800,
- ["Nowrap"] = 1390000,
- ["Npby"] = 2100,
- ["Nq"] = 2800,
- ["Nrut"] = 3400,
- ["Ns"] = 2300,
- ["Ns0"] = 328000,
- ["Ns_has_subpages"] = 1820000,
- ["Nts"] = 15000,
- ["Ntsh"] = 3000,
- ["Number_of_defined_parameters"] = 4400,
- ["Number_table_sorting"] = 27000,
- ["Number_table_sorting_hidden"] = 3000,
- ["Nutshell"] = 3700,
- ["Nw="] = 3800,
- ["Module:NUMBEROFSECTIONS"] = 3300,
- ["Module:Namespace_detect"] = 14300000,
- ["Module:Namespace_detect/config"] = 15600000,
- ["Module:Namespace_detect/data"] = 15600000,
- ["Module:National_squad"] = 52000,
- ["Module:Native_name"] = 85000,
- ["Module:Navbar"] = 6090000,
- ["Module:Navbar/configuration"] = 5410000,
- ["Module:Navbar/styles.css"] = 4790000,
- ["Module:Navbox"] = 4250000,
- ["Module:Navbox/configuration"] = 4120000,
- ["Module:Navbox/styles.css"] = 4120000,
- ["Module:Navbox_top_and_bottom"] = 14000,
- ["Module:Navbox_with_collapsible_groups"] = 135000,
- ["Module:Navboxes"] = 51000,
- ["Module:Navseasoncats"] = 446000,
- ["Module:Nihongo"] = 100000,
- ["Module:No_globals"] = 18000000,
- ["Module:No_ping"] = 434000,
- ["Module:Noinclude"] = 368000,
- ["Module:Ns_has_subpages"] = 1820000,
- ["Module:Number_table_sorting"] = 29000,
- }</text>
- <sha1>iy6voi40ghymue0cyb4o5zma8u59cvh</sha1>
- </revision>
- </page>
- <page>
- <title>Module:Yesno</title>
- <ns>828</ns>
- <id>38665046</id>
- <revision>
- <id>948473803</id>
- <parentid>948472535</parentid>
- <timestamp>2020-04-01T06:27:55Z</timestamp>
- <contributor>
- <username>MusikAnimal</username>
- <id>14882394</id>
- </contributor>
- <comment>Undid revision 948472533 by [[Special:Contributions/w>Vogone|w>Vogone]] ([[User talk:w>Vogone|talk]])</comment>
- <model>Scribunto</model>
- <format>text/plain</format>
- <text bytes="745" xml:space="preserve">-- Function allowing for consistent treatment of boolean-like wikitext input.
- -- It works similarly to the template {{yesno}}.
- return function (val, default)
- -- If your wiki uses non-ascii characters for any of "yes", "no", etc., you
- -- should replace "val:lower()" with "mw.ustring.lower(val)" in the
- -- following line.
- val = type(val) == 'string' and val:lower() or val
- if val == nil then
- return nil
- elseif val == true
- or val == 'yes'
- or val == 'y'
- or val == 'true'
- or val == 't'
- or val == 'on'
- or tonumber(val) == 1
- then
- return true
- elseif val == false
- or val == 'no'
- or val == 'n'
- or val == 'false'
- or val == 'f'
- or val == 'off'
- or tonumber(val) == 0
- then
- return false
- else
- return default
- end
- end</text>
- <sha1>swdskn7svew8i9wuydn9uj5l3r2ghcs</sha1>
- </revision>
- </page>
- </mediawiki>
Add Comment
Please, Sign In to add comment