https://public.kitware.com/Wiki/api.php?action=feedcontributions&user=WikiSysop&feedformat=atomKitwarePublic - User contributions [en]2024-03-28T09:33:54ZUser contributionsMediaWiki 1.38.6https://public.kitware.com/Wiki/index.php?title=Module:Documentation/config&diff=64786Module:Documentation/config2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>----------------------------------------------------------------------------------------------------<br />
--<br />
-- Configuration for Module:Documentation<br />
--<br />
-- Here you can set the values of the parameters and messages used in Module:Documentation to<br />
-- localise it to your wiki and your language. Unless specified otherwise, values given here<br />
-- should be string values.<br />
----------------------------------------------------------------------------------------------------<br />
<br />
local cfg = {} -- Do not edit this line.<br />
<br />
----------------------------------------------------------------------------------------------------<br />
-- Protection template configuration<br />
----------------------------------------------------------------------------------------------------<br />
<br />
-- cfg['protection-reason-edit']<br />
-- The protection reason for edit-protected templates to pass to<br />
-- [[Module:Protection banner]].<br />
cfg['protection-reason-edit'] = 'template'<br />
<br />
--[[<br />
----------------------------------------------------------------------------------------------------<br />
-- Sandbox notice configuration<br />
--<br />
-- On sandbox pages the module can display a template notifying users that the current page is a<br />
-- sandbox, and the location of test cases pages, etc. The module decides whether the page is a<br />
-- sandbox or not based on the value of cfg['sandbox-subpage']. The following settings configure the<br />
-- messages that the notices contains.<br />
----------------------------------------------------------------------------------------------------<br />
--]]<br />
<br />
-- cfg['sandbox-notice-image']<br />
-- The image displayed in the sandbox notice.<br />
cfg['sandbox-notice-image'] = '[[File:Sandbox.svg|50px|alt=|link=]]'<br />
<br />
--[[<br />
-- cfg['sandbox-notice-pagetype-template']<br />
-- cfg['sandbox-notice-pagetype-module']<br />
-- cfg['sandbox-notice-pagetype-other']<br />
-- The page type of the sandbox page. The message that is displayed depends on the current subject<br />
-- namespace. This message is used in either cfg['sandbox-notice-blurb'] or<br />
-- cfg['sandbox-notice-diff-blurb'].<br />
--]]<br />
cfg['sandbox-notice-pagetype-template'] = '[[Wikipedia:Template test cases|template sandbox]] page'<br />
cfg['sandbox-notice-pagetype-module'] = '[[Wikipedia:Template test cases|module sandbox]] page'<br />
cfg['sandbox-notice-pagetype-other'] = 'sandbox page'<br />
<br />
--[[<br />
-- cfg['sandbox-notice-blurb']<br />
-- cfg['sandbox-notice-diff-blurb']<br />
-- cfg['sandbox-notice-diff-display']<br />
-- Either cfg['sandbox-notice-blurb'] or cfg['sandbox-notice-diff-blurb'] is the opening sentence<br />
-- of the sandbox notice. The latter has a diff link, but the former does not. $1 is the page<br />
-- type, which is either cfg['sandbox-notice-pagetype-template'],<br />
-- cfg['sandbox-notice-pagetype-module'] or cfg['sandbox-notice-pagetype-other'] depending what<br />
-- namespace we are in. $2 is a link to the main template page, and $3 is a diff link between<br />
-- the sandbox and the main template. The display value of the diff link is set by <br />
-- cfg['sandbox-notice-compare-link-display'].<br />
--]]<br />
cfg['sandbox-notice-blurb'] = 'This is the $1 for $2.'<br />
cfg['sandbox-notice-diff-blurb'] = 'This is the $1 for $2 ($3).'<br />
cfg['sandbox-notice-compare-link-display'] = 'diff'<br />
<br />
--[[<br />
-- cfg['sandbox-notice-testcases-blurb']<br />
-- cfg['sandbox-notice-testcases-link-display']<br />
-- cfg['sandbox-notice-testcases-run-blurb']<br />
-- cfg['sandbox-notice-testcases-run-link-display']<br />
-- cfg['sandbox-notice-testcases-blurb'] is a sentence notifying the user that there is a test cases page<br />
-- corresponding to this sandbox that they can edit. $1 is a link to the test cases page.<br />
-- cfg['sandbox-notice-testcases-link-display'] is the display value for that link.<br />
-- cfg['sandbox-notice-testcases-run-blurb'] is a sentence notifying the user that there is a test cases page<br />
-- corresponding to this sandbox that they can edit, along with a link to run it. $1 is a link to the test<br />
-- cases page, and $2 is a link to the page to run it.<br />
-- cfg['sandbox-notice-testcases-run-link-display'] is the display value for the link to run the test<br />
-- cases.<br />
--]]<br />
cfg['sandbox-notice-testcases-blurb'] = 'See also the companion subpage for $1.'<br />
cfg['sandbox-notice-testcases-link-display'] = 'test cases'<br />
cfg['sandbox-notice-testcases-run-blurb'] = 'See also the companion subpage for $1 ($2).'<br />
cfg['sandbox-notice-testcases-run-link-display'] = 'run'<br />
<br />
-- cfg['sandbox-category']<br />
-- A category to add to all template sandboxes.<br />
cfg['sandbox-category'] = 'Template sandboxes'<br />
<br />
----------------------------------------------------------------------------------------------------<br />
-- Start box configuration<br />
----------------------------------------------------------------------------------------------------<br />
<br />
-- cfg['documentation-icon-wikitext']<br />
-- The wikitext for the icon shown at the top of the template.<br />
cfg['documentation-icon-wikitext'] = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'<br />
<br />
-- cfg['template-namespace-heading']<br />
-- The heading shown in the template namespace.<br />
cfg['template-namespace-heading'] = 'Template documentation'<br />
<br />
-- cfg['module-namespace-heading']<br />
-- The heading shown in the module namespace.<br />
cfg['module-namespace-heading'] = 'Module documentation'<br />
<br />
-- cfg['file-namespace-heading']<br />
-- The heading shown in the file namespace.<br />
cfg['file-namespace-heading'] = 'Summary'<br />
<br />
-- cfg['other-namespaces-heading']<br />
-- The heading shown in other namespaces.<br />
cfg['other-namespaces-heading'] = 'Documentation'<br />
<br />
-- cfg['view-link-display']<br />
-- The text to display for "view" links.<br />
cfg['view-link-display'] = 'view'<br />
<br />
-- cfg['edit-link-display']<br />
-- The text to display for "edit" links.<br />
cfg['edit-link-display'] = 'edit'<br />
<br />
-- cfg['history-link-display']<br />
-- The text to display for "history" links.<br />
cfg['history-link-display'] = 'history'<br />
<br />
-- cfg['purge-link-display']<br />
-- The text to display for "purge" links.<br />
cfg['purge-link-display'] = 'purge'<br />
<br />
-- cfg['create-link-display']<br />
-- The text to display for "create" links.<br />
cfg['create-link-display'] = 'create'<br />
<br />
----------------------------------------------------------------------------------------------------<br />
-- Link box (end box) configuration<br />
----------------------------------------------------------------------------------------------------<br />
<br />
-- cfg['transcluded-from-blurb']<br />
-- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page.<br />
cfg['transcluded-from-blurb'] = 'The above [[Wikipedia:Template documentation|documentation]] is [[Help:Transclusion|transcluded]] from $1.'<br />
<br />
--[[<br />
-- cfg['create-module-doc-blurb']<br />
-- Notice displayed in the module namespace when the documentation subpage does not exist.<br />
-- $1 is a link to create the documentation page with the preload cfg['module-preload'] and the<br />
-- display cfg['create-link-display'].<br />
--]]<br />
cfg['create-module-doc-blurb'] = 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'<br />
<br />
----------------------------------------------------------------------------------------------------<br />
-- Experiment blurb configuration<br />
----------------------------------------------------------------------------------------------------<br />
<br />
--[[<br />
-- cfg['experiment-blurb-template']<br />
-- cfg['experiment-blurb-module']<br />
-- The experiment blurb is the text inviting editors to experiment in sandbox and test cases pages.<br />
-- It is only shown in the template and module namespaces. With the default English settings, it<br />
-- might look like this:<br />
--<br />
-- Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.<br />
--<br />
-- In this example, "sandbox", "edit", "diff", "testcases", and "edit" would all be links.<br />
--<br />
-- There are two versions, cfg['experiment-blurb-template'] and cfg['experiment-blurb-module'], depending<br />
-- on what namespace we are in.<br />
-- <br />
-- Parameters:<br />
--<br />
-- $1 is a link to the sandbox page. If the sandbox exists, it is in the following format:<br />
--<br />
-- cfg['sandbox-link-display'] (cfg['sandbox-edit-link-display'] | cfg['compare-link-display'])<br />
-- <br />
-- If the sandbox doesn't exist, it is in the format:<br />
--<br />
-- cfg['sandbox-link-display'] (cfg['sandbox-create-link-display'] | cfg['mirror-link-display'])<br />
-- <br />
-- The link for cfg['sandbox-create-link-display'] link preloads the page with cfg['template-sandbox-preload']<br />
-- or cfg['module-sandbox-preload'], depending on the current namespace. The link for cfg['mirror-link-display']<br />
-- loads a default edit summary of cfg['mirror-edit-summary'].<br />
--<br />
-- $2 is a link to the test cases page. If the test cases page exists, it is in the following format:<br />
--<br />
-- cfg['testcases-link-display'] (cfg['testcases-edit-link-display'] | cfg['testcases-run-link-display'])<br />
--<br />
-- If the test cases page doesn't exist, it is in the format:<br />
-- <br />
-- cfg['testcases-link-display'] (cfg['testcases-create-link-display'])<br />
--<br />
-- If the test cases page doesn't exist, the link for cfg['testcases-create-link-display'] preloads the<br />
-- page with cfg['template-testcases-preload'] or cfg['module-testcases-preload'], depending on the current<br />
-- namespace.<br />
--]]<br />
cfg['experiment-blurb-template'] = "Editors can experiment in this template's $1 and $2 pages."<br />
cfg['experiment-blurb-module'] = "Editors can experiment in this module's $1 and $2 pages."<br />
<br />
----------------------------------------------------------------------------------------------------<br />
-- Sandbox link configuration<br />
----------------------------------------------------------------------------------------------------<br />
<br />
-- cfg['sandbox-subpage']<br />
-- The name of the template subpage typically used for sandboxes.<br />
cfg['sandbox-subpage'] = 'sandbox'<br />
<br />
-- cfg['template-sandbox-preload']<br />
-- Preload file for template sandbox pages.<br />
cfg['template-sandbox-preload'] = 'Template:Documentation/preload-sandbox'<br />
<br />
-- cfg['module-sandbox-preload']<br />
-- Preload file for Lua module sandbox pages.<br />
cfg['module-sandbox-preload'] = 'Template:Documentation/preload-module-sandbox'<br />
<br />
-- cfg['sandbox-link-display']<br />
-- The text to display for "sandbox" links.<br />
cfg['sandbox-link-display'] = 'sandbox'<br />
<br />
-- cfg['sandbox-edit-link-display']<br />
-- The text to display for sandbox "edit" links.<br />
cfg['sandbox-edit-link-display'] = 'edit'<br />
<br />
-- cfg['sandbox-create-link-display']<br />
-- The text to display for sandbox "create" links.<br />
cfg['sandbox-create-link-display'] = 'create'<br />
<br />
-- cfg['compare-link-display']<br />
-- The text to display for "compare" links.<br />
cfg['compare-link-display'] = 'diff'<br />
<br />
-- cfg['mirror-edit-summary']<br />
-- The default edit summary to use when a user clicks the "mirror" link. $1 is a wikilink to the<br />
-- template page.<br />
cfg['mirror-edit-summary'] = 'Create sandbox version of $1'<br />
<br />
-- cfg['mirror-link-display']<br />
-- The text to display for "mirror" links.<br />
cfg['mirror-link-display'] = 'mirror'<br />
<br />
-- cfg['mirror-link-preload']<br />
-- The page to preload when a user clicks the "mirror" link.<br />
cfg['mirror-link-preload'] = 'Template:Documentation/mirror'<br />
<br />
----------------------------------------------------------------------------------------------------<br />
-- Test cases link configuration<br />
----------------------------------------------------------------------------------------------------<br />
<br />
-- cfg['testcases-subpage']<br />
-- The name of the template subpage typically used for test cases.<br />
cfg['testcases-subpage'] = 'testcases'<br />
<br />
-- cfg['template-testcases-preload']<br />
-- Preload file for template test cases pages.<br />
cfg['template-testcases-preload'] = 'Template:Documentation/preload-testcases'<br />
<br />
-- cfg['module-testcases-preload']<br />
-- Preload file for Lua module test cases pages.<br />
cfg['module-testcases-preload'] = 'Template:Documentation/preload-module-testcases'<br />
<br />
-- cfg['testcases-link-display']<br />
-- The text to display for "testcases" links.<br />
cfg['testcases-link-display'] = 'testcases'<br />
<br />
-- cfg['testcases-edit-link-display']<br />
-- The text to display for test cases "edit" links.<br />
cfg['testcases-edit-link-display'] = 'edit'<br />
<br />
-- cfg['testcases-run-link-display']<br />
-- The text to display for test cases "run" links.<br />
cfg['testcases-run-link-display'] = 'run'<br />
<br />
-- cfg['testcases-create-link-display']<br />
-- The text to display for test cases "create" links.<br />
cfg['testcases-create-link-display'] = 'create'<br />
<br />
----------------------------------------------------------------------------------------------------<br />
-- Add categories blurb configuration<br />
----------------------------------------------------------------------------------------------------<br />
<br />
--[[<br />
-- cfg['add-categories-blurb']<br />
-- Text to direct users to add categories to the /doc subpage. Not used if the "content" or<br />
-- "docname fed" arguments are set, as then it is not clear where to add the categories. $1 is a<br />
-- link to the /doc subpage with a display value of cfg['doc-link-display'].<br />
--]]<br />
cfg['add-categories-blurb'] = 'Add categories to the $1 subpage.'<br />
<br />
-- cfg['doc-link-display']<br />
-- The text to display when linking to the /doc subpage.<br />
cfg['doc-link-display'] = '/doc'<br />
<br />
----------------------------------------------------------------------------------------------------<br />
-- Subpages link configuration<br />
----------------------------------------------------------------------------------------------------<br />
<br />
--[[<br />
-- cfg['subpages-blurb']<br />
-- The "Subpages of this template" blurb. $1 is a link to the main template's subpages with a<br />
-- display value of cfg['subpages-link-display']. In the English version this blurb is simply<br />
-- the link followed by a period, and the link display provides the actual text.<br />
--]]<br />
cfg['subpages-blurb'] = '$1.'<br />
<br />
--[[<br />
-- cfg['subpages-link-display']<br />
-- The text to display for the "subpages of this page" link. $1 is cfg['template-pagetype'],<br />
-- cfg['module-pagetype'] or cfg['default-pagetype'], depending on whether the current page is in<br />
-- the template namespace, the module namespace, or another namespace.<br />
--]]<br />
cfg['subpages-link-display'] = 'Subpages of this $1'<br />
<br />
-- cfg['template-pagetype']<br />
-- The pagetype to display for template pages.<br />
cfg['template-pagetype'] = 'template'<br />
<br />
-- cfg['module-pagetype']<br />
-- The pagetype to display for Lua module pages.<br />
cfg['module-pagetype'] = 'module'<br />
<br />
-- cfg['default-pagetype']<br />
-- The pagetype to display for pages other than templates or Lua modules.<br />
cfg['default-pagetype'] = 'page'<br />
<br />
----------------------------------------------------------------------------------------------------<br />
-- Doc link configuration<br />
----------------------------------------------------------------------------------------------------<br />
<br />
-- cfg['doc-subpage']<br />
-- The name of the subpage typically used for documentation pages.<br />
cfg['doc-subpage'] = 'doc'<br />
<br />
-- cfg['docpage-preload']<br />
-- Preload file for template documentation pages in all namespaces.<br />
cfg['docpage-preload'] = 'Template:Documentation/preload'<br />
<br />
-- cfg['module-preload']<br />
-- Preload file for Lua module documentation pages.<br />
cfg['module-preload'] = 'Template:Documentation/preload-module-doc'<br />
<br />
----------------------------------------------------------------------------------------------------<br />
-- HTML and CSS configuration<br />
----------------------------------------------------------------------------------------------------<br />
<br />
-- cfg['templatestyles']<br />
-- The name of the TemplateStyles page where CSS is kept.<br />
-- Sandbox CSS will be at Module:Documentation/sandbox/styles.css when needed.<br />
cfg['templatestyles'] = 'Module:Documentation/styles.css'<br />
<br />
-- cfg['container']<br />
-- Class which can be used to set flex or grid CSS on the<br />
-- two child divs documentation and documentation-metadata<br />
cfg['container'] = 'documentation-container'<br />
<br />
-- cfg['main-div-classes']<br />
-- Classes added to the main HTML "div" tag.<br />
cfg['main-div-classes'] = 'documentation'<br />
<br />
-- cfg['main-div-heading-class']<br />
-- Class for the main heading for templates and modules and assoc. talk spaces<br />
cfg['main-div-heading-class'] = 'documentation-heading'<br />
<br />
-- cfg['start-box-class']<br />
-- Class for the start box<br />
cfg['start-box-class'] = 'documentation-startbox'<br />
<br />
-- cfg['start-box-link-classes']<br />
-- Classes used for the [view][edit][history] or [create] links in the start box.<br />
-- mw-editsection-like is per [[Wikipedia:Village pump (technical)/Archive 117]]<br />
cfg['start-box-link-classes'] = 'mw-editsection-like plainlinks'<br />
<br />
-- cfg['end-box-class']<br />
-- Class for the end box.<br />
cfg['end-box-class'] = 'documentation-metadata'<br />
<br />
-- cfg['end-box-plainlinks']<br />
-- Plainlinks<br />
cfg['end-box-plainlinks'] = 'plainlinks'<br />
<br />
-- cfg['toolbar-class']<br />
-- Class added for toolbar links.<br />
cfg['toolbar-class'] = 'documentation-toolbar'<br />
<br />
-- cfg['clear']<br />
-- Just used to clear things.<br />
cfg['clear'] = 'documentation-clear'<br />
<br />
<br />
----------------------------------------------------------------------------------------------------<br />
-- Tracking category configuration<br />
----------------------------------------------------------------------------------------------------<br />
<br />
-- cfg['display-strange-usage-category']<br />
-- Set to true to enable output of cfg['strange-usage-category'] if the module is used on a /doc subpage<br />
-- or a /testcases subpage. This should be a boolean value (either true or false).<br />
cfg['display-strange-usage-category'] = true<br />
<br />
-- cfg['strange-usage-category']<br />
-- Category to output if cfg['display-strange-usage-category'] is set to true and the module is used on a<br />
-- /doc subpage or a /testcases subpage.<br />
cfg['strange-usage-category'] = 'Wikipedia pages with strange ((documentation)) usage'<br />
<br />
--[[<br />
----------------------------------------------------------------------------------------------------<br />
-- End configuration<br />
--<br />
-- Don't edit anything below this line.<br />
----------------------------------------------------------------------------------------------------<br />
--]]<br />
<br />
return cfg</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Documentation&diff=64784Module:Documentation2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>-- This module implements {{documentation}}.<br />
<br />
-- Get required modules.<br />
local getArgs = require('Module:Arguments').getArgs<br />
<br />
-- Get the config table.<br />
local cfg = mw.loadData('Module:Documentation/config')<br />
<br />
local p = {}<br />
<br />
-- Often-used functions.<br />
local ugsub = mw.ustring.gsub<br />
<br />
----------------------------------------------------------------------------<br />
-- Helper functions<br />
--<br />
-- These are defined as local functions, but are made available in the p<br />
-- table for testing purposes.<br />
----------------------------------------------------------------------------<br />
<br />
local function message(cfgKey, valArray, expectType)<br />
--[[<br />
-- Gets a message from the cfg table and formats it if appropriate.<br />
-- The function raises an error if the value from the cfg table is not<br />
-- of the type expectType. The default type for expectType is 'string'.<br />
-- If the table valArray is present, strings such as $1, $2 etc. in the<br />
-- message are substituted with values from the table keys [1], [2] etc.<br />
-- For example, if the message "foo-message" had the value 'Foo $2 bar $1.',<br />
-- message('foo-message', {'baz', 'qux'}) would return "Foo qux bar baz."<br />
--]]<br />
local msg = cfg[cfgKey]<br />
expectType = expectType or 'string'<br />
if type(msg) ~= expectType then<br />
error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)<br />
end<br />
if not valArray then<br />
return msg<br />
end<br />
<br />
local function getMessageVal(match)<br />
match = tonumber(match)<br />
return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)<br />
end<br />
<br />
return ugsub(msg, '$([1-9][0-9]*)', getMessageVal)<br />
end<br />
<br />
p.message = message<br />
<br />
local function makeWikilink(page, display)<br />
if display then<br />
return mw.ustring.format('[[%s|%s]]', page, display)<br />
else<br />
return mw.ustring.format('[[%s]]', page)<br />
end<br />
end<br />
<br />
p.makeWikilink = makeWikilink<br />
<br />
local function makeCategoryLink(cat, sort)<br />
local catns = mw.site.namespaces[14].name<br />
return makeWikilink(catns .. ':' .. cat, sort)<br />
end<br />
<br />
p.makeCategoryLink = makeCategoryLink<br />
<br />
local function makeUrlLink(url, display)<br />
return mw.ustring.format('[%s %s]', url, display)<br />
end<br />
<br />
p.makeUrlLink = makeUrlLink<br />
<br />
local function makeToolbar(...)<br />
local ret = {}<br />
local lim = select('#', ...)<br />
if lim < 1 then<br />
return nil<br />
end<br />
for i = 1, lim do<br />
ret[#ret + 1] = select(i, ...)<br />
end<br />
-- 'documentation-toolbar'<br />
return '<span class="' .. message('toolbar-class') .. '">('<br />
.. table.concat(ret, ' &#124; ') .. ')</span>'<br />
end <br />
<br />
p.makeToolbar = makeToolbar<br />
<br />
----------------------------------------------------------------------------<br />
-- Argument processing<br />
----------------------------------------------------------------------------<br />
<br />
local function makeInvokeFunc(funcName)<br />
return function (frame)<br />
local args = getArgs(frame, {<br />
valueFunc = function (key, value)<br />
if type(value) == 'string' then<br />
value = value:match('^%s*(.-)%s*$') -- Remove whitespace.<br />
if key == 'heading' or value ~= '' then<br />
return value<br />
else<br />
return nil<br />
end<br />
else<br />
return value<br />
end<br />
end<br />
})<br />
return p[funcName](args)<br />
end<br />
end<br />
<br />
----------------------------------------------------------------------------<br />
-- Entry points<br />
----------------------------------------------------------------------------<br />
<br />
function p.nonexistent(frame)<br />
if mw.title.getCurrentTitle().subpageText == 'testcases' then<br />
return frame:expandTemplate{title = 'module test cases notice'}<br />
else<br />
return p.main(frame)<br />
end<br />
end<br />
<br />
p.main = makeInvokeFunc('_main')<br />
<br />
function p._main(args)<br />
--[[<br />
-- This function defines logic flow for the module.<br />
-- @args - table of arguments passed by the user<br />
--]]<br />
local env = p.getEnvironment(args)<br />
local root = mw.html.create()<br />
root<br />
:wikitext(p._getModuleWikitext(args, env))<br />
:wikitext(p.protectionTemplate(env))<br />
:wikitext(p.sandboxNotice(args, env))<br />
:tag('div')<br />
-- 'documentation-container'<br />
:addClass(message('container'))<br />
:attr('role', 'complementary')<br />
:attr('aria-labelledby', args.heading ~= '' and 'documentation-heading' or nil)<br />
:attr('aria-label', args.heading == '' and 'Documentation' or nil)<br />
:newline()<br />
:tag('div')<br />
-- 'documentation'<br />
:addClass(message('main-div-classes'))<br />
:newline()<br />
:wikitext(p._startBox(args, env))<br />
:wikitext(p._content(args, env))<br />
:tag('div')<br />
-- 'documentation-clear'<br />
:addClass(message('clear'))<br />
:done()<br />
:newline()<br />
:done()<br />
:wikitext(p._endBox(args, env))<br />
:done()<br />
:wikitext(p.addTrackingCategories(env))<br />
-- 'Module:Documentation/styles.css'<br />
return mw.getCurrentFrame():extensionTag (<br />
'templatestyles', '', {src=cfg['templatestyles']<br />
}) .. tostring(root)<br />
end<br />
<br />
----------------------------------------------------------------------------<br />
-- Environment settings<br />
----------------------------------------------------------------------------<br />
<br />
function p.getEnvironment(args)<br />
--[[<br />
-- Returns a table with information about the environment, including title<br />
-- objects and other namespace- or path-related data.<br />
-- @args - table of arguments passed by the user<br />
--<br />
-- Title objects include:<br />
-- env.title - the page we are making documentation for (usually the current title)<br />
-- env.templateTitle - the template (or module, file, etc.)<br />
-- env.docTitle - the /doc subpage.<br />
-- env.sandboxTitle - the /sandbox subpage.<br />
-- env.testcasesTitle - the /testcases subpage.<br />
--<br />
-- Data includes:<br />
-- env.protectionLevels - the protection levels table of the title object.<br />
-- env.subjectSpace - the number of the title's subject namespace.<br />
-- env.docSpace - the number of the namespace the title puts its documentation in.<br />
-- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.<br />
-- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.<br />
-- <br />
-- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value<br />
-- returned will be nil.<br />
--]]<br />
<br />
local env, envFuncs = {}, {}<br />
<br />
-- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value<br />
-- returned by that function is memoized in the env table so that we don't call any of the functions<br />
-- more than once. (Nils won't be memoized.)<br />
setmetatable(env, {<br />
__index = function (t, key)<br />
local envFunc = envFuncs[key]<br />
if envFunc then<br />
local success, val = pcall(envFunc)<br />
if success then<br />
env[key] = val -- Memoise the value.<br />
return val<br />
end<br />
end<br />
return nil<br />
end<br />
}) <br />
<br />
function envFuncs.title()<br />
-- The title object for the current page, or a test page passed with args.page.<br />
local title<br />
local titleArg = args.page<br />
if titleArg then<br />
title = mw.title.new(titleArg)<br />
else<br />
title = mw.title.getCurrentTitle()<br />
end<br />
return title<br />
end<br />
<br />
function envFuncs.templateTitle()<br />
--[[<br />
-- The template (or module, etc.) title object.<br />
-- Messages:<br />
-- 'sandbox-subpage' --> 'sandbox'<br />
-- 'testcases-subpage' --> 'testcases'<br />
--]]<br />
local subjectSpace = env.subjectSpace<br />
local title = env.title<br />
local subpage = title.subpageText<br />
if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then<br />
return mw.title.makeTitle(subjectSpace, title.baseText)<br />
else<br />
return mw.title.makeTitle(subjectSpace, title.text)<br />
end<br />
end<br />
<br />
function envFuncs.docTitle()<br />
--[[<br />
-- Title object of the /doc subpage.<br />
-- Messages:<br />
-- 'doc-subpage' --> 'doc'<br />
--]]<br />
local title = env.title<br />
local docname = args[1] -- User-specified doc page.<br />
local docpage<br />
if docname then<br />
docpage = docname<br />
else<br />
docpage = env.docpageBase .. '/' .. message('doc-subpage')<br />
end<br />
return mw.title.new(docpage)<br />
end<br />
<br />
function envFuncs.sandboxTitle()<br />
--[[<br />
-- Title object for the /sandbox subpage.<br />
-- Messages:<br />
-- 'sandbox-subpage' --> 'sandbox'<br />
--]]<br />
return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage'))<br />
end<br />
<br />
function envFuncs.testcasesTitle()<br />
--[[<br />
-- Title object for the /testcases subpage.<br />
-- Messages:<br />
-- 'testcases-subpage' --> 'testcases'<br />
--]]<br />
return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))<br />
end<br />
<br />
function envFuncs.protectionLevels()<br />
-- The protection levels table of the title object.<br />
return env.title.protectionLevels<br />
end<br />
<br />
function envFuncs.subjectSpace()<br />
-- The subject namespace number.<br />
return mw.site.namespaces[env.title.namespace].subject.id<br />
end<br />
<br />
function envFuncs.docSpace()<br />
-- The documentation namespace number. For most namespaces this is the<br />
-- same as the subject namespace. However, pages in the Article, File,<br />
-- MediaWiki or Category namespaces must have their /doc, /sandbox and<br />
-- /testcases pages in talk space.<br />
local subjectSpace = env.subjectSpace<br />
if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then<br />
return subjectSpace + 1<br />
else<br />
return subjectSpace<br />
end<br />
end<br />
<br />
function envFuncs.docpageBase()<br />
-- The base page of the /doc, /sandbox, and /testcases subpages.<br />
-- For some namespaces this is the talk page, rather than the template page.<br />
local templateTitle = env.templateTitle<br />
local docSpace = env.docSpace<br />
local docSpaceText = mw.site.namespaces[docSpace].name<br />
-- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon.<br />
return docSpaceText .. ':' .. templateTitle.text<br />
end<br />
<br />
function envFuncs.compareUrl()<br />
-- Diff link between the sandbox and the main template using [[Special:ComparePages]].<br />
local templateTitle = env.templateTitle<br />
local sandboxTitle = env.sandboxTitle<br />
if templateTitle.exists and sandboxTitle.exists then<br />
local compareUrl = mw.uri.fullUrl(<br />
'Special:ComparePages',<br />
{ page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}<br />
)<br />
return tostring(compareUrl)<br />
else<br />
return nil<br />
end<br />
end <br />
<br />
return env<br />
end <br />
<br />
----------------------------------------------------------------------------<br />
-- Auxiliary templates<br />
----------------------------------------------------------------------------<br />
<br />
p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext')<br />
<br />
function p._getModuleWikitext(args, env)<br />
local currentTitle = mw.title.getCurrentTitle()<br />
if currentTitle.contentModel ~= 'Scribunto' then return end<br />
pcall(require, currentTitle.prefixedText) -- if it fails, we don't care<br />
local moduleWikitext = package.loaded["Module:Module wikitext"]<br />
if moduleWikitext then<br />
return moduleWikitext.main()<br />
end<br />
end<br />
<br />
function p.sandboxNotice(args, env)<br />
--[=[<br />
-- Generates a sandbox notice for display above sandbox pages.<br />
-- @args - a table of arguments passed by the user<br />
-- @env - environment table containing title objects, etc., generated with p.getEnvironment<br />
-- <br />
-- Messages:<br />
-- 'sandbox-notice-image' --> '[[File:Sandbox.svg|50px|alt=|link=]]'<br />
-- 'sandbox-notice-blurb' --> 'This is the $1 for $2.'<br />
-- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).'<br />
-- 'sandbox-notice-pagetype-template' --> '[[Wikipedia:Template test cases|template sandbox]] page'<br />
-- 'sandbox-notice-pagetype-module' --> '[[Wikipedia:Template test cases|module sandbox]] page'<br />
-- 'sandbox-notice-pagetype-other' --> 'sandbox page'<br />
-- 'sandbox-notice-compare-link-display' --> 'diff'<br />
-- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.'<br />
-- 'sandbox-notice-testcases-link-display' --> 'test cases'<br />
-- 'sandbox-category' --> 'Template sandboxes'<br />
--]=]<br />
local title = env.title<br />
local sandboxTitle = env.sandboxTitle<br />
local templateTitle = env.templateTitle<br />
local subjectSpace = env.subjectSpace<br />
if not (subjectSpace and title and sandboxTitle and templateTitle<br />
and mw.title.equals(title, sandboxTitle)) then<br />
return nil<br />
end<br />
-- Build the table of arguments to pass to {{ombox}}. We need just two fields, "image" and "text".<br />
local omargs = {}<br />
omargs.image = message('sandbox-notice-image')<br />
-- Get the text. We start with the opening blurb, which is something like<br />
-- "This is the template sandbox for [[Template:Foo]] (diff)."<br />
local text = ''<br />
local pagetype<br />
if subjectSpace == 10 then<br />
pagetype = message('sandbox-notice-pagetype-template')<br />
elseif subjectSpace == 828 then<br />
pagetype = message('sandbox-notice-pagetype-module')<br />
else<br />
pagetype = message('sandbox-notice-pagetype-other')<br />
end<br />
local templateLink = makeWikilink(templateTitle.prefixedText)<br />
local compareUrl = env.compareUrl<br />
if compareUrl then<br />
local compareDisplay = message('sandbox-notice-compare-link-display')<br />
local compareLink = makeUrlLink(compareUrl, compareDisplay)<br />
text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})<br />
else<br />
text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})<br />
end<br />
-- Get the test cases page blurb if the page exists. This is something like<br />
-- "See also the companion subpage for [[Template:Foo/testcases|test cases]]."<br />
local testcasesTitle = env.testcasesTitle<br />
if testcasesTitle and testcasesTitle.exists then<br />
if testcasesTitle.contentModel == "Scribunto" then<br />
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')<br />
local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')<br />
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)<br />
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)<br />
text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink})<br />
else<br />
local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')<br />
local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)<br />
text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink})<br />
end<br />
end<br />
-- Add the sandbox to the sandbox category.<br />
omargs.text = text .. makeCategoryLink(message('sandbox-category'))<br />
<br />
-- 'documentation-clear'<br />
return '<div class="' .. message('clear') .. '"></div>'<br />
.. require('Module:Message box').main('ombox', omargs)<br />
end<br />
<br />
function p.protectionTemplate(env)<br />
-- Generates the padlock icon in the top right.<br />
-- @env - environment table containing title objects, etc., generated with p.getEnvironment<br />
-- Messages:<br />
-- 'protection-template' --> 'pp-template'<br />
-- 'protection-template-args' --> {docusage = 'yes'}<br />
local protectionLevels = env.protectionLevels<br />
if not protectionLevels then<br />
return nil<br />
end<br />
local editProt = protectionLevels.edit and protectionLevels.edit[1]<br />
local moveProt = protectionLevels.move and protectionLevels.move[1]<br />
if editProt then<br />
-- The page is edit-protected.<br />
return require('Module:Protection banner')._main{<br />
message('protection-reason-edit'), small = true<br />
}<br />
elseif moveProt and moveProt ~= 'autoconfirmed' then<br />
-- The page is move-protected but not edit-protected. Exclude move<br />
-- protection with the level "autoconfirmed", as this is equivalent to<br />
-- no move protection at all.<br />
return require('Module:Protection banner')._main{<br />
action = 'move', small = true<br />
}<br />
else<br />
return nil<br />
end<br />
end<br />
<br />
----------------------------------------------------------------------------<br />
-- Start box<br />
----------------------------------------------------------------------------<br />
<br />
p.startBox = makeInvokeFunc('_startBox')<br />
<br />
function p._startBox(args, env)<br />
--[[<br />
-- This function generates the start box.<br />
-- @args - a table of arguments passed by the user<br />
-- @env - environment table containing title objects, etc., generated with p.getEnvironment<br />
-- <br />
-- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make<br />
-- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox<br />
-- which generate the box HTML.<br />
--]]<br />
env = env or p.getEnvironment(args)<br />
local links<br />
local content = args.content<br />
if not content or args[1] then<br />
-- No need to include the links if the documentation is on the template page itself.<br />
local linksData = p.makeStartBoxLinksData(args, env)<br />
if linksData then<br />
links = p.renderStartBoxLinks(linksData)<br />
end<br />
end<br />
-- Generate the start box html.<br />
local data = p.makeStartBoxData(args, env, links)<br />
if data then<br />
return p.renderStartBox(data)<br />
else<br />
-- User specified no heading.<br />
return nil<br />
end<br />
end<br />
<br />
function p.makeStartBoxLinksData(args, env)<br />
--[[<br />
-- Does initial processing of data to make the [view] [edit] [history] [purge] links.<br />
-- @args - a table of arguments passed by the user<br />
-- @env - environment table containing title objects, etc., generated with p.getEnvironment<br />
-- <br />
-- Messages:<br />
-- 'view-link-display' --> 'view'<br />
-- 'edit-link-display' --> 'edit'<br />
-- 'history-link-display' --> 'history'<br />
-- 'purge-link-display' --> 'purge'<br />
-- 'module-preload' --> 'Template:Documentation/preload-module-doc'<br />
-- 'docpage-preload' --> 'Template:Documentation/preload'<br />
-- 'create-link-display' --> 'create'<br />
--]]<br />
local subjectSpace = env.subjectSpace<br />
local title = env.title<br />
local docTitle = env.docTitle<br />
if not title or not docTitle then<br />
return nil<br />
end<br />
if docTitle.isRedirect then <br />
docTitle = docTitle.redirectTarget<br />
end<br />
<br />
local data = {}<br />
data.title = title<br />
data.docTitle = docTitle<br />
-- View, display, edit, and purge links if /doc exists.<br />
data.viewLinkDisplay = message('view-link-display')<br />
data.editLinkDisplay = message('edit-link-display')<br />
data.historyLinkDisplay = message('history-link-display')<br />
data.purgeLinkDisplay = message('purge-link-display')<br />
-- Create link if /doc doesn't exist.<br />
local preload = args.preload<br />
if not preload then<br />
if subjectSpace == 828 then -- Module namespace<br />
preload = message('module-preload')<br />
else<br />
preload = message('docpage-preload')<br />
end<br />
end<br />
data.preload = preload<br />
data.createLinkDisplay = message('create-link-display')<br />
return data<br />
end<br />
<br />
function p.renderStartBoxLinks(data)<br />
--[[<br />
-- Generates the [view][edit][history][purge] or [create][purge] links from the data table.<br />
-- @data - a table of data generated by p.makeStartBoxLinksData<br />
--]]<br />
<br />
local function escapeBrackets(s)<br />
-- Escapes square brackets with HTML entities.<br />
s = s:gsub('%[', '&#91;') -- Replace square brackets with HTML entities.<br />
s = s:gsub('%]', '&#93;')<br />
return s<br />
end<br />
<br />
local ret<br />
local docTitle = data.docTitle<br />
local title = data.title<br />
local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay)<br />
if docTitle.exists then<br />
local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)<br />
local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay)<br />
local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay)<br />
ret = '[%s] [%s] [%s] [%s]'<br />
ret = escapeBrackets(ret)<br />
ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink)<br />
else<br />
local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)<br />
ret = '[%s] [%s]'<br />
ret = escapeBrackets(ret)<br />
ret = mw.ustring.format(ret, createLink, purgeLink)<br />
end<br />
return ret<br />
end<br />
<br />
function p.makeStartBoxData(args, env, links)<br />
--[=[<br />
-- Does initial processing of data to pass to the start-box render function, p.renderStartBox.<br />
-- @args - a table of arguments passed by the user<br />
-- @env - environment table containing title objects, etc., generated with p.getEnvironment<br />
-- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error.<br />
--<br />
-- Messages:<br />
-- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'<br />
-- 'template-namespace-heading' --> 'Template documentation'<br />
-- 'module-namespace-heading' --> 'Module documentation'<br />
-- 'file-namespace-heading' --> 'Summary'<br />
-- 'other-namespaces-heading' --> 'Documentation'<br />
-- 'testcases-create-link-display' --> 'create'<br />
--]=]<br />
local subjectSpace = env.subjectSpace<br />
if not subjectSpace then<br />
-- Default to an "other namespaces" namespace, so that we get at least some output<br />
-- if an error occurs.<br />
subjectSpace = 2<br />
end<br />
local data = {}<br />
<br />
-- Heading<br />
local heading = args.heading -- Blank values are not removed.<br />
if heading == '' then<br />
-- Don't display the start box if the heading arg is defined but blank.<br />
return nil<br />
end<br />
if heading then<br />
data.heading = heading<br />
elseif subjectSpace == 10 then -- Template namespace<br />
data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading')<br />
elseif subjectSpace == 828 then -- Module namespace<br />
data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading')<br />
elseif subjectSpace == 6 then -- File namespace<br />
data.heading = message('file-namespace-heading')<br />
else<br />
data.heading = message('other-namespaces-heading')<br />
end<br />
<br />
-- Heading CSS<br />
local headingStyle = args['heading-style']<br />
if headingStyle then<br />
data.headingStyleText = headingStyle<br />
else<br />
-- 'documentation-heading'<br />
data.headingClass = message('main-div-heading-class')<br />
end<br />
<br />
-- Data for the [view][edit][history][purge] or [create] links.<br />
if links then<br />
-- 'mw-editsection-like plainlinks'<br />
data.linksClass = message('start-box-link-classes')<br />
data.links = links<br />
end<br />
<br />
return data<br />
end<br />
<br />
function p.renderStartBox(data)<br />
-- Renders the start box html.<br />
-- @data - a table of data generated by p.makeStartBoxData.<br />
local sbox = mw.html.create('div')<br />
sbox<br />
-- 'documentation-startbox'<br />
:addClass(message('start-box-class'))<br />
:newline()<br />
:tag('span')<br />
:addClass(data.headingClass)<br />
:attr('id', 'documentation-heading')<br />
:cssText(data.headingStyleText)<br />
:wikitext(data.heading)<br />
local links = data.links<br />
if links then<br />
sbox:tag('span')<br />
:addClass(data.linksClass)<br />
:attr('id', data.linksId)<br />
:wikitext(links)<br />
end<br />
return tostring(sbox)<br />
end<br />
<br />
----------------------------------------------------------------------------<br />
-- Documentation content<br />
----------------------------------------------------------------------------<br />
<br />
p.content = makeInvokeFunc('_content')<br />
<br />
function p._content(args, env)<br />
-- Displays the documentation contents<br />
-- @args - a table of arguments passed by the user<br />
-- @env - environment table containing title objects, etc., generated with p.getEnvironment<br />
env = env or p.getEnvironment(args)<br />
local docTitle = env.docTitle<br />
local content = args.content<br />
if not content and docTitle and docTitle.exists then<br />
content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}<br />
end<br />
-- The line breaks below are necessary so that "=== Headings ===" at the start and end<br />
-- of docs are interpreted correctly.<br />
return '\n' .. (content or '') .. '\n' <br />
end<br />
<br />
p.contentTitle = makeInvokeFunc('_contentTitle')<br />
<br />
function p._contentTitle(args, env)<br />
env = env or p.getEnvironment(args)<br />
local docTitle = env.docTitle<br />
if not args.content and docTitle and docTitle.exists then<br />
return docTitle.prefixedText<br />
else<br />
return ''<br />
end<br />
end<br />
<br />
----------------------------------------------------------------------------<br />
-- End box<br />
----------------------------------------------------------------------------<br />
<br />
p.endBox = makeInvokeFunc('_endBox')<br />
<br />
function p._endBox(args, env)<br />
--[=[<br />
-- This function generates the end box (also known as the link box).<br />
-- @args - a table of arguments passed by the user<br />
-- @env - environment table containing title objects, etc., generated with p.getEnvironment<br />
-- <br />
--]=]<br />
<br />
-- Get environment data.<br />
env = env or p.getEnvironment(args)<br />
local subjectSpace = env.subjectSpace<br />
local docTitle = env.docTitle<br />
if not subjectSpace or not docTitle then<br />
return nil<br />
end<br />
<br />
-- Check whether we should output the end box at all. Add the end<br />
-- box by default if the documentation exists or if we are in the<br />
-- user, module or template namespaces.<br />
local linkBox = args['link box']<br />
if linkBox == 'off'<br />
or not (<br />
docTitle.exists<br />
or subjectSpace == 2<br />
or subjectSpace == 828<br />
or subjectSpace == 10<br />
)<br />
then<br />
return nil<br />
end<br />
<br />
-- Assemble the link box.<br />
local text = ''<br />
if linkBox then<br />
text = text .. linkBox<br />
else<br />
text = text .. (p.makeDocPageBlurb(args, env) or '') -- "This documentation is transcluded from [[Foo]]." <br />
if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then<br />
-- We are in the user, template or module namespaces.<br />
-- Add sandbox and testcases links.<br />
-- "Editors can experiment in this template's sandbox and testcases pages."<br />
text = text .. (p.makeExperimentBlurb(args, env) or '') .. '<br />'<br />
if not args.content and not args[1] then<br />
-- "Please add categories to the /doc subpage."<br />
-- Don't show this message with inline docs or with an explicitly specified doc page,<br />
-- as then it is unclear where to add the categories.<br />
text = text .. (p.makeCategoriesBlurb(args, env) or '')<br />
end<br />
text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template"<br />
end<br />
end<br />
<br />
local box = mw.html.create('div')<br />
-- 'documentation-metadata'<br />
box:attr('role', 'note')<br />
:addClass(message('end-box-class'))<br />
-- 'plainlinks'<br />
:addClass(message('end-box-plainlinks'))<br />
:wikitext(text)<br />
:done()<br />
<br />
return '\n' .. tostring(box)<br />
end<br />
<br />
function p.makeDocPageBlurb(args, env)<br />
--[=[<br />
-- Makes the blurb "This documentation is transcluded from [[Template:Foo]] (edit, history)".<br />
-- @args - a table of arguments passed by the user<br />
-- @env - environment table containing title objects, etc., generated with p.getEnvironment<br />
-- <br />
-- Messages:<br />
-- 'edit-link-display' --> 'edit'<br />
-- 'history-link-display' --> 'history'<br />
-- 'transcluded-from-blurb' --> <br />
-- 'The above [[Wikipedia:Template documentation|documentation]] <br />
-- is [[Help:Transclusion|transcluded]] from $1.'<br />
-- 'module-preload' --> 'Template:Documentation/preload-module-doc'<br />
-- 'create-link-display' --> 'create'<br />
-- 'create-module-doc-blurb' --><br />
-- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'<br />
--]=]<br />
local docTitle = env.docTitle<br />
if not docTitle then<br />
return nil<br />
end<br />
local ret<br />
if docTitle.exists then<br />
-- /doc exists; link to it.<br />
local docLink = makeWikilink(docTitle.prefixedText)<br />
local editUrl = docTitle:fullUrl{action = 'edit'}<br />
local editDisplay = message('edit-link-display')<br />
local editLink = makeUrlLink(editUrl, editDisplay)<br />
local historyUrl = docTitle:fullUrl{action = 'history'}<br />
local historyDisplay = message('history-link-display')<br />
local historyLink = makeUrlLink(historyUrl, historyDisplay)<br />
ret = message('transcluded-from-blurb', {docLink})<br />
.. ' '<br />
.. makeToolbar(editLink, historyLink)<br />
.. '<br />'<br />
elseif env.subjectSpace == 828 then<br />
-- /doc does not exist; ask to create it.<br />
local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')}<br />
local createDisplay = message('create-link-display')<br />
local createLink = makeUrlLink(createUrl, createDisplay)<br />
ret = message('create-module-doc-blurb', {createLink})<br />
.. '<br />'<br />
end<br />
return ret<br />
end<br />
<br />
function p.makeExperimentBlurb(args, env)<br />
--[[<br />
-- Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages."<br />
-- @args - a table of arguments passed by the user<br />
-- @env - environment table containing title objects, etc., generated with p.getEnvironment<br />
-- <br />
-- Messages:<br />
-- 'sandbox-link-display' --> 'sandbox'<br />
-- 'sandbox-edit-link-display' --> 'edit'<br />
-- 'compare-link-display' --> 'diff'<br />
-- 'module-sandbox-preload' --> 'Template:Documentation/preload-module-sandbox'<br />
-- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'<br />
-- 'sandbox-create-link-display' --> 'create'<br />
-- 'mirror-edit-summary' --> 'Create sandbox version of $1'<br />
-- 'mirror-link-display' --> 'mirror'<br />
-- 'mirror-link-preload' --> 'Template:Documentation/mirror'<br />
-- 'sandbox-link-display' --> 'sandbox'<br />
-- 'testcases-link-display' --> 'testcases'<br />
-- 'testcases-edit-link-display'--> 'edit'<br />
-- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox'<br />
-- 'testcases-create-link-display' --> 'create'<br />
-- 'testcases-link-display' --> 'testcases'<br />
-- 'testcases-edit-link-display' --> 'edit'<br />
-- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases'<br />
-- 'template-testcases-preload' --> 'Template:Documentation/preload-testcases'<br />
-- 'experiment-blurb-module' --> 'Editors can experiment in this module's $1 and $2 pages.'<br />
-- 'experiment-blurb-template' --> 'Editors can experiment in this template's $1 and $2 pages.'<br />
--]]<br />
local subjectSpace = env.subjectSpace<br />
local templateTitle = env.templateTitle<br />
local sandboxTitle = env.sandboxTitle<br />
local testcasesTitle = env.testcasesTitle<br />
local templatePage = templateTitle.prefixedText<br />
if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then<br />
return nil<br />
end<br />
-- Make links.<br />
local sandboxLinks, testcasesLinks<br />
if sandboxTitle.exists then<br />
local sandboxPage = sandboxTitle.prefixedText<br />
local sandboxDisplay = message('sandbox-link-display')<br />
local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)<br />
local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'}<br />
local sandboxEditDisplay = message('sandbox-edit-link-display')<br />
local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay)<br />
local compareUrl = env.compareUrl<br />
local compareLink<br />
if compareUrl then<br />
local compareDisplay = message('compare-link-display')<br />
compareLink = makeUrlLink(compareUrl, compareDisplay)<br />
end<br />
sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)<br />
else<br />
local sandboxPreload<br />
if subjectSpace == 828 then<br />
sandboxPreload = message('module-sandbox-preload')<br />
else<br />
sandboxPreload = message('template-sandbox-preload')<br />
end<br />
local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload}<br />
local sandboxCreateDisplay = message('sandbox-create-link-display')<br />
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)<br />
local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})<br />
local mirrorPreload = message('mirror-link-preload')<br />
local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}<br />
if subjectSpace == 828 then<br />
mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}<br />
end<br />
local mirrorDisplay = message('mirror-link-display')<br />
local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)<br />
sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink)<br />
end<br />
if testcasesTitle.exists then<br />
local testcasesPage = testcasesTitle.prefixedText<br />
local testcasesDisplay = message('testcases-link-display')<br />
local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)<br />
local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'}<br />
local testcasesEditDisplay = message('testcases-edit-link-display')<br />
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)<br />
-- for Modules, add testcases run link if exists<br />
if testcasesTitle.contentModel == "Scribunto" and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then<br />
local testcasesRunLinkDisplay = message('testcases-run-link-display')<br />
local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)<br />
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink)<br />
else<br />
testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)<br />
end<br />
else<br />
local testcasesPreload<br />
if subjectSpace == 828 then<br />
testcasesPreload = message('module-testcases-preload')<br />
else<br />
testcasesPreload = message('template-testcases-preload')<br />
end<br />
local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload}<br />
local testcasesCreateDisplay = message('testcases-create-link-display')<br />
local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)<br />
testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink)<br />
end<br />
local messageName<br />
if subjectSpace == 828 then<br />
messageName = 'experiment-blurb-module'<br />
else<br />
messageName = 'experiment-blurb-template'<br />
end<br />
return message(messageName, {sandboxLinks, testcasesLinks})<br />
end<br />
<br />
function p.makeCategoriesBlurb(args, env)<br />
--[[<br />
-- Generates the text "Please add categories to the /doc subpage."<br />
-- @args - a table of arguments passed by the user<br />
-- @env - environment table containing title objects, etc., generated with p.getEnvironment<br />
-- Messages:<br />
-- 'doc-link-display' --> '/doc'<br />
-- 'add-categories-blurb' --> 'Please add categories to the $1 subpage.'<br />
--]]<br />
local docTitle = env.docTitle<br />
if not docTitle then<br />
return nil<br />
end<br />
local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))<br />
return message('add-categories-blurb', {docPathLink})<br />
end<br />
<br />
function p.makeSubpagesBlurb(args, env)<br />
--[[<br />
-- Generates the "Subpages of this template" link.<br />
-- @args - a table of arguments passed by the user<br />
-- @env - environment table containing title objects, etc., generated with p.getEnvironment<br />
<br />
-- Messages:<br />
-- 'template-pagetype' --> 'template'<br />
-- 'module-pagetype' --> 'module'<br />
-- 'default-pagetype' --> 'page'<br />
-- 'subpages-link-display' --> 'Subpages of this $1'<br />
--]]<br />
local subjectSpace = env.subjectSpace<br />
local templateTitle = env.templateTitle<br />
if not subjectSpace or not templateTitle then<br />
return nil<br />
end<br />
local pagetype<br />
if subjectSpace == 10 then<br />
pagetype = message('template-pagetype')<br />
elseif subjectSpace == 828 then<br />
pagetype = message('module-pagetype')<br />
else<br />
pagetype = message('default-pagetype')<br />
end<br />
local subpagesLink = makeWikilink(<br />
'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',<br />
message('subpages-link-display', {pagetype})<br />
)<br />
return message('subpages-blurb', {subpagesLink})<br />
end<br />
<br />
----------------------------------------------------------------------------<br />
-- Tracking categories<br />
----------------------------------------------------------------------------<br />
<br />
function p.addTrackingCategories(env)<br />
--[[<br />
-- Check if {{documentation}} is transcluded on a /doc or /testcases page.<br />
-- @env - environment table containing title objects, etc., generated with p.getEnvironment<br />
<br />
-- Messages:<br />
-- 'display-strange-usage-category' --> true<br />
-- 'doc-subpage' --> 'doc'<br />
-- 'testcases-subpage' --> 'testcases'<br />
-- 'strange-usage-category' --> 'Wikipedia pages with strange ((documentation)) usage'<br />
-- <br />
-- /testcases pages in the module namespace are not categorised, as they may have<br />
-- {{documentation}} transcluded automatically.<br />
--]]<br />
local title = env.title<br />
local subjectSpace = env.subjectSpace<br />
if not title or not subjectSpace then<br />
return nil<br />
end<br />
local subpage = title.subpageText<br />
local ret = ''<br />
if message('display-strange-usage-category', nil, 'boolean')<br />
and (<br />
subpage == message('doc-subpage')<br />
or subjectSpace ~= 828 and subpage == message('testcases-subpage')<br />
)<br />
then<br />
ret = ret .. makeCategoryLink(message('strange-usage-category'))<br />
end<br />
return ret<br />
end<br />
<br />
return p</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Template:Documentation&diff=64782Template:Documentation2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>{{#invoke:documentation|main|_content={{ {{#invoke:documentation|contentTitle}}}}}}<noinclude><br />
<!-- Add categories to the /doc subpage --><br />
</noinclude></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Template:No_redirect&diff=64780Template:No redirect2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>{{safesubst:<noinclude/>#if: {{safesubst:<noinclude/>#invoke:Redirect|isRedirect|{{{1}}}}}<br />
| <span class="plainlinks">[{{safesubst:<noinclude/>fullurl:{{{1}}}|redirect=no}} {{{2|{{{1}}}}}}]</span><br />
| {{safesubst:<noinclude/>#if:{{{2|}}}|[[:{{safesubst:<noinclude/>FULLPAGENAME:{{{1}}}}}|{{{2}}}]]|[[:{{safesubst:<noinclude/>FULLPAGENAME:{{{1}}}}}]]}}<br />
}}<noinclude><br />
{{documentation}}<br />
</noinclude></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Template:Para&diff=64778Template:Para2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div><code class="tpl-para" style="word-break:break-word;{{SAFESUBST:<noinclude />#if:{{{plain|}}}|border: none; background-color: inherit;}} {{SAFESUBST:<noinclude />#if:{{{plain|}}}{{{mxt|}}}{{{green|}}}{{{!mxt|}}}{{{red|}}}|color: {{SAFESUBST:<noinclude />#if:{{{mxt|}}}{{{green|}}}|#006400|{{SAFESUBST:<noinclude />#if:{{{!mxt|}}}{{{red|}}}|#8B0000|inherit}}}};}} {{SAFESUBST:<noinclude />#if:{{{style|}}}|{{{style}}}}}">&#124;{{SAFESUBST:<noinclude />#if:{{{1|}}}|{{{1}}}&#61;}}{{{2|}}}</code><noinclude><br />
{{Documentation}}<br />
<!--Categories and interwikis go near the bottom of the /doc subpage.--><br />
</noinclude></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Template:Em&diff=64776Template:Em2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div><em {{#if:{{{role|}}}|role="{{{role}}}"}} {{#if:{{{class|}}}|class="{{{class}}}"}} {{#if:{{{id|}}}|id="{{{id}}}"}} {{#if:{{{style|}}}|style="{{{style}}}"}} {{#if:{{{title|}}}|title="{{{title}}}"}}>{{{1}}}</em><noinclude><br />
{{documentation}}<br />
<!-- Add categories to the /doc subpage, interwikis to Wikidata, not here --><br />
</noinclude></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Protection_banner/config&diff=64774Module:Protection banner/config2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>-- This module provides configuration data for [[Module:Protection banner]].<br />
<br />
return {<br />
<br />
--------------------------------------------------------------------------------<br />
--<br />
-- BANNER DATA<br />
--<br />
--------------------------------------------------------------------------------<br />
<br />
--[[<br />
-- Banner data consists of six fields:<br />
-- * text - the main protection text that appears at the top of protection<br />
-- banners.<br />
-- * explanation - the text that appears below the main protection text, used<br />
-- to explain the details of the protection.<br />
-- * tooltip - the tooltip text you see when you move the mouse over a small<br />
-- padlock icon.<br />
-- * link - the page that the small padlock icon links to.<br />
-- * alt - the alt text for the small padlock icon. This is also used as tooltip<br />
-- text for the large protection banners.<br />
-- * image - the padlock image used in both protection banners and small padlock<br />
-- icons.<br />
--<br />
-- The module checks in three separate tables to find a value for each field.<br />
-- First it checks the banners table, which has values specific to the reason<br />
-- for the page being protected. Then the module checks the defaultBanners<br />
-- table, which has values specific to each protection level. Finally, the<br />
-- module checks the masterBanner table, which holds data for protection<br />
-- templates to use if no data has been found in the previous two tables.<br />
--<br />
-- The values in the banner data can take parameters. These are specified<br />
-- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name<br />
-- enclosed in curly braces).<br />
--<br />
-- Available parameters:<br />
--<br />
-- ${CURRENTVERSION} - a link to the page history or the move log, with the<br />
-- display message "current-version-edit-display" or<br />
-- "current-version-move-display".<br />
--<br />
-- ${EDITREQUEST} - a link to create an edit request for the current page.<br />
--<br />
-- ${EXPLANATIONBLURB} - an explanation blurb, e.g. "Please discuss any changes<br />
-- on the talk page; you may submit a request to ask an administrator to make<br />
-- an edit if it is minor or supported by consensus."<br />
--<br />
-- ${IMAGELINK} - a link to set the image to, depending on the protection<br />
-- action and protection level.<br />
--<br />
-- ${INTROBLURB} - the PROTECTIONBLURB parameter, plus the expiry if an expiry<br />
-- is set. E.g. "Editing of this page by new or unregistered users is currently <br />
-- disabled until dd Month YYYY."<br />
--<br />
-- ${INTROFRAGMENT} - the same as ${INTROBLURB}, but without final punctuation<br />
-- so that it can be used in run-on sentences.<br />
--<br />
-- ${PAGETYPE} - the type of the page, e.g. "article" or "template".<br />
-- Defined in the cfg.pagetypes table.<br />
--<br />
-- ${PROTECTIONBLURB} - a blurb explaining the protection level of the page, e.g.<br />
-- "Editing of this page by new or unregistered users is currently disabled"<br />
--<br />
-- ${PROTECTIONDATE} - the protection date, if it has been supplied to the<br />
-- template.<br />
--<br />
-- ${PROTECTIONLEVEL} - the protection level, e.g. "fully protected" or<br />
-- "semi-protected".<br />
--<br />
-- ${PROTECTIONLOG} - a link to the protection log or the pending changes log,<br />
-- depending on the protection action.<br />
--<br />
-- ${TALKPAGE} - a link to the talk page. If a section is specified, links<br />
-- straight to that talk page section.<br />
--<br />
-- ${TOOLTIPBLURB} - uses the PAGETYPE, PROTECTIONTYPE and EXPIRY parameters to<br />
-- create a blurb like "This template is semi-protected", or "This article is<br />
-- move-protected until DD Month YYYY".<br />
--<br />
-- ${VANDAL} - links for the specified username (or the root page name)<br />
-- using Module:Vandal-m.<br />
--<br />
-- Functions<br />
--<br />
-- For advanced users, it is possible to use Lua functions instead of strings<br />
-- in the banner config tables. Using functions gives flexibility that is not<br />
-- possible just by using parameters. Functions take two arguments, the<br />
-- protection object and the template arguments, and they must output a string.<br />
--<br />
-- For example:<br />
--<br />
-- text = function (protectionObj, args)<br />
-- if protectionObj.level == 'autoconfirmed' then<br />
-- return 'foo'<br />
-- else<br />
-- return 'bar'<br />
-- end<br />
-- end<br />
--<br />
-- Some protection object properties and methods that may be useful:<br />
-- protectionObj.action - the protection action<br />
-- protectionObj.level - the protection level<br />
-- protectionObj.reason - the protection reason<br />
-- protectionObj.expiry - the expiry. Nil if unset, the string "indef" if set<br />
-- to indefinite, and the protection time in unix time if temporary.<br />
-- protectionObj.protectionDate - the protection date in unix time, or nil if<br />
-- unspecified.<br />
-- protectionObj.bannerConfig - the banner config found by the module. Beware<br />
-- of editing the config field used by the function, as it could create an<br />
-- infinite loop.<br />
-- protectionObj:isProtected - returns a boolean showing whether the page is<br />
-- protected.<br />
-- protectionObj:isTemporary - returns a boolean showing whether the expiry is<br />
-- temporary.<br />
-- protectionObj:isIncorrect - returns a boolean showing whether the protection<br />
-- template is incorrect.<br />
--]]<br />
<br />
-- The master banner data, used if no values have been found in banners or<br />
-- defaultBanners.<br />
masterBanner = {<br />
text = '${INTROBLURB}',<br />
explanation = '${EXPLANATIONBLURB}',<br />
tooltip = '${TOOLTIPBLURB}',<br />
link = '${IMAGELINK}',<br />
alt = 'Page ${PROTECTIONLEVEL}'<br />
},<br />
<br />
-- The default banner data. This holds banner data for different protection<br />
-- levels.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
defaultBanners = {<br />
edit = {},<br />
move = {},<br />
autoreview = {<br />
default = {<br />
alt = 'Page protected with pending changes',<br />
tooltip = 'All edits by unregistered and new users are subject to review prior to becoming visible to unregistered users',<br />
image = 'Pending-protection-shackle.svg'<br />
}<br />
},<br />
upload = {}<br />
},<br />
<br />
-- The banner data. This holds banner data for different protection reasons.<br />
-- In fact, the reasons specified in this table control which reasons are<br />
-- valid inputs to the first positional parameter.<br />
--<br />
-- There is also a non-standard "description" field that can be used for items<br />
-- in this table. This is a description of the protection reason for use in the<br />
-- module documentation.<br />
--<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
banners = {<br />
edit = {<br />
blp = {<br />
description = 'For pages protected to promote compliance with the'<br />
.. ' [[Wikipedia:Biographies of living persons'<br />
.. '|biographies of living persons]] policy',<br />
text = '${INTROFRAGMENT} to promote compliance with'<br />
.. ' [[Wikipedia:Biographies of living persons'<br />
.. "|Wikipedia's&nbsp;policy on&nbsp;the&nbsp;biographies"<br />
.. ' of&nbsp;living&nbsp;people]].',<br />
tooltip = '${TOOLTIPFRAGMENT} to promote compliance with the policy on'<br />
.. ' biographies of living persons',<br />
},<br />
dmca = {<br />
description = 'For pages protected by the Wikimedia Foundation'<br />
.. ' due to [[Digital Millennium Copyright Act]] takedown requests',<br />
explanation = function (protectionObj, args)<br />
local ret = 'Pursuant to a rights owner notice under the Digital'<br />
.. ' Millennium Copyright Act (DMCA) regarding some content'<br />
.. ' in this article, the Wikimedia Foundation acted under'<br />
.. ' applicable law and took down and restricted the content'<br />
.. ' in question.'<br />
if args.notice then<br />
ret = ret .. ' A copy of the received notice can be found here: '<br />
.. args.notice .. '.'<br />
end<br />
ret = ret .. ' For more information, including websites discussing'<br />
.. ' how to file a counter-notice, please see'<br />
.. " [[Wikipedia:Office actions]] and the article's ${TALKPAGE}."<br />
.. "'''Do not remove this template from the article until the"<br />
.. " restrictions are withdrawn'''."<br />
return ret<br />
end,<br />
image = 'Office-protection-shackle.svg',<br />
},<br />
dispute = {<br />
description = 'For pages protected due to editing disputes',<br />
text = function (protectionObj, args)<br />
-- Find the value of "disputes".<br />
local display = 'disputes'<br />
local disputes<br />
if args.section then<br />
disputes = string.format(<br />
'[[%s:%s#%s|%s]]',<br />
mw.site.namespaces[protectionObj.title.namespace].talk.name,<br />
protectionObj.title.text,<br />
args.section,<br />
display<br />
)<br />
else<br />
disputes = display<br />
end<br />
<br />
-- Make the blurb, depending on the expiry.<br />
local msg<br />
if type(protectionObj.expiry) == 'number' then<br />
msg = '${INTROFRAGMENT} or until editing %s have been resolved.'<br />
else<br />
msg = '${INTROFRAGMENT} until editing %s have been resolved.'<br />
end<br />
return string.format(msg, disputes)<br />
end,<br />
explanation = "This protection is '''not''' an endorsement of the"<br />
.. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',<br />
tooltip = '${TOOLTIPFRAGMENT} due to editing disputes',<br />
},<br />
ecp = {<br />
description = 'For articles in topic areas authorized by'<br />
.. ' [[Wikipedia:Arbitration Committee|ArbCom]] or'<br />
.. ' meets the criteria for community use',<br />
tooltip = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}',<br />
alt = 'Extended-protected ${PAGETYPE}',<br />
},<br />
mainpage = {<br />
description = 'For pages protected for being displayed on the [[Main Page]]',<br />
text = 'This file is currently'<br />
.. ' [[Wikipedia:This page is protected|protected]] from'<br />
.. ' editing because it is currently or will soon be displayed'<br />
.. ' on the [[Main Page]].',<br />
explanation = 'Images on the Main Page are protected due to their high'<br />
.. ' visibility. Please discuss any necessary changes on the ${TALKPAGE}.'<br />
.. '<br /><span style="font-size:90%;">'<br />
.. "'''Administrators:''' Once this image is definitely off the Main Page,"<br />
.. ' please unprotect this file, or reduce to semi-protection,'<br />
.. ' as appropriate.</span>',<br />
},<br />
office = {<br />
description = 'For pages protected by the Wikimedia Foundation',<br />
text = function (protectionObj, args)<br />
local ret = 'This ${PAGETYPE} is currently under the'<br />
.. ' scrutiny of the'<br />
.. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]'<br />
.. ' and is protected.'<br />
if protectionObj.protectionDate then<br />
ret = ret .. ' It has been protected since ${PROTECTIONDATE}.'<br />
end<br />
return ret<br />
end,<br />
explanation = "If you can edit this page, please discuss all changes and"<br />
.. " additions on the ${TALKPAGE} first. '''Do not remove protection from this"<br />
.. " page unless you are authorized by the Wikimedia Foundation to do"<br />
.. " so.'''",<br />
image = 'Office-protection-shackle.svg',<br />
},<br />
reset = {<br />
description = 'For pages protected by the Wikimedia Foundation and'<br />
.. ' "reset" to a bare-bones version',<br />
text = 'This ${PAGETYPE} is currently under the'<br />
.. ' scrutiny of the'<br />
.. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]'<br />
.. ' and is protected.',<br />
explanation = function (protectionObj, args)<br />
local ret = ''<br />
if protectionObj.protectionDate then<br />
ret = ret .. 'On ${PROTECTIONDATE} this ${PAGETYPE} was'<br />
else<br />
ret = ret .. 'This ${PAGETYPE} has been'<br />
end<br />
ret = ret .. ' reduced to a'<br />
.. ' simplified, "bare bones" version so that it may be completely'<br />
.. ' rewritten to ensure it meets the policies of'<br />
.. ' [[WP:NPOV|Neutral Point of View]] and [[WP:V|Verifiability]].'<br />
.. ' Standard Wikipedia policies will apply to its rewriting—which'<br />
.. ' will eventually be open to all editors—and will be strictly'<br />
.. ' enforced. The ${PAGETYPE} has been ${PROTECTIONLEVEL} while'<br />
.. ' it is being rebuilt.\n\n'<br />
.. 'Any insertion of material directly from'<br />
.. ' pre-protection revisions of the ${PAGETYPE} will be removed, as'<br />
.. ' will any material added to the ${PAGETYPE} that is not properly'<br />
.. ' sourced. The associated talk page(s) were also cleared on the'<br />
.. " same date.\n\n"<br />
.. "If you can edit this page, please discuss all changes and"<br />
.. " additions on the ${TALKPAGE} first. '''Do not override"<br />
.. " this action, and do not remove protection from this page,"<br />
.. " unless you are authorized by the Wikimedia Foundation"<br />
.. " to do so. No editor may remove this notice.'''"<br />
<br />
return ret<br />
end,<br />
image = 'Office-protection-shackle.svg',<br />
},<br />
sock = {<br />
description = 'For pages protected due to'<br />
.. ' [[Wikipedia:Sock puppetry|sock puppetry]]',<br />
text = '${INTROFRAGMENT} to prevent [[Wikipedia:Sock puppetry|sock puppets]] of'<br />
.. ' [[Wikipedia:Blocking policy|blocked]] or'<br />
.. ' [[Wikipedia:Banning policy|banned users]]'<br />
.. ' from editing it.',<br />
tooltip = '${TOOLTIPFRAGMENT} to prevent sock puppets of blocked or banned users from'<br />
.. ' editing it',<br />
},<br />
template = {<br />
description = 'For [[Wikipedia:High-risk templates|high-risk]]'<br />
.. ' templates and Lua modules',<br />
text = 'This is a permanently [[Help:Protection|protected]] ${PAGETYPE},'<br />
.. ' as it is [[Wikipedia:High-risk templates|high-risk]].',<br />
explanation = 'Please discuss any changes on the ${TALKPAGE}; you may'<br />
.. ' ${EDITREQUEST} to ask an'<br />
.. ' [[Wikipedia:Administrators|administrator]] or'<br />
.. ' [[Wikipedia:Template editor|template editor]] to make an edit if'<br />
.. ' it is [[Help:Minor edit#When to mark an edit as a minor edit'<br />
.. '|uncontroversial]] or supported by'<br />
.. ' [[Wikipedia:Consensus|consensus]]. You can also'<br />
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'<br />
.. ' unprotected.',<br />
tooltip = 'This high-risk ${PAGETYPE} is permanently ${PROTECTIONLEVEL}'<br />
.. ' to prevent vandalism',<br />
alt = 'Permanently protected ${PAGETYPE}',<br />
},<br />
usertalk = {<br />
description = 'For pages protected against disruptive edits by a'<br />
.. ' particular user',<br />
text = '${INTROFRAGMENT} to prevent ${VANDAL} from using it to make disruptive edits,'<br />
.. ' such as abusing the'<br />
.. ' &#123;&#123;[[Template:unblock|unblock]]&#125;&#125; template.',<br />
explanation = 'If you cannot edit this user talk page and you need to'<br />
.. ' make a change or leave a message, you can'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for edits to a protected page'<br />
.. '|request an edit]],'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]],'<br />
.. ' [[Special:Userlogin|log in]],'<br />
.. ' or [[Special:UserLogin/signup|create an account]].',<br />
},<br />
vandalism = {<br />
description = 'For pages protected against'<br />
.. ' [[Wikipedia:Vandalism|vandalism]]',<br />
text = '${INTROFRAGMENT} due to [[Wikipedia:Vandalism|vandalism]].',<br />
explanation = function (protectionObj, args)<br />
local ret = ''<br />
if protectionObj.level == 'sysop' then<br />
ret = ret .. "This protection is '''not''' an endorsement of the"<br />
.. ' ${CURRENTVERSION}. '<br />
end<br />
return ret .. '${EXPLANATIONBLURB}'<br />
end,<br />
tooltip = '${TOOLTIPFRAGMENT} due to vandalism',<br />
}<br />
},<br />
move = {<br />
dispute = {<br />
description = 'For pages protected against page moves due to'<br />
.. ' disputes over the page title',<br />
explanation = "This protection is '''not''' an endorsement of the"<br />
.. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',<br />
image = 'Move-protection-shackle.svg'<br />
},<br />
vandalism = {<br />
description = 'For pages protected against'<br />
.. ' [[Wikipedia:Vandalism#Page-move vandalism'<br />
.. ' |page-move vandalism]]'<br />
}<br />
},<br />
autoreview = {},<br />
upload = {}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
--<br />
-- GENERAL DATA TABLES<br />
--<br />
--------------------------------------------------------------------------------<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection blurbs<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table produces the protection blurbs available with the<br />
-- ${PROTECTIONBLURB} parameter. It is sorted by protection action and<br />
-- protection level, and is checked by the module in the following order:<br />
-- 1. page's protection action, page's protection level<br />
-- 2. page's protection action, default protection level<br />
-- 3. "edit" protection action, default protection level<br />
--<br />
-- It is possible to use banner parameters inside this table.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
protectionBlurbs = {<br />
edit = {<br />
default = 'This ${PAGETYPE} is currently [[Help:Protection|'<br />
.. 'protected]] from editing',<br />
autoconfirmed = 'Editing of this ${PAGETYPE} by [[Wikipedia:User access'<br />
.. ' levels#New users|new]] or [[Wikipedia:User access levels#Unregistered'<br />
.. ' users|unregistered]] users is currently [[Help:Protection|disabled]]',<br />
extendedconfirmed = 'This ${PAGETYPE} is currently under extended confirmed protection',<br />
},<br />
move = {<br />
default = 'This ${PAGETYPE} is currently [[Help:Protection|protected]]'<br />
.. ' from [[Help:Moving a page|page moves]]'<br />
},<br />
autoreview = {<br />
default = 'All edits made to this ${PAGETYPE} by'<br />
.. ' [[Wikipedia:User access levels#New users|new]] or'<br />
.. ' [[Wikipedia:User access levels#Unregistered users|unregistered]]'<br />
.. ' users are currently'<br />
.. ' [[Wikipedia:Pending changes|subject to review]]'<br />
},<br />
upload = {<br />
default = 'Uploading new versions of this ${PAGETYPE} is currently disabled'<br />
}<br />
},<br />
<br />
<br />
--------------------------------------------------------------------------------<br />
-- Explanation blurbs<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table produces the explanation blurbs available with the<br />
-- ${EXPLANATIONBLURB} parameter. It is sorted by protection action,<br />
-- protection level, and whether the page is a talk page or not. If the page is<br />
-- a talk page it will have a talk key of "talk"; otherwise it will have a talk<br />
-- key of "subject". The table is checked in the following order:<br />
-- 1. page's protection action, page's protection level, page's talk key<br />
-- 2. page's protection action, page's protection level, default talk key<br />
-- 3. page's protection action, default protection level, page's talk key<br />
-- 4. page's protection action, default protection level, default talk key<br />
--<br />
-- It is possible to use banner parameters inside this table.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
explanationBlurbs = {<br />
edit = {<br />
autoconfirmed = {<br />
subject = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details. If you'<br />
.. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can'<br />
.. ' ${EDITREQUEST}, discuss changes on the ${TALKPAGE},'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]], [[Special:Userlogin|log in]], or'<br />
.. ' [[Special:UserLogin/signup|create an account]].',<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details. If you'<br />
.. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]], [[Special:Userlogin|log in]], or'<br />
.. ' [[Special:UserLogin/signup|create an account]].',<br />
},<br />
extendedconfirmed = {<br />
default = 'Extended confirmed protection prevents edits from all unregistered editors'<br />
.. ' and registered users with fewer than 30 days tenure and 500 edits.'<br />
.. ' The [[Wikipedia:Protection policy#extended|policy on community use]]'<br />
.. ' specifies that extended confirmed protection can be applied to combat'<br />
.. ' disruption, if semi-protection has proven to be ineffective.'<br />
.. ' Extended confirmed protection may also be applied to enforce'<br />
.. ' [[Wikipedia:Arbitration Committee|arbitration sanctions]].'<br />
.. ' Please discuss any changes on the ${TALKPAGE}; you may'<br />
.. ' ${EDITREQUEST} to ask for uncontroversial changes supported by'<br />
.. ' [[Wikipedia:Consensus|consensus]].'<br />
},<br />
default = {<br />
subject = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' Please discuss any changes on the ${TALKPAGE}; you'<br />
.. ' may ${EDITREQUEST} to ask an'<br />
.. ' [[Wikipedia:Administrators|administrator]] to make an edit if it'<br />
.. ' is [[Help:Minor edit#When to mark an edit as a minor edit'<br />
.. '|uncontroversial]] or supported by [[Wikipedia:Consensus'<br />
.. '|consensus]]. You may also [[Wikipedia:Requests for'<br />
.. ' page protection#Current requests for reduction in protection level'<br />
.. '|request]] that this page be unprotected.',<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' You may [[Wikipedia:Requests for page'<br />
.. ' protection#Current requests for edits to a protected page|request an'<br />
.. ' edit]] to this page, or [[Wikipedia:Requests for'<br />
.. ' page protection#Current requests for reduction in protection level'<br />
.. '|ask]] for it to be unprotected.'<br />
}<br />
},<br />
move = {<br />
default = {<br />
subject = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' The page may still be edited but cannot be moved'<br />
.. ' until unprotected. Please discuss any suggested moves on the'<br />
.. ' ${TALKPAGE} or at [[Wikipedia:Requested moves]]. You can also'<br />
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'<br />
.. ' unprotected.',<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' The page may still be edited but cannot be moved'<br />
.. ' until unprotected. Please discuss any suggested moves at'<br />
.. ' [[Wikipedia:Requested moves]]. You can also'<br />
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'<br />
.. ' unprotected.'<br />
}<br />
},<br />
autoreview = {<br />
default = {<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' Edits to this ${PAGETYPE} by new and unregistered users'<br />
.. ' will not be visible to readers until they are accepted by'<br />
.. ' a reviewer. To avoid the need for your edits to be'<br />
.. ' reviewed, you may'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]], [[Special:Userlogin|log in]], or'<br />
.. ' [[Special:UserLogin/signup|create an account]].'<br />
},<br />
},<br />
upload = {<br />
default = {<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' The page may still be edited but new versions of the file'<br />
.. ' cannot be uploaded until it is unprotected. You can'<br />
.. ' request that a new version be uploaded by using a'<br />
.. ' [[Wikipedia:Edit requests|protected edit request]], or you'<br />
.. ' can [[Wikipedia:Requests for page protection|request]]'<br />
.. ' that the file be unprotected.'<br />
}<br />
}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection levels<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table provides the data for the ${PROTECTIONLEVEL} parameter, which<br />
-- produces a short label for different protection levels. It is sorted by<br />
-- protection action and protection level, and is checked in the following<br />
-- order:<br />
-- 1. page's protection action, page's protection level<br />
-- 2. page's protection action, default protection level<br />
-- 3. "edit" protection action, default protection level<br />
--<br />
-- It is possible to use banner parameters inside this table.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
protectionLevels = {<br />
edit = {<br />
default = 'protected',<br />
templateeditor = 'template-protected',<br />
extendedconfirmed = 'extended-protected',<br />
autoconfirmed = 'semi-protected',<br />
},<br />
move = {<br />
default = 'move-protected'<br />
},<br />
autoreview = {<br />
},<br />
upload = {<br />
default = 'upload-protected'<br />
}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Images<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table lists different padlock images for each protection action and<br />
-- protection level. It is used if an image is not specified in any of the<br />
-- banner data tables, and if the page does not satisfy the conditions for using<br />
-- the ['image-filename-indef'] image. It is checked in the following order:<br />
-- 1. page's protection action, page's protection level<br />
-- 2. page's protection action, default protection level<br />
images = {<br />
edit = {<br />
default = 'Full-protection-shackle.svg',<br />
templateeditor = 'Template-protection-shackle.svg',<br />
extendedconfirmed = 'Extended-protection-shackle.svg',<br />
autoconfirmed = 'Semi-protection-shackle.svg'<br />
},<br />
move = {<br />
default = 'Move-protection-shackle.svg',<br />
},<br />
autoreview = {<br />
default = 'Pending-protection-shackle.svg'<br />
},<br />
upload = {<br />
default = 'Upload-protection-shackle.svg'<br />
}<br />
},<br />
<br />
-- Pages with a reason specified in this table will show the special "indef"<br />
-- padlock, defined in the 'image-filename-indef' message, if no expiry is set.<br />
indefImageReasons = {<br />
template = true<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Image links<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table provides the data for the ${IMAGELINK} parameter, which gets<br />
-- the image link for small padlock icons based on the page's protection action<br />
-- and protection level. It is checked in the following order:<br />
-- 1. page's protection action, page's protection level<br />
-- 2. page's protection action, default protection level<br />
-- 3. "edit" protection action, default protection level<br />
--<br />
-- It is possible to use banner parameters inside this table.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
imageLinks = {<br />
edit = {<br />
default = 'Wikipedia:Protection policy#full',<br />
templateeditor = 'Wikipedia:Protection policy#template',<br />
extendedconfirmed = 'Wikipedia:Protection policy#extended',<br />
autoconfirmed = 'Wikipedia:Protection policy#semi'<br />
},<br />
move = {<br />
default = 'Wikipedia:Protection policy#move'<br />
},<br />
autoreview = {<br />
default = 'Wikipedia:Protection policy#pending'<br />
},<br />
upload = {<br />
default = 'Wikipedia:Protection policy#upload'<br />
}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Padlock indicator names<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table provides the "name" attribute for the <indicator> extension tag<br />
-- with which small padlock icons are generated. All indicator tags on a page<br />
-- are displayed in alphabetical order based on this attribute, and with<br />
-- indicator tags with duplicate names, the last tag on the page wins.<br />
-- The attribute is chosen based on the protection action; table keys must be a<br />
-- protection action name or the string "default".<br />
padlockIndicatorNames = {<br />
autoreview = 'pp-autoreview',<br />
default = 'pp-default'<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection categories<br />
--------------------------------------------------------------------------------<br />
<br />
--[[<br />
-- The protection categories are stored in the protectionCategories table.<br />
-- Keys to this table are made up of the following strings:<br />
--<br />
-- 1. the expiry date<br />
-- 2. the namespace<br />
-- 3. the protection reason (e.g. "dispute" or "vandalism")<br />
-- 4. the protection level (e.g. "sysop" or "autoconfirmed")<br />
-- 5. the action (e.g. "edit" or "move")<br />
-- <br />
-- When the module looks up a category in the table, first it will will check to<br />
-- see a key exists that corresponds to all five parameters. For example, a<br />
-- user page semi-protected from vandalism for two weeks would have the key<br />
-- "temp-user-vandalism-autoconfirmed-edit". If no match is found, the module<br />
-- changes the first part of the key to "all" and checks the table again. It<br />
-- keeps checking increasingly generic key combinations until it finds the<br />
-- field, or until it reaches the key "all-all-all-all-all".<br />
--<br />
-- The module uses a binary matrix to determine the order in which to search.<br />
-- This is best demonstrated by a table. In this table, the "0" values<br />
-- represent "all", and the "1" values represent the original data (e.g.<br />
-- "indef" or "file" or "vandalism").<br />
--<br />
-- expiry namespace reason level action<br />
-- order<br />
-- 1 1 1 1 1 1<br />
-- 2 0 1 1 1 1<br />
-- 3 1 0 1 1 1<br />
-- 4 0 0 1 1 1<br />
-- 5 1 1 0 1 1<br />
-- 6 0 1 0 1 1<br />
-- 7 1 0 0 1 1<br />
-- 8 0 0 0 1 1<br />
-- 9 1 1 1 0 1<br />
-- 10 0 1 1 0 1<br />
-- 11 1 0 1 0 1<br />
-- 12 0 0 1 0 1<br />
-- 13 1 1 0 0 1<br />
-- 14 0 1 0 0 1<br />
-- 15 1 0 0 0 1<br />
-- 16 0 0 0 0 1<br />
-- 17 1 1 1 1 0<br />
-- 18 0 1 1 1 0<br />
-- 19 1 0 1 1 0<br />
-- 20 0 0 1 1 0<br />
-- 21 1 1 0 1 0<br />
-- 22 0 1 0 1 0<br />
-- 23 1 0 0 1 0<br />
-- 24 0 0 0 1 0<br />
-- 25 1 1 1 0 0<br />
-- 26 0 1 1 0 0<br />
-- 27 1 0 1 0 0<br />
-- 28 0 0 1 0 0<br />
-- 29 1 1 0 0 0<br />
-- 30 0 1 0 0 0<br />
-- 31 1 0 0 0 0<br />
-- 32 0 0 0 0 0<br />
--<br />
-- In this scheme the action has the highest priority, as it is the last<br />
-- to change, and the expiry has the least priority, as it changes the most.<br />
-- The priorities of the expiry, the protection level and the action are<br />
-- fixed, but the priorities of the reason and the namespace can be swapped<br />
-- through the use of the cfg.bannerDataNamespaceHasPriority table.<br />
--]]<br />
<br />
-- If the reason specified to the template is listed in this table,<br />
-- namespace data will take priority over reason data in the protectionCategories<br />
-- table.<br />
reasonsWithNamespacePriority = {<br />
vandalism = true,<br />
},<br />
<br />
-- The string to use as a namespace key for the protectionCategories table for each<br />
-- namespace number.<br />
categoryNamespaceKeys = {<br />
[ 2] = 'user',<br />
[ 3] = 'user',<br />
[ 4] = 'project',<br />
[ 6] = 'file',<br />
[ 8] = 'mediawiki',<br />
[ 10] = 'template',<br />
[ 12] = 'project',<br />
[ 14] = 'category',<br />
[100] = 'portal',<br />
[828] = 'module',<br />
},<br />
<br />
protectionCategories = {<br />
['all|all|all|all|all'] = 'Wikipedia fully protected pages',<br />
['all|all|office|all|all'] = 'Wikipedia Office-protected pages',<br />
['all|all|reset|all|all'] = 'Wikipedia Office-protected pages',<br />
['all|all|dmca|all|all'] = 'Wikipedia Office-protected pages',<br />
['all|all|mainpage|all|all'] = 'Wikipedia fully-protected main page files',<br />
['all|all|all|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages',<br />
['all|all|ecp|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages',<br />
['all|template|all|all|edit'] = 'Wikipedia fully protected templates',<br />
['all|all|all|autoconfirmed|edit'] = 'Wikipedia semi-protected pages',<br />
['indef|all|all|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected pages',<br />
['all|all|blp|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected biographies of living people',<br />
['temp|all|blp|autoconfirmed|edit'] = 'Wikipedia temporarily semi-protected biographies of living people',<br />
['all|all|dispute|autoconfirmed|edit'] = 'Wikipedia pages semi-protected due to dispute',<br />
['all|all|sock|autoconfirmed|edit'] = 'Wikipedia pages semi-protected from banned users',<br />
['all|all|vandalism|autoconfirmed|edit'] = 'Wikipedia pages semi-protected against vandalism',<br />
['all|category|all|autoconfirmed|edit'] = 'Wikipedia semi-protected categories',<br />
['all|file|all|autoconfirmed|edit'] = 'Wikipedia semi-protected files',<br />
['all|portal|all|autoconfirmed|edit'] = 'Wikipedia semi-protected portals',<br />
['all|project|all|autoconfirmed|edit'] = 'Wikipedia semi-protected project pages',<br />
['all|talk|all|autoconfirmed|edit'] = 'Wikipedia semi-protected talk pages',<br />
['all|template|all|autoconfirmed|edit'] = 'Wikipedia semi-protected templates',<br />
['all|user|all|autoconfirmed|edit'] = 'Wikipedia semi-protected user and user talk pages',<br />
['all|all|all|templateeditor|edit'] = 'Wikipedia template-protected pages other than templates and modules',<br />
['all|template|all|templateeditor|edit'] = 'Wikipedia template-protected templates',<br />
['all|template|all|templateeditor|move'] = 'Wikipedia template-protected templates', -- move-protected templates<br />
['all|all|blp|sysop|edit'] = 'Wikipedia indefinitely protected biographies of living people',<br />
['temp|all|blp|sysop|edit'] = 'Wikipedia temporarily protected biographies of living people',<br />
['all|all|dispute|sysop|edit'] = 'Wikipedia pages protected due to dispute',<br />
['all|all|sock|sysop|edit'] = 'Wikipedia pages protected from banned users',<br />
['all|all|vandalism|sysop|edit'] = 'Wikipedia pages protected against vandalism',<br />
['all|category|all|sysop|edit'] = 'Wikipedia fully protected categories',<br />
['all|file|all|sysop|edit'] = 'Wikipedia fully-protected files',<br />
['all|project|all|sysop|edit'] = 'Wikipedia fully-protected project pages',<br />
['all|talk|all|sysop|edit'] = 'Wikipedia fully-protected talk pages',<br />
['all|template|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed-protected templates',<br />
['all|template|all|sysop|edit'] = 'Wikipedia fully protected templates',<br />
['all|user|all|sysop|edit'] = 'Wikipedia fully protected user and user talk pages',<br />
['all|module|all|all|edit'] = 'Wikipedia fully-protected modules',<br />
['all|module|all|templateeditor|edit'] = 'Wikipedia template-protected modules',<br />
['all|module|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed-protected modules',<br />
['all|module|all|autoconfirmed|edit'] = 'Wikipedia semi-protected modules',<br />
['all|all|all|sysop|move'] = 'Wikipedia move-protected pages',<br />
['indef|all|all|sysop|move'] = 'Wikipedia indefinitely move-protected pages',<br />
['all|all|dispute|sysop|move'] = 'Wikipedia pages move-protected due to dispute',<br />
['all|all|vandalism|sysop|move'] = 'Wikipedia pages move-protected due to vandalism',<br />
['all|portal|all|sysop|move'] = 'Wikipedia move-protected portals',<br />
['all|project|all|sysop|move'] = 'Wikipedia move-protected project pages',<br />
['all|talk|all|sysop|move'] = 'Wikipedia move-protected talk pages',<br />
['all|template|all|sysop|move'] = 'Wikipedia move-protected templates',<br />
['all|user|all|sysop|move'] = 'Wikipedia move-protected user and user talk pages',<br />
['all|all|all|autoconfirmed|autoreview'] = 'Wikipedia pending changes protected pages',<br />
['all|file|all|all|upload'] = 'Wikipedia upload-protected files',<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Expiry category config<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table configures the expiry category behaviour for each protection<br />
-- action.<br />
-- * If set to true, setting that action will always categorise the page if<br />
-- an expiry parameter is not set.<br />
-- * If set to false, setting that action will never categorise the page.<br />
-- * If set to nil, the module will categorise the page if:<br />
-- 1) an expiry parameter is not set, and<br />
-- 2) a reason is provided, and<br />
-- 3) the specified reason is not blacklisted in the reasonsWithoutExpiryCheck<br />
-- table.<br />
<br />
expiryCheckActions = {<br />
edit = nil,<br />
move = false,<br />
autoreview = true,<br />
upload = false<br />
},<br />
<br />
reasonsWithoutExpiryCheck = {<br />
blp = true,<br />
template = true,<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Pagetypes<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table produces the page types available with the ${PAGETYPE} parameter.<br />
-- Keys are namespace numbers, or the string "default" for the default value.<br />
pagetypes = {<br />
[0] = 'article',<br />
[6] = 'file',<br />
[10] = 'template',<br />
[14] = 'category',<br />
[828] = 'module',<br />
default = 'page'<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Strings marking indefinite protection<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table contains values passed to the expiry parameter that mean the page<br />
-- is protected indefinitely.<br />
indefStrings = {<br />
['indef'] = true,<br />
['indefinite'] = true,<br />
['indefinitely'] = true,<br />
['infinite'] = true,<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Group hierarchy<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table maps each group to all groups that have a superset of the original<br />
-- group's page editing permissions.<br />
hierarchy = {<br />
sysop = {},<br />
reviewer = {'sysop'},<br />
filemover = {'sysop'},<br />
templateeditor = {'sysop'},<br />
extendedconfirmed = {'sysop'},<br />
autoconfirmed = {'reviewer', 'filemover', 'templateeditor', 'extendedconfirmed'},<br />
user = {'autoconfirmed'},<br />
['*'] = {'user'}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Wrapper templates and their default arguments<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table contains wrapper templates used with the module, and their<br />
-- default arguments. Templates specified in this table should contain the<br />
-- following invocation, and no other template content:<br />
--<br />
-- {{#invoke:Protection banner|main}}<br />
--<br />
-- If other content is desired, it can be added between<br />
-- <noinclude>...</noinclude> tags.<br />
--<br />
-- When a user calls one of these wrapper templates, they will use the<br />
-- default arguments automatically. However, users can override any of the<br />
-- arguments.<br />
wrappers = {<br />
['Template:Pp'] = {},<br />
['Template:Pp-extended'] = {'ecp'},<br />
['Template:Pp-blp'] = {'blp'},<br />
-- we don't need Template:Pp-create<br />
['Template:Pp-dispute'] = {'dispute'},<br />
['Template:Pp-main-page'] = {'mainpage'},<br />
['Template:Pp-move'] = {action = 'move', catonly = 'yes'},<br />
['Template:Pp-move-dispute'] = {'dispute', action = 'move', catonly = 'yes'},<br />
-- we don't need Template:Pp-move-indef<br />
['Template:Pp-move-vandalism'] = {'vandalism', action = 'move', catonly = 'yes'},<br />
['Template:Pp-office'] = {'office'},<br />
['Template:Pp-office-dmca'] = {'dmca'},<br />
['Template:Pp-pc'] = {action = 'autoreview', small = true},<br />
['Template:Pp-pc1'] = {action = 'autoreview', small = true},<br />
['Template:Pp-reset'] = {'reset'},<br />
['Template:Pp-semi-indef'] = {small = true},<br />
['Template:Pp-sock'] = {'sock'},<br />
['Template:Pp-template'] = {'template', small = true},<br />
['Template:Pp-upload'] = {action = 'upload'},<br />
['Template:Pp-usertalk'] = {'usertalk'},<br />
['Template:Pp-vandalism'] = {'vandalism'},<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- <br />
-- MESSAGES<br />
-- <br />
--------------------------------------------------------------------------------<br />
<br />
msg = {<br />
<br />
--------------------------------------------------------------------------------<br />
-- Intro blurb and intro fragment<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages specify what is produced by the ${INTROBLURB} and<br />
-- ${INTROFRAGMENT} parameters. If the protection is temporary they use the<br />
-- intro-blurb-expiry or intro-fragment-expiry, and if not they use<br />
-- intro-blurb-noexpiry or intro-fragment-noexpiry.<br />
-- It is possible to use banner parameters in these messages.<br />
['intro-blurb-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY}.',<br />
['intro-blurb-noexpiry'] = '${PROTECTIONBLURB}.',<br />
['intro-fragment-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY},',<br />
['intro-fragment-noexpiry'] = '${PROTECTIONBLURB}',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Tooltip blurb<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages specify what is produced by the ${TOOLTIPBLURB} parameter.<br />
-- If the protection is temporary the tooltip-blurb-expiry message is used, and<br />
-- if not the tooltip-blurb-noexpiry message is used.<br />
-- It is possible to use banner parameters in these messages.<br />
['tooltip-blurb-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY}.',<br />
['tooltip-blurb-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}.',<br />
['tooltip-fragment-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY},',<br />
['tooltip-fragment-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Special explanation blurb<br />
--------------------------------------------------------------------------------<br />
<br />
-- An explanation blurb for pages that cannot be unprotected, e.g. for pages<br />
-- in the MediaWiki namespace.<br />
-- It is possible to use banner parameters in this message.<br />
['explanation-blurb-nounprotect'] = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' Please discuss any changes on the ${TALKPAGE}; you'<br />
.. ' may ${EDITREQUEST} to ask an'<br />
.. ' [[Wikipedia:Administrators|administrator]] to make an edit if it'<br />
.. ' is [[Help:Minor edit#When to mark an edit as a minor edit'<br />
.. '|uncontroversial]] or supported by [[Wikipedia:Consensus'<br />
.. '|consensus]].',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection log display values<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages determine the display values for the protection log link<br />
-- or the pending changes log link produced by the ${PROTECTIONLOG} parameter.<br />
-- It is possible to use banner parameters in these messages.<br />
['protection-log-display'] = 'protection log',<br />
['pc-log-display'] = 'pending changes log',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Current version display values<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages determine the display values for the page history link<br />
-- or the move log link produced by the ${CURRENTVERSION} parameter.<br />
-- It is possible to use banner parameters in these messages.<br />
['current-version-move-display'] = 'current title',<br />
['current-version-edit-display'] = 'current version',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Talk page<br />
--------------------------------------------------------------------------------<br />
<br />
-- This message determines the display value of the talk page link produced<br />
-- with the ${TALKPAGE} parameter.<br />
-- It is possible to use banner parameters in this message.<br />
['talk-page-link-display'] = 'talk page',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Edit requests<br />
--------------------------------------------------------------------------------<br />
<br />
-- This message determines the display value of the edit request link produced<br />
-- with the ${EDITREQUEST} parameter.<br />
-- It is possible to use banner parameters in this message.<br />
['edit-request-display'] = 'submit an edit request',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Expiry date format<br />
--------------------------------------------------------------------------------<br />
<br />
-- This is the format for the blurb expiry date. It should be valid input for<br />
-- the first parameter of the #time parser function.<br />
['expiry-date-format'] = 'F j, Y "at" H:i e',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Tracking categories<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages determine which tracking categories the module outputs.<br />
['tracking-category-incorrect'] = 'Wikipedia pages with incorrect protection templates',<br />
['tracking-category-template'] = 'Wikipedia template-protected pages other than templates and modules',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Images<br />
--------------------------------------------------------------------------------<br />
<br />
-- These are images that are not defined by their protection action and protection level.<br />
['image-filename-indef'] = 'Full-protection-shackle.svg',<br />
['image-filename-default'] = 'Transparent.gif',<br />
<br />
--------------------------------------------------------------------------------<br />
-- End messages<br />
--------------------------------------------------------------------------------<br />
}<br />
<br />
--------------------------------------------------------------------------------<br />
-- End configuration<br />
--------------------------------------------------------------------------------<br />
}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Protection_banner&diff=64772Module:Protection banner2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>-- This module implements {{pp-meta}} and its daughter templates such as<br />
-- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}.<br />
<br />
-- Initialise necessary modules.<br />
require('strict')<br />
local makeFileLink = require('Module:File link')._main<br />
local effectiveProtectionLevel = require('Module:Effective protection level')._main<br />
local effectiveProtectionExpiry = require('Module:Effective protection expiry')._main<br />
local yesno = require('Module:Yesno')<br />
<br />
-- Lazily initialise modules and objects we don't always need.<br />
local getArgs, makeMessageBox, lang<br />
<br />
-- Set constants.<br />
local CONFIG_MODULE = 'Module:Protection banner/config'<br />
<br />
--------------------------------------------------------------------------------<br />
-- Helper functions<br />
--------------------------------------------------------------------------------<br />
<br />
local function makeCategoryLink(cat, sort)<br />
if cat then<br />
return string.format(<br />
'[[%s:%s|%s]]',<br />
mw.site.namespaces[14].name,<br />
cat,<br />
sort<br />
)<br />
end<br />
end<br />
<br />
-- Validation function for the expiry and the protection date<br />
local function validateDate(dateString, dateType)<br />
if not lang then<br />
lang = mw.language.getContentLanguage()<br />
end<br />
local success, result = pcall(lang.formatDate, lang, 'U', dateString)<br />
if success then<br />
result = tonumber(result)<br />
if result then<br />
return result<br />
end<br />
end<br />
error(string.format(<br />
'invalid %s: %s',<br />
dateType,<br />
tostring(dateString)<br />
), 4)<br />
end<br />
<br />
local function makeFullUrl(page, query, display)<br />
return string.format(<br />
'[%s %s]',<br />
tostring(mw.uri.fullUrl(page, query)),<br />
display<br />
)<br />
end<br />
<br />
-- Given a directed graph formatted as node -> table of direct successors,<br />
-- get a table of all nodes reachable from a given node (though always<br />
-- including the given node).<br />
local function getReachableNodes(graph, start)<br />
local toWalk, retval = {[start] = true}, {}<br />
while true do<br />
-- Can't use pairs() since we're adding and removing things as we're iterating<br />
local k = next(toWalk) -- This always gets the "first" key<br />
if k == nil then<br />
return retval<br />
end<br />
toWalk[k] = nil<br />
retval[k] = true<br />
for _,v in ipairs(graph[k]) do<br />
if not retval[v] then<br />
toWalk[v] = true<br />
end<br />
end<br />
end<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection class<br />
--------------------------------------------------------------------------------<br />
<br />
local Protection = {}<br />
Protection.__index = Protection<br />
<br />
Protection.supportedActions = {<br />
edit = true,<br />
move = true,<br />
autoreview = true,<br />
upload = true<br />
}<br />
<br />
Protection.bannerConfigFields = {<br />
'text',<br />
'explanation',<br />
'tooltip',<br />
'alt',<br />
'link',<br />
'image'<br />
}<br />
<br />
function Protection.new(args, cfg, title)<br />
local obj = {}<br />
obj._cfg = cfg<br />
obj.title = title or mw.title.getCurrentTitle()<br />
<br />
-- Set action<br />
if not args.action then<br />
obj.action = 'edit'<br />
elseif Protection.supportedActions[args.action] then<br />
obj.action = args.action<br />
else<br />
error(string.format(<br />
'invalid action: %s',<br />
tostring(args.action)<br />
), 3)<br />
end<br />
<br />
-- Set level<br />
obj.level = args.demolevel or effectiveProtectionLevel(obj.action, obj.title)<br />
if not obj.level or (obj.action == 'move' and obj.level == 'autoconfirmed') then<br />
-- Users need to be autoconfirmed to move pages anyway, so treat<br />
-- semi-move-protected pages as unprotected.<br />
obj.level = '*'<br />
end<br />
<br />
-- Set expiry<br />
local effectiveExpiry = effectiveProtectionExpiry(obj.action, obj.title)<br />
if effectiveExpiry == 'infinity' then<br />
obj.expiry = 'indef'<br />
elseif effectiveExpiry ~= 'unknown' then<br />
obj.expiry = validateDate(effectiveExpiry, 'expiry date')<br />
end<br />
<br />
-- Set reason<br />
if args[1] then<br />
obj.reason = mw.ustring.lower(args[1])<br />
if obj.reason:find('|') then<br />
error('reasons cannot contain the pipe character ("|")', 3)<br />
end<br />
end<br />
<br />
-- Set protection date<br />
if args.date then<br />
obj.protectionDate = validateDate(args.date, 'protection date')<br />
end<br />
<br />
-- Set banner config<br />
do<br />
obj.bannerConfig = {}<br />
local configTables = {}<br />
if cfg.banners[obj.action] then<br />
configTables[#configTables + 1] = cfg.banners[obj.action][obj.reason]<br />
end<br />
if cfg.defaultBanners[obj.action] then<br />
configTables[#configTables + 1] = cfg.defaultBanners[obj.action][obj.level]<br />
configTables[#configTables + 1] = cfg.defaultBanners[obj.action].default<br />
end<br />
configTables[#configTables + 1] = cfg.masterBanner<br />
for i, field in ipairs(Protection.bannerConfigFields) do<br />
for j, t in ipairs(configTables) do<br />
if t[field] then<br />
obj.bannerConfig[field] = t[field]<br />
break<br />
end<br />
end<br />
end<br />
end<br />
return setmetatable(obj, Protection)<br />
end<br />
<br />
function Protection:isUserScript()<br />
-- Whether the page is a user JavaScript or CSS page.<br />
local title = self.title<br />
return title.namespace == 2 and (<br />
title.contentModel == 'javascript' or title.contentModel == 'css'<br />
)<br />
end<br />
<br />
function Protection:isProtected()<br />
return self.level ~= '*'<br />
end<br />
<br />
function Protection:shouldShowLock()<br />
-- Whether we should output a banner/padlock<br />
return self:isProtected() and not self:isUserScript()<br />
end<br />
<br />
-- Whether this page needs a protection category.<br />
Protection.shouldHaveProtectionCategory = Protection.shouldShowLock<br />
<br />
function Protection:isTemporary()<br />
return type(self.expiry) == 'number'<br />
end<br />
<br />
function Protection:makeProtectionCategory()<br />
if not self:shouldHaveProtectionCategory() then<br />
return ''<br />
end<br />
<br />
local cfg = self._cfg<br />
local title = self.title<br />
<br />
-- Get the expiry key fragment.<br />
local expiryFragment<br />
if self.expiry == 'indef' then<br />
expiryFragment = self.expiry<br />
elseif type(self.expiry) == 'number' then<br />
expiryFragment = 'temp'<br />
end<br />
<br />
-- Get the namespace key fragment.<br />
local namespaceFragment = cfg.categoryNamespaceKeys[title.namespace]<br />
if not namespaceFragment and title.namespace % 2 == 1 then<br />
namespaceFragment = 'talk'<br />
end<br />
<br />
-- Define the order that key fragments are tested in. This is done with an<br />
-- array of tables containing the value to be tested, along with its<br />
-- position in the cfg.protectionCategories table.<br />
local order = {<br />
{val = expiryFragment, keypos = 1},<br />
{val = namespaceFragment, keypos = 2},<br />
{val = self.reason, keypos = 3},<br />
{val = self.level, keypos = 4},<br />
{val = self.action, keypos = 5}<br />
}<br />
<br />
--[[<br />
-- The old protection templates used an ad-hoc protection category system,<br />
-- with some templates prioritising namespaces in their categories, and<br />
-- others prioritising the protection reason. To emulate this in this module<br />
-- we use the config table cfg.reasonsWithNamespacePriority to set the<br />
-- reasons for which namespaces have priority over protection reason.<br />
-- If we are dealing with one of those reasons, move the namespace table to<br />
-- the end of the order table, i.e. give it highest priority. If not, the<br />
-- reason should have highest priority, so move that to the end of the table<br />
-- instead.<br />
--]]<br />
table.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] and 2 or 3))<br />
<br />
--[[<br />
-- Define the attempt order. Inactive subtables (subtables with nil "value"<br />
-- fields) are moved to the end, where they will later be given the key<br />
-- "all". This is to cut down on the number of table lookups in<br />
-- cfg.protectionCategories, which grows exponentially with the number of<br />
-- non-nil keys. We keep track of the number of active subtables with the<br />
-- noActive parameter.<br />
--]]<br />
local noActive, attemptOrder<br />
do<br />
local active, inactive = {}, {}<br />
for i, t in ipairs(order) do<br />
if t.val then<br />
active[#active + 1] = t<br />
else<br />
inactive[#inactive + 1] = t<br />
end<br />
end<br />
noActive = #active<br />
attemptOrder = active<br />
for i, t in ipairs(inactive) do<br />
attemptOrder[#attemptOrder + 1] = t<br />
end<br />
end<br />
<br />
--[[<br />
-- Check increasingly generic key combinations until we find a match. If a<br />
-- specific category exists for the combination of key fragments we are<br />
-- given, that match will be found first. If not, we keep trying different<br />
-- key fragment combinations until we match using the key<br />
-- "all-all-all-all-all".<br />
--<br />
-- To generate the keys, we index the key subtables using a binary matrix<br />
-- with indexes i and j. j is only calculated up to the number of active<br />
-- subtables. For example, if there were three active subtables, the matrix<br />
-- would look like this, with 0 corresponding to the key fragment "all", and<br />
-- 1 corresponding to other key fragments.<br />
-- <br />
-- j 1 2 3<br />
-- i <br />
-- 1 1 1 1<br />
-- 2 0 1 1<br />
-- 3 1 0 1<br />
-- 4 0 0 1<br />
-- 5 1 1 0<br />
-- 6 0 1 0<br />
-- 7 1 0 0<br />
-- 8 0 0 0<br />
-- <br />
-- Values of j higher than the number of active subtables are set<br />
-- to the string "all".<br />
--<br />
-- A key for cfg.protectionCategories is constructed for each value of i.<br />
-- The position of the value in the key is determined by the keypos field in<br />
-- each subtable.<br />
--]]<br />
local cats = cfg.protectionCategories<br />
for i = 1, 2^noActive do<br />
local key = {}<br />
for j, t in ipairs(attemptOrder) do<br />
if j > noActive then<br />
key[t.keypos] = 'all'<br />
else<br />
local quotient = i / 2 ^ (j - 1)<br />
quotient = math.ceil(quotient)<br />
if quotient % 2 == 1 then<br />
key[t.keypos] = t.val<br />
else<br />
key[t.keypos] = 'all'<br />
end<br />
end<br />
end<br />
key = table.concat(key, '|')<br />
local attempt = cats[key]<br />
if attempt then<br />
return makeCategoryLink(attempt, title.text)<br />
end<br />
end<br />
return ''<br />
end<br />
<br />
function Protection:isIncorrect()<br />
local expiry = self.expiry<br />
return not self:shouldHaveProtectionCategory()<br />
or type(expiry) == 'number' and expiry < os.time()<br />
end<br />
<br />
function Protection:isTemplateProtectedNonTemplate()<br />
local action, namespace = self.action, self.title.namespace<br />
return self.level == 'templateeditor'<br />
and (<br />
(action ~= 'edit' and action ~= 'move')<br />
or (namespace ~= 10 and namespace ~= 828)<br />
)<br />
end<br />
<br />
function Protection:makeCategoryLinks()<br />
local msg = self._cfg.msg<br />
local ret = {self:makeProtectionCategory()}<br />
if self:isIncorrect() then<br />
ret[#ret + 1] = makeCategoryLink(<br />
msg['tracking-category-incorrect'],<br />
self.title.text<br />
)<br />
end<br />
if self:isTemplateProtectedNonTemplate() then<br />
ret[#ret + 1] = makeCategoryLink(<br />
msg['tracking-category-template'],<br />
self.title.text<br />
)<br />
end<br />
return table.concat(ret)<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Blurb class<br />
--------------------------------------------------------------------------------<br />
<br />
local Blurb = {}<br />
Blurb.__index = Blurb<br />
<br />
Blurb.bannerTextFields = {<br />
text = true,<br />
explanation = true,<br />
tooltip = true,<br />
alt = true,<br />
link = true<br />
}<br />
<br />
function Blurb.new(protectionObj, args, cfg)<br />
return setmetatable({<br />
_cfg = cfg,<br />
_protectionObj = protectionObj,<br />
_args = args<br />
}, Blurb)<br />
end<br />
<br />
-- Private methods --<br />
<br />
function Blurb:_formatDate(num)<br />
-- Formats a Unix timestamp into dd Month, YYYY format.<br />
lang = lang or mw.language.getContentLanguage()<br />
local success, date = pcall(<br />
lang.formatDate,<br />
lang,<br />
self._cfg.msg['expiry-date-format'] or 'j F Y',<br />
'@' .. tostring(num)<br />
)<br />
if success then<br />
return date<br />
end<br />
end<br />
<br />
function Blurb:_getExpandedMessage(msgKey)<br />
return self:_substituteParameters(self._cfg.msg[msgKey])<br />
end<br />
<br />
function Blurb:_substituteParameters(msg)<br />
if not self._params then<br />
local parameterFuncs = {}<br />
<br />
parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter<br />
parameterFuncs.EDITREQUEST = self._makeEditRequestParameter<br />
parameterFuncs.EXPIRY = self._makeExpiryParameter<br />
parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter<br />
parameterFuncs.IMAGELINK = self._makeImageLinkParameter<br />
parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter<br />
parameterFuncs.INTROFRAGMENT = self._makeIntroFragmentParameter<br />
parameterFuncs.PAGETYPE = self._makePagetypeParameter<br />
parameterFuncs.PROTECTIONBLURB = self._makeProtectionBlurbParameter<br />
parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter<br />
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter<br />
parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter<br />
parameterFuncs.TALKPAGE = self._makeTalkPageParameter<br />
parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter<br />
parameterFuncs.TOOLTIPFRAGMENT = self._makeTooltipFragmentParameter<br />
parameterFuncs.VANDAL = self._makeVandalTemplateParameter<br />
<br />
self._params = setmetatable({}, {<br />
__index = function (t, k)<br />
local param<br />
if parameterFuncs[k] then<br />
param = parameterFuncs[k](self)<br />
end<br />
param = param or ''<br />
t[k] = param<br />
return param<br />
end<br />
})<br />
end<br />
<br />
msg = msg:gsub('${(%u+)}', self._params)<br />
return msg<br />
end<br />
<br />
function Blurb:_makeCurrentVersionParameter()<br />
-- A link to the page history or the move log, depending on the kind of<br />
-- protection.<br />
local pagename = self._protectionObj.title.prefixedText<br />
if self._protectionObj.action == 'move' then<br />
-- We need the move log link.<br />
return makeFullUrl(<br />
'Special:Log',<br />
{type = 'move', page = pagename},<br />
self:_getExpandedMessage('current-version-move-display')<br />
)<br />
else<br />
-- We need the history link.<br />
return makeFullUrl(<br />
pagename,<br />
{action = 'history'},<br />
self:_getExpandedMessage('current-version-edit-display')<br />
)<br />
end<br />
end<br />
<br />
function Blurb:_makeEditRequestParameter()<br />
local mEditRequest = require('Module:Submit an edit request')<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
<br />
-- Get the edit request type.<br />
local requestType<br />
if action == 'edit' then<br />
if level == 'autoconfirmed' then<br />
requestType = 'semi'<br />
elseif level == 'extendedconfirmed' then<br />
requestType = 'extended'<br />
elseif level == 'templateeditor' then<br />
requestType = 'template'<br />
end<br />
end<br />
requestType = requestType or 'full'<br />
<br />
-- Get the display value.<br />
local display = self:_getExpandedMessage('edit-request-display')<br />
<br />
return mEditRequest._link{type = requestType, display = display}<br />
end<br />
<br />
function Blurb:_makeExpiryParameter()<br />
local expiry = self._protectionObj.expiry<br />
if type(expiry) == 'number' then<br />
return self:_formatDate(expiry)<br />
else<br />
return expiry<br />
end<br />
end<br />
<br />
function Blurb:_makeExplanationBlurbParameter()<br />
-- Cover special cases first.<br />
if self._protectionObj.title.namespace == 8 then<br />
-- MediaWiki namespace<br />
return self:_getExpandedMessage('explanation-blurb-nounprotect')<br />
end<br />
<br />
-- Get explanation blurb table keys<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
local talkKey = self._protectionObj.title.isTalkPage and 'talk' or 'subject'<br />
<br />
-- Find the message in the explanation blurb table and substitute any<br />
-- parameters.<br />
local explanations = self._cfg.explanationBlurbs<br />
local msg<br />
if explanations[action][level] and explanations[action][level][talkKey] then<br />
msg = explanations[action][level][talkKey]<br />
elseif explanations[action][level] and explanations[action][level].default then<br />
msg = explanations[action][level].default<br />
elseif explanations[action].default and explanations[action].default[talkKey] then<br />
msg = explanations[action].default[talkKey]<br />
elseif explanations[action].default and explanations[action].default.default then<br />
msg = explanations[action].default.default<br />
else<br />
error(string.format(<br />
'could not find explanation blurb for action "%s", level "%s" and talk key "%s"',<br />
action,<br />
level,<br />
talkKey<br />
), 8)<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
<br />
function Blurb:_makeImageLinkParameter()<br />
local imageLinks = self._cfg.imageLinks<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
local msg<br />
if imageLinks[action][level] then<br />
msg = imageLinks[action][level]<br />
elseif imageLinks[action].default then<br />
msg = imageLinks[action].default<br />
else<br />
msg = imageLinks.edit.default<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
<br />
function Blurb:_makeIntroBlurbParameter()<br />
if self._protectionObj:isTemporary() then<br />
return self:_getExpandedMessage('intro-blurb-expiry')<br />
else<br />
return self:_getExpandedMessage('intro-blurb-noexpiry')<br />
end<br />
end<br />
<br />
function Blurb:_makeIntroFragmentParameter()<br />
if self._protectionObj:isTemporary() then<br />
return self:_getExpandedMessage('intro-fragment-expiry')<br />
else<br />
return self:_getExpandedMessage('intro-fragment-noexpiry')<br />
end<br />
end<br />
<br />
function Blurb:_makePagetypeParameter()<br />
local pagetypes = self._cfg.pagetypes<br />
return pagetypes[self._protectionObj.title.namespace]<br />
or pagetypes.default<br />
or error('no default pagetype defined', 8)<br />
end<br />
<br />
function Blurb:_makeProtectionBlurbParameter()<br />
local protectionBlurbs = self._cfg.protectionBlurbs<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
local msg<br />
if protectionBlurbs[action][level] then<br />
msg = protectionBlurbs[action][level]<br />
elseif protectionBlurbs[action].default then<br />
msg = protectionBlurbs[action].default<br />
elseif protectionBlurbs.edit.default then<br />
msg = protectionBlurbs.edit.default<br />
else<br />
error('no protection blurb defined for protectionBlurbs.edit.default', 8)<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
<br />
function Blurb:_makeProtectionDateParameter()<br />
local protectionDate = self._protectionObj.protectionDate<br />
if type(protectionDate) == 'number' then<br />
return self:_formatDate(protectionDate)<br />
else<br />
return protectionDate<br />
end<br />
end<br />
<br />
function Blurb:_makeProtectionLevelParameter()<br />
local protectionLevels = self._cfg.protectionLevels<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
local msg<br />
if protectionLevels[action][level] then<br />
msg = protectionLevels[action][level]<br />
elseif protectionLevels[action].default then<br />
msg = protectionLevels[action].default<br />
elseif protectionLevels.edit.default then<br />
msg = protectionLevels.edit.default<br />
else<br />
error('no protection level defined for protectionLevels.edit.default', 8)<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
<br />
function Blurb:_makeProtectionLogParameter()<br />
local pagename = self._protectionObj.title.prefixedText<br />
if self._protectionObj.action == 'autoreview' then<br />
-- We need the pending changes log.<br />
return makeFullUrl(<br />
'Special:Log',<br />
{type = 'stable', page = pagename},<br />
self:_getExpandedMessage('pc-log-display')<br />
)<br />
else<br />
-- We need the protection log.<br />
return makeFullUrl(<br />
'Special:Log',<br />
{type = 'protect', page = pagename},<br />
self:_getExpandedMessage('protection-log-display')<br />
)<br />
end<br />
end<br />
<br />
function Blurb:_makeTalkPageParameter()<br />
return string.format(<br />
'[[%s:%s#%s|%s]]',<br />
mw.site.namespaces[self._protectionObj.title.namespace].talk.name,<br />
self._protectionObj.title.text,<br />
self._args.section or 'top',<br />
self:_getExpandedMessage('talk-page-link-display')<br />
)<br />
end<br />
<br />
function Blurb:_makeTooltipBlurbParameter()<br />
if self._protectionObj:isTemporary() then<br />
return self:_getExpandedMessage('tooltip-blurb-expiry')<br />
else<br />
return self:_getExpandedMessage('tooltip-blurb-noexpiry')<br />
end<br />
end<br />
<br />
function Blurb:_makeTooltipFragmentParameter()<br />
if self._protectionObj:isTemporary() then<br />
return self:_getExpandedMessage('tooltip-fragment-expiry')<br />
else<br />
return self:_getExpandedMessage('tooltip-fragment-noexpiry')<br />
end<br />
end<br />
<br />
function Blurb:_makeVandalTemplateParameter()<br />
return mw.getCurrentFrame():expandTemplate{<br />
title="vandal-m",<br />
args={self._args.user or self._protectionObj.title.baseText}<br />
}<br />
end<br />
<br />
-- Public methods --<br />
<br />
function Blurb:makeBannerText(key)<br />
-- Validate input.<br />
if not key or not Blurb.bannerTextFields[key] then<br />
error(string.format(<br />
'"%s" is not a valid banner config field',<br />
tostring(key)<br />
), 2)<br />
end<br />
<br />
-- Generate the text.<br />
local msg = self._protectionObj.bannerConfig[key]<br />
if type(msg) == 'string' then<br />
return self:_substituteParameters(msg)<br />
elseif type(msg) == 'function' then<br />
msg = msg(self._protectionObj, self._args)<br />
if type(msg) ~= 'string' then<br />
error(string.format(<br />
'bad output from banner config function with key "%s"'<br />
.. ' (expected string, got %s)',<br />
tostring(key),<br />
type(msg)<br />
), 4)<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- BannerTemplate class<br />
--------------------------------------------------------------------------------<br />
<br />
local BannerTemplate = {}<br />
BannerTemplate.__index = BannerTemplate<br />
<br />
function BannerTemplate.new(protectionObj, cfg)<br />
local obj = {}<br />
obj._cfg = cfg<br />
<br />
-- Set the image filename.<br />
local imageFilename = protectionObj.bannerConfig.image<br />
if imageFilename then<br />
obj._imageFilename = imageFilename<br />
else<br />
-- If an image filename isn't specified explicitly in the banner config,<br />
-- generate it from the protection status and the namespace.<br />
local action = protectionObj.action<br />
local level = protectionObj.level<br />
local namespace = protectionObj.title.namespace<br />
local reason = protectionObj.reason<br />
<br />
-- Deal with special cases first.<br />
if (<br />
namespace == 10<br />
or namespace == 828<br />
or reason and obj._cfg.indefImageReasons[reason]<br />
)<br />
and action == 'edit'<br />
and level == 'sysop'<br />
and not protectionObj:isTemporary()<br />
then<br />
-- Fully protected modules and templates get the special red "indef"<br />
-- padlock.<br />
obj._imageFilename = obj._cfg.msg['image-filename-indef']<br />
else<br />
-- Deal with regular protection types.<br />
local images = obj._cfg.images<br />
if images[action] then<br />
if images[action][level] then<br />
obj._imageFilename = images[action][level]<br />
elseif images[action].default then<br />
obj._imageFilename = images[action].default<br />
end<br />
end<br />
end<br />
end<br />
return setmetatable(obj, BannerTemplate)<br />
end<br />
<br />
function BannerTemplate:renderImage()<br />
local filename = self._imageFilename<br />
or self._cfg.msg['image-filename-default']<br />
or 'Transparent.gif'<br />
return makeFileLink{<br />
file = filename,<br />
size = (self.imageWidth or 20) .. 'px',<br />
alt = self._imageAlt,<br />
link = self._imageLink,<br />
caption = self.imageCaption<br />
}<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Banner class<br />
--------------------------------------------------------------------------------<br />
<br />
local Banner = setmetatable({}, BannerTemplate)<br />
Banner.__index = Banner<br />
<br />
function Banner.new(protectionObj, blurbObj, cfg)<br />
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.<br />
obj.imageWidth = 40<br />
obj.imageCaption = blurbObj:makeBannerText('alt') -- Large banners use the alt text for the tooltip.<br />
obj._reasonText = blurbObj:makeBannerText('text')<br />
obj._explanationText = blurbObj:makeBannerText('explanation')<br />
obj._page = protectionObj.title.prefixedText -- Only makes a difference in testing.<br />
return setmetatable(obj, Banner)<br />
end<br />
<br />
function Banner:__tostring()<br />
-- Renders the banner.<br />
makeMessageBox = makeMessageBox or require('Module:Message box').main<br />
local reasonText = self._reasonText or error('no reason text set', 2)<br />
local explanationText = self._explanationText<br />
local mbargs = {<br />
page = self._page,<br />
type = 'protection',<br />
image = self:renderImage(),<br />
text = string.format(<br />
"'''%s'''%s",<br />
reasonText,<br />
explanationText and '<br />' .. explanationText or ''<br />
)<br />
}<br />
return makeMessageBox('mbox', mbargs)<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Padlock class<br />
--------------------------------------------------------------------------------<br />
<br />
local Padlock = setmetatable({}, BannerTemplate)<br />
Padlock.__index = Padlock<br />
<br />
function Padlock.new(protectionObj, blurbObj, cfg)<br />
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.<br />
obj.imageWidth = 20<br />
obj.imageCaption = blurbObj:makeBannerText('tooltip')<br />
obj._imageAlt = blurbObj:makeBannerText('alt')<br />
obj._imageLink = blurbObj:makeBannerText('link')<br />
obj._indicatorName = cfg.padlockIndicatorNames[protectionObj.action]<br />
or cfg.padlockIndicatorNames.default<br />
or 'pp-default'<br />
return setmetatable(obj, Padlock)<br />
end<br />
<br />
function Padlock:__tostring()<br />
local frame = mw.getCurrentFrame()<br />
-- The nowiki tag helps prevent whitespace at the top of articles.<br />
return frame:extensionTag{name = 'nowiki'} .. frame:extensionTag{<br />
name = 'indicator',<br />
args = {name = self._indicatorName},<br />
content = self:renderImage()<br />
}<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Exports<br />
--------------------------------------------------------------------------------<br />
<br />
local p = {}<br />
<br />
function p._exportClasses()<br />
-- This is used for testing purposes.<br />
return {<br />
Protection = Protection,<br />
Blurb = Blurb,<br />
BannerTemplate = BannerTemplate,<br />
Banner = Banner,<br />
Padlock = Padlock,<br />
}<br />
end<br />
<br />
function p._main(args, cfg, title)<br />
args = args or {}<br />
cfg = cfg or require(CONFIG_MODULE)<br />
<br />
local protectionObj = Protection.new(args, cfg, title)<br />
<br />
local ret = {}<br />
<br />
-- If a page's edit protection is equally or more restrictive than its<br />
-- protection from some other action, then don't bother displaying anything<br />
-- for the other action (except categories).<br />
if not yesno(args.catonly) and (protectionObj.action == 'edit' or<br />
args.demolevel or<br />
not getReachableNodes(<br />
cfg.hierarchy,<br />
protectionObj.level<br />
)[effectiveProtectionLevel('edit', protectionObj.title)])<br />
then<br />
-- Initialise the blurb object<br />
local blurbObj = Blurb.new(protectionObj, args, cfg)<br />
<br />
-- Render the banner<br />
if protectionObj:shouldShowLock() then<br />
ret[#ret + 1] = tostring(<br />
(yesno(args.small) and Padlock or Banner)<br />
.new(protectionObj, blurbObj, cfg)<br />
)<br />
end<br />
end<br />
<br />
-- Render the categories<br />
if yesno(args.category) ~= false then<br />
ret[#ret + 1] = protectionObj:makeCategoryLinks()<br />
end<br />
<br />
return table.concat(ret) <br />
end<br />
<br />
function p.main(frame, cfg)<br />
cfg = cfg or require(CONFIG_MODULE)<br />
<br />
-- Find default args, if any.<br />
local parent = frame.getParent and frame:getParent()<br />
local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')]<br />
<br />
-- Find user args, and use the parent frame if we are being called from a<br />
-- wrapper template.<br />
getArgs = getArgs or require('Module:Arguments').getArgs<br />
local userArgs = getArgs(frame, {<br />
parentOnly = defaultArgs,<br />
frameOnly = not defaultArgs<br />
})<br />
<br />
-- Build the args table. User-specified args overwrite default args.<br />
local args = {}<br />
for k, v in pairs(defaultArgs or {}) do<br />
args[k] = v<br />
end<br />
for k, v in pairs(userArgs) do<br />
args[k] = v<br />
end<br />
return p._main(args, cfg)<br />
end<br />
<br />
return p</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:File_link&diff=64770Module:File link2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>-- This module provides a library for formatting file wikilinks.<br />
<br />
local yesno = require('Module:Yesno')<br />
local checkType = require('libraryUtil').checkType<br />
<br />
local p = {}<br />
<br />
function p._main(args)<br />
checkType('_main', 1, args, 'table')<br />
<br />
-- This is basically libraryUtil.checkTypeForNamedArg, but we are rolling our<br />
-- own function to get the right error level.<br />
local function checkArg(key, val, level)<br />
if type(val) ~= 'string' then<br />
error(string.format(<br />
"type error in '%s' parameter of '_main' (expected string, got %s)",<br />
key, type(val)<br />
), level)<br />
end<br />
end<br />
<br />
local ret = {}<br />
<br />
-- Adds a positional parameter to the buffer.<br />
local function addPositional(key)<br />
local val = args[key]<br />
if not val then<br />
return nil<br />
end<br />
checkArg(key, val, 4)<br />
ret[#ret + 1] = val<br />
end<br />
<br />
-- Adds a named parameter to the buffer. We assume that the parameter name<br />
-- is the same as the argument key.<br />
local function addNamed(key)<br />
local val = args[key]<br />
if not val then<br />
return nil<br />
end<br />
checkArg(key, val, 4)<br />
ret[#ret + 1] = key .. '=' .. val<br />
end<br />
<br />
-- Filename<br />
checkArg('file', args.file, 3)<br />
ret[#ret + 1] = 'File:' .. args.file<br />
<br />
-- Format<br />
if args.format then<br />
checkArg('format', args.format)<br />
if args.formatfile then<br />
checkArg('formatfile', args.formatfile)<br />
ret[#ret + 1] = args.format .. '=' .. args.formatfile<br />
else<br />
ret[#ret + 1] = args.format<br />
end<br />
end<br />
<br />
-- Border<br />
if yesno(args.border) then<br />
ret[#ret + 1] = 'border'<br />
end<br />
<br />
addPositional('location')<br />
addPositional('alignment')<br />
addPositional('size')<br />
addNamed('upright')<br />
addNamed('link')<br />
addNamed('alt')<br />
addNamed('page')<br />
addNamed('class')<br />
addNamed('lang')<br />
addNamed('start')<br />
addNamed('end')<br />
addNamed('thumbtime')<br />
addPositional('caption')<br />
<br />
return string.format('[[%s]]', table.concat(ret, '|'))<br />
end<br />
<br />
function p.main(frame)<br />
local origArgs = require('Module:Arguments').getArgs(frame, {<br />
wrappers = 'Template:File link'<br />
})<br />
if not origArgs.file then<br />
error("'file' parameter missing from [[Template:File link]]", 0)<br />
end<br />
<br />
-- Copy the arguments that were passed to a new table to avoid looking up<br />
-- every possible parameter in the frame object.<br />
local args = {}<br />
for k, v in pairs(origArgs) do<br />
-- Make _BLANK a special argument to add a blank parameter. For use in<br />
-- conditional templates etc. it is useful for blank arguments to be<br />
-- ignored, but we still need a way to specify them so that we can do<br />
-- things like [[File:Example.png|link=]].<br />
if v == '_BLANK' then<br />
v = ''<br />
end<br />
args[k] = v<br />
end<br />
return p._main(args)<br />
end<br />
<br />
return p</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Effective_protection_level&diff=64768Module:Effective protection level2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>local p = {}<br />
<br />
-- Returns the permission required to perform a given action on a given title.<br />
-- If no title is specified, the title of the page being displayed is used.<br />
function p._main(action, pagename)<br />
local title<br />
if type(pagename) == 'table' and pagename.prefixedText then<br />
title = pagename<br />
elseif pagename then<br />
title = mw.title.new(pagename)<br />
else<br />
title = mw.title.getCurrentTitle()<br />
end<br />
pagename = title.prefixedText<br />
if action == 'autoreview' then<br />
local level = mw.ext.FlaggedRevs.getStabilitySettings(title)<br />
level = level and level.autoreview<br />
if level == 'review' then<br />
return 'reviewer'<br />
elseif level ~= '' then<br />
return level<br />
else<br />
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<br />
end<br />
elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' and action ~= 'undelete' then<br />
error( 'First parameter must be one of edit, move, create, upload, undelete, autoreview', 2 )<br />
end<br />
if title.namespace == 8 then -- MediaWiki namespace<br />
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<br />
return 'interfaceadmin'<br />
else -- any non-JS/CSS MediaWiki page<br />
return 'sysop'<br />
end<br />
elseif title.namespace == 2 and title.isSubpage then<br />
if title.contentModel == 'javascript' or title.contentModel == 'css' then -- user JS or CSS page<br />
return 'interfaceadmin'<br />
elseif title.contentModel == 'json' then -- user JSON page<br />
return 'sysop'<br />
end<br />
end<br />
if action == 'undelete' then<br />
return 'sysop'<br />
end<br />
local level = title.protectionLevels[action] and title.protectionLevels[action][1]<br />
if level == 'sysop' or level == 'editprotected' then<br />
return 'sysop'<br />
elseif title.cascadingProtection.restrictions[action] and title.cascadingProtection.restrictions[action][1] then -- used by a cascading-protected page<br />
return 'sysop'<br />
elseif level == 'templateeditor' then<br />
return 'templateeditor'<br />
elseif action == 'move' then<br />
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.<br />
if blacklistentry and not blacklistentry.params.autoconfirmed then<br />
return 'templateeditor'<br />
elseif title.namespace == 6 then<br />
return 'filemover'<br />
elseif level == 'extendedconfirmed' then<br />
return 'extendedconfirmed'<br />
else<br />
return 'autoconfirmed'<br />
end<br />
end<br />
local blacklistentry = mw.ext.TitleBlacklist.test(action, pagename)<br />
if blacklistentry then<br />
if not blacklistentry.params.autoconfirmed then<br />
return 'templateeditor'<br />
elseif level == 'extendedconfirmed' then<br />
return 'extendedconfirmed'<br />
else<br />
return 'autoconfirmed'<br />
end<br />
elseif level == 'editsemiprotected' then -- create-semiprotected pages return this for some reason<br />
return 'autoconfirmed'<br />
elseif level then<br />
return level<br />
elseif action == 'upload' then<br />
return 'autoconfirmed'<br />
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<br />
return 'user'<br />
else<br />
return '*'<br />
end<br />
end<br />
<br />
setmetatable(p, { __index = function(t, k)<br />
return function(frame)<br />
return t._main(k, frame.args[1])<br />
end<br />
end })<br />
<br />
return p</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Effective_protection_expiry&diff=64766Module:Effective protection expiry2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>local p = {}<br />
<br />
-- Returns the expiry of a restriction of an action on a given title, or unknown if it cannot be known.<br />
-- If no title is specified, the title of the page being displayed is used.<br />
function p._main(action, pagename)<br />
local title<br />
if type(pagename) == 'table' and pagename.prefixedText then<br />
title = pagename<br />
elseif pagename then<br />
title = mw.title.new(pagename)<br />
else<br />
title = mw.title.getCurrentTitle()<br />
end<br />
pagename = title.prefixedText<br />
if action == 'autoreview' then<br />
local stabilitySettings = mw.ext.FlaggedRevs.getStabilitySettings(title)<br />
return stabilitySettings and stabilitySettings.expiry or 'unknown'<br />
elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' then<br />
error( 'First parameter must be one of edit, move, create, upload, autoreview', 2 )<br />
end<br />
local rawExpiry = mw.getCurrentFrame():callParserFunction('PROTECTIONEXPIRY', action, pagename)<br />
if rawExpiry == 'infinity' then<br />
return 'infinity'<br />
elseif rawExpiry == '' then<br />
return 'unknown'<br />
else<br />
local year, month, day, hour, minute, second = rawExpiry:match(<br />
'^(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)$'<br />
)<br />
if year then<br />
return string.format(<br />
'%s-%s-%sT%s:%s:%s',<br />
year, month, day, hour, minute, second<br />
)<br />
else<br />
error('internal error in Module:Effective protection expiry; malformed expiry timestamp')<br />
end<br />
end<br />
end<br />
<br />
setmetatable(p, { __index = function(t, k)<br />
return function(frame)<br />
return t._main(k, frame.args[1])<br />
end<br />
end })<br />
<br />
return p</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Template_link_general&diff=64764Module:Template link general2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>-- This implements Template:Tlg<br />
local getArgs = require('Module:Arguments').getArgs<br />
local p = {}<br />
<br />
-- Is a string non-empty?<br />
local function _ne(s) <br />
return s ~= nil and s ~= ""<br />
end<br />
<br />
local nw = mw.text.nowiki<br />
<br />
local function addTemplate(s)<br />
local i, _ = s:find(':', 1, true)<br />
if i == nil then<br />
return 'Template:' .. s<br />
end<br />
local ns = s:sub(1, i - 1)<br />
if ns == '' or mw.site.namespaces[ns] then<br />
return s<br />
else<br />
return 'Template:' .. s<br />
end<br />
end<br />
<br />
local function trimTemplate(s)<br />
local needle = 'template:'<br />
if s:sub(1, needle:len()):lower() == needle then<br />
return s:sub(needle:len() + 1) <br />
else<br />
return s<br />
end<br />
end<br />
<br />
local function linkTitle(args)<br />
if _ne(args.nolink) then<br />
return args['1']<br />
end<br />
<br />
local titleObj<br />
local titlePart = '[['<br />
if args['1'] then<br />
-- This handles :Page and other NS<br />
titleObj = mw.title.new(args['1'], 'Template')<br />
else<br />
titleObj = mw.title.getCurrentTitle()<br />
end<br />
<br />
titlePart = titlePart .. (titleObj ~= nil and titleObj.fullText or<br />
addTemplate(args['1']))<br />
<br />
local textPart = args.alttext<br />
if not _ne(textPart) then<br />
if titleObj ~= nil then<br />
textPart = titleObj:inNamespace("Template") and args['1'] or titleObj.fullText<br />
else<br />
-- redlink<br />
textPart = args['1']<br />
end<br />
end<br />
<br />
if _ne(args.subst) then<br />
-- HACK: the ns thing above is probably broken<br />
textPart = 'subst:' .. textPart<br />
end<br />
<br />
if _ne(args.brace) then<br />
textPart = nw('{{') .. textPart .. nw('}}')<br />
elseif _ne(args.braceinside) then<br />
textPart = nw('{') .. textPart .. nw('}')<br />
end<br />
<br />
titlePart = titlePart .. '|' .. textPart .. ']]'<br />
if _ne(args.braceinside) then<br />
titlePart = nw('{') .. titlePart .. nw('}')<br />
end<br />
return titlePart<br />
end<br />
<br />
function p.main(frame)<br />
local args = getArgs(frame, {<br />
trim = true,<br />
removeBlanks = false<br />
})<br />
return p._main(args)<br />
end<br />
<br />
function p._main(args)<br />
local bold = _ne(args.bold) or _ne(args.boldlink) or _ne(args.boldname)<br />
local italic = _ne(args.italic) or _ne(args.italics)<br />
local dontBrace = _ne(args.brace) or _ne(args.braceinside)<br />
local code = _ne(args.code) or _ne(args.tt)<br />
local show_result = _ne(args._show_result)<br />
local expand = _ne(args._expand)<br />
<br />
-- Build the link part<br />
local titlePart = linkTitle(args)<br />
if bold then titlePart = "'''" .. titlePart .. "'''" end<br />
if _ne(args.nowrapname) then titlePart = '<span class="nowrap">' .. titlePart .. '</span>' end<br />
<br />
-- Build the arguments<br />
local textPart = ""<br />
local textPartBuffer = "&#124;"<br />
local codeArguments = {}<br />
local codeArgumentsString = ""<br />
local i = 2<br />
local j = 1<br />
while args[i] do<br />
local val = args[i]<br />
if val ~= "" then<br />
if _ne(args.nowiki) then<br />
-- Unstrip nowiki tags first because calling nw on something that already contains nowiki tags will<br />
-- mangle the nowiki strip marker and result in literal UNIQ...QINU showing up<br />
val = nw(mw.text.unstripNoWiki(val))<br />
end<br />
local k, v = string.match(val, "(.*)=(.*)")<br />
if not k then<br />
codeArguments[j] = val<br />
j = j + 1<br />
else<br />
codeArguments[k] = v<br />
end<br />
codeArgumentsString = codeArgumentsString .. textPartBuffer .. val<br />
if italic then<br />
val = '<span style="font-style:italic;">' .. val .. '</span>'<br />
end<br />
textPart = textPart .. textPartBuffer .. val<br />
end<br />
i = i + 1<br />
end<br />
<br />
-- final wrap<br />
local ret = titlePart .. textPart<br />
if not dontBrace then ret = nw('{{') .. ret .. nw('}}') end<br />
if _ne(args.a) then ret = nw('*') .. '&nbsp;' .. ret end<br />
if _ne(args.kbd) then ret = '<kbd>' .. ret .. '</kbd>' end<br />
if code then<br />
ret = '<code>' .. ret .. '</code>'<br />
elseif _ne(args.plaincode) then<br />
ret = '<code style="border:none;background:transparent;">' .. ret .. '</code>'<br />
end<br />
if _ne(args.nowrap) then ret = '<span class="nowrap">' .. ret .. '</span>' end<br />
<br />
--[[ Wrap as html?? <br />
local span = mw.html.create('span')<br />
span:wikitext(ret)<br />
--]]<br />
if _ne(args.debug) then ret = ret .. '\n<pre>' .. mw.text.encode(mw.dumpObject(args)) .. '</pre>' end<br />
<br />
if show_result then<br />
local result = mw.getCurrentFrame():expandTemplate{title = addTemplate(args[1]), args = codeArguments}<br />
ret = ret .. " → " .. result<br />
end<br />
<br />
if expand then<br />
local query = mw.text.encode('{{' .. addTemplate(args[1]) .. string.gsub(codeArgumentsString, textPartBuffer, "|") .. '}}')<br />
local url = mw.uri.fullUrl('special:ExpandTemplates', 'wpInput=' .. query)<br />
mw.log()<br />
ret = ret .. " [" .. tostring(url) .. "]"<br />
end<br />
<br />
return ret<br />
end<br />
<br />
return p</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Template:Template_link_expanded&diff=64762Template:Template link expanded2023-04-20T15:33:23Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>{{#Invoke:Template link general|main|code=on}}<noinclude><br />
{{Documentation|1=Template:Tlg/doc<br />
|content = {{tlg/doc|tlx}}<br />
}}<br />
<!-- Add categories to the /doc subpage, not here! --><br />
</noinclude></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Template:Tlx&diff=64760Template:Tlx2023-04-20T15:33:22Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>#REDIRECT [[Template:Template link expanded]]<br />
<br />
{{Redirect category shell|<br />
{{R from move}}<br />
}}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:TableTools&diff=64758Module:TableTools2023-04-20T15:33:22Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>------------------------------------------------------------------------------------<br />
-- TableTools --<br />
-- --<br />
-- This module includes a number of functions for dealing with Lua tables. --<br />
-- It is a meta-module, meant to be called from other Lua modules, and should not --<br />
-- be called directly from #invoke. --<br />
------------------------------------------------------------------------------------<br />
<br />
local libraryUtil = require('libraryUtil')<br />
<br />
local p = {}<br />
<br />
-- Define often-used variables and functions.<br />
local floor = math.floor<br />
local infinity = math.huge<br />
local checkType = libraryUtil.checkType<br />
local checkTypeMulti = libraryUtil.checkTypeMulti<br />
<br />
------------------------------------------------------------------------------------<br />
-- isPositiveInteger<br />
--<br />
-- This function returns true if the given value is a positive integer, and false<br />
-- if not. Although it doesn't operate on tables, it is included here as it is<br />
-- useful for determining whether a given table key is in the array part or the<br />
-- hash part of a table.<br />
------------------------------------------------------------------------------------<br />
function p.isPositiveInteger(v)<br />
return type(v) == 'number' and v >= 1 and floor(v) == v and v < infinity<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- isNan<br />
--<br />
-- This function returns true if the given number is a NaN value, and false if<br />
-- not. Although it doesn't operate on tables, it is included here as it is useful<br />
-- for determining whether a value can be a valid table key. Lua will generate an<br />
-- error if a NaN is used as a table key.<br />
------------------------------------------------------------------------------------<br />
function p.isNan(v)<br />
return type(v) == 'number' and v ~= v<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- shallowClone<br />
--<br />
-- This returns a clone of a table. The value returned is a new table, but all<br />
-- subtables and functions are shared. Metamethods are respected, but the returned<br />
-- table will have no metatable of its own.<br />
------------------------------------------------------------------------------------<br />
function p.shallowClone(t)<br />
checkType('shallowClone', 1, t, 'table')<br />
local ret = {}<br />
for k, v in pairs(t) do<br />
ret[k] = v<br />
end<br />
return ret<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- removeDuplicates<br />
--<br />
-- This removes duplicate values from an array. Non-positive-integer keys are<br />
-- ignored. The earliest value is kept, and all subsequent duplicate values are<br />
-- removed, but otherwise the array order is unchanged.<br />
------------------------------------------------------------------------------------<br />
function p.removeDuplicates(arr)<br />
checkType('removeDuplicates', 1, arr, 'table')<br />
local isNan = p.isNan<br />
local ret, exists = {}, {}<br />
for _, v in ipairs(arr) do<br />
if isNan(v) then<br />
-- NaNs can't be table keys, and they are also unique, so we don't need to check existence.<br />
ret[#ret + 1] = v<br />
else<br />
if not exists[v] then<br />
ret[#ret + 1] = v<br />
exists[v] = true<br />
end<br />
end<br />
end<br />
return ret<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- numKeys<br />
--<br />
-- This takes a table and returns an array containing the numbers of any numerical<br />
-- keys that have non-nil values, sorted in numerical order.<br />
------------------------------------------------------------------------------------<br />
function p.numKeys(t)<br />
checkType('numKeys', 1, t, 'table')<br />
local isPositiveInteger = p.isPositiveInteger<br />
local nums = {}<br />
for k in pairs(t) do<br />
if isPositiveInteger(k) then<br />
nums[#nums + 1] = k<br />
end<br />
end<br />
table.sort(nums)<br />
return nums<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- affixNums<br />
--<br />
-- This takes a table and returns an array containing the numbers of keys with the<br />
-- specified prefix and suffix. For example, for the table<br />
-- {a1 = 'foo', a3 = 'bar', a6 = 'baz'} and the prefix "a", affixNums will return<br />
-- {1, 3, 6}.<br />
------------------------------------------------------------------------------------<br />
function p.affixNums(t, prefix, suffix)<br />
checkType('affixNums', 1, t, 'table')<br />
checkType('affixNums', 2, prefix, 'string', true)<br />
checkType('affixNums', 3, suffix, 'string', true)<br />
<br />
local function cleanPattern(s)<br />
-- Cleans a pattern so that the magic characters ()%.[]*+-?^$ are interpreted literally.<br />
return s:gsub('([%(%)%%%.%[%]%*%+%-%?%^%$])', '%%%1')<br />
end<br />
<br />
prefix = prefix or ''<br />
suffix = suffix or ''<br />
prefix = cleanPattern(prefix)<br />
suffix = cleanPattern(suffix)<br />
local pattern = '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$'<br />
<br />
local nums = {}<br />
for k in pairs(t) do<br />
if type(k) == 'string' then<br />
local num = mw.ustring.match(k, pattern)<br />
if num then<br />
nums[#nums + 1] = tonumber(num)<br />
end<br />
end<br />
end<br />
table.sort(nums)<br />
return nums<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- numData<br />
--<br />
-- Given a table with keys like {"foo1", "bar1", "foo2", "baz2"}, returns a table<br />
-- of subtables in the format<br />
-- {[1] = {foo = 'text', bar = 'text'}, [2] = {foo = 'text', baz = 'text'}}.<br />
-- Keys that don't end with an integer are stored in a subtable named "other". The<br />
-- compress option compresses the table so that it can be iterated over with<br />
-- ipairs.<br />
------------------------------------------------------------------------------------<br />
function p.numData(t, compress)<br />
checkType('numData', 1, t, 'table')<br />
checkType('numData', 2, compress, 'boolean', true)<br />
local ret = {}<br />
for k, v in pairs(t) do<br />
local prefix, num = mw.ustring.match(tostring(k), '^([^0-9]*)([1-9][0-9]*)$')<br />
if num then<br />
num = tonumber(num)<br />
local subtable = ret[num] or {}<br />
if prefix == '' then<br />
-- Positional parameters match the blank string; put them at the start of the subtable instead.<br />
prefix = 1<br />
end<br />
subtable[prefix] = v<br />
ret[num] = subtable<br />
else<br />
local subtable = ret.other or {}<br />
subtable[k] = v<br />
ret.other = subtable<br />
end<br />
end<br />
if compress then<br />
local other = ret.other<br />
ret = p.compressSparseArray(ret)<br />
ret.other = other<br />
end<br />
return ret<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- compressSparseArray<br />
--<br />
-- This takes an array with one or more nil values, and removes the nil values<br />
-- while preserving the order, so that the array can be safely traversed with<br />
-- ipairs.<br />
------------------------------------------------------------------------------------<br />
function p.compressSparseArray(t)<br />
checkType('compressSparseArray', 1, t, 'table')<br />
local ret = {}<br />
local nums = p.numKeys(t)<br />
for _, num in ipairs(nums) do<br />
ret[#ret + 1] = t[num]<br />
end<br />
return ret<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- sparseIpairs<br />
--<br />
-- This is an iterator for sparse arrays. It can be used like ipairs, but can<br />
-- handle nil values.<br />
------------------------------------------------------------------------------------<br />
function p.sparseIpairs(t)<br />
checkType('sparseIpairs', 1, t, 'table')<br />
local nums = p.numKeys(t)<br />
local i = 0<br />
local lim = #nums<br />
return function ()<br />
i = i + 1<br />
if i <= lim then<br />
local key = nums[i]<br />
return key, t[key]<br />
else<br />
return nil, nil<br />
end<br />
end<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- size<br />
--<br />
-- This returns the size of a key/value pair table. It will also work on arrays,<br />
-- but for arrays it is more efficient to use the # operator.<br />
------------------------------------------------------------------------------------<br />
function p.size(t)<br />
checkType('size', 1, t, 'table')<br />
local i = 0<br />
for _ in pairs(t) do<br />
i = i + 1<br />
end<br />
return i<br />
end<br />
<br />
local function defaultKeySort(item1, item2)<br />
-- "number" < "string", so numbers will be sorted before strings.<br />
local type1, type2 = type(item1), type(item2)<br />
if type1 ~= type2 then<br />
return type1 < type2<br />
elseif type1 == 'table' or type1 == 'boolean' or type1 == 'function' then<br />
return tostring(item1) < tostring(item2)<br />
else<br />
return item1 < item2<br />
end<br />
end<br />
------------------------------------------------------------------------------------<br />
-- keysToList<br />
--<br />
-- Returns an array of the keys in a table, sorted using either a default<br />
-- comparison function or a custom keySort function.<br />
------------------------------------------------------------------------------------<br />
function p.keysToList(t, keySort, checked)<br />
if not checked then<br />
checkType('keysToList', 1, t, 'table')<br />
checkTypeMulti('keysToList', 2, keySort, {'function', 'boolean', 'nil'})<br />
end<br />
<br />
local arr = {}<br />
local index = 1<br />
for k in pairs(t) do<br />
arr[index] = k<br />
index = index + 1<br />
end<br />
<br />
if keySort ~= false then<br />
keySort = type(keySort) == 'function' and keySort or defaultKeySort<br />
table.sort(arr, keySort)<br />
end<br />
<br />
return arr<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- sortedPairs<br />
--<br />
-- Iterates through a table, with the keys sorted using the keysToList function.<br />
-- If there are only numerical keys, sparseIpairs is probably more efficient.<br />
------------------------------------------------------------------------------------<br />
function p.sortedPairs(t, keySort)<br />
checkType('sortedPairs', 1, t, 'table')<br />
checkType('sortedPairs', 2, keySort, 'function', true)<br />
<br />
local arr = p.keysToList(t, keySort, true)<br />
<br />
local i = 0<br />
return function ()<br />
i = i + 1<br />
local key = arr[i]<br />
if key ~= nil then<br />
return key, t[key]<br />
else<br />
return nil, nil<br />
end<br />
end<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- isArray<br />
--<br />
-- Returns true if the given value is a table and all keys are consecutive<br />
-- integers starting at 1.<br />
------------------------------------------------------------------------------------<br />
function p.isArray(v)<br />
if type(v) ~= 'table' then<br />
return false<br />
end<br />
local i = 0<br />
for _ in pairs(v) do<br />
i = i + 1<br />
if v[i] == nil then<br />
return false<br />
end<br />
end<br />
return true<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- isArrayLike<br />
--<br />
-- Returns true if the given value is iterable and all keys are consecutive<br />
-- integers starting at 1.<br />
------------------------------------------------------------------------------------<br />
function p.isArrayLike(v)<br />
if not pcall(pairs, v) then<br />
return false<br />
end<br />
local i = 0<br />
for _ in pairs(v) do<br />
i = i + 1<br />
if v[i] == nil then<br />
return false<br />
end<br />
end<br />
return true<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- invert<br />
--<br />
-- Transposes the keys and values in an array. For example, {"a", "b", "c"} -><br />
-- {a = 1, b = 2, c = 3}. Duplicates are not supported (result values refer to<br />
-- the index of the last duplicate) and NaN values are ignored.<br />
------------------------------------------------------------------------------------<br />
function p.invert(arr)<br />
checkType("invert", 1, arr, "table")<br />
local isNan = p.isNan<br />
local map = {}<br />
for i, v in ipairs(arr) do<br />
if not isNan(v) then<br />
map[v] = i<br />
end<br />
end<br />
<br />
return map<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- listToSet<br />
--<br />
-- Creates a set from the array part of the table. Indexing the set by any of the<br />
-- values of the array returns true. For example, {"a", "b", "c"} -><br />
-- {a = true, b = true, c = true}. NaN values are ignored as Lua considers them<br />
-- never equal to any value (including other NaNs or even themselves).<br />
------------------------------------------------------------------------------------<br />
function p.listToSet(arr)<br />
checkType("listToSet", 1, arr, "table")<br />
local isNan = p.isNan<br />
local set = {}<br />
for _, v in ipairs(arr) do<br />
if not isNan(v) then<br />
set[v] = true<br />
end<br />
end<br />
<br />
return set<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- deepCopy<br />
--<br />
-- Recursive deep copy function. Preserves identities of subtables.<br />
------------------------------------------------------------------------------------<br />
local function _deepCopy(orig, includeMetatable, already_seen)<br />
-- Stores copies of tables indexed by the original table.<br />
already_seen = already_seen or {}<br />
<br />
local copy = already_seen[orig]<br />
if copy ~= nil then<br />
return copy<br />
end<br />
<br />
if type(orig) == 'table' then<br />
copy = {}<br />
for orig_key, orig_value in pairs(orig) do<br />
copy[_deepCopy(orig_key, includeMetatable, already_seen)] = _deepCopy(orig_value, includeMetatable, already_seen)<br />
end<br />
already_seen[orig] = copy<br />
<br />
if includeMetatable then<br />
local mt = getmetatable(orig)<br />
if mt ~= nil then<br />
local mt_copy = _deepCopy(mt, includeMetatable, already_seen)<br />
setmetatable(copy, mt_copy)<br />
already_seen[mt] = mt_copy<br />
end<br />
end<br />
else -- number, string, boolean, etc<br />
copy = orig<br />
end<br />
return copy<br />
end<br />
<br />
function p.deepCopy(orig, noMetatable, already_seen)<br />
checkType("deepCopy", 3, already_seen, "table", true)<br />
return _deepCopy(orig, not noMetatable, already_seen)<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- sparseConcat<br />
--<br />
-- Concatenates all values in the table that are indexed by a number, in order.<br />
-- sparseConcat{a, nil, c, d} => "acd"<br />
-- sparseConcat{nil, b, c, d} => "bcd"<br />
------------------------------------------------------------------------------------<br />
function p.sparseConcat(t, sep, i, j)<br />
local arr = {}<br />
<br />
local arr_i = 0<br />
for _, v in p.sparseIpairs(t) do<br />
arr_i = arr_i + 1<br />
arr[arr_i] = v<br />
end<br />
<br />
return table.concat(arr, sep, i, j)<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- length<br />
--<br />
-- Finds the length of an array, or of a quasi-array with keys such as "data1",<br />
-- "data2", etc., using an exponential search algorithm. It is similar to the<br />
-- operator #, but may return a different value when there are gaps in the array<br />
-- portion of the table. Intended to be used on data loaded with mw.loadData. For<br />
-- other tables, use #.<br />
-- Note: #frame.args in frame object always be set to 0, regardless of the number<br />
-- of unnamed template parameters, so use this function for frame.args.<br />
------------------------------------------------------------------------------------<br />
function p.length(t, prefix)<br />
-- requiring module inline so that [[Module:Exponential search]] which is<br />
-- only needed by this one function doesn't get millions of transclusions<br />
local expSearch = require("Module:Exponential search")<br />
checkType('length', 1, t, 'table')<br />
checkType('length', 2, prefix, 'string', true)<br />
return expSearch(function (i)<br />
local key<br />
if prefix then<br />
key = prefix .. tostring(i)<br />
else<br />
key = i<br />
end<br />
return t[key] ~= nil<br />
end) or 0<br />
end<br />
<br />
------------------------------------------------------------------------------------<br />
-- inArray<br />
--<br />
-- Returns true if valueToFind is a member of the array, and false otherwise.<br />
------------------------------------------------------------------------------------<br />
function p.inArray(arr, valueToFind)<br />
checkType("inArray", 1, arr, "table")<br />
-- if valueToFind is nil, error?<br />
<br />
for _, v in ipairs(arr) do<br />
if v == valueToFind then<br />
return true<br />
end<br />
end<br />
return false<br />
end<br />
<br />
return p</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:List&diff=64756Module:List2023-04-20T15:33:22Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>local libUtil = require('libraryUtil')<br />
local checkType = libUtil.checkType<br />
local mTableTools = require('Module:TableTools')<br />
<br />
local p = {}<br />
<br />
local listTypes = {<br />
['bulleted'] = true,<br />
['unbulleted'] = true,<br />
['horizontal'] = true,<br />
['ordered'] = true,<br />
['horizontal_ordered'] = true<br />
}<br />
<br />
function p.makeListData(listType, args)<br />
-- Constructs a data table to be passed to p.renderList.<br />
local data = {}<br />
<br />
-- Classes and TemplateStyles<br />
data.classes = {}<br />
data.templatestyles = ''<br />
if listType == 'horizontal' or listType == 'horizontal_ordered' then<br />
table.insert(data.classes, 'hlist')<br />
data.templatestyles = mw.getCurrentFrame():extensionTag{<br />
name = 'templatestyles', args = { src = 'Hlist/styles.css' }<br />
}<br />
elseif listType == 'unbulleted' then<br />
table.insert(data.classes, 'plainlist')<br />
data.templatestyles = mw.getCurrentFrame():extensionTag{<br />
name = 'templatestyles', args = { src = 'Plainlist/styles.css' }<br />
}<br />
end<br />
table.insert(data.classes, args.class)<br />
<br />
-- Main div style<br />
data.style = args.style<br />
<br />
-- Indent for horizontal lists<br />
if listType == 'horizontal' or listType == 'horizontal_ordered' then<br />
local indent = tonumber(args.indent)<br />
indent = indent and indent * 1.6 or 0<br />
if indent > 0 then<br />
data.marginLeft = indent .. 'em'<br />
end<br />
end<br />
<br />
-- List style types for ordered lists<br />
-- This could be "1, 2, 3", "a, b, c", or a number of others. The list style<br />
-- type is either set by the "type" attribute or the "list-style-type" CSS<br />
-- property.<br />
if listType == 'ordered' or listType == 'horizontal_ordered' then <br />
data.listStyleType = args.list_style_type or args['list-style-type']<br />
data.type = args['type']<br />
<br />
-- Detect invalid type attributes and attempt to convert them to<br />
-- list-style-type CSS properties.<br />
if data.type <br />
and not data.listStyleType<br />
and not tostring(data.type):find('^%s*[1AaIi]%s*$')<br />
then<br />
data.listStyleType = data.type<br />
data.type = nil<br />
end<br />
end<br />
<br />
-- List tag type<br />
if listType == 'ordered' or listType == 'horizontal_ordered' then<br />
data.listTag = 'ol'<br />
else<br />
data.listTag = 'ul'<br />
end<br />
<br />
-- Start number for ordered lists<br />
data.start = args.start<br />
if listType == 'horizontal_ordered' then<br />
-- Apply fix to get start numbers working with horizontal ordered lists.<br />
local startNum = tonumber(data.start)<br />
if startNum then<br />
data.counterReset = 'listitem ' .. tostring(startNum - 1)<br />
end<br />
end<br />
<br />
-- List style<br />
-- ul_style and ol_style are included for backwards compatibility. No<br />
-- distinction is made for ordered or unordered lists.<br />
data.listStyle = args.list_style<br />
<br />
-- List items<br />
-- li_style is included for backwards compatibility. item_style was included<br />
-- to be easier to understand for non-coders.<br />
data.itemStyle = args.item_style or args.li_style<br />
data.items = {}<br />
for _, num in ipairs(mTableTools.numKeys(args)) do<br />
local item = {}<br />
item.content = args[num]<br />
item.style = args['item' .. tostring(num) .. '_style']<br />
or args['item_style' .. tostring(num)]<br />
item.value = args['item' .. tostring(num) .. '_value']<br />
or args['item_value' .. tostring(num)]<br />
table.insert(data.items, item)<br />
end<br />
<br />
return data<br />
end<br />
<br />
function p.renderList(data)<br />
-- Renders the list HTML.<br />
<br />
-- Return the blank string if there are no list items.<br />
if type(data.items) ~= 'table' or #data.items < 1 then<br />
return ''<br />
end<br />
<br />
-- Render the main div tag.<br />
local root = mw.html.create('div')<br />
for _, class in ipairs(data.classes or {}) do<br />
root:addClass(class)<br />
end<br />
root:css{['margin-left'] = data.marginLeft}<br />
if data.style then<br />
root:cssText(data.style)<br />
end<br />
<br />
-- Render the list tag.<br />
local list = root:tag(data.listTag or 'ul')<br />
list<br />
:attr{start = data.start, type = data.type}<br />
:css{<br />
['counter-reset'] = data.counterReset,<br />
['list-style-type'] = data.listStyleType<br />
}<br />
if data.listStyle then<br />
list:cssText(data.listStyle)<br />
end<br />
<br />
-- Render the list items<br />
for _, t in ipairs(data.items or {}) do<br />
local item = list:tag('li')<br />
if data.itemStyle then<br />
item:cssText(data.itemStyle)<br />
end<br />
if t.style then<br />
item:cssText(t.style)<br />
end<br />
item<br />
:attr{value = t.value}<br />
:wikitext(t.content)<br />
end<br />
<br />
return data.templatestyles .. tostring(root)<br />
end<br />
<br />
function p.renderTrackingCategories(args)<br />
local isDeprecated = false -- Tracks deprecated parameters.<br />
for k, v in pairs(args) do<br />
k = tostring(k)<br />
if k:find('^item_style%d+$') or k:find('^item_value%d+$') then<br />
isDeprecated = true<br />
break<br />
end<br />
end<br />
local ret = ''<br />
if isDeprecated then<br />
ret = ret .. '[[Category:List templates with deprecated parameters]]'<br />
end<br />
return ret<br />
end<br />
<br />
function p.makeList(listType, args)<br />
if not listType or not listTypes[listType] then<br />
error(string.format(<br />
"bad argument #1 to 'makeList' ('%s' is not a valid list type)",<br />
tostring(listType)<br />
), 2)<br />
end<br />
checkType('makeList', 2, args, 'table')<br />
local data = p.makeListData(listType, args)<br />
local list = p.renderList(data)<br />
local trackingCategories = p.renderTrackingCategories(args)<br />
return list .. trackingCategories<br />
end<br />
<br />
for listType in pairs(listTypes) do<br />
p[listType] = function (frame)<br />
local mArguments = require('Module:Arguments')<br />
local origArgs = mArguments.getArgs(frame, {<br />
valueFunc = function (key, value)<br />
if not value or not mw.ustring.find(value, '%S') then return nil end<br />
if mw.ustring.find(value, '^%s*[%*#;:]') then<br />
return value<br />
else<br />
return value:match('^%s*(.-)%s*$')<br />
end<br />
return nil<br />
end<br />
})<br />
-- Copy all the arguments to a new table, for faster indexing.<br />
local args = {}<br />
for k, v in pairs(origArgs) do<br />
args[k] = v<br />
end<br />
return p.makeList(listType, args)<br />
end<br />
end<br />
<br />
return p</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:String&diff=64754Module:String2023-04-20T15:33:22Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>--[[<br />
<br />
This module is intended to provide access to basic string functions.<br />
<br />
Most of the functions provided here can be invoked with named parameters,<br />
unnamed parameters, or a mixture. If named parameters are used, Mediawiki will<br />
automatically remove any leading or trailing whitespace from the parameter.<br />
Depending on the intended use, it may be advantageous to either preserve or<br />
remove such whitespace.<br />
<br />
Global options<br />
ignore_errors: If set to 'true' or 1, any error condition will result in<br />
an empty string being returned rather than an error message.<br />
<br />
error_category: If an error occurs, specifies the name of a category to<br />
include with the error message. The default category is<br />
[Category:Errors reported by Module String].<br />
<br />
no_category: If set to 'true' or 1, no category will be added if an error<br />
is generated.<br />
<br />
Unit tests for this module are available at Module:String/tests.<br />
]]<br />
<br />
local str = {}<br />
<br />
--[[<br />
len<br />
<br />
This function returns the length of the target string.<br />
<br />
Usage:<br />
{{#invoke:String|len|target_string|}}<br />
OR<br />
{{#invoke:String|len|s=target_string}}<br />
<br />
Parameters<br />
s: The string whose length to report<br />
<br />
If invoked using named parameters, Mediawiki will automatically remove any leading or<br />
trailing whitespace from the target string.<br />
]]<br />
function str.len( frame )<br />
local new_args = str._getParameters( frame.args, {'s'} )<br />
local s = new_args['s'] or ''<br />
return mw.ustring.len( s )<br />
end<br />
<br />
--[[<br />
sub<br />
<br />
This function returns a substring of the target string at specified indices.<br />
<br />
Usage:<br />
{{#invoke:String|sub|target_string|start_index|end_index}}<br />
OR<br />
{{#invoke:String|sub|s=target_string|i=start_index|j=end_index}}<br />
<br />
Parameters<br />
s: The string to return a subset of<br />
i: The fist index of the substring to return, defaults to 1.<br />
j: The last index of the string to return, defaults to the last character.<br />
<br />
The first character of the string is assigned an index of 1. If either i or j<br />
is a negative value, it is interpreted the same as selecting a character by<br />
counting from the end of the string. Hence, a value of -1 is the same as<br />
selecting the last character of the string.<br />
<br />
If the requested indices are out of range for the given string, an error is<br />
reported.<br />
]]<br />
function str.sub( frame )<br />
local new_args = str._getParameters( frame.args, { 's', 'i', 'j' } )<br />
local s = new_args['s'] or ''<br />
local i = tonumber( new_args['i'] ) or 1<br />
local j = tonumber( new_args['j'] ) or -1<br />
<br />
local len = mw.ustring.len( s )<br />
<br />
-- Convert negatives for range checking<br />
if i < 0 then<br />
i = len + i + 1<br />
end<br />
if j < 0 then<br />
j = len + j + 1<br />
end<br />
<br />
if i > len or j > len or i < 1 or j < 1 then<br />
return str._error( 'String subset index out of range' )<br />
end<br />
if j < i then<br />
return str._error( 'String subset indices out of order' )<br />
end<br />
<br />
return mw.ustring.sub( s, i, j )<br />
end<br />
<br />
--[[<br />
This function implements that features of {{str sub old}} and is kept in order<br />
to maintain these older templates.<br />
]]<br />
function str.sublength( frame )<br />
local i = tonumber( frame.args.i ) or 0<br />
local len = tonumber( frame.args.len )<br />
return mw.ustring.sub( frame.args.s, i + 1, len and ( i + len ) )<br />
end<br />
<br />
--[[<br />
_match<br />
<br />
This function returns a substring from the source string that matches a<br />
specified pattern. It is exported for use in other modules<br />
<br />
Usage:<br />
strmatch = require("Module:String")._match<br />
sresult = strmatch( s, pattern, start, match, plain, nomatch )<br />
<br />
Parameters<br />
s: The string to search<br />
pattern: The pattern or string to find within the string<br />
start: The index within the source string to start the search. The first<br />
character of the string has index 1. Defaults to 1.<br />
match: In some cases it may be possible to make multiple matches on a single<br />
string. This specifies which match to return, where the first match is<br />
match= 1. If a negative number is specified then a match is returned<br />
counting from the last match. Hence match = -1 is the same as requesting<br />
the last match. Defaults to 1.<br />
plain: A flag indicating that the pattern should be understood as plain<br />
text. Defaults to false.<br />
nomatch: If no match is found, output the "nomatch" value rather than an error.<br />
<br />
For information on constructing Lua patterns, a form of [regular expression], see:<br />
<br />
* http://www.lua.org/manual/5.1/manual.html#5.4.1<br />
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns<br />
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns<br />
<br />
]]<br />
-- This sub-routine is exported for use in other modules<br />
function str._match( s, pattern, start, match_index, plain_flag, nomatch )<br />
if s == '' then<br />
return str._error( 'Target string is empty' )<br />
end<br />
if pattern == '' then<br />
return str._error( 'Pattern string is empty' )<br />
end<br />
start = tonumber(start) or 1<br />
if math.abs(start) < 1 or math.abs(start) > mw.ustring.len( s ) then<br />
return str._error( 'Requested start is out of range' )<br />
end<br />
if match_index == 0 then<br />
return str._error( 'Match index is out of range' )<br />
end<br />
if plain_flag then<br />
pattern = str._escapePattern( pattern )<br />
end<br />
<br />
local result<br />
if match_index == 1 then<br />
-- Find first match is simple case<br />
result = mw.ustring.match( s, pattern, start )<br />
else<br />
if start > 1 then<br />
s = mw.ustring.sub( s, start )<br />
end<br />
<br />
local iterator = mw.ustring.gmatch(s, pattern)<br />
if match_index > 0 then<br />
-- Forward search<br />
for w in iterator do<br />
match_index = match_index - 1<br />
if match_index == 0 then<br />
result = w<br />
break<br />
end<br />
end<br />
else<br />
-- Reverse search<br />
local result_table = {}<br />
local count = 1<br />
for w in iterator do<br />
result_table[count] = w<br />
count = count + 1<br />
end<br />
<br />
result = result_table[ count + match_index ]<br />
end<br />
end<br />
<br />
if result == nil then<br />
if nomatch == nil then<br />
return str._error( 'Match not found' )<br />
else<br />
return nomatch<br />
end<br />
else<br />
return result<br />
end<br />
end<br />
<br />
--[[<br />
match<br />
<br />
This function returns a substring from the source string that matches a<br />
specified pattern.<br />
<br />
Usage:<br />
{{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}}<br />
OR<br />
{{#invoke:String|match|s=source_string|pattern=pattern_string|start=start_index<br />
|match=match_number|plain=plain_flag|nomatch=nomatch_output}}<br />
<br />
Parameters<br />
s: The string to search<br />
pattern: The pattern or string to find within the string<br />
start: The index within the source string to start the search. The first<br />
character of the string has index 1. Defaults to 1.<br />
match: In some cases it may be possible to make multiple matches on a single<br />
string. This specifies which match to return, where the first match is<br />
match= 1. If a negative number is specified then a match is returned<br />
counting from the last match. Hence match = -1 is the same as requesting<br />
the last match. Defaults to 1.<br />
plain: A flag indicating that the pattern should be understood as plain<br />
text. Defaults to false.<br />
nomatch: If no match is found, output the "nomatch" value rather than an error.<br />
<br />
If invoked using named parameters, Mediawiki will automatically remove any leading or<br />
trailing whitespace from each string. In some circumstances this is desirable, in<br />
other cases one may want to preserve the whitespace.<br />
<br />
If the match_number or start_index are out of range for the string being queried, then<br />
this function generates an error. An error is also generated if no match is found.<br />
If one adds the parameter ignore_errors=true, then the error will be suppressed and<br />
an empty string will be returned on any failure.<br />
<br />
For information on constructing Lua patterns, a form of [regular expression], see:<br />
<br />
* http://www.lua.org/manual/5.1/manual.html#5.4.1<br />
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns<br />
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns<br />
<br />
]]<br />
-- This is the entry point for #invoke:String|match<br />
function str.match( frame )<br />
local new_args = str._getParameters( frame.args, {'s', 'pattern', 'start', 'match', 'plain', 'nomatch'} )<br />
local s = new_args['s'] or ''<br />
local start = tonumber( new_args['start'] ) or 1<br />
local plain_flag = str._getBoolean( new_args['plain'] or false )<br />
local pattern = new_args['pattern'] or ''<br />
local match_index = math.floor( tonumber(new_args['match']) or 1 )<br />
local nomatch = new_args['nomatch']<br />
<br />
return str._match( s, pattern, start, match_index, plain_flag, nomatch )<br />
end<br />
<br />
--[[<br />
pos<br />
<br />
This function returns a single character from the target string at position pos.<br />
<br />
Usage:<br />
{{#invoke:String|pos|target_string|index_value}}<br />
OR<br />
{{#invoke:String|pos|target=target_string|pos=index_value}}<br />
<br />
Parameters<br />
target: The string to search<br />
pos: The index for the character to return<br />
<br />
If invoked using named parameters, Mediawiki will automatically remove any leading or<br />
trailing whitespace from the target string. In some circumstances this is desirable, in<br />
other cases one may want to preserve the whitespace.<br />
<br />
The first character has an index value of 1.<br />
<br />
If one requests a negative value, this function will select a character by counting backwards<br />
from the end of the string. In other words pos = -1 is the same as asking for the last character.<br />
<br />
A requested value of zero, or a value greater than the length of the string returns an error.<br />
]]<br />
function str.pos( frame )<br />
local new_args = str._getParameters( frame.args, {'target', 'pos'} )<br />
local target_str = new_args['target'] or ''<br />
local pos = tonumber( new_args['pos'] ) or 0<br />
<br />
if pos == 0 or math.abs(pos) > mw.ustring.len( target_str ) then<br />
return str._error( 'String index out of range' )<br />
end<br />
<br />
return mw.ustring.sub( target_str, pos, pos )<br />
end<br />
<br />
--[[<br />
str_find<br />
<br />
This function duplicates the behavior of {{str_find}}, including all of its quirks.<br />
This is provided in order to support existing templates, but is NOT RECOMMENDED for<br />
new code and templates. New code is recommended to use the "find" function instead.<br />
<br />
Returns the first index in "source" that is a match to "target". Indexing is 1-based,<br />
and the function returns -1 if the "target" string is not present in "source".<br />
<br />
Important Note: If the "target" string is empty / missing, this function returns a<br />
value of "1", which is generally unexpected behavior, and must be accounted for<br />
separatetly.<br />
]]<br />
function str.str_find( frame )<br />
local new_args = str._getParameters( frame.args, {'source', 'target'} )<br />
local source_str = new_args['source'] or ''<br />
local target_str = new_args['target'] or ''<br />
<br />
if target_str == '' then<br />
return 1<br />
end<br />
<br />
local start = mw.ustring.find( source_str, target_str, 1, true )<br />
if start == nil then<br />
start = -1<br />
end<br />
<br />
return start<br />
end<br />
<br />
--[[<br />
find<br />
<br />
This function allows one to search for a target string or pattern within another<br />
string.<br />
<br />
Usage:<br />
{{#invoke:String|find|source_str|target_string|start_index|plain_flag}}<br />
OR<br />
{{#invoke:String|find|source=source_str|target=target_str|start=start_index|plain=plain_flag}}<br />
<br />
Parameters<br />
source: The string to search<br />
target: The string or pattern to find within source<br />
start: The index within the source string to start the search, defaults to 1<br />
plain: Boolean flag indicating that target should be understood as plain<br />
text and not as a Lua style regular expression, defaults to true<br />
<br />
If invoked using named parameters, Mediawiki will automatically remove any leading or<br />
trailing whitespace from the parameter. In some circumstances this is desirable, in<br />
other cases one may want to preserve the whitespace.<br />
<br />
This function returns the first index >= "start" where "target" can be found<br />
within "source". Indices are 1-based. If "target" is not found, then this<br />
function returns 0. If either "source" or "target" are missing / empty, this<br />
function also returns 0.<br />
<br />
This function should be safe for UTF-8 strings.<br />
]]<br />
function str.find( frame )<br />
local new_args = str._getParameters( frame.args, {'source', 'target', 'start', 'plain' } )<br />
local source_str = new_args['source'] or ''<br />
local pattern = new_args['target'] or ''<br />
local start_pos = tonumber(new_args['start']) or 1<br />
local plain = new_args['plain'] or true<br />
<br />
if source_str == '' or pattern == '' then<br />
return 0<br />
end<br />
<br />
plain = str._getBoolean( plain )<br />
<br />
local start = mw.ustring.find( source_str, pattern, start_pos, plain )<br />
if start == nil then<br />
start = 0<br />
end<br />
<br />
return start<br />
end<br />
<br />
--[[<br />
replace<br />
<br />
This function allows one to replace a target string or pattern within another<br />
string.<br />
<br />
Usage:<br />
{{#invoke:String|replace|source_str|pattern_string|replace_string|replacement_count|plain_flag}}<br />
OR<br />
{{#invoke:String|replace|source=source_string|pattern=pattern_string|replace=replace_string|<br />
count=replacement_count|plain=plain_flag}}<br />
<br />
Parameters<br />
source: The string to search<br />
pattern: The string or pattern to find within source<br />
replace: The replacement text<br />
count: The number of occurences to replace, defaults to all.<br />
plain: Boolean flag indicating that pattern should be understood as plain<br />
text and not as a Lua style regular expression, defaults to true<br />
]]<br />
function str.replace( frame )<br />
local new_args = str._getParameters( frame.args, {'source', 'pattern', 'replace', 'count', 'plain' } )<br />
local source_str = new_args['source'] or ''<br />
local pattern = new_args['pattern'] or ''<br />
local replace = new_args['replace'] or ''<br />
local count = tonumber( new_args['count'] )<br />
local plain = new_args['plain'] or true<br />
<br />
if source_str == '' or pattern == '' then<br />
return source_str<br />
end<br />
plain = str._getBoolean( plain )<br />
<br />
if plain then<br />
pattern = str._escapePattern( pattern )<br />
replace = mw.ustring.gsub( replace, "%%", "%%%%" ) --Only need to escape replacement sequences.<br />
end<br />
<br />
local result<br />
<br />
if count ~= nil then<br />
result = mw.ustring.gsub( source_str, pattern, replace, count )<br />
else<br />
result = mw.ustring.gsub( source_str, pattern, replace )<br />
end<br />
<br />
return result<br />
end<br />
<br />
--[[<br />
simple function to pipe string.rep to templates.<br />
]]<br />
function str.rep( frame )<br />
local repetitions = tonumber( frame.args[2] )<br />
if not repetitions then<br />
return str._error( 'function rep expects a number as second parameter, received "' .. ( frame.args[2] or '' ) .. '"' )<br />
end<br />
return string.rep( frame.args[1] or '', repetitions )<br />
end<br />
<br />
--[[<br />
escapePattern<br />
<br />
This function escapes special characters from a Lua string pattern. See [1]<br />
for details on how patterns work.<br />
<br />
[1] https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns<br />
<br />
Usage:<br />
{{#invoke:String|escapePattern|pattern_string}}<br />
<br />
Parameters<br />
pattern_string: The pattern string to escape.<br />
]]<br />
function str.escapePattern( frame )<br />
local pattern_str = frame.args[1]<br />
if not pattern_str then<br />
return str._error( 'No pattern string specified' )<br />
end<br />
local result = str._escapePattern( pattern_str )<br />
return result<br />
end<br />
<br />
--[[<br />
count<br />
This function counts the number of occurrences of one string in another.<br />
]]<br />
function str.count(frame)<br />
local args = str._getParameters(frame.args, {'source', 'pattern', 'plain'})<br />
local source = args.source or ''<br />
local pattern = args.pattern or ''<br />
local plain = str._getBoolean(args.plain or true)<br />
if plain then<br />
pattern = str._escapePattern(pattern)<br />
end<br />
local _, count = mw.ustring.gsub(source, pattern, '')<br />
return count<br />
end<br />
<br />
--[[<br />
endswith<br />
This function determines whether a string ends with another string.<br />
]]<br />
function str.endswith(frame)<br />
local args = str._getParameters(frame.args, {'source', 'pattern'})<br />
local source = args.source or ''<br />
local pattern = args.pattern or ''<br />
if pattern == '' then<br />
-- All strings end with the empty string.<br />
return "yes"<br />
end<br />
if mw.ustring.sub(source, -mw.ustring.len(pattern), -1) == pattern then<br />
return "yes"<br />
else<br />
return ""<br />
end<br />
end<br />
<br />
--[[<br />
join<br />
<br />
Join all non empty arguments together; the first argument is the separator.<br />
Usage:<br />
{{#invoke:String|join|sep|one|two|three}}<br />
]]<br />
function str.join(frame)<br />
local args = {}<br />
local sep<br />
for _, v in ipairs( frame.args ) do<br />
if sep then<br />
if v ~= '' then<br />
table.insert(args, v)<br />
end<br />
else<br />
sep = v<br />
end<br />
end<br />
return table.concat( args, sep or '' )<br />
end<br />
<br />
--[[<br />
Helper function that populates the argument list given that user may need to use a mix of<br />
named and unnamed parameters. This is relevant because named parameters are not<br />
identical to unnamed parameters due to string trimming, and when dealing with strings<br />
we sometimes want to either preserve or remove that whitespace depending on the application.<br />
]]<br />
function str._getParameters( frame_args, arg_list )<br />
local new_args = {}<br />
local index = 1<br />
local value<br />
<br />
for _, arg in ipairs( arg_list ) do<br />
value = frame_args[arg]<br />
if value == nil then<br />
value = frame_args[index]<br />
index = index + 1<br />
end<br />
new_args[arg] = value<br />
end<br />
<br />
return new_args<br />
end<br />
<br />
--[[<br />
Helper function to handle error messages.<br />
]]<br />
function str._error( error_str )<br />
local frame = mw.getCurrentFrame()<br />
local error_category = frame.args.error_category or 'Errors reported by Module String'<br />
local ignore_errors = frame.args.ignore_errors or false<br />
local no_category = frame.args.no_category or false<br />
<br />
if str._getBoolean(ignore_errors) then<br />
return ''<br />
end<br />
<br />
local error_str = '<strong class="error">String Module Error: ' .. error_str .. '</strong>'<br />
if error_category ~= '' and not str._getBoolean( no_category ) then<br />
error_str = '[[Category:' .. error_category .. ']]' .. error_str<br />
end<br />
<br />
return error_str<br />
end<br />
<br />
--[[<br />
Helper Function to interpret boolean strings<br />
]]<br />
function str._getBoolean( boolean_str )<br />
local boolean_value<br />
<br />
if type( boolean_str ) == 'string' then<br />
boolean_str = boolean_str:lower()<br />
if boolean_str == 'false' or boolean_str == 'no' or boolean_str == '0'<br />
or boolean_str == '' then<br />
boolean_value = false<br />
else<br />
boolean_value = true<br />
end<br />
elseif type( boolean_str ) == 'boolean' then<br />
boolean_value = boolean_str<br />
else<br />
error( 'No boolean value found' )<br />
end<br />
return boolean_value<br />
end<br />
<br />
--[[<br />
Helper function that escapes all pattern characters so that they will be treated<br />
as plain text.<br />
]]<br />
function str._escapePattern( pattern_str )<br />
return mw.ustring.gsub( pattern_str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" )<br />
end<br />
<br />
return str</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Redirect&diff=64752Module:Redirect2023-04-20T15:33:22Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>-- This module provides functions for getting the target of a redirect page.<br />
<br />
local p = {}<br />
<br />
-- Gets a mw.title object, using pcall to avoid generating script errors if we<br />
-- are over the expensive function count limit (among other possible causes).<br />
local function getTitle(...)<br />
local success, titleObj = pcall(mw.title.new, ...)<br />
if success then<br />
return titleObj<br />
else<br />
return nil<br />
end<br />
end<br />
<br />
-- Gets the name of a page that a redirect leads to, or nil if it isn't a<br />
-- redirect.<br />
function p.getTargetFromText(text)<br />
local target = string.match(<br />
text,<br />
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)%]%]"<br />
) or string.match(<br />
text,<br />
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)|[^%[%]]-%]%]"<br />
)<br />
return target and mw.uri.decode(target, 'PATH')<br />
end<br />
<br />
-- Gets the target of a redirect. If the page specified is not a redirect,<br />
-- returns nil.<br />
function p.getTarget(page, fulltext)<br />
-- Get the title object. Both page names and title objects are allowed<br />
-- as input.<br />
local titleObj<br />
if type(page) == 'string' or type(page) == 'number' then<br />
titleObj = getTitle(page)<br />
elseif type(page) == 'table' and type(page.getContent) == 'function' then<br />
titleObj = page<br />
else<br />
error(string.format(<br />
"bad argument #1 to 'getTarget'"<br />
.. " (string, number, or title object expected, got %s)",<br />
type(page)<br />
), 2)<br />
end<br />
if not titleObj then<br />
return nil<br />
end<br />
local targetTitle = titleObj.redirectTarget<br />
if targetTitle then<br />
if fulltext then<br />
return targetTitle.fullText<br />
else<br />
return targetTitle.prefixedText<br />
end<br />
else<br />
return nil<br />
end<br />
end<br />
<br />
--[[<br />
-- Given a single page name determines what page it redirects to and returns the<br />
-- target page name, or the passed page name when not a redirect. The passed<br />
-- page name can be given as plain text or as a page link.<br />
--<br />
-- Returns page name as plain text, or when the bracket parameter is given, as a<br />
-- page link. Returns an error message when page does not exist or the redirect<br />
-- target cannot be determined for some reason.<br />
--]]<br />
function p.luaMain(rname, bracket, fulltext)<br />
if type(rname) ~= "string" or not rname:find("%S") then<br />
return nil<br />
end<br />
bracket = bracket and "[[%s]]" or "%s"<br />
rname = rname:match("%[%[(.+)%]%]") or rname<br />
local target = p.getTarget(rname, fulltext)<br />
local ret = target or rname<br />
ret = getTitle(ret)<br />
if ret then<br />
if fulltext then<br />
ret = ret.fullText<br />
else<br />
ret = ret.prefixedText<br />
end<br />
return bracket:format(ret)<br />
else<br />
return nil<br />
end<br />
end<br />
<br />
-- Provides access to the luaMain function from wikitext.<br />
function p.main(frame)<br />
local args = require('Module:Arguments').getArgs(frame, {frameOnly = true})<br />
return p.luaMain(args[1], args.bracket, args.fulltext) or ''<br />
end<br />
<br />
-- Returns true if the specified page is a redirect, and false otherwise.<br />
function p.luaIsRedirect(page)<br />
local titleObj = getTitle(page)<br />
if not titleObj then<br />
return false<br />
end<br />
if titleObj.isRedirect then<br />
return true<br />
else<br />
return false<br />
end<br />
end<br />
<br />
-- Provides access to the luaIsRedirect function from wikitext, returning 'yes'<br />
-- if the specified page is a redirect, and the blank string otherwise.<br />
function p.isRedirect(frame)<br />
local args = require('Module:Arguments').getArgs(frame, {frameOnly = true})<br />
if p.luaIsRedirect(args[1]) then<br />
return 'yes'<br />
else<br />
return ''<br />
end<br />
end<br />
<br />
return p</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Message_box/configuration&diff=64750Module:Message box/configuration2023-04-20T15:33:22Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>--------------------------------------------------------------------------------<br />
-- Message box configuration --<br />
-- --<br />
-- This module contains configuration data for [[Module:Message box]]. --<br />
--------------------------------------------------------------------------------<br />
<br />
return {<br />
ambox = {<br />
types = {<br />
speedy = {<br />
class = 'ambox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'ambox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'ambox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'ambox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'ambox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'ambox-protection',<br />
image = 'Semi-protection-shackle-keyhole.svg'<br />
},<br />
notice = {<br />
class = 'ambox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
allowBlankParams = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'},<br />
allowSmall = true,<br />
smallParam = 'left',<br />
smallClass = 'mbox-small-left',<br />
substCheck = true,<br />
classes = {'metadata', 'ambox'},<br />
imageEmptyCell = true,<br />
imageCheckBlank = true,<br />
imageSmallSize = '20x20px',<br />
imageCellDiv = true,<br />
useCollapsibleTextFields = true,<br />
imageRightNone = true,<br />
sectionDefault = 'article',<br />
allowMainspaceCategories = true,<br />
templateCategory = 'Article message templates',<br />
templateCategoryRequireName = true,<br />
templateErrorCategory = 'Article message templates with missing parameters',<br />
templateErrorParamsToCheck = {'issue', 'fix', 'subst'},<br />
removalNotice = '<small>[[Help:Maintenance template removal|Learn how and when to remove this template message]]</small>',<br />
templatestyles = 'Module:Message box/ambox.css'<br />
},<br />
<br />
cmbox = {<br />
types = {<br />
speedy = {<br />
class = 'cmbox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'cmbox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'cmbox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'cmbox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'cmbox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'cmbox-protection',<br />
image = 'Semi-protection-shackle-keyhole.svg'<br />
},<br />
notice = {<br />
class = 'cmbox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
showInvalidTypeError = true,<br />
classes = {'cmbox'},<br />
imageEmptyCell = true,<br />
templatestyles = 'Module:Message box/cmbox.css'<br />
},<br />
<br />
fmbox = {<br />
types = {<br />
warning = {<br />
class = 'fmbox-warning',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
editnotice = {<br />
class = 'fmbox-editnotice',<br />
image = 'Information icon4.svg'<br />
},<br />
system = {<br />
class = 'fmbox-system',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'system',<br />
showInvalidTypeError = true,<br />
classes = {'fmbox'},<br />
imageEmptyCell = false,<br />
imageRightNone = false,<br />
templatestyles = 'Module:Message box/fmbox.css'<br />
},<br />
<br />
imbox = {<br />
types = {<br />
speedy = {<br />
class = 'imbox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'imbox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'imbox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'imbox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'imbox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'imbox-protection',<br />
image = 'Semi-protection-shackle-keyhole.svg'<br />
},<br />
license = {<br />
class = 'imbox-license licensetpl',<br />
image = 'Imbox license.png' -- @todo We need an SVG version of this<br />
},<br />
featured = {<br />
class = 'imbox-featured',<br />
image = 'Cscr-featured.svg'<br />
},<br />
notice = {<br />
class = 'imbox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
showInvalidTypeError = true,<br />
classes = {'imbox'},<br />
imageEmptyCell = true,<br />
below = true,<br />
templateCategory = 'File message boxes',<br />
templatestyles = 'Module:Message box/imbox.css'<br />
},<br />
<br />
ombox = {<br />
types = {<br />
speedy = {<br />
class = 'ombox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'ombox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'ombox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'ombox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'ombox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'ombox-protection',<br />
image = 'Semi-protection-shackle-keyhole.svg'<br />
},<br />
notice = {<br />
class = 'ombox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
showInvalidTypeError = true,<br />
classes = {'ombox'},<br />
allowSmall = true,<br />
imageEmptyCell = true,<br />
imageRightNone = true,<br />
templatestyles = 'Module:Message box/ombox.css'<br />
},<br />
<br />
tmbox = {<br />
types = {<br />
speedy = {<br />
class = 'tmbox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'tmbox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'tmbox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'tmbox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'tmbox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'tmbox-protection',<br />
image = 'Semi-protection-shackle-keyhole.svg'<br />
},<br />
notice = {<br />
class = 'tmbox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
showInvalidTypeError = true,<br />
classes = {'tmbox'},<br />
allowSmall = true,<br />
imageRightNone = true,<br />
imageEmptyCell = true,<br />
templateCategory = 'Talk message boxes',<br />
templatestyles = 'Module:Message box/tmbox.css'<br />
}<br />
}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Message_box&diff=64748Module:Message box2023-04-20T15:33:22Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>require('strict')<br />
local getArgs<br />
local yesno = require('Module:Yesno')<br />
local lang = mw.language.getContentLanguage()<br />
<br />
local CONFIG_MODULE = 'Module:Message box/configuration'<br />
local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'}<br />
<br />
--------------------------------------------------------------------------------<br />
-- Helper functions<br />
--------------------------------------------------------------------------------<br />
<br />
local function getTitleObject(...)<br />
-- Get the title object, passing the function through pcall<br />
-- in case we are over the expensive function count limit.<br />
local success, title = pcall(mw.title.new, ...)<br />
if success then<br />
return title<br />
end<br />
end<br />
<br />
local function union(t1, t2)<br />
-- Returns the union of two arrays.<br />
local vals = {}<br />
for i, v in ipairs(t1) do<br />
vals[v] = true<br />
end<br />
for i, v in ipairs(t2) do<br />
vals[v] = true<br />
end<br />
local ret = {}<br />
for k in pairs(vals) do<br />
table.insert(ret, k)<br />
end<br />
table.sort(ret)<br />
return ret<br />
end<br />
<br />
local function getArgNums(args, prefix)<br />
local nums = {}<br />
for k, v in pairs(args) do<br />
local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$')<br />
if num then<br />
table.insert(nums, tonumber(num))<br />
end<br />
end<br />
table.sort(nums)<br />
return nums<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Box class definition<br />
--------------------------------------------------------------------------------<br />
<br />
local MessageBox = {}<br />
MessageBox.__index = MessageBox<br />
<br />
function MessageBox.new(boxType, args, cfg)<br />
args = args or {}<br />
local obj = {}<br />
<br />
-- Set the title object and the namespace.<br />
obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()<br />
<br />
-- Set the config for our box type.<br />
obj.cfg = cfg[boxType]<br />
if not obj.cfg then<br />
local ns = obj.title.namespace<br />
-- boxType is "mbox" or invalid input<br />
if args.demospace and args.demospace ~= '' then<br />
-- implement demospace parameter of mbox<br />
local demospace = string.lower(args.demospace)<br />
if DEMOSPACES[demospace] then<br />
-- use template from DEMOSPACES<br />
obj.cfg = cfg[DEMOSPACES[demospace]]<br />
elseif string.find( demospace, 'talk' ) then<br />
-- demo as a talk page<br />
obj.cfg = cfg.tmbox<br />
else<br />
-- default to ombox<br />
obj.cfg = cfg.ombox<br />
end<br />
elseif ns == 0 then<br />
obj.cfg = cfg.ambox -- main namespace<br />
elseif ns == 6 then<br />
obj.cfg = cfg.imbox -- file namespace<br />
elseif ns == 14 then<br />
obj.cfg = cfg.cmbox -- category namespace<br />
else<br />
local nsTable = mw.site.namespaces[ns]<br />
if nsTable and nsTable.isTalk then<br />
obj.cfg = cfg.tmbox -- any talk namespace<br />
else<br />
obj.cfg = cfg.ombox -- other namespaces or invalid input<br />
end<br />
end<br />
end<br />
<br />
-- Set the arguments, and remove all blank arguments except for the ones<br />
-- listed in cfg.allowBlankParams.<br />
do<br />
local newArgs = {}<br />
for k, v in pairs(args) do<br />
if v ~= '' then<br />
newArgs[k] = v<br />
end<br />
end<br />
for i, param in ipairs(obj.cfg.allowBlankParams or {}) do<br />
newArgs[param] = args[param]<br />
end<br />
obj.args = newArgs<br />
end<br />
<br />
-- Define internal data structure.<br />
obj.categories = {}<br />
obj.classes = {}<br />
-- For lazy loading of [[Module:Category handler]].<br />
obj.hasCategories = false<br />
<br />
return setmetatable(obj, MessageBox)<br />
end<br />
<br />
function MessageBox:addCat(ns, cat, sort)<br />
if not cat then<br />
return nil<br />
end<br />
if sort then<br />
cat = string.format('[[Category:%s|%s]]', cat, sort)<br />
else<br />
cat = string.format('[[Category:%s]]', cat)<br />
end<br />
self.hasCategories = true<br />
self.categories[ns] = self.categories[ns] or {}<br />
table.insert(self.categories[ns], cat)<br />
end<br />
<br />
function MessageBox:addClass(class)<br />
if not class then<br />
return nil<br />
end<br />
table.insert(self.classes, class)<br />
end<br />
<br />
function MessageBox:setParameters()<br />
local args = self.args<br />
local cfg = self.cfg<br />
<br />
-- Get type data.<br />
self.type = args.type<br />
local typeData = cfg.types[self.type]<br />
self.invalidTypeError = cfg.showInvalidTypeError<br />
and self.type<br />
and not typeData<br />
typeData = typeData or cfg.types[cfg.default]<br />
self.typeClass = typeData.class<br />
self.typeImage = typeData.image<br />
<br />
-- Find if the box has been wrongly substituted.<br />
self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'<br />
<br />
-- Find whether we are using a small message box.<br />
self.isSmall = cfg.allowSmall and (<br />
cfg.smallParam and args.small == cfg.smallParam<br />
or not cfg.smallParam and yesno(args.small)<br />
)<br />
<br />
-- Add attributes, classes and styles.<br />
self.id = args.id<br />
self.name = args.name<br />
if self.name then<br />
self:addClass('box-' .. string.gsub(self.name,' ','_'))<br />
end<br />
if yesno(args.plainlinks) ~= false then<br />
self:addClass('plainlinks')<br />
end<br />
for _, class in ipairs(cfg.classes or {}) do<br />
self:addClass(class)<br />
end<br />
if self.isSmall then<br />
self:addClass(cfg.smallClass or 'mbox-small')<br />
end<br />
self:addClass(self.typeClass)<br />
self:addClass(args.class)<br />
self.style = args.style<br />
self.attrs = args.attrs<br />
<br />
-- Set text style.<br />
self.textstyle = args.textstyle<br />
<br />
-- Find if we are on the template page or not. This functionality is only<br />
-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory<br />
-- and cfg.templateCategoryRequireName are set.<br />
self.useCollapsibleTextFields = cfg.useCollapsibleTextFields<br />
if self.useCollapsibleTextFields<br />
or cfg.templateCategory<br />
and cfg.templateCategoryRequireName<br />
then<br />
if self.name then<br />
local templateName = mw.ustring.match(<br />
self.name,<br />
'^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$'<br />
) or self.name<br />
templateName = 'Template:' .. templateName<br />
self.templateTitle = getTitleObject(templateName)<br />
end<br />
self.isTemplatePage = self.templateTitle<br />
and mw.title.equals(self.title, self.templateTitle)<br />
end<br />
<br />
-- Process data for collapsible text fields. At the moment these are only<br />
-- used in {{ambox}}.<br />
if self.useCollapsibleTextFields then<br />
-- Get the self.issue value.<br />
if self.isSmall and args.smalltext then<br />
self.issue = args.smalltext<br />
else<br />
local sect<br />
if args.sect == '' then<br />
sect = 'This ' .. (cfg.sectionDefault or 'page')<br />
elseif type(args.sect) == 'string' then<br />
sect = 'This ' .. args.sect<br />
end<br />
local issue = args.issue<br />
issue = type(issue) == 'string' and issue ~= '' and issue or nil<br />
local text = args.text<br />
text = type(text) == 'string' and text or nil<br />
local issues = {}<br />
table.insert(issues, sect)<br />
table.insert(issues, issue)<br />
table.insert(issues, text)<br />
self.issue = table.concat(issues, ' ')<br />
end<br />
<br />
-- Get the self.talk value.<br />
local talk = args.talk<br />
-- Show talk links on the template page or template subpages if the talk<br />
-- parameter is blank.<br />
if talk == ''<br />
and self.templateTitle<br />
and (<br />
mw.title.equals(self.templateTitle, self.title)<br />
or self.title:isSubpageOf(self.templateTitle)<br />
)<br />
then<br />
talk = '#'<br />
elseif talk == '' then<br />
talk = nil<br />
end<br />
if talk then<br />
-- If the talk value is a talk page, make a link to that page. Else<br />
-- assume that it's a section heading, and make a link to the talk<br />
-- page of the current page with that section heading.<br />
local talkTitle = getTitleObject(talk)<br />
local talkArgIsTalkPage = true<br />
if not talkTitle or not talkTitle.isTalkPage then<br />
talkArgIsTalkPage = false<br />
talkTitle = getTitleObject(<br />
self.title.text,<br />
mw.site.namespaces[self.title.namespace].talk.id<br />
)<br />
end<br />
if talkTitle and talkTitle.exists then<br />
local talkText<br />
if self.isSmall then<br />
local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk)<br />
talkText = string.format('([[%s|talk]])', talkLink)<br />
else<br />
talkText = 'Relevant discussion may be found on'<br />
if talkArgIsTalkPage then<br />
talkText = string.format(<br />
'%s [[%s|%s]].',<br />
talkText,<br />
talk,<br />
talkTitle.prefixedText<br />
)<br />
else<br />
talkText = string.format(<br />
'%s the [[%s#%s|talk page]].',<br />
talkText,<br />
talkTitle.prefixedText,<br />
talk<br />
)<br />
end<br />
end<br />
self.talk = talkText<br />
end<br />
end<br />
<br />
-- Get other values.<br />
self.fix = args.fix ~= '' and args.fix or nil<br />
local date<br />
if args.date and args.date ~= '' then<br />
date = args.date<br />
elseif args.date == '' and self.isTemplatePage then<br />
date = lang:formatDate('F Y')<br />
end<br />
if date then<br />
self.date = string.format(" <span class='date-container'><i>(<span class='date'>%s</span>)</i></span>", date)<br />
end<br />
self.info = args.info<br />
if yesno(args.removalnotice) then<br />
self.removalNotice = cfg.removalNotice<br />
end<br />
end<br />
<br />
-- Set the non-collapsible text field. At the moment this is used by all box<br />
-- types other than ambox, and also by ambox when small=yes.<br />
if self.isSmall then<br />
self.text = args.smalltext or args.text<br />
else<br />
self.text = args.text<br />
end<br />
<br />
-- Set the below row.<br />
self.below = cfg.below and args.below<br />
<br />
-- General image settings.<br />
self.imageCellDiv = not self.isSmall and cfg.imageCellDiv<br />
self.imageEmptyCell = cfg.imageEmptyCell<br />
<br />
-- Left image settings.<br />
local imageLeft = self.isSmall and args.smallimage or args.image<br />
if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none'<br />
or not cfg.imageCheckBlank and imageLeft ~= 'none'<br />
then<br />
self.imageLeft = imageLeft<br />
if not imageLeft then<br />
local imageSize = self.isSmall<br />
and (cfg.imageSmallSize or '30x30px')<br />
or '40x40px'<br />
self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage<br />
or 'Imbox notice.png', imageSize)<br />
end<br />
end<br />
<br />
-- Right image settings.<br />
local imageRight = self.isSmall and args.smallimageright or args.imageright<br />
if not (cfg.imageRightNone and imageRight == 'none') then<br />
self.imageRight = imageRight<br />
end<br />
<br />
-- set templatestyles<br />
self.base_templatestyles = cfg.templatestyles<br />
self.templatestyles = args.templatestyles<br />
end<br />
<br />
function MessageBox:setMainspaceCategories()<br />
local args = self.args<br />
local cfg = self.cfg<br />
<br />
if not cfg.allowMainspaceCategories then<br />
return nil<br />
end<br />
<br />
local nums = {}<br />
for _, prefix in ipairs{'cat', 'category', 'all'} do<br />
args[prefix .. '1'] = args[prefix]<br />
nums = union(nums, getArgNums(args, prefix))<br />
end<br />
<br />
-- The following is roughly equivalent to the old {{Ambox/category}}.<br />
local date = args.date<br />
date = type(date) == 'string' and date<br />
local preposition = 'from'<br />
for _, num in ipairs(nums) do<br />
local mainCat = args['cat' .. tostring(num)]<br />
or args['category' .. tostring(num)]<br />
local allCat = args['all' .. tostring(num)]<br />
mainCat = type(mainCat) == 'string' and mainCat<br />
allCat = type(allCat) == 'string' and allCat<br />
if mainCat and date and date ~= '' then<br />
local catTitle = string.format('%s %s %s', mainCat, preposition, date)<br />
self:addCat(0, catTitle)<br />
catTitle = getTitleObject('Category:' .. catTitle)<br />
if not catTitle or not catTitle.exists then<br />
self:addCat(0, 'Articles with invalid date parameter in template')<br />
end<br />
elseif mainCat and (not date or date == '') then<br />
self:addCat(0, mainCat)<br />
end<br />
if allCat then<br />
self:addCat(0, allCat)<br />
end<br />
end<br />
end<br />
<br />
function MessageBox:setTemplateCategories()<br />
local args = self.args<br />
local cfg = self.cfg<br />
<br />
-- Add template categories.<br />
if cfg.templateCategory then<br />
if cfg.templateCategoryRequireName then<br />
if self.isTemplatePage then<br />
self:addCat(10, cfg.templateCategory)<br />
end<br />
elseif not self.title.isSubpage then<br />
self:addCat(10, cfg.templateCategory)<br />
end<br />
end<br />
<br />
-- Add template error categories.<br />
if cfg.templateErrorCategory then<br />
local templateErrorCategory = cfg.templateErrorCategory<br />
local templateCat, templateSort<br />
if not self.name and not self.title.isSubpage then<br />
templateCat = templateErrorCategory<br />
elseif self.isTemplatePage then<br />
local paramsToCheck = cfg.templateErrorParamsToCheck or {}<br />
local count = 0<br />
for i, param in ipairs(paramsToCheck) do<br />
if not args[param] then<br />
count = count + 1<br />
end<br />
end<br />
if count > 0 then<br />
templateCat = templateErrorCategory<br />
templateSort = tostring(count)<br />
end<br />
if self.categoryNums and #self.categoryNums > 0 then<br />
templateCat = templateErrorCategory<br />
templateSort = 'C'<br />
end<br />
end<br />
self:addCat(10, templateCat, templateSort)<br />
end<br />
end<br />
<br />
function MessageBox:setAllNamespaceCategories()<br />
-- Set categories for all namespaces.<br />
if self.invalidTypeError then<br />
local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText<br />
self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort)<br />
end<br />
if self.isSubstituted then<br />
self:addCat('all', 'Pages with incorrectly substituted templates')<br />
end<br />
end<br />
<br />
function MessageBox:setCategories()<br />
if self.title.namespace == 0 then<br />
self:setMainspaceCategories()<br />
elseif self.title.namespace == 10 then<br />
self:setTemplateCategories()<br />
end<br />
self:setAllNamespaceCategories()<br />
end<br />
<br />
function MessageBox:renderCategories()<br />
if not self.hasCategories then<br />
-- No categories added, no need to pass them to Category handler so,<br />
-- if it was invoked, it would return the empty string.<br />
-- So we shortcut and return the empty string.<br />
return ""<br />
end<br />
-- Convert category tables to strings and pass them through<br />
-- [[Module:Category handler]].<br />
return require('Module:Category handler')._main{<br />
main = table.concat(self.categories[0] or {}),<br />
template = table.concat(self.categories[10] or {}),<br />
all = table.concat(self.categories.all or {}),<br />
nocat = self.args.nocat,<br />
page = self.args.page<br />
}<br />
end<br />
<br />
function MessageBox:export()<br />
local root = mw.html.create()<br />
<br />
-- Add the subst check error.<br />
if self.isSubstituted and self.name then<br />
root:tag('b')<br />
:addClass('error')<br />
:wikitext(string.format(<br />
'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.',<br />
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')<br />
))<br />
end<br />
<br />
local frame = mw.getCurrentFrame()<br />
root:wikitext(frame:extensionTag{<br />
name = 'templatestyles',<br />
args = { src = self.base_templatestyles },<br />
})<br />
-- Add support for a single custom templatestyles sheet. Undocumented as<br />
-- need should be limited and many templates using mbox are substed; we<br />
-- don't want to spread templatestyles sheets around to arbitrary places<br />
if self.templatestyles then<br />
root:wikitext(frame:extensionTag{<br />
name = 'templatestyles',<br />
args = { src = self.templatestyles },<br />
})<br />
end<br />
<br />
-- Create the box table.<br />
local boxTable = root:tag('table')<br />
boxTable:attr('id', self.id or nil)<br />
for i, class in ipairs(self.classes or {}) do<br />
boxTable:addClass(class or nil)<br />
end<br />
boxTable<br />
:cssText(self.style or nil)<br />
:attr('role', 'presentation')<br />
<br />
if self.attrs then<br />
boxTable:attr(self.attrs)<br />
end<br />
<br />
-- Add the left-hand image.<br />
local row = boxTable:tag('tr')<br />
if self.imageLeft then<br />
local imageLeftCell = row:tag('td'):addClass('mbox-image')<br />
if self.imageCellDiv then<br />
-- If we are using a div, redefine imageLeftCell so that the image<br />
-- is inside it. Divs use style="width: 52px;", which limits the<br />
-- image width to 52px. If any images in a div are wider than that,<br />
-- they may overlap with the text or cause other display problems.<br />
imageLeftCell = imageLeftCell:tag('div'):addClass('mbox-image-div')<br />
end<br />
imageLeftCell:wikitext(self.imageLeft or nil)<br />
elseif self.imageEmptyCell then<br />
-- Some message boxes define an empty cell if no image is specified, and<br />
-- some don't. The old template code in templates where empty cells are<br />
-- specified gives the following hint: "No image. Cell with some width<br />
-- or padding necessary for text cell to have 100% width."<br />
row:tag('td')<br />
:addClass('mbox-empty-cell')<br />
end<br />
<br />
-- Add the text.<br />
local textCell = row:tag('td'):addClass('mbox-text')<br />
if self.useCollapsibleTextFields then<br />
-- The message box uses advanced text parameters that allow things to be<br />
-- collapsible. At the moment, only ambox uses this.<br />
textCell:cssText(self.textstyle or nil)<br />
local textCellDiv = textCell:tag('div')<br />
textCellDiv<br />
:addClass('mbox-text-span')<br />
:wikitext(self.issue or nil)<br />
if (self.talk or self.fix) then<br />
textCellDiv:tag('span')<br />
:addClass('hide-when-compact')<br />
:wikitext(self.talk and (' ' .. self.talk) or nil)<br />
:wikitext(self.fix and (' ' .. self.fix) or nil)<br />
end<br />
textCellDiv:wikitext(self.date and (' ' .. self.date) or nil)<br />
if self.info and not self.isSmall then<br />
textCellDiv<br />
:tag('span')<br />
:addClass('hide-when-compact')<br />
:wikitext(self.info and (' ' .. self.info) or nil)<br />
end<br />
if self.removalNotice then<br />
textCellDiv:tag('span')<br />
:addClass('hide-when-compact')<br />
:tag('i')<br />
:wikitext(string.format(" (%s)", self.removalNotice))<br />
end<br />
else<br />
-- Default text formatting - anything goes.<br />
textCell<br />
:cssText(self.textstyle or nil)<br />
:wikitext(self.text or nil)<br />
end<br />
<br />
-- Add the right-hand image.<br />
if self.imageRight then<br />
local imageRightCell = row:tag('td'):addClass('mbox-imageright')<br />
if self.imageCellDiv then<br />
-- If we are using a div, redefine imageRightCell so that the image<br />
-- is inside it.<br />
imageRightCell = imageRightCell:tag('div'):addClass('mbox-image-div')<br />
end<br />
imageRightCell<br />
:wikitext(self.imageRight or nil)<br />
end<br />
<br />
-- Add the below row.<br />
if self.below then<br />
boxTable:tag('tr')<br />
:tag('td')<br />
:attr('colspan', self.imageRight and '3' or '2')<br />
:addClass('mbox-text')<br />
:cssText(self.textstyle or nil)<br />
:wikitext(self.below or nil)<br />
end<br />
<br />
-- Add error message for invalid type parameters.<br />
if self.invalidTypeError then<br />
root:tag('div')<br />
:addClass('mbox-invalid-type')<br />
:wikitext(string.format(<br />
'This message box is using an invalid "type=%s" parameter and needs fixing.',<br />
self.type or ''<br />
))<br />
end<br />
<br />
-- Add categories.<br />
root:wikitext(self:renderCategories() or nil)<br />
<br />
return tostring(root)<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Exports<br />
--------------------------------------------------------------------------------<br />
<br />
local p, mt = {}, {}<br />
<br />
function p._exportClasses()<br />
-- For testing.<br />
return {<br />
MessageBox = MessageBox<br />
}<br />
end<br />
<br />
function p.main(boxType, args, cfgTables)<br />
local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE))<br />
box:setParameters()<br />
box:setCategories()<br />
return box:export()<br />
end<br />
<br />
function mt.__index(t, k)<br />
return function (frame)<br />
if not getArgs then<br />
getArgs = require('Module:Arguments').getArgs<br />
end<br />
return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))<br />
end<br />
end<br />
<br />
return setmetatable(p, mt)</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Template:Template_link&diff=64746Template:Template link2023-04-20T15:33:22Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>&#123;&#123;[[Template:{{{1}}}|{{{1}}}]]&#125;&#125;<noinclude>{{documentation}}<br />
<!-- Categories go on the /doc subpage and interwikis go on Wikidata. --><br />
</noinclude></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Template:Tl&diff=64744Template:Tl2023-04-20T15:33:22Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>#REDIRECT [[Template:Template link]]<br />
<br />
{{Redirect category shell|<br />
{{R from move}}<br />
}}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Template:Mbox&diff=64742Template:Mbox2023-04-20T15:33:22Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>{{#invoke:Message box|mbox}}<noinclude><br />
{{documentation}}<br />
<!-- Add categories to the /doc subpage; interwikis go to Wikidata, thank you! --><br />
</noinclude></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Arguments&diff=64740Module:Arguments2023-04-20T15:33:21Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>-- This module provides easy processing of arguments passed to Scribunto from<br />
-- #invoke. It is intended for use by other Lua modules, and should not be<br />
-- called from #invoke directly.<br />
<br />
local libraryUtil = require('libraryUtil')<br />
local checkType = libraryUtil.checkType<br />
<br />
local arguments = {}<br />
<br />
-- Generate four different tidyVal functions, so that we don't have to check the<br />
-- options every time we call it.<br />
<br />
local function tidyValDefault(key, val)<br />
if type(val) == 'string' then<br />
val = val:match('^%s*(.-)%s*$')<br />
if val == '' then<br />
return nil<br />
else<br />
return val<br />
end<br />
else<br />
return val<br />
end<br />
end<br />
<br />
local function tidyValTrimOnly(key, val)<br />
if type(val) == 'string' then<br />
return val:match('^%s*(.-)%s*$')<br />
else<br />
return val<br />
end<br />
end<br />
<br />
local function tidyValRemoveBlanksOnly(key, val)<br />
if type(val) == 'string' then<br />
if val:find('%S') then<br />
return val<br />
else<br />
return nil<br />
end<br />
else<br />
return val<br />
end<br />
end<br />
<br />
local function tidyValNoChange(key, val)<br />
return val<br />
end<br />
<br />
local function matchesTitle(given, title)<br />
local tp = type( given )<br />
return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title<br />
end<br />
<br />
local translate_mt = { __index = function(t, k) return k end }<br />
<br />
function arguments.getArgs(frame, options)<br />
checkType('getArgs', 1, frame, 'table', true)<br />
checkType('getArgs', 2, options, 'table', true)<br />
frame = frame or {}<br />
options = options or {}<br />
<br />
--[[<br />
-- Set up argument translation.<br />
--]]<br />
options.translate = options.translate or {}<br />
if getmetatable(options.translate) == nil then<br />
setmetatable(options.translate, translate_mt)<br />
end<br />
if options.backtranslate == nil then<br />
options.backtranslate = {}<br />
for k,v in pairs(options.translate) do<br />
options.backtranslate[v] = k<br />
end<br />
end<br />
if options.backtranslate and getmetatable(options.backtranslate) == nil then<br />
setmetatable(options.backtranslate, {<br />
__index = function(t, k)<br />
if options.translate[k] ~= k then<br />
return nil<br />
else<br />
return k<br />
end<br />
end<br />
})<br />
end<br />
<br />
--[[<br />
-- Get the argument tables. If we were passed a valid frame object, get the<br />
-- frame arguments (fargs) and the parent frame arguments (pargs), depending<br />
-- on the options set and on the parent frame's availability. If we weren't<br />
-- passed a valid frame object, we are being called from another Lua module<br />
-- or from the debug console, so assume that we were passed a table of args<br />
-- directly, and assign it to a new variable (luaArgs).<br />
--]]<br />
local fargs, pargs, luaArgs<br />
if type(frame.args) == 'table' and type(frame.getParent) == 'function' then<br />
if options.wrappers then<br />
--[[<br />
-- The wrappers option makes Module:Arguments look up arguments in<br />
-- either the frame argument table or the parent argument table, but<br />
-- not both. This means that users can use either the #invoke syntax<br />
-- or a wrapper template without the loss of performance associated<br />
-- with looking arguments up in both the frame and the parent frame.<br />
-- Module:Arguments will look up arguments in the parent frame<br />
-- if it finds the parent frame's title in options.wrapper;<br />
-- otherwise it will look up arguments in the frame object passed<br />
-- to getArgs.<br />
--]]<br />
local parent = frame:getParent()<br />
if not parent then<br />
fargs = frame.args<br />
else<br />
local title = parent:getTitle():gsub('/sandbox$', '')<br />
local found = false<br />
if matchesTitle(options.wrappers, title) then<br />
found = true<br />
elseif type(options.wrappers) == 'table' then<br />
for _,v in pairs(options.wrappers) do<br />
if matchesTitle(v, title) then<br />
found = true<br />
break<br />
end<br />
end<br />
end<br />
<br />
-- We test for false specifically here so that nil (the default) acts like true.<br />
if found or options.frameOnly == false then<br />
pargs = parent.args<br />
end<br />
if not found or options.parentOnly == false then<br />
fargs = frame.args<br />
end<br />
end<br />
else<br />
-- options.wrapper isn't set, so check the other options.<br />
if not options.parentOnly then<br />
fargs = frame.args<br />
end<br />
if not options.frameOnly then<br />
local parent = frame:getParent()<br />
pargs = parent and parent.args or nil<br />
end<br />
end<br />
if options.parentFirst then<br />
fargs, pargs = pargs, fargs<br />
end<br />
else<br />
luaArgs = frame<br />
end<br />
<br />
-- Set the order of precedence of the argument tables. If the variables are<br />
-- nil, nothing will be added to the table, which is how we avoid clashes<br />
-- between the frame/parent args and the Lua args.<br />
local argTables = {fargs}<br />
argTables[#argTables + 1] = pargs<br />
argTables[#argTables + 1] = luaArgs<br />
<br />
--[[<br />
-- Generate the tidyVal function. If it has been specified by the user, we<br />
-- use that; if not, we choose one of four functions depending on the<br />
-- options chosen. This is so that we don't have to call the options table<br />
-- every time the function is called.<br />
--]]<br />
local tidyVal = options.valueFunc<br />
if tidyVal then<br />
if type(tidyVal) ~= 'function' then<br />
error(<br />
"bad value assigned to option 'valueFunc'"<br />
.. '(function expected, got '<br />
.. type(tidyVal)<br />
.. ')',<br />
2<br />
)<br />
end<br />
elseif options.trim ~= false then<br />
if options.removeBlanks ~= false then<br />
tidyVal = tidyValDefault<br />
else<br />
tidyVal = tidyValTrimOnly<br />
end<br />
else<br />
if options.removeBlanks ~= false then<br />
tidyVal = tidyValRemoveBlanksOnly<br />
else<br />
tidyVal = tidyValNoChange<br />
end<br />
end<br />
<br />
--[[<br />
-- Set up the args, metaArgs and nilArgs tables. args will be the one<br />
-- accessed from functions, and metaArgs will hold the actual arguments. Nil<br />
-- arguments are memoized in nilArgs, and the metatable connects all of them<br />
-- together.<br />
--]]<br />
local args, metaArgs, nilArgs, metatable = {}, {}, {}, {}<br />
setmetatable(args, metatable)<br />
<br />
local function mergeArgs(tables)<br />
--[[<br />
-- Accepts multiple tables as input and merges their keys and values<br />
-- into one table. If a value is already present it is not overwritten;<br />
-- tables listed earlier have precedence. We are also memoizing nil<br />
-- values, which can be overwritten if they are 's' (soft).<br />
--]]<br />
for _, t in ipairs(tables) do<br />
for key, val in pairs(t) do<br />
if metaArgs[key] == nil and nilArgs[key] ~= 'h' then<br />
local tidiedVal = tidyVal(key, val)<br />
if tidiedVal == nil then<br />
nilArgs[key] = 's'<br />
else<br />
metaArgs[key] = tidiedVal<br />
end<br />
end<br />
end<br />
end<br />
end<br />
<br />
--[[<br />
-- Define metatable behaviour. Arguments are memoized in the metaArgs table,<br />
-- and are only fetched from the argument tables once. Fetching arguments<br />
-- from the argument tables is the most resource-intensive step in this<br />
-- module, so we try and avoid it where possible. For this reason, nil<br />
-- arguments are also memoized, in the nilArgs table. Also, we keep a record<br />
-- in the metatable of when pairs and ipairs have been called, so we do not<br />
-- run pairs and ipairs on the argument tables more than once. We also do<br />
-- not run ipairs on fargs and pargs if pairs has already been run, as all<br />
-- the arguments will already have been copied over.<br />
--]]<br />
<br />
metatable.__index = function (t, key)<br />
--[[<br />
-- Fetches an argument when the args table is indexed. First we check<br />
-- to see if the value is memoized, and if not we try and fetch it from<br />
-- the argument tables. When we check memoization, we need to check<br />
-- metaArgs before nilArgs, as both can be non-nil at the same time.<br />
-- If the argument is not present in metaArgs, we also check whether<br />
-- pairs has been run yet. If pairs has already been run, we return nil.<br />
-- This is because all the arguments will have already been copied into<br />
-- metaArgs by the mergeArgs function, meaning that any other arguments<br />
-- must be nil.<br />
--]]<br />
if type(key) == 'string' then<br />
key = options.translate[key]<br />
end<br />
local val = metaArgs[key]<br />
if val ~= nil then<br />
return val<br />
elseif metatable.donePairs or nilArgs[key] then<br />
return nil<br />
end<br />
for _, argTable in ipairs(argTables) do<br />
local argTableVal = tidyVal(key, argTable[key])<br />
if argTableVal ~= nil then<br />
metaArgs[key] = argTableVal<br />
return argTableVal<br />
end<br />
end<br />
nilArgs[key] = 'h'<br />
return nil<br />
end<br />
<br />
metatable.__newindex = function (t, key, val)<br />
-- This function is called when a module tries to add a new value to the<br />
-- args table, or tries to change an existing value.<br />
if type(key) == 'string' then<br />
key = options.translate[key]<br />
end<br />
if options.readOnly then<br />
error(<br />
'could not write to argument table key "'<br />
.. tostring(key)<br />
.. '"; the table is read-only',<br />
2<br />
)<br />
elseif options.noOverwrite and args[key] ~= nil then<br />
error(<br />
'could not write to argument table key "'<br />
.. tostring(key)<br />
.. '"; overwriting existing arguments is not permitted',<br />
2<br />
)<br />
elseif val == nil then<br />
--[[<br />
-- If the argument is to be overwritten with nil, we need to erase<br />
-- the value in metaArgs, so that __index, __pairs and __ipairs do<br />
-- not use a previous existing value, if present; and we also need<br />
-- to memoize the nil in nilArgs, so that the value isn't looked<br />
-- up in the argument tables if it is accessed again.<br />
--]]<br />
metaArgs[key] = nil<br />
nilArgs[key] = 'h'<br />
else<br />
metaArgs[key] = val<br />
end<br />
end<br />
<br />
local function translatenext(invariant)<br />
local k, v = next(invariant.t, invariant.k)<br />
invariant.k = k<br />
if k == nil then<br />
return nil<br />
elseif type(k) ~= 'string' or not options.backtranslate then<br />
return k, v<br />
else<br />
local backtranslate = options.backtranslate[k]<br />
if backtranslate == nil then<br />
-- Skip this one. This is a tail call, so this won't cause stack overflow<br />
return translatenext(invariant)<br />
else<br />
return backtranslate, v<br />
end<br />
end<br />
end<br />
<br />
metatable.__pairs = function ()<br />
-- Called when pairs is run on the args table.<br />
if not metatable.donePairs then<br />
mergeArgs(argTables)<br />
metatable.donePairs = true<br />
end<br />
return translatenext, { t = metaArgs }<br />
end<br />
<br />
local function inext(t, i)<br />
-- This uses our __index metamethod<br />
local v = t[i + 1]<br />
if v ~= nil then<br />
return i + 1, v<br />
end<br />
end<br />
<br />
metatable.__ipairs = function (t)<br />
-- Called when ipairs is run on the args table.<br />
return inext, t, 0<br />
end<br />
<br />
return args<br />
end<br />
<br />
return arguments</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Yesno&diff=64738Module:Yesno2023-04-20T15:33:21Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>-- Function allowing for consistent treatment of boolean-like wikitext input.<br />
-- It works similarly to the template {{yesno}}.<br />
<br />
return function (val, default)<br />
-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you<br />
-- should replace "val:lower()" with "mw.ustring.lower(val)" in the<br />
-- following line.<br />
val = type(val) == 'string' and val:lower() or val<br />
if val == nil then<br />
return nil<br />
elseif val == true <br />
or val == 'yes'<br />
or val == 'y'<br />
or val == 'true'<br />
or val == 't'<br />
or val == 'on'<br />
or tonumber(val) == 1<br />
then<br />
return true<br />
elseif val == false<br />
or val == 'no'<br />
or val == 'n'<br />
or val == 'false'<br />
or val == 'f'<br />
or val == 'off'<br />
or tonumber(val) == 0<br />
then<br />
return false<br />
else<br />
return default<br />
end<br />
end</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Template:Historical&diff=64736Template:Historical2023-04-20T15:33:20Z<p>WikiSysop: 1 revision imported</p>
<hr />
<div>{{mbox<br />
| type = notice<br />
| image = [[File:Historical.svg|30px|alt=|link= WP:HISPAGES]]<br />
| imageright = {{#if:{{{1<includeonly>|</includeonly>}}} | {{Shortcut|{{{1|<noinclude>WP:THIS</noinclude>}}}|{{{2|<noinclude>WP:EXAMPLE</noinclude>}}}|{{{3|}}}|{{{4|}}}|{{{5|}}} }} }}<br />
| text = {{#switch:{{NAMESPACE}}<br />
|User|User talk='''This user {{#ifeq:{{BASEPAGENAME}}|{{PAGENAME}}||sub}}page is currently inactive and is retained for ''historical'' reference.'''<br /><span style="font-size: 90%">{{#if: {{{last|}}}{{{date|}}}|It was last substantively updated {{{last|{{{date|}}}}}}.<br />}}If you want to revive discussion regarding the subject, you might try contacting [[User talk:{{ROOTPAGENAME}}|the user in question]] or seeking broader input via a forum such as the [[Wikipedia:Village pump (proposals)|village pump]].</span><br />
|#default={{#switch:{{{type}}}<br />
|policy='''This former [[Wikipedia:Policies and guidelines|Wikipedia policy]], no longer backed by community consensus, is retained for historical reference.'''<br />
|guideline='''This former [[Wikipedia:Policies and guidelines|Wikipedia guideline]], no longer backed by community consensus, is retained for historical reference.'''<br />
|woundup='''This page has been closed down by [[Wikipedia:Consensus|community consensus]], and is retained only for [[WP:HISPAGES|historical]] reference.'''<br /><span style="font-size: 90%">If you wish to restart discussion on the status of this page, seek community input at a forum such as the [[Wikipedia:Village pump|village pump]].</span><br />
|dbr='''This [[Wikipedia:Database reports|database report]] is no longer updated, and is retained for [[WP:HISPAGES|historical]] reference.'''<br /><span style="font-size: 90%">However, it may have been superseded by another report, or replaced with a [[Wikipedia:Maintenance|maintenance]] or [[:Category:Tracking categories|tracking category]].<br />To see currently maintained reports, consult the [[WP:Database reports|main database report page]].<br />If you would like a historical database report be run again, see the main [[WT:Database reports|database reports talk page]].<br />Other discontinued database reports can be found in the [[Wikipedia:Database reports/Archive|archive]].</span><br />
|#default='''This page is currently inactive and is retained for [[WP:HISPAGES|historical]] reference.'''{{#if: {{{brief|}}}||<br /><span style="font-size: 90%">Either the page is no longer relevant or consensus on its purpose has become unclear. To revive discussion, seek broader input via a forum such as the [[Wikipedia:Village pump (proposals)|village pump]].</span><br />
}}<br />
}}<br />
}} <span style="font-size: 90%">{{{comment|{{{reason|{{{result|}}}}}}}}} {{#if: {{{last|}}}{{{date|}}}|It was last substantively updated {{{last|{{{date}}}}}}.}}</span><br />
}}<includeonly>{{#switch:{{NAMESPACE}}|User|User talk=|#default={{#ifeq:{{{category}}}|no||[[Category:Inactive project pages|{{PAGENAME}}]]}}}}</includeonly><noinclude>{{documentation}}<!-- Add categories and interwikis to the /doc subpage, not here! --><br />
</noinclude></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Main_Page&diff=64514Main Page2020-02-11T21:26:36Z<p>WikiSysop: </p>
<hr />
<div>{|<br />
| <ImageLink>https://cmake.org/cmake/img/CMake-logo-download.jpg|https://cmake.org/Wiki/CMake|CMake Wiki</ImageLink><br />
| [[CMake]] is the cross-platform, open-source make system. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice. CMake is quite sophisticated: it is possible to support complex environments requiring system configuration, pre-processor generation, code generation, and template instantiation.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://www.vtk.org/Wiki/images/0/0b/Vtk_newlogo.png|http://www.vtk.org/Wiki/VTK|CMake Web Page</ImageLink><br />
| [[VTK|The Visualization ToolKit (VTK)]] is an open source, freely available software system for 3D computer graphics, image processing, and visualization used by thousands of researchers and developers around the world. VTK consists of a C++ class library, and several interpreted interface layers including Tcl/Tk, Java, and Python. Professional support and products for VTK are provided by [http://www.kitware.com Kitware, Inc.] VTK supports a wide variety of visualization algorithms including scalar, vector, tensor, texture, and volumetric methods; and advanced modeling techniques such as implicit modelling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay triangulation. In addition, dozens of imaging algorithms have been directly integrated to allow the user to mix 2D imaging / 3D graphics algorithms and data. <br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/8/81/ITK-small.png|http://www.itk.org/Wiki/ITK|ITK Wiki</ImageLink><br />
| [[ITK|National Library of Medicine Insight Segmentation and Registration Toolkit (ITK)]] is an open-source software system to support the Visible Human Project. Currently under active development, ITK employs leading-edge segmentation and registration algorithms in two, three, and more dimensions.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/e/ea/Pvlogo.png|http://www.paraview.org/Wiki/ParaView|ParaView Wiki</ImageLink><br />
| [[ParaView]] is an open-source, multi-platform application designed to visualize data sets of size varying from small to very large. The goals of the ParaView project include developing an open-source, multi-platform visualization application that support distributed computational models to process large data sets. It has an open, flexible, and intuitive user interface. Furthermore, ParaView is built on an extensible architecture based on open standards. ParaView runs on distributed and shared memory parallel as well as single processor systems and has been succesfully tested on Windows, Linux, Mac OS X, IBM Blue Gene, Cray XT3 and various Unix workstations and clusters. Under the hood, ParaView uses the Visualization Toolkit as the data processing and rendering engine and has a user interface written using the Qt cross-platform application framework.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/e/e7/Cdash.gif|http://public.kitware.com/Wiki/CDash|CDash Wiki</ImageLink><br />
| [[CDash]] is an open source, web-based software testing server. CDash aggregates, analyzes and displays the results of software testing processes submitted from clients located around the world. Developers depend on CDash to convey the state of a software system, and to continually improve its quality. CDash is a part of a larger software process that integrates Kitware's CMake, CTest, and CPack tools, as well as other external packages used to design, manage and maintain large-scale software systems. Good examples of a CDash are the [http://www.cdash.org/CDash/index.php?project=CMake CMake quality dashboard] and the [http://www.cdash.org/CDash/index.php?project=VTK VTK quality dashboard]. <br />
|-<br />
|}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Main_Page&diff=63994Main Page2019-12-16T17:39:47Z<p>WikiSysop: </p>
<hr />
<div>{|<br />
| <ImageLink>https://cmake.org/cmake/img/CMake-logo-download.jpg|https://cmake.org/Wiki/CMake|CMake Wiki</ImageLink><br />
| [[CMake]] is the cross-platform, open-source make system. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice. CMake is quite sophisticated: it is possible to support complex environments requiring system configuration, pre-processor generation, code generation, and template instantiation.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://www.vtk.org/Wiki/images/0/0b/Vtk_newlogo.png|http://www.vtk.org/Wiki/VTK|CMake Web Page</ImageLink><br />
| [[VTK|The Visualization ToolKit (VTK)]] is an open source, freely available software system for 3D computer graphics, image processing, and visualization used by thousands of researchers and developers around the world. VTK consists of a C++ class library, and several interpreted interface layers including Tcl/Tk, Java, and Python. Professional support and products for VTK are provided by [http://www.kitware.com Kitware, Inc.] VTK supports a wide variety of visualization algorithms including scalar, vector, tensor, texture, and volumetric methods; and advanced modeling techniques such as implicit modelling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay triangulation. In addition, dozens of imaging algorithms have been directly integrated to allow the user to mix 2D imaging / 3D graphics algorithms and data. <br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/8/81/ITK-small.png|http://www.itk.org/Wiki/ITK|ITK Wiki</ImageLink><br />
| [[ITK|National Library of Medicine Insight Segmentation and Registration Toolkit (ITK)]] is an open-source software system to support the Visible Human Project. Currently under active development, ITK employs leading-edge segmentation and registration algorithms in two, three, and more dimensions.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/e/ea/Pvlogo.png|http://www.paraview.org/Wiki/ParaView|ParaView Wiki</ImageLink><br />
| [[ParaView]] is an open-source, multi-platform application designed to visualize data sets of size varying from small to very large. The goals of the ParaView project include developing an open-source, multi-platform visualization application that support distributed computational models to process large data sets. It has an open, flexible, and intuitive user interface. Furthermore, ParaView is built on an extensible architecture based on open standards. ParaView runs on distributed and shared memory parallel as well as single processor systems and has been succesfully tested on Windows, Linux, Mac OS X, IBM Blue Gene, Cray XT3 and various Unix workstations and clusters. Under the hood, ParaView uses the Visualization Toolkit as the data processing and rendering engine and has a user interface written using the Qt cross-platform application framework.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/f/f0/KWWidgetsSplashScreenSmall.png|http://www.kwwidgets.org/Wiki/KWWidgets|KWWidgets Wiki</ImageLink><br />
| [http://www.KWWidgets.org KWWidgets] is a free, cross-platform and open-license GUI Toolkit. It provides low-level core widgets, advanced composite widgets, and high-level visualization-oriented widgets that can be interfaced to visualization libraries like VTK. KWWidgets is an object-oriented C++ toolkit that can interact and co-exist with Tcl/Tk directly from C++. It is wrapped automatically into a Tcl package, and therefore can be used directly from Tcl/Tk also, allowing for fast-prototyping and scripting.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/e/e7/Cdash.gif|http://public.kitware.com/Wiki/CDash|CDash Wiki</ImageLink><br />
| [[CDash]] is an open source, web-based software testing server. CDash aggregates, analyzes and displays the results of software testing processes submitted from clients located around the world. Developers depend on CDash to convey the state of a software system, and to continually improve its quality. CDash is a part of a larger software process that integrates Kitware's CMake, CTest, and CPack tools, as well as other external packages used to design, manage and maintain large-scale software systems. Good examples of a CDash are the [http://www.cdash.org/CDash/index.php?project=CMake CMake quality dashboard] and the [http://www.cdash.org/CDash/index.php?project=VTK VTK quality dashboard]. <br />
|-<br />
|}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=KwGrid:Editing_Help&diff=63986KwGrid:Editing Help2019-11-15T13:27:54Z<p>WikiSysop: /* Extensions */</p>
<hr />
<div>In addition to the guidelines provided in the [http://meta.wikimedia.org/wiki/Help:Editing MediaWiki General Editing] page, the following rules are suggested:<br />
<br />
==Page and File Names==<br />
<br />
* Prefix a page name with the <tt>kwGrid:</tt> namespace (lowercase <tt>kw</tt>). For example, [[kwGrid:Welcome]]. Used the [http://meta.wikimedia.org/wiki/Help:Piped_link piped link] notation to hide the namespace when the page is rendered. Namespaces allow separation of different kinds of unrelated content within the same Wiki (i.e. isolate projects like VTK, CMake, ITK, kwGrid). Namespaces also provide facilities to limit searches to a particular area and allow easy exporting of a selection of work.<br />
* Use spaces at will. For example, use [[kwGrid:My Own Hardware]] over [[kwGrid:MyOwnHardware]].<br />
* Use slashes (/) to provide additional structure and depth. For example, the [[kwGrid:Partners]] page provides links to pages describing each partner one by one: use [[kwGrid:Partners/Argonne National Lab]] over [[kwGrid:Partners Argonne National Lab]], as it emphasizes that it is a "sub-page" of [[kwGrid:Partners]] and mimics the traditional web structure. Furthermore, if the [http://en.wikipedia.org/wiki/Help:Link#Subpage_feature sub-page feature] is enabled in the Wiki, a link is automatically created on top of the sub-page to the "parent" page.<br />
* Use the same rules to upload files, but remove spaces and slashes since they are not allowed in a file name. For example: <tt>kwGridPartnersArgonneNationalLab.png</tt>. Let the [[kwGrid:Team|team]] know about the files, images, PDF or Word documents you upload, so that we can also archive a copy in the [[kwGrid:Download#CVS|CVS]] repository.<br />
<br />
==Page Content==<br />
<br />
* Terminate a page with a call to the [[:kwGrid:Template/Footer|Footer]] template. This automatically adds a footer to the page. This template is used to provide extra navigational links and associate the page to specific searchable categories. Check the bottom of this page to see how this template is rendered.<br />
<pre><br />
{{:kwGrid:Template/Footer}}<br />
</pre><br />
<br />
==Templates==<br />
<br />
===<tt>Mail To</tt>===<br />
The [[:kwGrid:Template/Mail To|Mail To]] template can be used to build a mailto: link prefixed with a small mail icon [[Image:kwGridMailToIcon.png]]. For example:<br />
<pre><br />
{{:kwGrid:Template/Mail To|sebastien.barre@kitware.com|Sebastien Barre}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Mail To|sebastien.barre@kitware.com|Sebastien Barre}}<br />
<br />
===<tt>Note Box</tt>===<br />
The [[:kwGrid:Template/Note Box|Note Box]] template can be used to provide a short note:<br />
<pre><br />
{{:kwGrid:Template/Note Box|message=This is an example of text inside a Note Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Note Box|message=This is an example of text inside a Note Box template.}}<br />
<br />
===<tt>Warning Box</tt>===<br />
The [[:kwGrid:Template/Warning Box|Warning Box]] template can be used to provide a short warning:<br />
<pre><br />
{{:kwGrid:Template/Warning Box|message=This is an example of text inside a Warning Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Warning Box|message=This is an example of text inside a Warning Box template.}}<br />
<br />
===<tt>Help Box</tt>===<br />
The [[:kwGrid:Template/Help Box|Help Box]] template can be used to provide a short help:<br />
<pre><br />
{{:kwGrid:Template/Help Box|message=This is an example of text inside a Help Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Help Box|message=This is an example of text inside a Help Box template.}}<br />
<br />
===<tt>Tip Box</tt>===<br />
The [[:kwGrid:Template/Tip Box|Tip Box]] template can be used to provide a short tip:<br />
<pre><br />
{{:kwGrid:Template/Tip Box|message=This is an example of text inside a Tip Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Tip Box|message=This is an example of text inside a Tip Box template.}}<br />
<br />
===<tt>Security Box</tt>===<br />
The [[:kwGrid:Template/Security Box|Security Box]] template can be used to provide a short security notice:<br />
<pre><br />
{{:kwGrid:Template/Security Box|message=This is an example of text inside a Security Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Security Box|message=This is an example of text inside a Security Box template.}}<br />
<br />
<br />
{{:kwGrid:Template/Footer}}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=KwGrid:Editing_Help&diff=63985KwGrid:Editing Help2019-11-15T13:27:20Z<p>WikiSysop: </p>
<hr />
<div>In addition to the guidelines provided in the [http://meta.wikimedia.org/wiki/Help:Editing MediaWiki General Editing] page, the following rules are suggested:<br />
<br />
==Page and File Names==<br />
<br />
* Prefix a page name with the <tt>kwGrid:</tt> namespace (lowercase <tt>kw</tt>). For example, [[kwGrid:Welcome]]. Used the [http://meta.wikimedia.org/wiki/Help:Piped_link piped link] notation to hide the namespace when the page is rendered. Namespaces allow separation of different kinds of unrelated content within the same Wiki (i.e. isolate projects like VTK, CMake, ITK, kwGrid). Namespaces also provide facilities to limit searches to a particular area and allow easy exporting of a selection of work.<br />
* Use spaces at will. For example, use [[kwGrid:My Own Hardware]] over [[kwGrid:MyOwnHardware]].<br />
* Use slashes (/) to provide additional structure and depth. For example, the [[kwGrid:Partners]] page provides links to pages describing each partner one by one: use [[kwGrid:Partners/Argonne National Lab]] over [[kwGrid:Partners Argonne National Lab]], as it emphasizes that it is a "sub-page" of [[kwGrid:Partners]] and mimics the traditional web structure. Furthermore, if the [http://en.wikipedia.org/wiki/Help:Link#Subpage_feature sub-page feature] is enabled in the Wiki, a link is automatically created on top of the sub-page to the "parent" page.<br />
* Use the same rules to upload files, but remove spaces and slashes since they are not allowed in a file name. For example: <tt>kwGridPartnersArgonneNationalLab.png</tt>. Let the [[kwGrid:Team|team]] know about the files, images, PDF or Word documents you upload, so that we can also archive a copy in the [[kwGrid:Download#CVS|CVS]] repository.<br />
<br />
==Page Content==<br />
<br />
* Terminate a page with a call to the [[:kwGrid:Template/Footer|Footer]] template. This automatically adds a footer to the page. This template is used to provide extra navigational links and associate the page to specific searchable categories. Check the bottom of this page to see how this template is rendered.<br />
<pre><br />
{{:kwGrid:Template/Footer}}<br />
</pre><br />
<br />
==Templates==<br />
<br />
===<tt>Mail To</tt>===<br />
The [[:kwGrid:Template/Mail To|Mail To]] template can be used to build a mailto: link prefixed with a small mail icon [[Image:kwGridMailToIcon.png]]. For example:<br />
<pre><br />
{{:kwGrid:Template/Mail To|sebastien.barre@kitware.com|Sebastien Barre}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Mail To|sebastien.barre@kitware.com|Sebastien Barre}}<br />
<br />
===<tt>Note Box</tt>===<br />
The [[:kwGrid:Template/Note Box|Note Box]] template can be used to provide a short note:<br />
<pre><br />
{{:kwGrid:Template/Note Box|message=This is an example of text inside a Note Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Note Box|message=This is an example of text inside a Note Box template.}}<br />
<br />
===<tt>Warning Box</tt>===<br />
The [[:kwGrid:Template/Warning Box|Warning Box]] template can be used to provide a short warning:<br />
<pre><br />
{{:kwGrid:Template/Warning Box|message=This is an example of text inside a Warning Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Warning Box|message=This is an example of text inside a Warning Box template.}}<br />
<br />
===<tt>Help Box</tt>===<br />
The [[:kwGrid:Template/Help Box|Help Box]] template can be used to provide a short help:<br />
<pre><br />
{{:kwGrid:Template/Help Box|message=This is an example of text inside a Help Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Help Box|message=This is an example of text inside a Help Box template.}}<br />
<br />
===<tt>Tip Box</tt>===<br />
The [[:kwGrid:Template/Tip Box|Tip Box]] template can be used to provide a short tip:<br />
<pre><br />
{{:kwGrid:Template/Tip Box|message=This is an example of text inside a Tip Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Tip Box|message=This is an example of text inside a Tip Box template.}}<br />
<br />
===<tt>Security Box</tt>===<br />
The [[:kwGrid:Template/Security Box|Security Box]] template can be used to provide a short security notice:<br />
<pre><br />
{{:kwGrid:Template/Security Box|message=This is an example of text inside a Security Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Security Box|message=This is an example of text inside a Security Box template.}}<br />
<br />
==Extensions==<br />
<br />
MediaWiki, the software that runs this wiki, allows developers to [http://meta.wikimedia.org/wiki/Write_your_own_MediaWiki_extension write their own extensions] to the wiki markup. An extension defines an HTML/XML-style tag which can be used in the wiki editor like any other markup.<br />
<br />
===<tt>kw_include_file</tt>===<br />
This tag allows you to include the contents of a remote file in your page. It is typically used to include source code and prevent duplication between a source tree and a web page. For safety reasons, access to the local filesystem is denied and translations are performed to (hopefully) prevent people from including malicious HTML/JavaScript code. The following example include the [http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/scripts/media-wiki-extensions/kwIncludeFile.php?content-type=text%2Fplain&root=kwGridWeb extension code] itself through CVSWeb:<br />
<pre><br />
<kw_include_file>http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/scripts/media-wiki-extensions/kwIncludeFile.php?content-type=text%2Fplain&root=kwGridWeb</kw_include_file><br />
</pre><br />
...is rendered as:<br />
<kw_include_file>http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/scripts/media-wiki-extensions/kwIncludeFile.php?content-type=text%2Fplain&root=kwGridWeb</kw_include_file><br />
<br />
{{:kwGrid:Template/Footer}}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=KwGrid:Editing_Help&diff=63984KwGrid:Editing Help2019-11-15T13:25:15Z<p>WikiSysop: /* Extensions */</p>
<hr />
<div>{{:kwGrid:Template/Header}}<br />
In addition to the guidelines provided in the [http://meta.wikimedia.org/wiki/Help:Editing MediaWiki General Editing] page, the following rules are suggested:<br />
<br />
==Page and File Names==<br />
<br />
* Prefix a page name with the <tt>kwGrid:</tt> namespace (lowercase <tt>kw</tt>). For example, [[kwGrid:Welcome]]. Used the [http://meta.wikimedia.org/wiki/Help:Piped_link piped link] notation to hide the namespace when the page is rendered. Namespaces allow separation of different kinds of unrelated content within the same Wiki (i.e. isolate projects like VTK, CMake, ITK, kwGrid). Namespaces also provide facilities to limit searches to a particular area and allow easy exporting of a selection of work.<br />
* Use spaces at will. For example, use [[kwGrid:My Own Hardware]] over [[kwGrid:MyOwnHardware]].<br />
* Use slashes (/) to provide additional structure and depth. For example, the [[kwGrid:Partners]] page provides links to pages describing each partner one by one: use [[kwGrid:Partners/Argonne National Lab]] over [[kwGrid:Partners Argonne National Lab]], as it emphasizes that it is a "sub-page" of [[kwGrid:Partners]] and mimics the traditional web structure. Furthermore, if the [http://en.wikipedia.org/wiki/Help:Link#Subpage_feature sub-page feature] is enabled in the Wiki, a link is automatically created on top of the sub-page to the "parent" page.<br />
* Use the same rules to upload files, but remove spaces and slashes since they are not allowed in a file name. For example: <tt>kwGridPartnersArgonneNationalLab.png</tt>. Let the [[kwGrid:Team|team]] know about the files, images, PDF or Word documents you upload, so that we can also archive a copy in the [[kwGrid:Download#CVS|CVS]] repository.<br />
<br />
==Page Content==<br />
<br />
* Start a page with a call to the [[:kwGrid:Template/Header|Header]] template. Terminate a page with a call to the [[:kwGrid:Template/Footer|Footer]] template. This automatically adds a header and footer to the page. They provide extra navigational links and associate the page to specific searchable categories. Check the top and bottom of this page to see how the templates are rendered.<br />
<pre><br />
{{:kwGrid:Template/Header}}<br />
...<br />
{{:kwGrid:Template/Footer}}<br />
</pre><br />
<br />
==Templates==<br />
<br />
===<tt>Mail To</tt>===<br />
The [[:kwGrid:Template/Mail To|Mail To]] template can be used to build a mailto: link prefixed with a small mail icon [[Image:kwGridMailToIcon.png]]. For example:<br />
<pre><br />
{{:kwGrid:Template/Mail To|sebastien.barre@kitware.com|Sebastien Barre}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Mail To|sebastien.barre@kitware.com|Sebastien Barre}}<br />
<br />
===<tt>Note Box</tt>===<br />
The [[:kwGrid:Template/Note Box|Note Box]] template can be used to provide a short note:<br />
<pre><br />
{{:kwGrid:Template/Note Box|message=This is an example of text inside a Note Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Note Box|message=This is an example of text inside a Note Box template.}}<br />
<br />
===<tt>Warning Box</tt>===<br />
The [[:kwGrid:Template/Warning Box|Warning Box]] template can be used to provide a short warning:<br />
<pre><br />
{{:kwGrid:Template/Warning Box|message=This is an example of text inside a Warning Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Warning Box|message=This is an example of text inside a Warning Box template.}}<br />
<br />
===<tt>Help Box</tt>===<br />
The [[:kwGrid:Template/Help Box|Help Box]] template can be used to provide a short help:<br />
<pre><br />
{{:kwGrid:Template/Help Box|message=This is an example of text inside a Help Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Help Box|message=This is an example of text inside a Help Box template.}}<br />
<br />
===<tt>Tip Box</tt>===<br />
The [[:kwGrid:Template/Tip Box|Tip Box]] template can be used to provide a short tip:<br />
<pre><br />
{{:kwGrid:Template/Tip Box|message=This is an example of text inside a Tip Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Tip Box|message=This is an example of text inside a Tip Box template.}}<br />
<br />
===<tt>Security Box</tt>===<br />
The [[:kwGrid:Template/Security Box|Security Box]] template can be used to provide a short security notice:<br />
<pre><br />
{{:kwGrid:Template/Security Box|message=This is an example of text inside a Security Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Security Box|message=This is an example of text inside a Security Box template.}}<br />
<br />
==Extensions==<br />
<br />
{{:kwGrid:Template/Footer}}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=User:Barre/MediaWiki/Extensions/kw_bread_crumbs&diff=63983User:Barre/MediaWiki/Extensions/kw bread crumbs2019-11-15T13:24:13Z<p>WikiSysop: </p>
<hr />
<div><br />
===MediaWiki 1.5===<br />
See discussion tab for help with MediaWiki 1.5.<br />
<br />
===Examples===<br />
<br />
First, if everything is setup correctly, this extension should be in use on top of this page. Try navigating inside [[User:Barre]] and the [[kwGrid:Welcome|kwGrid]] sub-site to check how the trace<br />
evolves. The following code was used inside this page by include this [[:User:Barre/Template/Header|template]]:<br />
<pre><br />
<kw_bread_crumbs>prefix=&raquo; |small=1|bgcolor=F9F9F9|trim_prefix=User:|on_top_hack=1</kw_bread_crumbs><br />
</pre><br />
Note that the "User:" prefix is trimmed to leave only the user name, and that the trace is positioned<br />
on top of the page.<br />
<br />
The following code will create the same trace again, with a different prefix, a different separator and no trim:<br />
<pre><br />
<kw_bread_crumbs>prefix=Trace: |separator= # |small=1</kw_bread_crumbs><br />
</pre><br />
...is rendered as:<br />
<kw_bread_crumbs>prefix=Trace: |separator= # |small=1</kw_bread_crumbs><br />
<br />
The above examples use the current trace, i.e. the pages you have visited so far that make explicit use of this extension. If you have not moved around this site much, your trace might be a little too small to figure out what is going on. Here is a static example though. Say you had visited the following pages, in order: [[User:Barre]], [[User:Barre/MediaWiki]], [[User:Barre/MediaWiki/Extensions]] then this page, [[User:Barre/MediaWiki/Extensions/kw_bread_crumbs]]. The following code:<br />
<pre><br />
<kw_bread_crumbs>prefix=Trace: |trim_prefix=User:|small=1</kw_bread_crumbs><br />
</pre><br />
...would have rendered your trace pretty much like this:<br />
<br />
<small>Trace: [[User:Barre|Barre]] » [[User:Barre/MediaWiki|Barre/MediaWiki]] » [[User:Barre/MediaWiki/Extensions|Barre/MediaWiki/Extensions]] » Barre/Extensio…kw bread crumbs</small></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=User:Barre/MediaWiki/Extensions/kw_bread_crumbs&diff=63982User:Barre/MediaWiki/Extensions/kw bread crumbs2019-11-15T13:23:47Z<p>WikiSysop: </p>
<hr />
<div>{{User:Barre/Template/Header}}<br />
<br />
===MediaWiki 1.5===<br />
See discussion tab for help with MediaWiki 1.5.<br />
<br />
===Examples===<br />
<br />
First, if everything is setup correctly, this extension should be in use on top of this page. Try navigating inside [[User:Barre]] and the [[kwGrid:Welcome|kwGrid]] sub-site to check how the trace<br />
evolves. The following code was used inside this page by include this [[:User:Barre/Template/Header|template]]:<br />
<pre><br />
<kw_bread_crumbs>prefix=&raquo; |small=1|bgcolor=F9F9F9|trim_prefix=User:|on_top_hack=1</kw_bread_crumbs><br />
</pre><br />
Note that the "User:" prefix is trimmed to leave only the user name, and that the trace is positioned<br />
on top of the page.<br />
<br />
The following code will create the same trace again, with a different prefix, a different separator and no trim:<br />
<pre><br />
<kw_bread_crumbs>prefix=Trace: |separator= # |small=1</kw_bread_crumbs><br />
</pre><br />
...is rendered as:<br />
<kw_bread_crumbs>prefix=Trace: |separator= # |small=1</kw_bread_crumbs><br />
<br />
The above examples use the current trace, i.e. the pages you have visited so far that make explicit use of this extension. If you have not moved around this site much, your trace might be a little too small to figure out what is going on. Here is a static example though. Say you had visited the following pages, in order: [[User:Barre]], [[User:Barre/MediaWiki]], [[User:Barre/MediaWiki/Extensions]] then this page, [[User:Barre/MediaWiki/Extensions/kw_bread_crumbs]]. The following code:<br />
<pre><br />
<kw_bread_crumbs>prefix=Trace: |trim_prefix=User:|small=1</kw_bread_crumbs><br />
</pre><br />
...would have rendered your trace pretty much like this:<br />
<br />
<small>Trace: [[User:Barre|Barre]] » [[User:Barre/MediaWiki|Barre/MediaWiki]] » [[User:Barre/MediaWiki/Extensions|Barre/MediaWiki/Extensions]] » Barre/Extensio…kw bread crumbs</small></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=KwGrid:Editing_Help&diff=63981KwGrid:Editing Help2019-11-15T13:21:41Z<p>WikiSysop: Reverted edits by WikiSysop (talk) to last revision by Andy</p>
<hr />
<div>{{:kwGrid:Template/Header}}<br />
In addition to the guidelines provided in the [http://meta.wikimedia.org/wiki/Help:Editing MediaWiki General Editing] page, the following rules are suggested:<br />
<br />
==Page and File Names==<br />
<br />
* Prefix a page name with the <tt>kwGrid:</tt> namespace (lowercase <tt>kw</tt>). For example, [[kwGrid:Welcome]]. Used the [http://meta.wikimedia.org/wiki/Help:Piped_link piped link] notation to hide the namespace when the page is rendered. Namespaces allow separation of different kinds of unrelated content within the same Wiki (i.e. isolate projects like VTK, CMake, ITK, kwGrid). Namespaces also provide facilities to limit searches to a particular area and allow easy exporting of a selection of work.<br />
* Use spaces at will. For example, use [[kwGrid:My Own Hardware]] over [[kwGrid:MyOwnHardware]].<br />
* Use slashes (/) to provide additional structure and depth. For example, the [[kwGrid:Partners]] page provides links to pages describing each partner one by one: use [[kwGrid:Partners/Argonne National Lab]] over [[kwGrid:Partners Argonne National Lab]], as it emphasizes that it is a "sub-page" of [[kwGrid:Partners]] and mimics the traditional web structure. Furthermore, if the [http://en.wikipedia.org/wiki/Help:Link#Subpage_feature sub-page feature] is enabled in the Wiki, a link is automatically created on top of the sub-page to the "parent" page.<br />
* Use the same rules to upload files, but remove spaces and slashes since they are not allowed in a file name. For example: <tt>kwGridPartnersArgonneNationalLab.png</tt>. Let the [[kwGrid:Team|team]] know about the files, images, PDF or Word documents you upload, so that we can also archive a copy in the [[kwGrid:Download#CVS|CVS]] repository.<br />
<br />
==Page Content==<br />
<br />
* Start a page with a call to the [[:kwGrid:Template/Header|Header]] template. Terminate a page with a call to the [[:kwGrid:Template/Footer|Footer]] template. This automatically adds a header and footer to the page. They provide extra navigational links and associate the page to specific searchable categories. Check the top and bottom of this page to see how the templates are rendered.<br />
<pre><br />
{{:kwGrid:Template/Header}}<br />
...<br />
{{:kwGrid:Template/Footer}}<br />
</pre><br />
<br />
==Templates==<br />
<br />
===<tt>Mail To</tt>===<br />
The [[:kwGrid:Template/Mail To|Mail To]] template can be used to build a mailto: link prefixed with a small mail icon [[Image:kwGridMailToIcon.png]]. For example:<br />
<pre><br />
{{:kwGrid:Template/Mail To|sebastien.barre@kitware.com|Sebastien Barre}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Mail To|sebastien.barre@kitware.com|Sebastien Barre}}<br />
<br />
===<tt>Note Box</tt>===<br />
The [[:kwGrid:Template/Note Box|Note Box]] template can be used to provide a short note:<br />
<pre><br />
{{:kwGrid:Template/Note Box|message=This is an example of text inside a Note Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Note Box|message=This is an example of text inside a Note Box template.}}<br />
<br />
===<tt>Warning Box</tt>===<br />
The [[:kwGrid:Template/Warning Box|Warning Box]] template can be used to provide a short warning:<br />
<pre><br />
{{:kwGrid:Template/Warning Box|message=This is an example of text inside a Warning Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Warning Box|message=This is an example of text inside a Warning Box template.}}<br />
<br />
===<tt>Help Box</tt>===<br />
The [[:kwGrid:Template/Help Box|Help Box]] template can be used to provide a short help:<br />
<pre><br />
{{:kwGrid:Template/Help Box|message=This is an example of text inside a Help Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Help Box|message=This is an example of text inside a Help Box template.}}<br />
<br />
===<tt>Tip Box</tt>===<br />
The [[:kwGrid:Template/Tip Box|Tip Box]] template can be used to provide a short tip:<br />
<pre><br />
{{:kwGrid:Template/Tip Box|message=This is an example of text inside a Tip Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Tip Box|message=This is an example of text inside a Tip Box template.}}<br />
<br />
===<tt>Security Box</tt>===<br />
The [[:kwGrid:Template/Security Box|Security Box]] template can be used to provide a short security notice:<br />
<pre><br />
{{:kwGrid:Template/Security Box|message=This is an example of text inside a Security Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Security Box|message=This is an example of text inside a Security Box template.}}<br />
<br />
==Extensions==<br />
{{User:Barre/MediaWiki/Extensions}}<br />
<br />
{{:kwGrid:Template/Footer}}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=KwGrid:Editing_Help&diff=63980KwGrid:Editing Help2019-11-15T13:21:25Z<p>WikiSysop: /* Extensions */</p>
<hr />
<div>{{:kwGrid:Template/Header}}<br />
In addition to the guidelines provided in the [http://meta.wikimedia.org/wiki/Help:Editing MediaWiki General Editing] page, the following rules are suggested:<br />
<br />
==Page and File Names==<br />
<br />
* Prefix a page name with the <tt>kwGrid:</tt> namespace (lowercase <tt>kw</tt>). For example, [[kwGrid:Welcome]]. Used the [http://meta.wikimedia.org/wiki/Help:Piped_link piped link] notation to hide the namespace when the page is rendered. Namespaces allow separation of different kinds of unrelated content within the same Wiki (i.e. isolate projects like VTK, CMake, ITK, kwGrid). Namespaces also provide facilities to limit searches to a particular area and allow easy exporting of a selection of work.<br />
* Use spaces at will. For example, use [[kwGrid:My Own Hardware]] over [[kwGrid:MyOwnHardware]].<br />
* Use slashes (/) to provide additional structure and depth. For example, the [[kwGrid:Partners]] page provides links to pages describing each partner one by one: use [[kwGrid:Partners/Argonne National Lab]] over [[kwGrid:Partners Argonne National Lab]], as it emphasizes that it is a "sub-page" of [[kwGrid:Partners]] and mimics the traditional web structure. Furthermore, if the [http://en.wikipedia.org/wiki/Help:Link#Subpage_feature sub-page feature] is enabled in the Wiki, a link is automatically created on top of the sub-page to the "parent" page.<br />
* Use the same rules to upload files, but remove spaces and slashes since they are not allowed in a file name. For example: <tt>kwGridPartnersArgonneNationalLab.png</tt>. Let the [[kwGrid:Team|team]] know about the files, images, PDF or Word documents you upload, so that we can also archive a copy in the [[kwGrid:Download#CVS|CVS]] repository.<br />
<br />
==Page Content==<br />
<br />
* Start a page with a call to the [[:kwGrid:Template/Header|Header]] template. Terminate a page with a call to the [[:kwGrid:Template/Footer|Footer]] template. This automatically adds a header and footer to the page. They provide extra navigational links and associate the page to specific searchable categories. Check the top and bottom of this page to see how the templates are rendered.<br />
<pre><br />
{{:kwGrid:Template/Header}}<br />
...<br />
{{:kwGrid:Template/Footer}}<br />
</pre><br />
<br />
==Templates==<br />
<br />
===<tt>Mail To</tt>===<br />
The [[:kwGrid:Template/Mail To|Mail To]] template can be used to build a mailto: link prefixed with a small mail icon [[Image:kwGridMailToIcon.png]]. For example:<br />
<pre><br />
{{:kwGrid:Template/Mail To|sebastien.barre@kitware.com|Sebastien Barre}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Mail To|sebastien.barre@kitware.com|Sebastien Barre}}<br />
<br />
===<tt>Note Box</tt>===<br />
The [[:kwGrid:Template/Note Box|Note Box]] template can be used to provide a short note:<br />
<pre><br />
{{:kwGrid:Template/Note Box|message=This is an example of text inside a Note Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Note Box|message=This is an example of text inside a Note Box template.}}<br />
<br />
===<tt>Warning Box</tt>===<br />
The [[:kwGrid:Template/Warning Box|Warning Box]] template can be used to provide a short warning:<br />
<pre><br />
{{:kwGrid:Template/Warning Box|message=This is an example of text inside a Warning Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Warning Box|message=This is an example of text inside a Warning Box template.}}<br />
<br />
===<tt>Help Box</tt>===<br />
The [[:kwGrid:Template/Help Box|Help Box]] template can be used to provide a short help:<br />
<pre><br />
{{:kwGrid:Template/Help Box|message=This is an example of text inside a Help Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Help Box|message=This is an example of text inside a Help Box template.}}<br />
<br />
===<tt>Tip Box</tt>===<br />
The [[:kwGrid:Template/Tip Box|Tip Box]] template can be used to provide a short tip:<br />
<pre><br />
{{:kwGrid:Template/Tip Box|message=This is an example of text inside a Tip Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Tip Box|message=This is an example of text inside a Tip Box template.}}<br />
<br />
===<tt>Security Box</tt>===<br />
The [[:kwGrid:Template/Security Box|Security Box]] template can be used to provide a short security notice:<br />
<pre><br />
{{:kwGrid:Template/Security Box|message=This is an example of text inside a Security Box template.}}<br />
</pre><br />
...is rendered as:<br />
{{:kwGrid:Template/Security Box|message=This is an example of text inside a Security Box template.}}<br />
<br />
==Extensions==<br />
{{:kwGrid:Template/Footer}}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Main_Page&diff=62853Main Page2018-05-23T19:18:52Z<p>WikiSysop: </p>
<hr />
<div>{|<br />
| <ImageLink>https://cmake.org/cmake/img/CMake-logo-download.jpg|https://cmake.org/Wiki/CMake|CMake Wiki</ImageLink><br />
| [[CMake]] is the cross-platform, open-source make system. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice. CMake is quite sophisticated: it is possible to support complex environments requiring system configuration, pre-processor generation, code generation, and template instantiation.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://www.vtk.org/Wiki/images/0/0b/Vtk_newlogo.png|http://www.vtk.org/Wiki/VTK|CMake Web Page</ImageLink><br />
| [[VTK|The Visualization ToolKit (VTK)]] is an open source, freely available software system for 3D computer graphics, image processing, and visualization used by thousands of researchers and developers around the world. VTK consists of a C++ class library, and several interpreted interface layers including Tcl/Tk, Java, and Python. Professional support and products for VTK are provided by [http://www.kitware.com Kitware, Inc.] VTK supports a wide variety of visualization algorithms including scalar, vector, tensor, texture, and volumetric methods; and advanced modeling techniques such as implicit modelling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay triangulation. In addition, dozens of imaging algorithms have been directly integrated to allow the user to mix 2D imaging / 3D graphics algorithms and data. <br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/8/81/ITK-small.png|http://www.itk.org/Wiki/ITK|ITK Wiki</ImageLink><br />
| [[ITK|National Library of Medicine Insight Segmentation and Registration Toolkit (ITK)]] is an open-source software system to support the Visible Human Project. Currently under active development, ITK employs leading-edge segmentation and registration algorithms in two, three, and more dimensions.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/2/2a/NAMIC-Logo.png|http://www.na-mic.org/Wiki/|NA-MIC Wiki</ImageLink><br />
| [http://www.na-mic.org/Wiki The National Alliance for Medical Imaging Computing (NAMIC)] is a multi-institutional, interdisciplinary team of computer scientists, software engineers, and medical investigators who develop computational tools for the analysis and visualization of medical image data. The purpose of the center is to provide the infrastructure and environment for the development of computational algorithms and open source technologies, and then oversee the training and dissemination of these tools to the medical research community. This world-class software and development environment serves as a foundation for accelerating the development and deployment of computational tools that are readily accessible to the medical research community. The team combines cutting-edge computer vision research (to create medical imaging analysis algorithms) with state of the art software engineering techniques (based on "extreme" programming techniques in a distributed, open-source environment) to enable computational examination of both basic neurosience and neurological disorders. In developing this infrastructure resource, the team will significantly expand upon proven open systems technology and platforms.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/e/ea/Pvlogo.png|http://www.paraview.org/Wiki/ParaView|ParaView Wiki</ImageLink><br />
| [[ParaView]] is an open-source, multi-platform application designed to visualize data sets of size varying from small to very large. The goals of the ParaView project include developing an open-source, multi-platform visualization application that support distributed computational models to process large data sets. It has an open, flexible, and intuitive user interface. Furthermore, ParaView is built on an extensible architecture based on open standards. ParaView runs on distributed and shared memory parallel as well as single processor systems and has been succesfully tested on Windows, Linux, Mac OS X, IBM Blue Gene, Cray XT3 and various Unix workstations and clusters. Under the hood, ParaView uses the Visualization Toolkit as the data processing and rendering engine and has a user interface written using the Qt cross-platform application framework.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/f/f0/KWWidgetsSplashScreenSmall.png|http://www.kwwidgets.org/Wiki/KWWidgets|KWWidgets Wiki</ImageLink><br />
| [http://www.KWWidgets.org KWWidgets] is a free, cross-platform and open-license GUI Toolkit. It provides low-level core widgets, advanced composite widgets, and high-level visualization-oriented widgets that can be interfaced to visualization libraries like VTK. KWWidgets is an object-oriented C++ toolkit that can interact and co-exist with Tcl/Tk directly from C++. It is wrapped automatically into a Tcl package, and therefore can be used directly from Tcl/Tk also, allowing for fast-prototyping and scripting.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/8/8c/BatchmakeLogo.gif|http://www.batchmake.org/Wiki/BatchMake|BatchMake Wiki</ImageLink><br />
| [http://www.batchmake.org BatchMake] is a cross platform tool for batch processing of large amount of data. BatchMake can process datasets locally or on distributed systems using Condor. BatchMake also reports results and analysis online on the [http://insight-journal.org/batchmake/index.php Batchboards].<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/e/e7/Cdash.gif|http://public.kitware.com/Wiki/CDash|CDash Wiki</ImageLink><br />
| [[CDash]] is an open source, web-based software testing server. CDash aggregates, analyzes and displays the results of software testing processes submitted from clients located around the world. Developers depend on CDash to convey the state of a software system, and to continually improve its quality. CDash is a part of a larger software process that integrates Kitware's CMake, CTest, and CPack tools, as well as other external packages used to design, manage and maintain large-scale software systems. Good examples of a CDash are the [http://www.cdash.org/CDash/index.php?project=CMake CMake quality dashboard] and the [http://www.cdash.org/CDash/index.php?project=VTK VTK quality dashboard]. <br />
|-<br />
|}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=File:Vtk_newlogo.png&diff=62852File:Vtk newlogo.png2018-05-23T19:06:51Z<p>WikiSysop: WikiSysop uploaded a new version of &quot;File:Vtk newlogo.png&quot;</p>
<hr />
<div></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=File:Vtk-logo.jpg&diff=62851File:Vtk-logo.jpg2018-05-23T18:39:24Z<p>WikiSysop: </p>
<hr />
<div></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Main_Page&diff=62147Main Page2017-12-07T01:28:27Z<p>WikiSysop: </p>
<hr />
<div>{|<br />
| <ImageLink>https://cmake.org/cmake/img/CMake-logo-download.jpg|https://cmake.org/Wiki/CMake|CMake Wiki</ImageLink><br />
| [[CMake]] is the cross-platform, open-source make system. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice. CMake is quite sophisticated: it is possible to support complex environments requiring system configuration, pre-processor generation, code generation, and template instantiation.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/images/logos/vtk-logo.jpg|http://www.vtk.org/Wiki/VTK|CMake Web Page</ImageLink><br />
| [[VTK|The Visualization ToolKit (VTK)]] is an open source, freely available software system for 3D computer graphics, image processing, and visualization used by thousands of researchers and developers around the world. VTK consists of a C++ class library, and several interpreted interface layers including Tcl/Tk, Java, and Python. Professional support and products for VTK are provided by [http://www.kitware.com Kitware, Inc.] VTK supports a wide variety of visualization algorithms including scalar, vector, tensor, texture, and volumetric methods; and advanced modeling techniques such as implicit modelling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay triangulation. In addition, dozens of imaging algorithms have been directly integrated to allow the user to mix 2D imaging / 3D graphics algorithms and data. <br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/8/81/ITK-small.png|http://www.itk.org/Wiki/ITK|ITK Wiki</ImageLink><br />
| [[ITK|National Library of Medicine Insight Segmentation and Registration Toolkit (ITK)]] is an open-source software system to support the Visible Human Project. Currently under active development, ITK employs leading-edge segmentation and registration algorithms in two, three, and more dimensions.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/2/2a/NAMIC-Logo.png|http://www.na-mic.org/Wiki/|NA-MIC Wiki</ImageLink><br />
| [http://www.na-mic.org/Wiki The National Alliance for Medical Imaging Computing (NAMIC)] is a multi-institutional, interdisciplinary team of computer scientists, software engineers, and medical investigators who develop computational tools for the analysis and visualization of medical image data. The purpose of the center is to provide the infrastructure and environment for the development of computational algorithms and open source technologies, and then oversee the training and dissemination of these tools to the medical research community. This world-class software and development environment serves as a foundation for accelerating the development and deployment of computational tools that are readily accessible to the medical research community. The team combines cutting-edge computer vision research (to create medical imaging analysis algorithms) with state of the art software engineering techniques (based on "extreme" programming techniques in a distributed, open-source environment) to enable computational examination of both basic neurosience and neurological disorders. In developing this infrastructure resource, the team will significantly expand upon proven open systems technology and platforms.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/e/ea/Pvlogo.png|http://www.paraview.org/Wiki/ParaView|ParaView Wiki</ImageLink><br />
| [[ParaView]] is an open-source, multi-platform application designed to visualize data sets of size varying from small to very large. The goals of the ParaView project include developing an open-source, multi-platform visualization application that support distributed computational models to process large data sets. It has an open, flexible, and intuitive user interface. Furthermore, ParaView is built on an extensible architecture based on open standards. ParaView runs on distributed and shared memory parallel as well as single processor systems and has been succesfully tested on Windows, Linux, Mac OS X, IBM Blue Gene, Cray XT3 and various Unix workstations and clusters. Under the hood, ParaView uses the Visualization Toolkit as the data processing and rendering engine and has a user interface written using the Qt cross-platform application framework.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/f/f0/KWWidgetsSplashScreenSmall.png|http://www.kwwidgets.org/Wiki/KWWidgets|KWWidgets Wiki</ImageLink><br />
| [http://www.KWWidgets.org KWWidgets] is a free, cross-platform and open-license GUI Toolkit. It provides low-level core widgets, advanced composite widgets, and high-level visualization-oriented widgets that can be interfaced to visualization libraries like VTK. KWWidgets is an object-oriented C++ toolkit that can interact and co-exist with Tcl/Tk directly from C++. It is wrapped automatically into a Tcl package, and therefore can be used directly from Tcl/Tk also, allowing for fast-prototyping and scripting.<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/8/8c/BatchmakeLogo.gif|http://www.batchmake.org/Wiki/BatchMake|BatchMake Wiki</ImageLink><br />
| [http://www.batchmake.org BatchMake] is a cross platform tool for batch processing of large amount of data. BatchMake can process datasets locally or on distributed systems using Condor. BatchMake also reports results and analysis online on the [http://insight-journal.org/batchmake/index.php Batchboards].<br />
|-<br />
|<br />
|<br />
|-<br />
| <ImageLink>https://public.kitware.com/Wiki/images/e/e7/Cdash.gif|http://public.kitware.com/Wiki/CDash|CDash Wiki</ImageLink><br />
| [[CDash]] is an open source, web-based software testing server. CDash aggregates, analyzes and displays the results of software testing processes submitted from clients located around the world. Developers depend on CDash to convey the state of a software system, and to continually improve its quality. CDash is a part of a larger software process that integrates Kitware's CMake, CTest, and CPack tools, as well as other external packages used to design, manage and maintain large-scale software systems. Good examples of a CDash are the [http://www.cdash.org/CDash/index.php?project=CMake CMake quality dashboard] and the [http://www.cdash.org/CDash/index.php?project=VTK VTK quality dashboard]. <br />
|-<br />
|}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=MediaWiki:Common.css&diff=60825MediaWiki:Common.css2016-07-29T15:01:17Z<p>WikiSysop: Created page with "/* CSS placed here will be applied to all skins */ /* Reset italic styling set by user agent */ cite, dfn { font-style: inherit; } /* Straight quote marks for <q> */ q {..."</p>
<hr />
<div>/* CSS placed here will be applied to all skins */<br />
/* Reset italic styling set by user agent */<br />
cite, dfn {<br />
font-style: inherit;<br />
}<br />
<br />
/* Straight quote marks for <q> */<br />
q {<br />
quotes: '"' '"' "'" "'";<br />
}<br />
<br />
/* Avoid collision of blockquote with floating elements by swapping margin and padding */<br />
blockquote {<br />
overflow: hidden;<br />
margin: 1em 0;<br />
padding: 0 40px;<br />
}<br />
<br />
/* Prevent the 'double bold' bug in Firefox when using DirectWrite */<br />
strong.selflink {<br />
font-weight: 700;<br />
}<br />
<br />
/* Consistent size for <small>, <sub> and <sup> */<br />
small {<br />
font-size: 85%;<br />
}<br />
.mw-body sub,<br />
.mw-body sup,<br />
span.reference /* for Parsoid */ {<br />
font-size: 80%;<br />
}<br />
<br />
/* Main page fixes */<br />
#interwiki-completelist {<br />
font-weight: bold;<br />
}<br />
body.page-Main_Page #ca-delete {<br />
display: none !important;<br />
}<br />
body.page-Main_Page #mp-topbanner {<br />
clear: both;<br />
}<br />
<br />
/* Reduce page jumps by hiding collapsed/dismissed content */<br />
.client-js .mw-special-Watchlist #watchlist-message,<br />
.client-js .collapsible.collapsed > tbody > tr:not(:first-child) {<br />
display: none;<br />
}<br />
<br />
/* Tone down 'Changed since last visit' colors */<br />
span.updatedmarker {<br />
background-color: transparent;<br />
color: #006400;<br />
}<br />
<br />
/* Edit window toolbar */<br />
#toolbar {<br />
height: 22px;<br />
margin-bottom: 6px;<br />
}<br />
<br />
/* Hide charinsert base for those not using the gadget */<br />
#editpage-specialchars {<br />
display: none;<br />
}<br />
<br />
/* Highlight linked elements (such as clicked references) in blue */<br />
body.action-info :target,<br />
.citation:target {<br />
background-color: #DEF; /* Fallback */<br />
background-color: rgba(0, 127, 255, 0.133);<br />
}<br />
<br />
/* Styling for citations. Breaks long urls, etc., rather than overflowing box */<br />
.citation {<br />
word-wrap: break-word;<br />
}<br />
<br />
/* For linked citation numbers and document IDs, where the number need not be shown<br />
on a screen or a handheld, but should be included in the printed version */<br />
@media screen, handheld {<br />
.citation .printonly {<br />
display: none;<br />
}<br />
}<br />
<br />
/* Make the list of references smaller */<br />
ol.references,<br />
div.reflist,<br />
div.refbegin {<br />
font-size: 90%; /* Default font-size */<br />
margin-bottom: 0.5em;<br />
}<br />
div.refbegin-100 {<br />
font-size: 100%; /* Option for normal fontsize in {{refbegin}} */<br />
}<br />
div.reflist ol.references {<br />
font-size: 100%; /* Reset font-size when nested in div.reflist */<br />
margin-bottom: 0; /* Avoid double margin when nested in dev.reflist */<br />
list-style-type: inherit; /* Enable custom list style types */<br />
}<br />
<br />
/* Ensure refs in table headers and the like aren't bold or italic */<br />
sup.reference {<br />
font-weight: normal;<br />
font-style: normal;<br />
}<br />
<br />
/* Allow hidden ref errors to be shown by user CSS */<br />
span.brokenref {<br />
display: none;<br />
}<br />
<br />
/* Reset top margin for lists embedded in columns */<br />
div.columns {<br />
margin-top: 0.3em;<br />
}<br />
div.columns dl,<br />
div.columns ol,<br />
div.columns ul {<br />
margin-top: 0;<br />
}<br />
<br />
/* Avoid elements from breaking between columns */<br />
.nocolbreak,<br />
div.columns li,<br />
div.columns dd dd {<br />
-webkit-column-break-inside: avoid;<br />
page-break-inside: avoid;<br />
break-inside: avoid-column;<br />
}<br />
<br />
/* Style for [[Template:Flowlist]] that Lets lists flow around floating objecs */<br />
.flowlist ul {<br />
overflow-x: hidden;<br />
margin-left: 0;<br />
padding-left: 1.6em;<br />
}<br />
.flowlist ol {<br />
overflow-x: hidden;<br />
margin-left: 0;<br />
padding-left: 3.2em;<br />
}<br />
.flowlist dl {<br />
overflow-x: hidden;<br />
}<br />
<br />
/* Style for horizontal lists (separator following item).<br />
@source mediawiki.org/wiki/Snippets/Horizontal_lists<br />
@revision 8 (2016-05-21)<br />
@author [[User:Edokter]]<br />
*/<br />
.hlist dl,<br />
.hlist ol,<br />
.hlist ul {<br />
margin: 0;<br />
padding: 0;<br />
}<br />
/* Display list items inline */<br />
.hlist dd,<br />
.hlist dt,<br />
.hlist li {<br />
margin: 0;<br />
display: inline;<br />
}<br />
/* Display nested lists inline */<br />
.hlist.inline,<br />
.hlist.inline dl,<br />
.hlist.inline ol,<br />
.hlist.inline ul,<br />
.hlist dl dl, .hlist dl ol, .hlist dl ul,<br />
.hlist ol dl, .hlist ol ol, .hlist ol ul,<br />
.hlist ul dl, .hlist ul ol, .hlist ul ul {<br />
display: inline;<br />
}<br />
/* Hide empty list items */<br />
.hlist .mw-empty-li {<br />
display: none;<br />
}<br />
/* Generate interpuncts */<br />
.hlist dt:after {<br />
content: ": ";<br />
}<br />
.hlist dd:after,<br />
.hlist li:after {<br />
content: " · ";<br />
font-weight: bold;<br />
}<br />
.hlist dd:last-child:after,<br />
.hlist dt:last-child:after,<br />
.hlist li:last-child:after {<br />
content: none;<br />
}<br />
/* Add parentheses around nested lists */<br />
.hlist dd dd:first-child:before, .hlist dd dt:first-child:before, .hlist dd li:first-child:before,<br />
.hlist dt dd:first-child:before, .hlist dt dt:first-child:before, .hlist dt li:first-child:before,<br />
.hlist li dd:first-child:before, .hlist li dt:first-child:before, .hlist li li:first-child:before {<br />
content: " (";<br />
font-weight: normal;<br />
}<br />
.hlist dd dd:last-child:after, .hlist dd dt:last-child:after, .hlist dd li:last-child:after,<br />
.hlist dt dd:last-child:after, .hlist dt dt:last-child:after, .hlist dt li:last-child:after,<br />
.hlist li dd:last-child:after, .hlist li dt:last-child:after, .hlist li li:last-child:after {<br />
content: ")";<br />
font-weight: normal;<br />
}<br />
/* Put ordinals in front of ordered list items */<br />
.hlist ol {<br />
counter-reset: listitem;<br />
}<br />
.hlist ol > li {<br />
counter-increment: listitem;<br />
}<br />
.hlist ol > li:before {<br />
content: " " counter(listitem) "\a0";<br />
}<br />
.hlist dd ol > li:first-child:before,<br />
.hlist dt ol > li:first-child:before,<br />
.hlist li ol > li:first-child:before {<br />
content: " (" counter(listitem) "\a0";<br />
}<br />
<br />
/* Unbulleted lists */<br />
.plainlist ol,<br />
.plainlist ul {<br />
line-height: inherit;<br />
list-style: none none;<br />
margin: 0;<br />
}<br />
.plainlist ol li,<br />
.plainlist ul li {<br />
margin-bottom: 0;<br />
}<br />
<br />
/* Default style for navigation boxes */<br />
.navbox { /* Navbox container style */<br />
box-sizing: border-box;<br />
border: 1px solid #aaa;<br />
width: 100%;<br />
clear: both;<br />
font-size: 88%;<br />
text-align: center;<br />
padding: 1px;<br />
margin: 1em auto 0; /* Prevent preceding content from clinging to navboxes */<br />
}<br />
.navbox .navbox {<br />
margin-top: 0; /* No top margin for nested navboxes */<br />
}<br />
.navbox + .navbox {<br />
margin-top: -1px; /* Single pixel border between adjacent navboxes */<br />
}<br />
.navbox-inner,<br />
.navbox-subgroup {<br />
width: 100%;<br />
}<br />
.navbox-group,<br />
.navbox-title,<br />
.navbox-abovebelow {<br />
padding: 0.25em 1em; /* Title, group and above/below styles */<br />
line-height: 1.5em;<br />
text-align: center;<br />
}<br />
th.navbox-group { /* Group style */<br />
white-space: nowrap;<br />
/* @noflip */<br />
text-align: right;<br />
}<br />
.navbox,<br />
.navbox-subgroup {<br />
background: #fdfdfd; /* Background color */<br />
}<br />
.navbox-list {<br />
line-height: 1.5em;<br />
border-color: #fdfdfd; /* Must match background color */<br />
}<br />
.navbox th,<br />
.navbox-title {<br />
background: #ccccff; /* Level 1 color */<br />
}<br />
.navbox-abovebelow,<br />
th.navbox-group,<br />
.navbox-subgroup .navbox-title {<br />
background: #ddddff; /* Level 2 color */<br />
}<br />
.navbox-subgroup .navbox-group,<br />
.navbox-subgroup .navbox-abovebelow {<br />
background: #e6e6ff; /* Level 3 color */<br />
}<br />
.navbox-even {<br />
background: #f7f7f7; /* Even row striping */<br />
}<br />
.navbox-odd {<br />
background: transparent; /* Odd row striping */<br />
}<br />
.navbox .hlist td dl,<br />
.navbox .hlist td ol,<br />
.navbox .hlist td ul,<br />
.navbox td.hlist dl,<br />
.navbox td.hlist ol,<br />
.navbox td.hlist ul {<br />
padding: 0.125em 0; /* Adjust hlist padding in navboxes */<br />
}<br />
<br />
/* Default styling for Navbar template */<br />
.navbar {<br />
display: inline;<br />
font-size: 88%;<br />
font-weight: normal;<br />
}<br />
.navbar ul {<br />
display: inline;<br />
white-space: nowrap;<br />
}<br />
.mw-body-content .navbar ul {<br />
line-height: inherit;<br />
}<br />
.navbar li {<br />
word-spacing: -0.125em;<br />
}<br />
.navbar.mini li abbr[title] {<br />
font-variant: small-caps;<br />
border-bottom: none;<br />
text-decoration: none;<br />
cursor: inherit;<br />
}<br />
/* Navbar styling when nested in infobox and navbox */<br />
.infobox .navbar {<br />
font-size: 100%;<br />
}<br />
.navbox .navbar {<br />
display: block;<br />
font-size: 100%;<br />
}<br />
.navbox-title .navbar {<br />
/* @noflip */<br />
float: left;<br />
/* @noflip */<br />
text-align: left;<br />
/* @noflip */<br />
margin-right: 0.5em;<br />
width: 6em;<br />
}<br />
<br />
/* 'show'/'hide' buttons created dynamically by the CollapsibleTables javascript<br />
in [[MediaWiki:Common.js]] are styled here so they can be customised. */<br />
.collapseButton {<br />
/* @noflip */<br />
float: right;<br />
font-weight: normal;<br />
/* @noflip */<br />
margin-left: 0.5em;<br />
/* @noflip */<br />
text-align: right;<br />
width: auto;<br />
}<br />
/* In navboxes, the show/hide button balances the v·d·e links<br />
from [[Template:Navbar]], so they need to be the same width. */<br />
.navbox .collapseButton {<br />
width: 6em;<br />
}<br />
<br />
/* Styling for JQuery makeCollapsible, matching that of collapseButton */<br />
.mw-collapsible-toggle {<br />
font-weight: normal;<br />
/* @noflip */<br />
text-align: right;<br />
}<br />
.navbox .mw-collapsible-toggle {<br />
width: 6em;<br />
}<br />
<br />
/* Infobox template style */<br />
.infobox {<br />
border: 1px solid #aaa;<br />
border-spacing: 3px;<br />
background-color: #f9f9f9;<br />
color: black;<br />
/* @noflip */<br />
margin: 0.5em 0 0.5em 1em;<br />
padding: 0.2em;<br />
/* @noflip */<br />
float: right;<br />
/* @noflip */<br />
clear: right;<br />
font-size: 88%;<br />
line-height: 1.5em;<br />
}<br />
.infobox caption {<br />
font-size: 125%;<br />
font-weight: bold;<br />
padding: 0.2em;<br />
}<br />
.infobox td,<br />
.infobox th {<br />
vertical-align: top;<br />
/* @noflip */<br />
text-align: left;<br />
}<br />
.infobox.bordered {<br />
border-collapse: collapse;<br />
}<br />
.infobox.bordered td,<br />
.infobox.bordered th {<br />
border: 1px solid #aaa;<br />
}<br />
.infobox.bordered .borderless td,<br />
.infobox.bordered .borderless th {<br />
border: 0;<br />
}<br />
<br />
.infobox.sisterproject {<br />
width: 20em;<br />
font-size: 90%;<br />
}<br />
<br />
.infobox.standard-talk {<br />
border: 1px solid #c0c090;<br />
background-color: #f8eaba;<br />
}<br />
.infobox.standard-talk.bordered td,<br />
.infobox.standard-talk.bordered th {<br />
border: 1px solid #c0c090;<br />
}<br />
<br />
/* styles for bordered infobox with merged rows */<br />
.infobox.bordered .mergedtoprow td,<br />
.infobox.bordered .mergedtoprow th {<br />
border: 0;<br />
border-top: 1px solid #aaa;<br />
/* @noflip */<br />
border-right: 1px solid #aaa;<br />
}<br />
<br />
.infobox.bordered .mergedrow td,<br />
.infobox.bordered .mergedrow th {<br />
border: 0;<br />
/* @noflip */<br />
border-right: 1px solid #aaa;<br />
}<br />
<br />
/* Styles for geography infoboxes, eg countries,<br />
country subdivisions, cities, etc. */<br />
.infobox.geography {<br />
border-collapse: collapse;<br />
line-height: 1.2em;<br />
font-size: 90%;<br />
}<br />
<br />
.infobox.geography td,<br />
.infobox.geography th {<br />
border-top: 1px solid #aaa;<br />
padding: 0.4em 0.6em 0.4em 0.6em;<br />
}<br />
.infobox.geography .mergedtoprow td,<br />
.infobox.geography .mergedtoprow th {<br />
border-top: 1px solid #aaa;<br />
padding: 0.4em 0.6em 0.2em 0.6em;<br />
}<br />
<br />
.infobox.geography .mergedrow td,<br />
.infobox.geography .mergedrow th {<br />
border: 0;<br />
padding: 0 0.6em 0.2em 0.6em;<br />
}<br />
<br />
.infobox.geography .mergedbottomrow td,<br />
.infobox.geography .mergedbottomrow th {<br />
border-top: 0;<br />
border-bottom: 1px solid #aaa;<br />
padding: 0 0.6em 0.4em 0.6em;<br />
}<br />
<br />
.infobox.geography .maptable td,<br />
.infobox.geography .maptable th {<br />
border: 0;<br />
padding: 0;<br />
}<br />
<br />
/* Normal font styling for table row headers with scope="row" tag */<br />
.wikitable.plainrowheaders th[scope=row] {<br />
font-weight: normal;<br />
/* @noflip */<br />
text-align: left;<br />
}<br />
<br />
/* Lists in data cells are always left-aligned */<br />
.wikitable td ul,<br />
.wikitable td ol,<br />
.wikitable td dl {<br />
/* @noflip */<br />
text-align: left;<br />
}<br />
/* ...unless they also use the hlist class */<br />
.toc.hlist ul,<br />
#toc.hlist ul,<br />
.wikitable.hlist td ul,<br />
.wikitable.hlist td ol,<br />
.wikitable.hlist td dl {<br />
text-align: inherit;<br />
}<br />
<br />
/* Icons for medialist templates [[Template:Listen]],<br />
[[Template:Multi-listen_start]], [[Template:Video]],<br />
[[Template:Multi-video_start]] */<br />
div.listenlist {<br />
background: url("//upload.wikimedia.org/wikipedia/commons/4/47/Sound-icon.svg") no-repeat scroll 0 0 transparent;<br />
background-size: 30px;<br />
padding-left: 40px;<br />
}<br />
<br />
/* Fix for hieroglyphs specificality issue in infoboxes ([[Phabricator:43869]]) */<br />
table.mw-hiero-table td {<br />
vertical-align: middle;<br />
}<br />
<br />
/* Style rules for media list templates */<br />
div.medialist {<br />
min-height: 50px;<br />
margin: 1em;<br />
/* @noflip */<br />
background-position: top left;<br />
background-repeat: no-repeat;<br />
}<br />
div.medialist ul {<br />
list-style-type: none;<br />
list-style-image: none;<br />
margin: 0;<br />
}<br />
div.medialist ul li {<br />
padding-bottom: 0.5em;<br />
}<br />
div.medialist ul li li {<br />
font-size: 91%;<br />
padding-bottom: 0;<br />
}<br />
<br />
/* Change the external link icon to an Adobe icon for all PDF files<br />
in browsers that support these CSS selectors, like Mozilla and Opera */<br />
div#content a[href$=".pdf"].external,<br />
div#content a[href*=".pdf?"].external,<br />
div#content a[href*=".pdf#"].external,<br />
div#content a[href$=".PDF"].external,<br />
div#content a[href*=".PDF?"].external,<br />
div#content a[href*=".PDF#"].external,<br />
div#mw_content a[href$=".pdf"].external,<br />
div#mw_content a[href*=".pdf?"].external,<br />
div#mw_content a[href*=".pdf#"].external,<br />
div#mw_content a[href$=".PDF"].external,<br />
div#mw_content a[href*=".PDF?"].external,<br />
div#mw_content a[href*=".PDF#"].external {<br />
background: url("//upload.wikimedia.org/wikipedia/commons/2/23/Icons-mini-file_acrobat.gif") no-repeat right;<br />
/* @noflip */<br />
padding-right: 18px;<br />
}<br />
<br />
/* Change the external link icon to an Adobe icon anywhere the PDFlink class<br />
is used (notably Template:PDFlink). This works in IE, unlike the above. */<br />
div#content span.PDFlink a,<br />
div#mw_content span.PDFlink a {<br />
background: url("//upload.wikimedia.org/wikipedia/commons/2/23/Icons-mini-file_acrobat.gif") no-repeat right;<br />
/* @noflip */<br />
padding-right: 18px;<br />
}<br />
<br />
/* Content in columns with CSS instead of tables ([[Template:Columns]]) */<br />
div.columns-2 div.column {<br />
/* @noflip */<br />
float: left;<br />
width: 50%;<br />
min-width: 300px;<br />
}<br />
div.columns-3 div.column {<br />
/* @noflip */<br />
float: left;<br />
width: 33.3%;<br />
min-width: 200px;<br />
}<br />
div.columns-4 div.column {<br />
/* @noflip */<br />
float: left;<br />
width: 25%;<br />
min-width: 150px;<br />
}<br />
div.columns-5 div.column {<br />
/* @noflip */<br />
float: left;<br />
width: 20%;<br />
min-width: 120px;<br />
}<br />
<br />
/* Messagebox templates */<br />
.messagebox {<br />
border: 1px solid #aaa;<br />
background-color: #f9f9f9;<br />
width: 80%;<br />
margin: 0 auto 1em auto;<br />
padding: .2em;<br />
}<br />
.messagebox.merge {<br />
border: 1px solid #c0b8cc;<br />
background-color: #f0e5ff;<br />
text-align: center;<br />
}<br />
.messagebox.cleanup {<br />
border: 1px solid #9f9fff;<br />
background-color: #efefff;<br />
text-align: center;<br />
}<br />
.messagebox.standard-talk {<br />
border: 1px solid #c0c090;<br />
background-color: #f8eaba;<br />
margin: 4px auto;<br />
}<br />
/* For old WikiProject banners inside banner shells. */<br />
.mbox-inside .standard-talk,<br />
.messagebox.nested-talk {<br />
border: 1px solid #c0c090;<br />
background-color: #f8eaba;<br />
width: 100%;<br />
margin: 2px 0;<br />
padding: 2px;<br />
}<br />
.messagebox.small {<br />
width: 238px;<br />
font-size: 85%;<br />
/* @noflip */<br />
float: right;<br />
clear: both;<br />
/* @noflip */<br />
margin: 0 0 1em 1em;<br />
line-height: 1.25em;<br />
}<br />
.messagebox.small-talk {<br />
width: 238px;<br />
font-size: 85%;<br />
/* @noflip */<br />
float: right;<br />
clear: both;<br />
/* @noflip */<br />
margin: 0 0 1em 1em;<br />
line-height: 1.25em;<br />
background: #F8EABA;<br />
}<br />
<br />
/* Cell sizes for ambox/tmbox/imbox/cmbox/ombox/fmbox/dmbox message boxes */<br />
th.mbox-text, td.mbox-text { /* The message body cell(s) */<br />
border: none;<br />
/* @noflip */<br />
padding: 0.25em 0.9em; /* 0.9em left/right */<br />
width: 100%; /* Make all mboxes the same width regardless of text length */<br />
}<br />
td.mbox-image { /* The left image cell */<br />
border: none;<br />
/* @noflip */<br />
padding: 2px 0 2px 0.9em; /* 0.9em left, 0px right */<br />
text-align: center;<br />
}<br />
td.mbox-imageright { /* The right image cell */<br />
border: none;<br />
/* @noflip */<br />
padding: 2px 0.9em 2px 0; /* 0px left, 0.9em right */<br />
text-align: center;<br />
}<br />
td.mbox-empty-cell { /* An empty narrow cell */<br />
border: none;<br />
padding: 0;<br />
width: 1px;<br />
}<br />
<br />
/* Article message box styles */<br />
table.ambox {<br />
margin: 0 10%; /* 10% = Will not overlap with other elements */<br />
border: 1px solid #aaa;<br />
/* @noflip */<br />
border-left: 10px solid #1e90ff; /* Default "notice" blue */<br />
background: #fbfbfb;<br />
}<br />
table.ambox + table.ambox { /* Single border between stacked boxes. */<br />
margin-top: -1px;<br />
}<br />
.ambox th.mbox-text,<br />
.ambox td.mbox-text { /* The message body cell(s) */<br />
padding: 0.25em 0.5em; /* 0.5em left/right */<br />
}<br />
.ambox td.mbox-image { /* The left image cell */<br />
/* @noflip */<br />
padding: 2px 0 2px 0.5em; /* 0.5em left, 0px right */<br />
}<br />
.ambox td.mbox-imageright { /* The right image cell */<br />
/* @noflip */<br />
padding: 2px 0.5em 2px 0; /* 0px left, 0.5em right */<br />
}<br />
<br />
table.ambox-notice {<br />
/* @noflip */<br />
border-left: 10px solid #1e90ff; /* Blue */<br />
}<br />
table.ambox-speedy {<br />
/* @noflip */<br />
border-left: 10px solid #b22222; /* Red */<br />
background: #fee; /* Pink */<br />
}<br />
table.ambox-delete {<br />
/* @noflip */<br />
border-left: 10px solid #b22222; /* Red */<br />
}<br />
table.ambox-content {<br />
/* @noflip */<br />
border-left: 10px solid #f28500; /* Orange */<br />
}<br />
table.ambox-style {<br />
/* @noflip */<br />
border-left: 10px solid #f4c430; /* Yellow */<br />
}<br />
table.ambox-move {<br />
/* @noflip */<br />
border-left: 10px solid #9932cc; /* Purple */<br />
}<br />
table.ambox-protection {<br />
/* @noflip */<br />
border-left: 10px solid #bba; /* Gray-gold */<br />
}<br />
<br />
/* Image message box styles */<br />
table.imbox {<br />
margin: 4px 10%;<br />
border-collapse: collapse;<br />
border: 3px solid #1e90ff; /* Default "notice" blue */<br />
background: #fbfbfb;<br />
}<br />
.imbox .mbox-text .imbox { /* For imboxes inside imbox-text cells. */<br />
margin: 0 -0.5em; /* 0.9 - 0.5 = 0.4em left/right. */<br />
display: block; /* Fix for webkit to force 100% width. */<br />
}<br />
.mbox-inside .imbox { /* For imboxes inside other templates. */<br />
margin: 4px;<br />
}<br />
<br />
table.imbox-notice {<br />
border: 3px solid #1e90ff; /* Blue */<br />
}<br />
table.imbox-speedy {<br />
border: 3px solid #b22222; /* Red */<br />
background: #fee; /* Pink */<br />
}<br />
table.imbox-delete {<br />
border: 3px solid #b22222; /* Red */<br />
}<br />
table.imbox-content {<br />
border: 3px solid #f28500; /* Orange */<br />
}<br />
table.imbox-style {<br />
border: 3px solid #f4c430; /* Yellow */<br />
}<br />
table.imbox-move {<br />
border: 3px solid #9932cc; /* Purple */<br />
}<br />
table.imbox-protection {<br />
border: 3px solid #bba; /* Gray-gold */<br />
}<br />
table.imbox-license {<br />
border: 3px solid #88a; /* Dark gray */<br />
background: #f7f8ff; /* Light gray */<br />
}<br />
table.imbox-featured {<br />
border: 3px solid #cba135; /* Brown-gold */<br />
}<br />
<br />
/* Category message box styles */<br />
table.cmbox {<br />
margin: 3px 10%;<br />
border-collapse: collapse;<br />
border: 1px solid #aaa;<br />
background: #DFE8FF; /* Default "notice" blue */<br />
}<br />
<br />
table.cmbox-notice {<br />
background: #D8E8FF; /* Blue */<br />
}<br />
table.cmbox-speedy {<br />
margin-top: 4px;<br />
margin-bottom: 4px;<br />
border: 4px solid #b22222; /* Red */<br />
background: #FFDBDB; /* Pink */<br />
}<br />
table.cmbox-delete {<br />
background: #FFDBDB; /* Red */<br />
}<br />
table.cmbox-content {<br />
background: #FFE7CE; /* Orange */<br />
}<br />
table.cmbox-style {<br />
background: #FFF9DB; /* Yellow */<br />
}<br />
table.cmbox-move {<br />
background: #E4D8FF; /* Purple */<br />
}<br />
table.cmbox-protection {<br />
background: #EFEFE1; /* Gray-gold */<br />
}<br />
<br />
/* Other pages message box styles */<br />
table.ombox {<br />
margin: 4px 10%;<br />
border-collapse: collapse;<br />
border: 1px solid #aaa; /* Default "notice" gray */<br />
background: #f9f9f9;<br />
}<br />
<br />
table.ombox-notice {<br />
border: 1px solid #aaa; /* Gray */<br />
}<br />
table.ombox-speedy {<br />
border: 2px solid #b22222; /* Red */<br />
background: #fee; /* Pink */<br />
}<br />
table.ombox-delete {<br />
border: 2px solid #b22222; /* Red */<br />
}<br />
table.ombox-content {<br />
border: 1px solid #f28500; /* Orange */<br />
}<br />
table.ombox-style {<br />
border: 1px solid #f4c430; /* Yellow */<br />
}<br />
table.ombox-move {<br />
border: 1px solid #9932cc; /* Purple */<br />
}<br />
table.ombox-protection {<br />
border: 2px solid #bba; /* Gray-gold */<br />
}<br />
<br />
/* Talk page message box styles */<br />
table.tmbox {<br />
margin: 4px 10%;<br />
border-collapse: collapse;<br />
border: 1px solid #c0c090; /* Default "notice" gray-brown */<br />
background: #f8eaba;<br />
}<br />
.mediawiki .mbox-inside .tmbox { /* For tmboxes inside other templates. The "mediawiki" class ensures that */<br />
margin: 2px 0; /* this declaration overrides other styles (including mbox-small above) */<br />
width: 100%; /* For Safari and Opera */<br />
}<br />
.mbox-inside .tmbox.mbox-small { /* "small" tmboxes should not be small when */<br />
line-height: 1.5em; /* also "nested", so reset styles that are */<br />
font-size: 100%; /* set in "mbox-small" above. */<br />
}<br />
<br />
table.tmbox-speedy {<br />
border: 2px solid #b22222; /* Red */<br />
background: #fee; /* Pink */<br />
}<br />
table.tmbox-delete {<br />
border: 2px solid #b22222; /* Red */<br />
}<br />
table.tmbox-content {<br />
border: 2px solid #f28500; /* Orange */<br />
}<br />
table.tmbox-style {<br />
border: 2px solid #f4c430; /* Yellow */<br />
}<br />
table.tmbox-move {<br />
border: 2px solid #9932cc; /* Purple */<br />
}<br />
table.tmbox-protection,<br />
table.tmbox-notice {<br />
border: 1px solid #c0c090; /* Gray-brown */<br />
}<br />
<br />
/* Disambig and set index box styles */<br />
table.dmbox {<br />
clear: both;<br />
margin: 0.9em 1em;<br />
border-top: 1px solid #ccc;<br />
border-bottom: 1px solid #ccc;<br />
background: transparent;<br />
}<br />
<br />
/* Footer and header message box styles */<br />
table.fmbox {<br />
clear: both;<br />
margin: 0.2em 0;<br />
width: 100%;<br />
border: 1px solid #aaa;<br />
background: #f9f9f9; /* Default "system" gray */<br />
}<br />
table.fmbox-system {<br />
background: #f9f9f9;<br />
}<br />
table.fmbox-warning {<br />
border: 1px solid #bb7070; /* Dark pink */<br />
background: #ffdbdb; /* Pink */<br />
}<br />
table.fmbox-editnotice {<br />
background: transparent;<br />
}<br />
/* Div based "warning" style fmbox messages. */<br />
div.mw-warning-with-logexcerpt,<br />
div.mw-lag-warn-high,<br />
div.mw-cascadeprotectedwarning,<br />
div#mw-protect-cascadeon,<br />
div.titleblacklist-warning,<br />
div.locked-warning {<br />
clear: both;<br />
margin: 0.2em 0;<br />
border: 1px solid #bb7070;<br />
background: #ffdbdb;<br />
padding: 0.25em 0.9em;<br />
}<br />
/* Div based "system" style fmbox messages.<br />
Used in [[MediaWiki:Readonly lag]]. */<br />
div.mw-lag-warn-normal,<br />
div.fmbox-system {<br />
clear: both;<br />
margin: 0.2em 0;<br />
border: 1px solid #aaa;<br />
background: #f9f9f9;<br />
padding: 0.25em 0.9em;<br />
}<br />
<br />
/* These mbox-small classes must be placed after all other<br />
ambox/tmbox/ombox etc classes. "html body.mediawiki" is so<br />
they override "table.ambox + table.ambox" above. */<br />
html body.mediawiki .mbox-small { /* For the "small=yes" option. */<br />
/* @noflip */<br />
clear: right;<br />
/* @noflip */<br />
float: right;<br />
/* @noflip */<br />
margin: 4px 0 4px 1em;<br />
box-sizing: border-box;<br />
width: 238px;<br />
font-size: 88%;<br />
line-height: 1.25em;<br />
}<br />
html body.mediawiki .mbox-small-left { /* For the "small=left" option. */<br />
/* @noflip */<br />
margin: 4px 1em 4px 0;<br />
box-sizing: border-box;<br />
overflow: hidden;<br />
width: 238px;<br />
border-collapse: collapse;<br />
font-size: 88%;<br />
line-height: 1.25em;<br />
}<br />
<br />
/* Style for compact ambox */<br />
/* Hide the images */<br />
.compact-ambox table .mbox-image,<br />
.compact-ambox table .mbox-imageright,<br />
.compact-ambox table .mbox-empty-cell {<br />
display: none;<br />
}<br />
/* Remove borders, backgrounds, padding, etc. */<br />
.compact-ambox table.ambox {<br />
border: none;<br />
border-collapse: collapse;<br />
background: transparent;<br />
margin: 0 0 0 1.6em !important;<br />
padding: 0 !important;<br />
width: auto;<br />
display: block;<br />
}<br />
body.mediawiki .compact-ambox table.mbox-small-left {<br />
font-size: 100%;<br />
width: auto;<br />
margin: 0;<br />
}<br />
/* Style the text cell as a list item and remove its padding */<br />
.compact-ambox table .mbox-text {<br />
padding: 0 !important;<br />
margin: 0 !important;<br />
}<br />
.compact-ambox table .mbox-text-span {<br />
display: list-item;<br />
line-height: 1.5em;<br />
list-style-type: square;<br />
list-style-image: url(/w/skins/MonoBook/bullet.gif);<br />
}<br />
.skin-vector .compact-ambox table .mbox-text-span {<br />
list-style-type: disc;<br />
list-style-image: url(/w/skins/Vector/images/bullet-icon.svg);<br />
list-style-image: url(/w/skins/Vector/images/bullet-icon.png)\9;<br />
}<br />
/* Allow for hiding text in compact form */<br />
.compact-ambox .hide-when-compact {<br />
display: none;<br />
}<br />
<br />
/* Remove default styles for [[MediaWiki:Noarticletext]]. */<br />
div.noarticletext {<br />
border: none;<br />
background: transparent;<br />
padding: 0;<br />
}<br />
<br />
/* Hide (formatting) elements from screen, but not from screenreaders */<br />
.visualhide {<br />
position: absolute;<br />
left: -10000px;<br />
top: auto;<br />
width: 1px;<br />
height: 1px;<br />
overflow: hidden;<br />
}<br />
<br />
/* Bold save button */<br />
#wpSave {<br />
font-weight: bold;<br />
}<br />
<br />
/* class hiddenStructure is defunct. See [[Wikipedia:hiddenStructure]] */<br />
.hiddenStructure {<br />
display: inline !important;<br />
color: #f00;<br />
background-color: #0f0;<br />
}<br />
<br />
/* suppress missing interwiki image links where #ifexist cannot<br />
be used due to high number of requests see .hidden-redlink on<br />
[[m:MediaWiki:Common.css]] */<br />
.check-icon a.new {<br />
display: none;<br />
speak: none;<br />
}<br />
<br />
/* Removes underlines from certain links */<br />
.nounderlines a,<br />
.IPA a:link, .IPA a:visited {<br />
text-decoration: none !important;<br />
}<br />
<br />
/* Standard Navigationsleisten, aka box hiding thingy<br />
from .de. Documentation at [[Wikipedia:NavFrame]]. */<br />
div.NavFrame {<br />
margin: 0;<br />
padding: 4px;<br />
border: 1px solid #aaa;<br />
text-align: center;<br />
border-collapse: collapse;<br />
font-size: 95%;<br />
}<br />
div.NavFrame + div.NavFrame {<br />
border-top-style: none;<br />
border-top-style: hidden;<br />
}<br />
div.NavPic {<br />
background-color: #fff;<br />
margin: 0;<br />
padding: 2px;<br />
/* @noflip */<br />
float: left;<br />
}<br />
div.NavFrame div.NavHead {<br />
line-height: 1.6em;<br />
font-weight: bold;<br />
background-color: #ccf;<br />
position: relative;<br />
}<br />
div.NavFrame p,<br />
div.NavFrame div.NavContent,<br />
div.NavFrame div.NavContent p {<br />
font-size: 100%;<br />
}<br />
div.NavEnd {<br />
margin: 0;<br />
padding: 0;<br />
line-height: 1px;<br />
clear: both;<br />
}<br />
a.NavToggle {<br />
position: absolute;<br />
top: 0;<br />
/* @noflip */<br />
right: 3px;<br />
font-weight: normal;<br />
font-size: 90%;<br />
}<br />
<br />
/* Hatnotes and disambiguation notices */<br />
.hatnote {<br />
font-style: italic;<br />
}<br />
.hatnote i {<br />
font-style: normal;<br />
}<br />
div.hatnote {<br />
/* @noflip */<br />
padding-left: 1.6em;<br />
margin-bottom: 0.5em;<br />
}<br />
div.hatnote + div.hatnote {<br />
margin-top: -0.5em;<br />
}<br />
<br />
/* Allow transcluded pages to display in lists rather than a table. */<br />
.listify td { display: list-item; }<br />
.listify tr { display: block; }<br />
.listify table { display: block; }<br />
<br />
/* Geographical coordinates defaults. See [[Template:Coord/link]]<br />
for how these are used. The classes "geo", "longitude", and<br />
"latitude" are used by the [[Geo microformat]]. */<br />
.geo-default, .geo-dms, .geo-dec { display: inline; }<br />
.geo-nondefault, .geo-multi-punct { display: none; }<br />
.longitude, .latitude { white-space: nowrap; }<br />
<br />
/* Temporary(!) fix for horizontal TOC in Blink (Chrone/Opera) */<br />
.hlist .tocnumber,<br />
.hlist .toctext {<br />
display: inline;<br />
}<br />
/* When <div class="nonumtoc"> is used on the table of contents,<br />
the ToC will display without numbers */<br />
.nonumtoc .tocnumber {<br />
display: none;<br />
}<br />
.nonumtoc #toc ul,<br />
.nonumtoc .toc ul {<br />
line-height: 1.5em;<br />
list-style: none none;<br />
margin: .3em 0 0;<br />
padding: 0;<br />
}<br />
.hlist.nonumtoc #toc ul ul,<br />
.hlist.nonumtoc .toc ul ul {<br />
/* @noflip */<br />
margin: 0;<br />
}<br />
<br />
/* Allow limiting of which header levels are shown in a TOC;<br />
<div class="toclimit-3">, for instance, will limit to<br />
showing ==headings== and ===headings=== but no further<br />
(as long as there are no =headings= on the page, which<br />
there shouldn't be according to the MoS). */<br />
.toclimit-2 .toclevel-1 ul,<br />
.toclimit-3 .toclevel-2 ul,<br />
.toclimit-4 .toclevel-3 ul,<br />
.toclimit-5 .toclevel-4 ul,<br />
.toclimit-6 .toclevel-5 ul,<br />
.toclimit-7 .toclevel-6 ul {<br />
display: none;<br />
}<br />
<br />
/* Styling for Template:Quote */<br />
blockquote.templatequote div.templatequotecite {<br />
line-height: 1.5em;<br />
/* @noflip */<br />
text-align: left;<br />
/* @noflip */<br />
padding-left: 1.6em;<br />
margin-top: 0;<br />
}<br />
<br />
/* User block messages */<br />
div.user-block {<br />
padding: 5px;<br />
margin-bottom: 0.5em;<br />
border: 1px solid #A9A9A9;<br />
background-color: #FFEFD5;<br />
}<br />
<br />
/* Prevent line breaks in silly places:<br />
1) Where desired<br />
2) Links when we don't want them to<br />
3) Bold "links" to the page itself<br />
4) Ref tags with group names <ref group="Note"> --> "[Note 1]" */<br />
.nowrap,<br />
.nowraplinks a,<br />
.nowraplinks .selflink,<br />
sup.reference a {<br />
white-space: nowrap;<br />
}<br />
.nowrap pre {<br />
white-space: pre;<br />
}<br />
/* But allow wrapping where desired: */<br />
.wrap,<br />
.wraplinks a {<br />
white-space: normal;<br />
}<br />
<br />
/* For template documentation */<br />
.template-documentation {<br />
clear: both;<br />
margin: 1em 0 0 0;<br />
border: 1px solid #aaa;<br />
background-color: #ecfcf4;<br />
padding: 1em;<br />
}<br />
<br />
/* Increase the height of the image upload box */<br />
#wpUploadDescription {<br />
height: 13em;<br />
}<br />
<br />
/* Minimum thumb width */<br />
.thumbinner {<br />
min-width: 100px;<br />
}<br />
<br />
/* Makes the background of a framed image white instead of gray.<br />
Only visible with transparent images. */<br />
div.thumb .thumbimage {<br />
background-color: #fff;<br />
}<br />
<br />
/* The backgrounds for galleries. */<br />
div#content .gallerybox div.thumb {<br />
/* Light gray padding */<br />
background-color: #F9F9F9;<br />
}<br />
/* Put a chequered background behind images, only visible if they have transparency.<br />
'.filehistory a img' and '#file img:hover' are handled by MediaWiki core (as of 1.19) */<br />
.gallerybox .thumb img {<br />
background: #fff url(//upload.wikimedia.org/wikipedia/commons/5/5d/Checker-16x16.png) repeat;<br />
}<br />
/* But not on articles, user pages, portals or with opt-out. */<br />
.ns-0 .gallerybox .thumb img,<br />
.ns-2 .gallerybox .thumb img,<br />
.ns-100 .gallerybox .thumb img,<br />
.nochecker .gallerybox .thumb img {<br />
background: #fff;<br />
}<br />
<br />
/* Prevent floating boxes from overlapping any category listings,<br />
file histories, edit previews, and edit [Show changes] views. */<br />
#mw-subcategories, #mw-pages, #mw-category-media,<br />
#filehistory, #wikiPreview, #wikiDiff {<br />
clear: both;<br />
}<br />
<br />
body.rtl #mw-articlefeedbackv5, body.rtl #mw-articlefeedback {<br />
display: block; /* Override inline block mode */<br />
margin-bottom: 1em;<br />
/* @noflip */<br />
clear: right; /* Clear any info boxes that stick out */<br />
/* @noflip */<br />
float: right; /* Prevents margin collapsing */<br />
}<br />
<br />
/* Selectively hide headers in WikiProject banners */<br />
.wpb .wpb-header { display: none; }<br />
.wpbs-inner .wpb .wpb-header { display: block; } /* for IE */<br />
.wpbs-inner .wpb .wpb-header { display: table-row; } /* for real browsers */<br />
.wpbs-inner .wpb-outside { display: none; } /* hide things that should only display outside shells */<br />
<br />
/* Styling for Abuse Filter tags */<br />
.mw-tag-markers {<br />
font-style:italic;<br />
font-size:90%;<br />
}<br />
<br />
/* Hide stuff meant for accounts with special permissions. Made visible again in<br />
[[MediaWiki:Group-sysop.css]], [[MediaWiki:Group-accountcreator.css]],<br />
[[MediaWiki:Group-templateeditor.css]], [[MediaWiki:Group-extendedmover.css]] and [[Mediawiki:Group-autoconfirmed.css]]. */<br />
.sysop-show,<br />
.accountcreator-show,<br />
.templateeditor-show,<br />
.extendedmover-show,<br />
.autoconfirmed-show {<br />
display: none;<br />
}<br />
<br />
/**<br />
* Hide the redlink generated by {{Editnotice}},<br />
* this overrides the ".sysop-show { display: none; }" above that applies<br />
* to the same link as well.<br />
*<br />
* See [[Phabricator:45013]].<br />
*/<br />
.ve-ui-mwNoticesPopupTool-item .editnotice-redlink, .mw-ve-editNotice .editnotice-redlink {<br />
display: none !important;<br />
}<br />
<br />
/* Remove bullets when there are multiple edit page warnings */<br />
ul.permissions-errors > li {<br />
list-style: none none;<br />
}<br />
ul.permissions-errors {<br />
margin: 0;<br />
}<br />
<br />
/* No linewrap on the labels of the login/signup page */<br />
body.page-Special_UserLogin .mw-label label,<br />
body.page-Special_UserLogin_signup .mw-label label {<br />
white-space: nowrap;<br />
}<br />
<br />
/* Pie chart: transparent borders */<br />
.transborder {<br />
border: solid transparent;<br />
}<br />
<br />
/* Generic class for Times-based serif, texhtml class for inline math */<br />
.times-serif,<br />
span.texhtml {<br />
font-family: "Nimbus Roman No9 L", "Times New Roman", Times, serif;<br />
font-size: 118%;<br />
line-height: 1;<br />
}<br />
span.texhtml {<br />
white-space: nowrap;<br />
}<br />
span.texhtml span.texhtml {<br />
font-size: 100%;<br />
}<br />
span.mwe-math-mathml-inline {<br />
font-size: 118%;<br />
}<br />
<br />
/* Force tabular and lining display for digits and texhtml */<br />
.digits,<br />
.texhtml {<br />
-moz-font-feature-settings: "lnum", "tnum", "kern" 0;<br />
-webkit-font-feature-settings: "lnum", "tnum", "kern" 0;<br />
font-feature-settings: "lnum", "tnum", "kern" 0;<br />
font-variant-numeric: lining-nums tabular-nums;<br />
font-kerning: none;<br />
}<br />
<br />
/* Make <math display="block"> be left aligned with one space indent for compatibility with style conventions */<br />
.mwe-math-fallback-image-display,<br />
.mwe-math-mathml-display {<br />
margin-left: 1.6em !important;<br />
margin-top: 0.6em;<br />
margin-bottom: 0.6em;<br />
}<br />
.mwe-math-mathml-display math {<br />
display: inline;<br />
}<br />
<br />
/* Fix styling of transcluded prefindex tables */<br />
table#mw-prefixindex-list-table,<br />
table#mw-prefixindex-nav-table {<br />
width: 98%;<br />
}<br />
<br />
/* For portals, added 2011-12-07 -bv<br />
On wide screens, show these as two columns<br />
On narrow and mobile screens, let them collapse into a single column */<br />
.portal-column-left {<br />
float: left;<br />
width: 50%;<br />
}<br />
.portal-column-right {<br />
float: right;<br />
width: 49%;<br />
}<br />
.portal-column-left-wide {<br />
float: left;<br />
width: 60%;<br />
}<br />
.portal-column-right-narrow {<br />
float: right;<br />
width: 39%;<br />
}<br />
.portal-column-left-extra-wide {<br />
float: left;<br />
width: 70%;<br />
}<br />
.portal-column-right-extra-narrow {<br />
float: right;<br />
width: 29%;<br />
}<br />
@media only screen and (max-width: 800px) {<br />
/* Decouple the columns on narrow screens */<br />
.portal-column-left,<br />
.portal-column-right,<br />
.portal-column-left-wide,<br />
.portal-column-right-narrow,<br />
.portal-column-left-extra-wide,<br />
.portal-column-right-extra-narrow {<br />
float: inherit;<br />
width: inherit;<br />
}<br />
}<br />
<br />
/* Formerly for announcements, now used intermittently */<br />
#bodyContent .letterhead {<br />
background-image:url('//upload.wikimedia.org/wikipedia/commons/e/e0/Tan-page-corner.png');<br />
background-repeat:no-repeat;<br />
padding: 2em;<br />
background-color: #faf9f2;<br />
}<br />
<br />
/* Tree style lists */<br />
.treeview ul {<br />
padding: 0;<br />
margin: 0;<br />
}<br />
.treeview li {<br />
padding: 0;<br />
margin: 0;<br />
list-style-type: none;<br />
list-style-image: none;<br />
}<br />
.treeview li li {<br />
background: url("//upload.wikimedia.org/wikipedia/commons/f/f2/Treeview-grey-line.png") no-repeat 0 -2981px;<br />
/* @noflip */<br />
padding-left: 20px;<br />
text-indent: 0.3em;<br />
}<br />
.treeview li li.lastline {<br />
background-position: 0 -5971px<br />
}<br />
.treeview li.emptyline > ul {<br />
/* @noflip */<br />
margin-left: -1px;<br />
}<br />
.treeview li.emptyline > ul > li:first-child {<br />
background-position: 0 9px<br />
}<br />
<br />
/* hidden sortkey for tablesorter */<br />
td .sortkey,<br />
th .sortkey {<br />
display: none;<br />
speak: none;<br />
}<br />
<br />
/* Make it possible to hide checkboxes in <inputbox> */<br />
.inputbox-hidecheckboxes form .inputbox-element {<br />
display: none !important;<br />
}<br />
<br />
/* Work-around for [[Phabricator:25965]] (Kaltura advertisement) */<br />
.k-player .k-attribution {<br />
visibility: hidden;<br />
}<br />
<br />
/* Move 'play' button of video player to bottom left corner */<br />
.PopUpMediaTransform a .play-btn-large {<br />
margin: 0;<br />
top: auto;<br />
right: auto;<br />
bottom: 0;<br />
left: 0;<br />
}<br />
<br />
/* Workaround to keep editnotices readable in VE view.<br />
Long term, editnotices should become a core feature so that they can be designed responsive. */<br />
.mw-ve-editNotice .mbox-image {<br />
display: none;<br />
}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Template:Tnull&diff=60782Template:Tnull2016-07-14T21:12:50Z<p>WikiSysop: 1 revision</p>
<hr />
<div><includeonly><code>&#123;&#123;{{#ifeq:{{lcfirst:{{{1|}}}}}|{{lc:{{{1|}}}}}|{{lcfirst:{{{1|}}}}}|{{{1|}}}}}{{#if:{{{2|}}}|&#124;{{{2}}}|}}{{#if:{{{3|}}}|&#124;{{{3}}}|}}{{#if:{{{4|}}}|&#124;{{{4}}}|}}{{#if:{{{5|}}}|&#124;{{{5}}}|}}{{#if:{{{6|}}}|&#124;{{{6}}}|}}{{#if:{{{7|}}}|&#124;{{{7}}}|}}{{#if:{{{8|}}}|&#124;{{{8}}}|}}&#125;&#125;</code></includeonly><noinclude>{{documentation}}</noinclude></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Template:Tnull&diff=60780Template:Tnull2016-07-14T16:01:57Z<p>WikiSysop: 1 revision</p>
<hr />
<div><includeonly><code>&#123;&#123;{{#ifeq:{{lcfirst:{{{1|}}}}}|{{lc:{{{1|}}}}}|{{lcfirst:{{{1|}}}}}|{{{1|}}}}}{{#if:{{{2|}}}|&#124;{{{2}}}|}}{{#if:{{{3|}}}|&#124;{{{3}}}|}}{{#if:{{{4|}}}|&#124;{{{4}}}|}}{{#if:{{{5|}}}|&#124;{{{5}}}|}}{{#if:{{{6|}}}|&#124;{{{6}}}|}}{{#if:{{{7|}}}|&#124;{{{7}}}|}}{{#if:{{{8|}}}|&#124;{{{8}}}|}}&#125;&#125;</code></includeonly><noinclude>{{documentation}}</noinclude></div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Yesno&diff=60778Module:Yesno2016-07-12T23:19:52Z<p>WikiSysop: 1 revision</p>
<hr />
<div>-- Function allowing for consistent treatment of boolean-like wikitext input.<br />
-- It works similarly to the template {{yesno}}.<br />
<br />
return function (val, default)<br />
-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you<br />
-- should replace "val:lower()" with "mw.ustring.lower(val)" in the<br />
-- following line.<br />
val = type(val) == 'string' and val:lower() or val<br />
if val == nil then<br />
return nil<br />
elseif val == true <br />
or val == 'yes'<br />
or val == 'y'<br />
or val == 'true'<br />
or val == 't'<br />
or tonumber(val) == 1<br />
then<br />
return true<br />
elseif val == false<br />
or val == 'no'<br />
or val == 'n'<br />
or val == 'false'<br />
or val == 'f'<br />
or tonumber(val) == 0<br />
then<br />
return false<br />
else<br />
return default<br />
end<br />
end</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Protection_banner/config&diff=60776Module:Protection banner/config2016-07-12T23:19:52Z<p>WikiSysop: 1 revision</p>
<hr />
<div>-- This module provides configuration data for [[Module:Protection banner]].<br />
<br />
return {<br />
<br />
--------------------------------------------------------------------------------<br />
--<br />
-- BANNER DATA<br />
--<br />
--------------------------------------------------------------------------------<br />
<br />
--[[<br />
-- Banner data consists of six fields:<br />
-- * text - the main protection text that appears at the top of protection<br />
-- banners.<br />
-- * explanation - the text that appears below the main protection text, used<br />
-- to explain the details of the protection.<br />
-- * tooltip - the tooltip text you see when you move the mouse over a small<br />
-- padlock icon.<br />
-- * link - the page that the small padlock icon links to.<br />
-- * alt - the alt text for the small padlock icon. This is also used as tooltip<br />
-- text for the large protection banners.<br />
-- * image - the padlock image used in both protection banners and small padlock<br />
-- icons.<br />
--<br />
-- The module checks in three separate tables to find a value for each field.<br />
-- First it checks the banners table, which has values specific to the reason<br />
-- for the page being protected. Then the module checks the defaultBanners<br />
-- table, which has values specific to each protection level. Finally, the<br />
-- module checks the masterBanner table, which holds data for protection<br />
-- templates to use if no data has been found in the previous two tables.<br />
--<br />
-- The values in the banner data can take parameters. These are specified<br />
-- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name<br />
-- enclosed in curly braces).<br />
--<br />
-- Available parameters:<br />
--<br />
-- ${CURRENTVERSION} - a link to the page history or the move log, with the<br />
-- display message "current-version-edit-display" or<br />
-- "current-version-move-display".<br />
--<br />
-- ${EDITREQUEST} - a link to create an edit request for the current page.<br />
--<br />
-- ${EXPIRY} - the protection expiry date in the format DD Month YYYY. If<br />
-- protection is indefinite or is not set, this is the blank string.<br />
--<br />
-- ${EXPLANATIONBLURB} - an explanation blurb, e.g. "Please discuss any changes<br />
-- on the talk page; you may submit a request to ask an administrator to make<br />
-- an edit if it is minor or supported by consensus."<br />
--<br />
-- ${IMAGELINK} - a link to set the image to, depending on the protection<br />
-- action and protection level.<br />
--<br />
-- ${INTROBLURB} - the PROTECTIONBLURB parameter, plus the expiry if an expiry<br />
-- is set. E.g. "Editing of this page by new or unregistered users is currently <br />
-- disabled until dd Month YYYY."<br />
--<br />
-- ${INTROFRAGMENT} - the same as ${INTROBLURB}, but without final punctuation<br />
-- so that it can be used in run-on sentences.<br />
--<br />
-- ${PAGETYPE} - the type of the page, e.g. "article" or "template".<br />
-- Defined in the cfg.pagetypes table.<br />
--<br />
-- ${PROTECTIONBLURB} - a blurb explaining the protection level of the page, e.g.<br />
-- "Editing of this page by new or unregistered users is currently disabled"<br />
--<br />
-- ${PROTECTIONDATE} - the protection date, if it has been supplied to the<br />
-- template.<br />
--<br />
-- ${PROTECTIONLEVEL} - the protection level, e.g. "fully protected" or<br />
-- "semi-protected".<br />
--<br />
-- ${PROTECTIONLOG} - a link to the protection log or the pending changes log,<br />
-- depending on the protection action.<br />
--<br />
-- ${TALKPAGE} - a link to the talk page. If a section is specified, links<br />
-- straight to that talk page section.<br />
--<br />
-- ${TOOLTIPBLURB} - uses the PAGETYPE, PROTECTIONTYPE and EXPIRY parameters to<br />
-- create a blurb like "This template is semi-protected", or "This article is<br />
-- move-protected until DD Month YYYY".<br />
--<br />
-- ${VANDAL} - links for the specified username (or the root page name)<br />
-- using Module:Vandal-m.<br />
--<br />
-- Functions<br />
--<br />
-- For advanced users, it is possible to use Lua functions instead of strings<br />
-- in the banner config tables. Using functions gives flexibility that is not<br />
-- possible just by using parameters. Functions take two arguments, the<br />
-- protection object and the template arguments, and they must output a string.<br />
--<br />
-- For example:<br />
--<br />
-- text = function (protectionObj, args)<br />
-- if protectionObj.level == 'autoconfirmed' then<br />
-- return 'foo'<br />
-- else<br />
-- return 'bar'<br />
-- end<br />
-- end<br />
--<br />
-- Some protection object properties and methods that may be useful:<br />
-- protectionObj.action - the protection action<br />
-- protectionObj.level - the protection level<br />
-- protectionObj.reason - the protection reason<br />
-- protectionObj.expiry - the expiry. Nil if unset, the string "indef" if set<br />
-- to indefinite, and the protection time in unix time if temporary.<br />
-- protectionObj.protectionDate - the protection date in unix time, or nil if<br />
-- unspecified.<br />
-- protectionObj.bannerConfig - the banner config found by the module. Beware<br />
-- of editing the config field used by the function, as it could create an<br />
-- infinite loop.<br />
-- protectionObj:isProtected - returns a boolean showing whether the page is<br />
-- protected.<br />
-- protectionObj:isTemporary - returns a boolean showing whether the expiry is<br />
-- temporary.<br />
-- protectionObj:isIncorrect - returns a boolean showing whether the protection<br />
-- template is incorrect.<br />
--]]<br />
<br />
-- The master banner data, used if no values have been found in banners or<br />
-- defaultBanners.<br />
masterBanner = {<br />
text = '${INTROBLURB}',<br />
explanation = '${EXPLANATIONBLURB}',<br />
tooltip = '${TOOLTIPBLURB}',<br />
link = '${IMAGELINK}',<br />
alt = 'Page ${PROTECTIONLEVEL}'<br />
},<br />
<br />
-- The default banner data. This holds banner data for different protection<br />
-- levels.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
defaultBanners = {<br />
edit = {},<br />
move = {},<br />
autoreview = {<br />
autoconfirmed = {<br />
alt = 'Page protected with pending changes level 1',<br />
tooltip = 'All edits by unregistered and new users are subject to review',<br />
image = 'Padlock-silver-light.svg'<br />
},<br />
default = {<br />
alt = 'Page protected with pending changes level 2',<br />
tooltip = 'All edits by users who are not reviewers or administrators are'<br />
.. ' subject to review',<br />
}<br />
},<br />
upload = {}<br />
},<br />
<br />
-- The banner data. This holds banner data for different protection reasons.<br />
-- In fact, the reasons specified in this table control which reasons are<br />
-- valid inputs to the first positional parameter.<br />
--<br />
-- There is also a non-standard "description" field that can be used for items<br />
-- in this table. This is a description of the protection reason for use in the<br />
-- module documentation.<br />
--<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
banners = {<br />
edit = {<br />
blp = {<br />
description = 'For pages protected to promote compliance with the'<br />
.. ' [[Wikipedia:Biographies of living persons'<br />
.. '|biographies of living persons]] policy',<br />
text = '${INTROFRAGMENT} to promote compliance with'<br />
.. ' [[Wikipedia:Biographies of living persons'<br />
.. "|Wikipedia's&nbsp;policy on&nbsp;the&nbsp;biographies"<br />
.. ' of&nbsp;living&nbsp;people]].',<br />
tooltip = '${TOOLTIPFRAGMENT} to promote compliance with the policy on'<br />
.. ' biographies of living people',<br />
},<br />
dmca = {<br />
description = 'For pages protected by the Wikimedia Foundation'<br />
.. ' due to [[Digital Millennium Copyright Act]] takedown requests',<br />
explanation = function (protectionObj, args)<br />
local ret = 'Pursuant to a rights owner notice under the Digital'<br />
.. ' Millennium Copyright Act (DMCA) regarding some content'<br />
.. ' in this article, the Wikimedia Foundation acted under'<br />
.. ' applicable law and took down and restricted the content'<br />
.. ' in question.'<br />
if args.notice then<br />
ret = ret .. ' A copy of the received notice can be found here: '<br />
.. args.notice .. '.'<br />
end<br />
ret = ret .. ' For more information, including websites discussing'<br />
.. ' how to file a counter-notice, please see'<br />
.. " [[Wikipedia:Office actions]] and the article's ${TALKPAGE}."<br />
.. "'''Do not remove this template from the article until the"<br />
.. " restrictions are withdrawn'''."<br />
return ret<br />
end,<br />
image = 'Padlock-black.svg',<br />
},<br />
dispute = {<br />
description = 'For pages protected due to editing disputes',<br />
text = function (protectionObj, args)<br />
-- Find the value of "disputes".<br />
local display = 'disputes'<br />
local disputes<br />
if args.section then<br />
disputes = string.format(<br />
'[[%s:%s#%s|%s]]',<br />
mw.site.namespaces[protectionObj.title.namespace].talk.name,<br />
protectionObj.title.text,<br />
args.section,<br />
display<br />
)<br />
else<br />
disputes = display<br />
end<br />
<br />
-- Make the blurb, depending on the expiry.<br />
local msg<br />
if type(protectionObj.expiry) == 'number' then<br />
msg = '${INTROFRAGMENT} or until editing %s have been resolved.'<br />
else<br />
msg = '${INTROFRAGMENT} until editing %s have been resolved.'<br />
end<br />
return string.format(msg, disputes)<br />
end,<br />
explanation = "This protection is '''not''' an endorsement of the"<br />
.. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',<br />
tooltip = '${TOOLTIPFRAGMENT} due to editing disputes',<br />
},<br />
mainpage = {<br />
description = 'For pages protected for being displayed on the [[Main Page]]',<br />
text = 'This file is currently'<br />
.. ' [[Wikipedia:This page is protected|protected]] from'<br />
.. ' editing because it is currently or will soon be displayed'<br />
.. ' on the [[Main Page]].',<br />
explanation = 'Images on the Main Page are protected due to their high'<br />
.. ' visibility. Please discuss any necessary changes on the ${TALKPAGE}.'<br />
.. '<br /><span style="font-size:90%;">'<br />
.. "'''Administrators:''' Once this image is definitely off the Main Page,"<br />
.. ' please unprotect this file, or reduce to semi-protection,'<br />
.. ' as appropriate.</span>',<br />
},<br />
office = {<br />
description = 'For pages protected by the Wikimedia Foundation',<br />
text = function (protectionObj, args)<br />
local ret = 'This ${PAGETYPE} is currently under the'<br />
.. ' scrutiny of the'<br />
.. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]'<br />
.. ' and is protected.'<br />
if protectionObj.protectionDate then<br />
ret = ret .. ' It has been protected since ${PROTECTIONDATE}.'<br />
end<br />
return ret<br />
end,<br />
explanation = "If you can edit this page, please discuss all changes and"<br />
.. " additions on the ${TALKPAGE} first. '''Do not remove protection from this"<br />
.. " page unless you are authorized by the Wikimedia Foundation to do"<br />
.. " so.'''",<br />
image = 'Padlock-black.svg',<br />
},<br />
reset = {<br />
description = 'For pages protected by the Wikimedia Foundation and'<br />
.. ' "reset" to a bare-bones version',<br />
text = 'This ${PAGETYPE} is currently under the'<br />
.. ' scrutiny of the'<br />
.. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]'<br />
.. ' and is protected.',<br />
explanation = function (protectionObj, args)<br />
local ret = ''<br />
if protectionObj.protectionDate then<br />
ret = ret .. 'On ${PROTECTIONDATE} this ${PAGETYPE} was'<br />
else<br />
ret = ret .. 'This ${PAGETYPE} has been'<br />
end<br />
ret = ret .. ' reduced to a'<br />
.. ' simplified, "bare bones" version so that it may be completely'<br />
.. ' rewritten to ensure it meets the policies of'<br />
.. ' [[WP:NPOV|Neutral Point of View]] and [[WP:V|Verifiability]].'<br />
.. ' Standard Wikipedia policies will apply to its rewriting—which'<br />
.. ' will eventually be open to all editors—and will be strictly'<br />
.. ' enforced. The ${PAGETYPE} has been ${PROTECTIONLEVEL} while'<br />
.. ' it is being rebuilt.\n\n'<br />
.. 'Any insertion of material directly from'<br />
.. ' pre-protection revisions of the ${PAGETYPE} will be removed, as'<br />
.. ' will any material added to the ${PAGETYPE} that is not properly'<br />
.. ' sourced. The associated talk page(s) were also cleared on the'<br />
.. " same date.\n\n"<br />
.. "If you can edit this page, please discuss all changes and"<br />
.. " additions on the ${TALKPAGE} first. '''Do not override"<br />
.. " this action, and do not remove protection from this page,"<br />
.. " unless you are authorized by the Wikimedia Foundation"<br />
.. " to do so. No editor may remove this notice.'''"<br />
<br />
return ret<br />
end,<br />
image = 'Padlock-black.svg',<br />
},<br />
sock = {<br />
description = 'For pages protected due to'<br />
.. ' [[Wikipedia:Sock puppetry|sock puppetry]]',<br />
text = '${INTROFRAGMENT} to prevent [[Wikipedia:Sock puppetry|sock puppets]] of'<br />
.. ' [[Wikipedia:Blocking policy|blocked]] or'<br />
.. ' [[Wikipedia:Banning policy|banned users]]'<br />
.. ' from editing it.',<br />
tooltip = '${TOOLTIPFRAGMENT} to prevent sock puppets of blocked or banned users from'<br />
.. ' editing it',<br />
},<br />
template = {<br />
description = 'For [[Wikipedia:High-risk templates|high-risk]]'<br />
.. ' templates and Lua modules',<br />
text = 'This is a permanently [[Help:Protection|protected]] ${PAGETYPE},'<br />
.. ' as it is [[Wikipedia:High-risk templates|high-risk]].',<br />
explanation = 'Please discuss any changes on the ${TALKPAGE}; you may'<br />
.. ' ${EDITREQUEST} to ask an'<br />
.. ' [[Wikipedia:Administrators|administrator]] or'<br />
.. ' [[Wikipedia:Template editor|template editor]] to make an edit if'<br />
.. ' it is [[Help:Minor edit#When to mark an edit as a minor edit'<br />
.. '|uncontroversial]] or supported by'<br />
.. ' [[Wikipedia:Consensus|consensus]]. You can also'<br />
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'<br />
.. ' unprotected.',<br />
tooltip = 'This high-risk ${PAGETYPE} is permanently ${PROTECTIONLEVEL}'<br />
.. ' to prevent vandalism',<br />
alt = 'Permanently protected ${PAGETYPE}',<br />
},<br />
usertalk = {<br />
description = 'For pages protected against disruptive edits by a'<br />
.. ' particular user',<br />
text = '${INTROFRAGMENT} to prevent ${VANDAL} from using it to make disruptive edits,'<br />
.. ' such as abusing the'<br />
.. ' &#123;&#123;[[Template:unblock|unblock]]&#125;&#125; template.',<br />
explanation = 'If you cannot edit this user talk page and you need to'<br />
.. ' make a change or leave a message, you can'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for edits to a protected page'<br />
.. '|request an edit]],'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]],'<br />
.. ' [[Special:Userlogin|log in]],'<br />
.. ' or [[Special:UserLogin/signup|create an account]].',<br />
},<br />
vandalism = {<br />
description = 'For pages protected against'<br />
.. ' [[Wikipedia:Vandalism|vandalism]]',<br />
text = '${INTROFRAGMENT} due to [[Wikipedia:Vandalism|vandalism]].',<br />
explanation = function (protectionObj, args)<br />
local ret = ''<br />
if protectionObj.level == 'sysop' then<br />
ret = ret .. "This protection is '''not''' an endorsement of the"<br />
.. ' ${CURRENTVERSION}. '<br />
end<br />
return ret .. '${EXPLANATIONBLURB}'<br />
end,<br />
tooltip = '${TOOLTIPFRAGMENT} due to vandalism',<br />
}<br />
},<br />
move = {<br />
dispute = {<br />
description = 'For pages protected against page moves due to'<br />
.. ' disputes over the page title',<br />
explanation = "This protection is '''not''' an endorsement of the"<br />
.. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',<br />
image = 'Padlock-olive.svg'<br />
},<br />
vandalism = {<br />
description = 'For pages protected against'<br />
.. ' [[Wikipedia:Vandalism#Page-move vandalism'<br />
.. ' |page-move vandalism]]'<br />
}<br />
},<br />
autoreview = {},<br />
upload = {}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
--<br />
-- GENERAL DATA TABLES<br />
--<br />
--------------------------------------------------------------------------------<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection blurbs<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table produces the protection blurbs available with the<br />
-- ${PROTECTIONBLURB} parameter. It is sorted by protection action and<br />
-- protection level, and is checked by the module in the following order:<br />
-- 1. page's protection action, page's protection level<br />
-- 2. page's protection action, default protection level<br />
-- 3. "edit" protection action, default protection level<br />
--<br />
-- It is possible to use banner parameters inside this table.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
protectionBlurbs = {<br />
edit = {<br />
default = 'This ${PAGETYPE} is currently [[Help:Protection|'<br />
.. 'protected]] from editing',<br />
autoconfirmed = 'Editing of this ${PAGETYPE} by [[Wikipedia:User access'<br />
.. ' levels#New users|new]] or [[Wikipedia:User access levels#Unregistered'<br />
.. ' users|unregistered]] users is currently [[Help:Protection|disabled]]'<br />
},<br />
move = {<br />
default = 'This ${PAGETYPE} is currently [[Help:Protection|protected]]'<br />
.. ' from [[Help:Moving a page|page moves]]'<br />
},<br />
autoreview = {<br />
autoconfirmed = 'All edits made to this ${PAGETYPE} by'<br />
.. ' [[Wikipedia:User access levels#New users|new]] or'<br />
.. ' [[Wikipedia:User access levels#Unregistered users|unregistered]]'<br />
.. ' users are currently'<br />
.. ' [[Wikipedia:Pending changes|subject to review]]',<br />
default = 'All edits made to this ${PAGETYPE} by users who are not'<br />
.. ' [[Wikipedia:Reviewing|reviewers]] or'<br />
.. ' [[Wikipedia:Administrators|administrators]] are currently'<br />
.. ' [[Wikipedia:Pending changes|subject to review]]'<br />
},<br />
upload = {<br />
default = 'Uploading new versions of this ${PAGETYPE} is currently disabled'<br />
}<br />
},<br />
<br />
<br />
--------------------------------------------------------------------------------<br />
-- Explanation blurbs<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table produces the explanation blurbs available with the<br />
-- ${EXPLANATIONBLURB} parameter. It is sorted by protection action,<br />
-- protection level, and whether the page is a talk page or not. If the page is<br />
-- a talk page it will have a talk key of "talk"; otherwise it will have a talk<br />
-- key of "subject". The table is checked in the following order:<br />
-- 1. page's protection action, page's protection level, page's talk key<br />
-- 2. page's protection action, page's protection level, default talk key<br />
-- 3. page's protection action, default protection level, page's talk key<br />
-- 4. page's protection action, default protection level, default talk key<br />
--<br />
-- It is possible to use banner parameters inside this table.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
explanationBlurbs = {<br />
edit = {<br />
autoconfirmed = {<br />
subject = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details. If you'<br />
.. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can'<br />
.. ' ${EDITREQUEST}, discuss changes on the ${TALKPAGE},'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]], [[Special:Userlogin|log in]], or'<br />
.. ' [[Special:UserLogin/signup|create an account]].',<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details. If you'<br />
.. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]], [[Special:Userlogin|log in]], or'<br />
.. ' [[Special:UserLogin/signup|create an account]].',<br />
},<br />
default = {<br />
subject = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' Please discuss any changes on the ${TALKPAGE}; you'<br />
.. ' may ${EDITREQUEST} to ask an'<br />
.. ' [[Wikipedia:Administrators|administrator]] to make an edit if it'<br />
.. ' is [[Help:Minor edit#When to mark an edit as a minor edit'<br />
.. '|uncontroversial]] or supported by [[Wikipedia:Consensus'<br />
.. '|consensus]]. You may also [[Wikipedia:Requests for'<br />
.. ' page protection#Current requests for reduction in protection level'<br />
.. '|request]] that this page be unprotected.',<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' You may [[Wikipedia:Requests for page'<br />
.. ' protection#Current requests for edits to a protected page|request an'<br />
.. ' edit]] to this page, or [[Wikipedia:Requests for'<br />
.. ' page protection#Current requests for reduction in protection level'<br />
.. '|ask]] for it to be unprotected.'<br />
}<br />
},<br />
move = {<br />
default = {<br />
subject = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' The page may still be edited but cannot be moved'<br />
.. ' until unprotected. Please discuss any suggested moves on the'<br />
.. ' ${TALKPAGE} or at [[Wikipedia:Requested moves]]. You can also'<br />
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'<br />
.. ' unprotected.',<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' The page may still be edited but cannot be moved'<br />
.. ' until unprotected. Please discuss any suggested moves at'<br />
.. ' [[Wikipedia:Requested moves]]. You can also'<br />
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'<br />
.. ' unprotected.'<br />
}<br />
},<br />
autoreview = {<br />
default = {<br />
reviewer = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' Edits to this ${PAGETYPE} will not be visible to readers'<br />
.. ' until they are accepted by a reviewer or an administrator.'<br />
.. ' To avoid the need for your edits to be reviewed, you may'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]]. Experienced editors may also'<br />
.. ' request the [[Wikipedia:Reviewing|reviewer user right]].',<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' Edits to this ${PAGETYPE} by new and unregistered users'<br />
.. ' will not be visible to readers until they are accepted by'<br />
.. ' a reviewer. To avoid the need for your edits to be'<br />
.. ' reviewed, you may'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]], [[Special:Userlogin|log in]], or'<br />
.. ' [[Special:UserLogin/signup|create an account]].'<br />
},<br />
},<br />
upload = {<br />
default = {<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' The page may still be edited but new versions of the file'<br />
.. ' cannot be uploaded until it is unprotected. You can'<br />
.. ' request that a new version be uploaded by using a'<br />
.. ' [[Wikipedia:Edit requests|protected edit request]], or you'<br />
.. ' can [[Wikipedia:Requests for page protection|request]]'<br />
.. ' that the file be unprotected.'<br />
}<br />
}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection levels<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table provides the data for the ${PROTECTIONLEVEL} parameter, which<br />
-- produces a short label for different protection levels. It is sorted by<br />
-- protection action and protection level, and is checked in the following<br />
-- order:<br />
-- 1. page's protection action, page's protection level<br />
-- 2. page's protection action, default protection level<br />
-- 3. "edit" protection action, default protection level<br />
--<br />
-- It is possible to use banner parameters inside this table.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
protectionLevels = {<br />
edit = {<br />
default = 'protected',<br />
templateeditor = 'template-protected',<br />
autoconfirmed = 'semi-protected',<br />
},<br />
move = {<br />
default = 'move-protected'<br />
},<br />
autoreview = {<br />
},<br />
upload = {<br />
default = 'upload-protected'<br />
}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Images<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table lists different padlock images for each protection action and<br />
-- protection level. It is used if an image is not specified in any of the<br />
-- banner data tables, and if the page does not satisfy the conditions for using<br />
-- the ['image-filename-indef'] image. It is checked in the following order:<br />
-- 1. page's protection action, page's protection level<br />
-- 2. page's protection action, default protection level<br />
images = {<br />
edit = {<br />
default = 'Padlock.svg',<br />
templateeditor = 'Padlock-pink.svg',<br />
autoconfirmed = 'Padlock-silver.svg'<br />
},<br />
move = {<br />
default = 'Padlock-olive.svg',<br />
},<br />
autoreview = {<br />
autoconfirmed = 'Padlock-silver-light.svg',<br />
default = 'Padlock-orange.svg'<br />
},<br />
upload = {<br />
default = 'Padlock-purple.svg'<br />
}<br />
},<br />
<br />
-- Pages with a reason specified in this table will show the special "indef"<br />
-- padlock, defined in the 'image-filename-indef' message, if no expiry is set.<br />
indefImageReasons = {<br />
template = true<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Image links<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table provides the data for the ${IMAGELINK} parameter, which gets<br />
-- the image link for small padlock icons based on the page's protection action<br />
-- and protection level. It is checked in the following order:<br />
-- 1. page's protection action, page's protection level<br />
-- 2. page's protection action, default protection level<br />
-- 3. "edit" protection action, default protection level<br />
--<br />
-- It is possible to use banner parameters inside this table.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
imageLinks = {<br />
edit = {<br />
default = 'Wikipedia:Protection policy#full',<br />
templateeditor = 'Wikipedia:Protection policy#template',<br />
autoconfirmed = 'Wikipedia:Protection policy#semi'<br />
},<br />
move = {<br />
default = 'Wikipedia:Protection policy#move'<br />
},<br />
autoreview = {<br />
autoconfirmed = 'Wikipedia:Protection policy#pc1',<br />
reviewer = 'Wikipedia:Protection policy#pc2'<br />
},<br />
upload = {<br />
default = 'Wikipedia:Protection policy#upload'<br />
}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Padlock indicator names<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table provides the "name" attribute for the <indicator> extension tag<br />
-- with which small padlock icons are generated. All indicator tags on a page<br />
-- are displayed in alphabetical order based on this attribute, and with<br />
-- indicator tags with duplicate names, the last tag on the page wins.<br />
-- The attribute is chosen based on the protection action; table keys must be a<br />
-- protection action name or the string "default".<br />
padlockIndicatorNames = {<br />
autoreview = 'pp-autoreview',<br />
default = 'pp-default'<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection categories<br />
--------------------------------------------------------------------------------<br />
<br />
--[[<br />
-- The protection categories are stored in the protectionCategories table.<br />
-- Keys to this table are made up of the following strings:<br />
--<br />
-- 1. the expiry date<br />
-- 2. the namespace<br />
-- 3. the protection reason (e.g. "dispute" or "vandalism")<br />
-- 4. the protection level (e.g. "sysop" or "autoconfirmed")<br />
-- 5. the action (e.g. "edit" or "move")<br />
-- <br />
-- When the module looks up a category in the table, first it will will check to<br />
-- see a key exists that corresponds to all five parameters. For example, a<br />
-- user page semi-protected from vandalism for two weeks would have the key<br />
-- "temp-user-vandalism-autoconfirmed-edit". If no match is found, the module<br />
-- changes the first part of the key to "all" and checks the table again. It<br />
-- keeps checking increasingly generic key combinations until it finds the<br />
-- field, or until it reaches the key "all-all-all-all-all".<br />
--<br />
-- The module uses a binary matrix to determine the order in which to search.<br />
-- This is best demonstrated by a table. In this table, the "0" values<br />
-- represent "all", and the "1" values represent the original data (e.g.<br />
-- "indef" or "file" or "vandalism").<br />
--<br />
-- expiry namespace reason level action<br />
-- order<br />
-- 1 1 1 1 1 1<br />
-- 2 0 1 1 1 1<br />
-- 3 1 0 1 1 1<br />
-- 4 0 0 1 1 1<br />
-- 5 1 1 0 1 1<br />
-- 6 0 1 0 1 1<br />
-- 7 1 0 0 1 1<br />
-- 8 0 0 0 1 1<br />
-- 9 1 1 1 0 1<br />
-- 10 0 1 1 0 1<br />
-- 11 1 0 1 0 1<br />
-- 12 0 0 1 0 1<br />
-- 13 1 1 0 0 1<br />
-- 14 0 1 0 0 1<br />
-- 15 1 0 0 0 1<br />
-- 16 0 0 0 0 1<br />
-- 17 1 1 1 1 0<br />
-- 18 0 1 1 1 0<br />
-- 19 1 0 1 1 0<br />
-- 20 0 0 1 1 0<br />
-- 21 1 1 0 1 0<br />
-- 22 0 1 0 1 0<br />
-- 23 1 0 0 1 0<br />
-- 24 0 0 0 1 0<br />
-- 25 1 1 1 0 0<br />
-- 26 0 1 1 0 0<br />
-- 27 1 0 1 0 0<br />
-- 28 0 0 1 0 0<br />
-- 29 1 1 0 0 0<br />
-- 30 0 1 0 0 0<br />
-- 31 1 0 0 0 0<br />
-- 32 0 0 0 0 0<br />
--<br />
-- In this scheme the action has the highest priority, as it is the last<br />
-- to change, and the expiry has the least priority, as it changes the most.<br />
-- The priorities of the expiry, the protection level and the action are<br />
-- fixed, but the priorities of the reason and the namespace can be swapped<br />
-- through the use of the cfg.bannerDataNamespaceHasPriority table.<br />
--]]<br />
<br />
-- If the reason specified to the template is listed in this table,<br />
-- namespace data will take priority over reason data in the protectionCategories<br />
-- table.<br />
reasonsWithNamespacePriority = {<br />
vandalism = true,<br />
},<br />
<br />
-- The string to use as a namespace key for the protectionCategories table for each<br />
-- namespace number.<br />
categoryNamespaceKeys = {<br />
[ 2] = 'user',<br />
[ 3] = 'user',<br />
[ 4] = 'project',<br />
[ 6] = 'file',<br />
[ 8] = 'mediawiki',<br />
[ 10] = 'template',<br />
[ 12] = 'project',<br />
[ 14] = 'category',<br />
[100] = 'portal',<br />
[828] = 'module',<br />
},<br />
<br />
protectionCategories = {<br />
['all|all|all|all|all'] = 'Wikipedia protected pages',<br />
['all|all|office|all|all'] = 'Wikipedia Office-protected pages',<br />
['all|all|reset|all|all'] = 'Wikipedia Office-protected pages',<br />
['all|all|dmca|all|all'] = 'Wikipedia Office-protected pages',<br />
['all|all|mainpage|all|all'] = 'Wikipedia fully-protected main page files',<br />
['all|template|all|all|edit'] = 'Wikipedia fully-protected templates',<br />
['all|all|all|autoconfirmed|edit'] = 'Wikipedia semi-protected pages',<br />
['indef|all|all|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected pages',<br />
['all|all|blp|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected biographies of living people',<br />
['temp|all|blp|autoconfirmed|edit'] = 'Wikipedia temporarily semi-protected biographies of living people',<br />
['all|all|dispute|autoconfirmed|edit'] = 'Wikipedia pages semi-protected due to dispute',<br />
['all|all|sock|autoconfirmed|edit'] = 'Wikipedia pages semi-protected from banned users',<br />
['all|all|vandalism|autoconfirmed|edit'] = 'Wikipedia pages semi-protected against vandalism',<br />
['all|category|all|autoconfirmed|edit'] = 'Wikipedia semi-protected categories',<br />
['all|file|all|autoconfirmed|edit'] = 'Wikipedia semi-protected files',<br />
['all|portal|all|autoconfirmed|edit'] = 'Wikipedia semi-protected portals',<br />
['all|project|all|autoconfirmed|edit'] = 'Wikipedia semi-protected project pages',<br />
['all|talk|all|autoconfirmed|edit'] = 'Wikipedia semi-protected talk pages',<br />
['all|template|all|autoconfirmed|edit'] = 'Wikipedia semi-protected templates',<br />
['all|user|all|autoconfirmed|edit'] = 'Wikipedia semi-protected user and user talk pages',<br />
['all|template|all|templateeditor|edit'] = 'Wikipedia template-protected templates',<br />
['all|all|blp|sysop|edit'] = 'Wikipedia indefinitely protected biographies of living people',<br />
['temp|all|blp|sysop|edit'] = 'Wikipedia temporarily protected biographies of living people',<br />
['all|all|dispute|sysop|edit'] = 'Wikipedia pages protected due to dispute',<br />
['all|all|sock|sysop|edit'] = 'Wikipedia pages protected from banned users',<br />
['all|all|vandalism|sysop|edit'] = 'Wikipedia pages protected against vandalism',<br />
['all|category|all|sysop|edit'] = 'Wikipedia protected categories',<br />
['all|file|all|sysop|edit'] = 'Wikipedia fully-protected files',<br />
['all|project|all|sysop|edit'] = 'Wikipedia fully-protected project pages',<br />
['all|talk|all|sysop|edit'] = 'Wikipedia fully-protected talk pages',<br />
['all|template|all|sysop|edit'] = 'Wikipedia fully-protected templates',<br />
['all|user|all|sysop|edit'] = 'Wikipedia protected user and user talk pages',<br />
['all|module|all|all|edit'] = 'Wikipedia fully-protected modules',<br />
['all|module|all|templateeditor|edit'] = 'Wikipedia template-protected modules',<br />
['all|module|all|autoconfirmed|edit'] = 'Wikipedia semi-protected modules',<br />
['all|all|all|sysop|move'] = 'Wikipedia move-protected pages',<br />
['indef|all|all|sysop|move'] = 'Wikipedia indefinitely move-protected pages',<br />
['all|all|dispute|sysop|move'] = 'Wikipedia pages move-protected due to dispute',<br />
['all|all|vandalism|sysop|move'] = 'Wikipedia pages move-protected due to vandalism',<br />
['all|portal|all|sysop|move'] = 'Wikipedia move-protected portals',<br />
['all|portal|all|sysop|move'] = 'Wikipedia move-protected portals',<br />
['all|project|all|sysop|move'] = 'Wikipedia move-protected project pages',<br />
['all|talk|all|sysop|move'] = 'Wikipedia move-protected talk pages',<br />
['all|template|all|sysop|move'] = 'Wikipedia move-protected templates',<br />
['all|user|all|sysop|move'] = 'Wikipedia move-protected user and user talk pages',<br />
['all|all|all|autoconfirmed|autoreview'] = 'Wikipedia pending changes protected pages (level 1)',<br />
['all|all|all|reviewer|autoreview'] = 'Wikipedia pending changes protected pages (level 2)',<br />
['all|file|all|all|upload'] = 'Wikipedia upload-protected files',<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Expiry category config<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table configures the expiry category behaviour for each protection<br />
-- action.<br />
-- * If set to true, setting that action will always categorise the page if<br />
-- an expiry parameter is not set.<br />
-- * If set to false, setting that action will never categorise the page.<br />
-- * If set to nil, the module will categorise the page if:<br />
-- 1) an expiry parameter is not set, and<br />
-- 2) a reason is provided, and<br />
-- 3) the specified reason is not blacklisted in the reasonsWithoutExpiryCheck<br />
-- table.<br />
<br />
expiryCheckActions = {<br />
edit = nil,<br />
move = false,<br />
autoreview = true,<br />
upload = false<br />
},<br />
<br />
reasonsWithoutExpiryCheck = {<br />
blp = true,<br />
template = true,<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Pagetypes<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table produces the page types available with the ${PAGETYPE} parameter.<br />
-- Keys are namespace numbers, or the string "default" for the default value.<br />
pagetypes = {<br />
[0] = 'article',<br />
[6] = 'file',<br />
[10] = 'template',<br />
[14] = 'category',<br />
[828] = 'module',<br />
default = 'page'<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Strings marking indefinite protection<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table contains values passed to the expiry parameter that mean the page<br />
-- is protected indefinitely.<br />
indefStrings = {<br />
['indef'] = true,<br />
['indefinite'] = true,<br />
['indefinitely'] = true,<br />
['infinite'] = true,<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Group hierarchy<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table maps each group to all groups that have a superset of the original<br />
-- group's page editing permissions.<br />
hierarchy = {<br />
sysop = {},<br />
reviewer = {'sysop'},<br />
filemover = {'sysop'},<br />
templateeditor = {'sysop'},<br />
autoconfirmed = {'reviewer', 'filemover', 'templateeditor'},<br />
user = {'autoconfirmed'},<br />
['*'] = {'user'}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Wrapper templates and their default arguments<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table contains wrapper templates used with the module, and their<br />
-- default arguments. Templates specified in this table should contain the<br />
-- following invocation, and no other template content:<br />
--<br />
-- {{#invoke:Protection banner|main}}<br />
--<br />
-- If other content is desired, it can be added between<br />
-- <noinclude>...</noinclude> tags.<br />
--<br />
-- When a user calls one of these wrapper templates, they will use the<br />
-- default arguments automatically. However, users can override any of the<br />
-- arguments.<br />
wrappers = {<br />
['Template:Pp'] = {},<br />
['Template:Pp-blp'] = {'blp'},<br />
-- we don't need Template:Pp-create<br />
['Template:Pp-dispute'] = {'dispute'},<br />
['Template:Pp-main-page'] = {'mainpage'},<br />
['Template:Pp-move'] = {action = 'move'},<br />
['Template:Pp-move-dispute'] = {'dispute', action = 'move'},<br />
-- we don't need Template:Pp-move-indef<br />
['Template:Pp-move-vandalism'] = {'vandalism', action = 'move'},<br />
['Template:Pp-office'] = {'office'},<br />
['Template:Pp-office-dmca'] = {'dmca'},<br />
['Template:Pp-pc1'] = {action = 'autoreview', small = true},<br />
['Template:Pp-pc2'] = {action = 'autoreview', small = true},<br />
['Template:Pp-reset'] = {'reset'},<br />
['Template:Pp-semi-indef'] = {expiry = 'indef', small = true},<br />
['Template:Pp-sock'] = {'sock'},<br />
['Template:Pp-template'] = {'template', small = true},<br />
['Template:Pp-upload'] = {action = 'upload'},<br />
['Template:Pp-usertalk'] = {'usertalk'},<br />
['Template:Pp-vandalism'] = {'vandalism'},<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- <br />
-- MESSAGES<br />
-- <br />
--------------------------------------------------------------------------------<br />
<br />
msg = {<br />
<br />
--------------------------------------------------------------------------------<br />
-- Intro blurb and intro fragment<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages specify what is produced by the ${INTROBLURB} and<br />
-- ${INTROFRAGMENT} parameters. If the protection is temporary they use the<br />
-- intro-blurb-expiry or intro-fragment-expiry, and if not they use<br />
-- intro-blurb-noexpiry or intro-fragment-noexpiry.<br />
-- It is possible to use banner parameters in these messages.<br />
['intro-blurb-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY}.',<br />
['intro-blurb-noexpiry'] = '${PROTECTIONBLURB}.',<br />
['intro-fragment-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY},',<br />
['intro-fragment-noexpiry'] = '${PROTECTIONBLURB}',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Tooltip blurb<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages specify what is produced by the ${TOOLTIPBLURB} parameter.<br />
-- If the protection is temporary the tooltip-blurb-expiry message is used, and<br />
-- if not the tooltip-blurb-noexpiry message is used.<br />
-- It is possible to use banner parameters in these messages.<br />
['tooltip-blurb-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY}.',<br />
['tooltip-blurb-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}.',<br />
['tooltip-fragment-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY},',<br />
['tooltip-fragment-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Special explanation blurb<br />
--------------------------------------------------------------------------------<br />
<br />
-- An explanation blurb for pages that cannot be unprotected, e.g. for pages<br />
-- in the MediaWiki namespace.<br />
-- It is possible to use banner parameters in this message.<br />
['explanation-blurb-nounprotect'] = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' Please discuss any changes on the ${TALKPAGE}; you'<br />
.. ' may ${EDITREQUEST} to ask an'<br />
.. ' [[Wikipedia:Administrators|administrator]] to make an edit if it'<br />
.. ' is [[Help:Minor edit#When to mark an edit as a minor edit'<br />
.. '|uncontroversial]] or supported by [[Wikipedia:Consensus'<br />
.. '|consensus]].',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection log display values<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages determine the display values for the protection log link<br />
-- or the pending changes log link produced by the ${PROTECTIONLOG} parameter.<br />
-- It is possible to use banner parameters in these messages.<br />
['protection-log-display'] = 'protection log',<br />
['pc-log-display'] = 'pending changes log',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Current version display values<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages determine the display values for the page history link<br />
-- or the move log link produced by the ${CURRENTVERSION} parameter.<br />
-- It is possible to use banner parameters in these messages.<br />
['current-version-move-display'] = 'current title',<br />
['current-version-edit-display'] = 'current version',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Talk page<br />
--------------------------------------------------------------------------------<br />
<br />
-- This message determines the display value of the talk page link produced<br />
-- with the ${TALKPAGE} parameter.<br />
-- It is possible to use banner parameters in this message.<br />
['talk-page-link-display'] = 'talk page',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Edit requests<br />
--------------------------------------------------------------------------------<br />
<br />
-- This message determines the display value of the edit request link produced<br />
-- with the ${EDITREQUEST} parameter.<br />
-- It is possible to use banner parameters in this message.<br />
['edit-request-display'] = 'submit an edit request',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Expiry date format<br />
--------------------------------------------------------------------------------<br />
<br />
-- This is the format for the blurb expiry date. It should be valid input for<br />
-- the first parameter of the #time parser function.<br />
['expiry-date-format'] = 'F j, Y',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Tracking categories<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages determine which tracking categories the module outputs.<br />
['tracking-category-incorrect'] = 'Wikipedia pages with incorrect protection templates',<br />
['tracking-category-expiry'] = 'Wikipedia protected pages without expiry',<br />
['tracking-category-template'] = 'Wikipedia template-protected pages other than templates and modules',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Images<br />
--------------------------------------------------------------------------------<br />
<br />
-- These are images that are not defined by their protection action and protection level.<br />
['image-filename-indef'] = 'Padlock.svg',<br />
['image-filename-default'] = 'Transparent.gif',<br />
<br />
--------------------------------------------------------------------------------<br />
-- End messages<br />
--------------------------------------------------------------------------------<br />
}<br />
<br />
--------------------------------------------------------------------------------<br />
-- End configuration<br />
--------------------------------------------------------------------------------<br />
}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Protection_banner&diff=60774Module:Protection banner2016-07-12T23:19:52Z<p>WikiSysop: 1 revision</p>
<hr />
<div>-- This module implements {{pp-meta}} and its daughter templates such as<br />
-- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}.<br />
<br />
-- Initialise necessary modules.<br />
require('Module:No globals')<br />
local makeFileLink = require('Module:File link')._main<br />
local effectiveProtectionLevel = require('Module:Effective protection level')._main<br />
local effectiveProtectionExpiry = require('Module:Effective protection expiry')._main<br />
local yesno = require('Module:Yesno')<br />
<br />
-- Lazily initialise modules and objects we don't always need.<br />
local getArgs, makeMessageBox, lang<br />
<br />
-- Set constants.<br />
local CONFIG_MODULE = 'Module:Protection banner/config'<br />
<br />
--------------------------------------------------------------------------------<br />
-- Helper functions<br />
--------------------------------------------------------------------------------<br />
<br />
local function makeCategoryLink(cat, sort)<br />
local nsText = mw.site.namespaces[14].name<br />
if cat and sort then<br />
return string.format(<br />
'[[%s:%s|%s]]',<br />
nsText,<br />
cat,<br />
sort<br />
)<br />
elseif cat then<br />
return string.format(<br />
'[[%s:%s]]',<br />
nsText,<br />
cat<br />
)<br />
else<br />
return ''<br />
end<br />
end<br />
<br />
-- Validation function for the expiry and the protection date<br />
local function validateDate(dateString, dateType)<br />
lang = lang or mw.language.getContentLanguage()<br />
local success, result = pcall(lang.formatDate, lang, 'U', dateString)<br />
if success then<br />
result = tonumber(result)<br />
if result then<br />
return result<br />
end<br />
end<br />
error(string.format(<br />
'invalid %s ("%s")',<br />
dateType,<br />
tostring(dateString)<br />
), 4)<br />
end<br />
<br />
local function makeFullUrl(page, query, display)<br />
return string.format(<br />
'[%s %s]',<br />
tostring(mw.uri.fullUrl(page, query)),<br />
display<br />
)<br />
end<br />
<br />
local function toTableEnd(t, pos)<br />
-- Sends the value at position pos to the end of array t, and shifts the<br />
-- other items down accordingly.<br />
return table.insert(t, table.remove(t, pos))<br />
end<br />
<br />
local function walkHierarchy(hierarchy, start)<br />
local toWalk, retval = {[start] = true}, {}<br />
while true do<br />
-- Can't use pairs() since we're adding and removing things as we're iterating<br />
local k = next(toWalk) -- This always gets the "first" key<br />
if k == nil then break end<br />
toWalk[k] = nil<br />
retval[k] = true<br />
for _,v in ipairs(hierarchy[k]) do<br />
if not retval[v] then<br />
toWalk[v] = true<br />
end<br />
end<br />
end<br />
return retval<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection class<br />
--------------------------------------------------------------------------------<br />
<br />
local Protection = {}<br />
Protection.__index = Protection<br />
<br />
Protection.supportedActions = {<br />
edit = true,<br />
move = true,<br />
autoreview = true,<br />
upload = true<br />
}<br />
<br />
Protection.bannerConfigFields = {<br />
'text',<br />
'explanation',<br />
'tooltip',<br />
'alt',<br />
'link',<br />
'image'<br />
}<br />
<br />
function Protection.new(args, cfg, title)<br />
local obj = {}<br />
obj._cfg = cfg<br />
obj.title = title or mw.title.getCurrentTitle()<br />
<br />
-- Set action<br />
if not args.action then<br />
obj.action = 'edit'<br />
elseif Protection.supportedActions[args.action] then<br />
obj.action = args.action<br />
else<br />
error(string.format(<br />
'invalid action ("%s")',<br />
tostring(args.action)<br />
), 3)<br />
end<br />
<br />
-- Set level<br />
obj.level = args.demolevel or effectiveProtectionLevel(obj.action, obj.title)<br />
if not obj.level or (obj.action == 'move' and obj.level == 'autoconfirmed') then<br />
-- Users need to be autoconfirmed to move pages anyway, so treat<br />
-- semi-move-protected pages as unprotected.<br />
obj.level = '*'<br />
end<br />
<br />
-- Set expiry<br />
local effectiveExpiry = effectiveProtectionExpiry(obj.action, obj.title)<br />
if effectiveExpiry == 'infinity' then<br />
obj.expiry = 'indef'<br />
elseif effectiveExpiry ~= 'unknown' then<br />
obj.expiry = validateDate(effectiveExpiry, 'expiry date')<br />
elseif args.expiry then<br />
if cfg.indefStrings[args.expiry] then<br />
obj.expiry = 'indef'<br />
elseif type(args.expiry) == 'number' then<br />
obj.expiry = args.expiry<br />
else<br />
obj.expiry = validateDate(args.expiry, 'expiry date')<br />
end<br />
end<br />
<br />
-- Set reason<br />
if args[1] then<br />
obj.reason = mw.ustring.lower(args[1])<br />
if obj.reason:find('|') then<br />
error('reasons cannot contain the pipe character ("|")', 3)<br />
end<br />
end<br />
<br />
-- Set protection date<br />
if args.date then<br />
obj.protectionDate = validateDate(args.date, 'protection date')<br />
end<br />
<br />
-- Set banner config<br />
do<br />
obj.bannerConfig = {}<br />
local configTables = {}<br />
if cfg.banners[obj.action] then<br />
configTables[#configTables + 1] = cfg.banners[obj.action][obj.reason]<br />
end<br />
if cfg.defaultBanners[obj.action] then<br />
configTables[#configTables + 1] = cfg.defaultBanners[obj.action][obj.level]<br />
configTables[#configTables + 1] = cfg.defaultBanners[obj.action].default<br />
end<br />
configTables[#configTables + 1] = cfg.masterBanner<br />
for i, field in ipairs(Protection.bannerConfigFields) do<br />
for j, t in ipairs(configTables) do<br />
if t[field] then<br />
obj.bannerConfig[field] = t[field]<br />
break<br />
end<br />
end<br />
end<br />
end<br />
return setmetatable(obj, Protection)<br />
end<br />
<br />
function Protection:isProtected()<br />
return self.level ~= '*'<br />
end<br />
<br />
function Protection:isTemporary()<br />
return type(self.expiry) == 'number'<br />
end<br />
<br />
function Protection:makeProtectionCategory()<br />
local cfg = self._cfg<br />
local title = self.title<br />
<br />
-- Exit if the page is not protected.<br />
if not self:isProtected() then<br />
return ''<br />
end<br />
<br />
-- Get the expiry key fragment.<br />
local expiryFragment<br />
if self.expiry == 'indef' then<br />
expiryFragment = self.expiry<br />
elseif type(self.expiry) == 'number' then<br />
expiryFragment = 'temp'<br />
end<br />
<br />
-- Get the namespace key fragment.<br />
local namespaceFragment<br />
do<br />
namespaceFragment = cfg.categoryNamespaceKeys[title.namespace]<br />
if not namespaceFragment and title.namespace % 2 == 1 then<br />
namespaceFragment = 'talk'<br />
end<br />
end<br />
<br />
-- Define the order that key fragments are tested in. This is done with an<br />
-- array of tables containing the value to be tested, along with its<br />
-- position in the cfg.protectionCategories table.<br />
local order = {<br />
{val = expiryFragment, keypos = 1},<br />
{val = namespaceFragment, keypos = 2},<br />
{val = self.reason, keypos = 3},<br />
{val = self.level, keypos = 4},<br />
{val = self.action, keypos = 5}<br />
}<br />
<br />
--[[<br />
-- The old protection templates used an ad-hoc protection category system,<br />
-- with some templates prioritising namespaces in their categories, and<br />
-- others prioritising the protection reason. To emulate this in this module<br />
-- we use the config table cfg.reasonsWithNamespacePriority to set the<br />
-- reasons for which namespaces have priority over protection reason.<br />
-- If we are dealing with one of those reasons, move the namespace table to<br />
-- the end of the order table, i.e. give it highest priority. If not, the<br />
-- reason should have highest priority, so move that to the end of the table<br />
-- instead.<br />
--]]<br />
if self.reason and cfg.reasonsWithNamespacePriority[self.reason] then<br />
-- table.insert(order, 3, table.remove(order, 2))<br />
toTableEnd(order, 2)<br />
else<br />
toTableEnd(order, 3)<br />
end<br />
<br />
--[[<br />
-- Define the attempt order. Inactive subtables (subtables with nil "value"<br />
-- fields) are moved to the end, where they will later be given the key<br />
-- "all". This is to cut down on the number of table lookups in<br />
-- cfg.protectionCategories, which grows exponentially with the number of<br />
-- non-nil keys. We keep track of the number of active subtables with the<br />
-- noActive parameter.<br />
--]]<br />
local noActive, attemptOrder<br />
do<br />
local active, inactive = {}, {}<br />
for i, t in ipairs(order) do<br />
if t.val then<br />
active[#active + 1] = t<br />
else<br />
inactive[#inactive + 1] = t<br />
end<br />
end<br />
noActive = #active<br />
attemptOrder = active<br />
for i, t in ipairs(inactive) do<br />
attemptOrder[#attemptOrder + 1] = t<br />
end<br />
end<br />
<br />
--[[<br />
-- Check increasingly generic key combinations until we find a match. If a<br />
-- specific category exists for the combination of key fragments we are<br />
-- given, that match will be found first. If not, we keep trying different<br />
-- key fragment combinations until we match using the key<br />
-- "all-all-all-all-all".<br />
--<br />
-- To generate the keys, we index the key subtables using a binary matrix<br />
-- with indexes i and j. j is only calculated up to the number of active<br />
-- subtables. For example, if there were three active subtables, the matrix<br />
-- would look like this, with 0 corresponding to the key fragment "all", and<br />
-- 1 corresponding to other key fragments.<br />
-- <br />
-- j 1 2 3<br />
-- i <br />
-- 1 1 1 1<br />
-- 2 0 1 1<br />
-- 3 1 0 1<br />
-- 4 0 0 1<br />
-- 5 1 1 0<br />
-- 6 0 1 0<br />
-- 7 1 0 0<br />
-- 8 0 0 0<br />
-- <br />
-- Values of j higher than the number of active subtables are set<br />
-- to the string "all".<br />
--<br />
-- A key for cfg.protectionCategories is constructed for each value of i.<br />
-- The position of the value in the key is determined by the keypos field in<br />
-- each subtable.<br />
--]]<br />
local cats = cfg.protectionCategories<br />
for i = 1, 2^noActive do<br />
local key = {}<br />
for j, t in ipairs(attemptOrder) do<br />
if j > noActive then<br />
key[t.keypos] = 'all'<br />
else<br />
local quotient = i / 2 ^ (j - 1)<br />
quotient = math.ceil(quotient)<br />
if quotient % 2 == 1 then<br />
key[t.keypos] = t.val<br />
else<br />
key[t.keypos] = 'all'<br />
end<br />
end<br />
end<br />
key = table.concat(key, '|')<br />
local attempt = cats[key]<br />
if attempt then<br />
return makeCategoryLink(attempt, title.text)<br />
end<br />
end<br />
return ''<br />
end<br />
<br />
function Protection:needsExpiry()<br />
local cfg = self._cfg<br />
local actionNeedsCheck = cfg.expiryCheckActions[self.action]<br />
return not self.expiry and (<br />
actionNeedsCheck or (<br />
actionNeedsCheck == nil<br />
and self.reason -- the old {{pp-protected}} didn't check for expiry<br />
and not cfg.reasonsWithoutExpiryCheck[self.reason]<br />
)<br />
)<br />
end<br />
<br />
function Protection:isIncorrect()<br />
local expiry = self.expiry<br />
return not self:isProtected()<br />
or type(expiry) == 'number' and expiry < os.time()<br />
end<br />
<br />
function Protection:isTemplateProtectedNonTemplate()<br />
local action, namespace = self.action, self.title.namespace<br />
return self.level == 'templateeditor'<br />
and (<br />
(action ~= 'edit' and action ~= 'move')<br />
or (namespace ~= 10 and namespace ~= 828)<br />
)<br />
end<br />
<br />
function Protection:makeCategoryLinks()<br />
local msg = self._cfg.msg<br />
local ret = { self:makeProtectionCategory() }<br />
if self:needsExpiry() then<br />
ret[#ret + 1] = makeCategoryLink(<br />
msg['tracking-category-expiry'],<br />
self.title.text<br />
)<br />
end<br />
if self:isIncorrect() then<br />
ret[#ret + 1] = makeCategoryLink(<br />
msg['tracking-category-incorrect'],<br />
self.title.text<br />
)<br />
end<br />
if self:isTemplateProtectedNonTemplate() then<br />
ret[#ret + 1] = makeCategoryLink(<br />
msg['tracking-category-template'],<br />
self.title.text<br />
)<br />
end<br />
return table.concat(ret)<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Blurb class<br />
--------------------------------------------------------------------------------<br />
<br />
local Blurb = {}<br />
Blurb.__index = Blurb<br />
<br />
Blurb.bannerTextFields = {<br />
text = true,<br />
explanation = true,<br />
tooltip = true,<br />
alt = true,<br />
link = true<br />
}<br />
<br />
function Blurb.new(protectionObj, args, cfg)<br />
return setmetatable({<br />
_cfg = cfg,<br />
_protectionObj = protectionObj,<br />
_args = args<br />
}, Blurb)<br />
end<br />
<br />
-- Private methods --<br />
<br />
function Blurb:_formatDate(num)<br />
-- Formats a Unix timestamp into dd Month, YYYY format.<br />
lang = lang or mw.language.getContentLanguage()<br />
local success, date = pcall(<br />
lang.formatDate,<br />
lang,<br />
self._cfg.msg['expiry-date-format'] or 'j F Y',<br />
'@' .. tostring(num)<br />
)<br />
if success then<br />
return date<br />
end<br />
end<br />
<br />
function Blurb:_getExpandedMessage(msgKey)<br />
return self:_substituteParameters(self._cfg.msg[msgKey])<br />
end<br />
<br />
function Blurb:_substituteParameters(msg)<br />
if not self._params then<br />
local parameterFuncs = {}<br />
<br />
parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter<br />
parameterFuncs.EDITREQUEST = self._makeEditRequestParameter<br />
parameterFuncs.EXPIRY = self._makeExpiryParameter<br />
parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter<br />
parameterFuncs.IMAGELINK = self._makeImageLinkParameter<br />
parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter<br />
parameterFuncs.INTROFRAGMENT = self._makeIntroFragmentParameter<br />
parameterFuncs.PAGETYPE = self._makePagetypeParameter<br />
parameterFuncs.PROTECTIONBLURB = self._makeProtectionBlurbParameter<br />
parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter<br />
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter<br />
parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter<br />
parameterFuncs.TALKPAGE = self._makeTalkPageParameter<br />
parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter<br />
parameterFuncs.TOOLTIPFRAGMENT = self._makeTooltipFragmentParameter<br />
parameterFuncs.VANDAL = self._makeVandalTemplateParameter<br />
<br />
self._params = setmetatable({}, {<br />
__index = function (t, k)<br />
local param<br />
if parameterFuncs[k] then<br />
param = parameterFuncs[k](self)<br />
end<br />
param = param or ''<br />
t[k] = param<br />
return param<br />
end<br />
})<br />
end<br />
<br />
msg = msg:gsub('${(%u+)}', self._params)<br />
return msg<br />
end<br />
<br />
function Blurb:_makeCurrentVersionParameter()<br />
-- A link to the page history or the move log, depending on the kind of<br />
-- protection.<br />
local pagename = self._protectionObj.title.prefixedText<br />
if self._protectionObj.action == 'move' then<br />
-- We need the move log link.<br />
return makeFullUrl(<br />
'Special:Log',<br />
{type = 'move', page = pagename},<br />
self:_getExpandedMessage('current-version-move-display')<br />
)<br />
else<br />
-- We need the history link.<br />
return makeFullUrl(<br />
pagename,<br />
{action = 'history'},<br />
self:_getExpandedMessage('current-version-edit-display')<br />
)<br />
end<br />
end<br />
<br />
function Blurb:_makeEditRequestParameter()<br />
local mEditRequest = require('Module:Submit an edit request')<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
<br />
-- Get the edit request type.<br />
local requestType<br />
if action == 'edit' then<br />
if level == 'autoconfirmed' then<br />
requestType = 'semi'<br />
elseif level == 'templateeditor' then<br />
requestType = 'template'<br />
end<br />
end<br />
requestType = requestType or 'full'<br />
<br />
-- Get the display value.<br />
local display = self:_getExpandedMessage('edit-request-display')<br />
<br />
return mEditRequest._link{type = requestType, display = display}<br />
end<br />
<br />
function Blurb:_makeExpiryParameter()<br />
local expiry = self._protectionObj.expiry<br />
if type(expiry) == 'number' then<br />
return self:_formatDate(expiry)<br />
else<br />
return expiry<br />
end<br />
end<br />
<br />
function Blurb:_makeExplanationBlurbParameter()<br />
-- Cover special cases first.<br />
if self._protectionObj.title.namespace == 8 then<br />
-- MediaWiki namespace<br />
return self:_getExpandedMessage('explanation-blurb-nounprotect')<br />
end<br />
<br />
-- Get explanation blurb table keys<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
local talkKey = self._protectionObj.title.isTalkPage and 'talk' or 'subject'<br />
<br />
-- Find the message in the explanation blurb table and substitute any<br />
-- parameters.<br />
local explanations = self._cfg.explanationBlurbs<br />
local msg<br />
if explanations[action][level] and explanations[action][level][talkKey] then<br />
msg = explanations[action][level][talkKey]<br />
elseif explanations[action][level] and explanations[action][level].default then<br />
msg = explanations[action][level].default<br />
elseif explanations[action].default and explanations[action].default[talkKey] then<br />
msg = explanations[action].default[talkKey]<br />
elseif explanations[action].default and explanations[action].default.default then<br />
msg = explanations[action].default.default<br />
else<br />
error(string.format(<br />
'could not find explanation blurb for action "%s", level "%s" and talk key "%s"',<br />
action,<br />
level,<br />
talkKey<br />
), 8)<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
<br />
function Blurb:_makeImageLinkParameter()<br />
local imageLinks = self._cfg.imageLinks<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
local msg<br />
if imageLinks[action][level] then<br />
msg = imageLinks[action][level]<br />
elseif imageLinks[action].default then<br />
msg = imageLinks[action].default<br />
else<br />
msg = imageLinks.edit.default<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
<br />
function Blurb:_makeIntroBlurbParameter()<br />
if self._protectionObj:isTemporary() then<br />
return self:_getExpandedMessage('intro-blurb-expiry')<br />
else<br />
return self:_getExpandedMessage('intro-blurb-noexpiry')<br />
end<br />
end<br />
<br />
function Blurb:_makeIntroFragmentParameter()<br />
if self._protectionObj:isTemporary() then<br />
return self:_getExpandedMessage('intro-fragment-expiry')<br />
else<br />
return self:_getExpandedMessage('intro-fragment-noexpiry')<br />
end<br />
end<br />
<br />
function Blurb:_makePagetypeParameter()<br />
local pagetypes = self._cfg.pagetypes<br />
return pagetypes[self._protectionObj.title.namespace]<br />
or pagetypes.default<br />
or error('no default pagetype defined', 8)<br />
end<br />
<br />
function Blurb:_makeProtectionBlurbParameter()<br />
local protectionBlurbs = self._cfg.protectionBlurbs<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
local msg<br />
if protectionBlurbs[action][level] then<br />
msg = protectionBlurbs[action][level]<br />
elseif protectionBlurbs[action].default then<br />
msg = protectionBlurbs[action].default<br />
elseif protectionBlurbs.edit.default then<br />
msg = protectionBlurbs.edit.default<br />
else<br />
error('no protection blurb defined for protectionBlurbs.edit.default', 8)<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
<br />
function Blurb:_makeProtectionDateParameter()<br />
local protectionDate = self._protectionObj.protectionDate<br />
if type(protectionDate) == 'number' then<br />
return self:_formatDate(protectionDate)<br />
else<br />
return protectionDate<br />
end<br />
end<br />
<br />
function Blurb:_makeProtectionLevelParameter()<br />
local protectionLevels = self._cfg.protectionLevels<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
local msg<br />
if protectionLevels[action][level] then<br />
msg = protectionLevels[action][level]<br />
elseif protectionLevels[action].default then<br />
msg = protectionLevels[action].default<br />
elseif protectionLevels.edit.default then<br />
msg = protectionLevels.edit.default<br />
else<br />
error('no protection level defined for protectionLevels.edit.default', 8)<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
<br />
function Blurb:_makeProtectionLogParameter()<br />
local pagename = self._protectionObj.title.prefixedText<br />
if self._protectionObj.action == 'autoreview' then<br />
-- We need the pending changes log.<br />
return makeFullUrl(<br />
'Special:Log',<br />
{type = 'stable', page = pagename},<br />
self:_getExpandedMessage('pc-log-display')<br />
)<br />
else<br />
-- We need the protection log.<br />
return makeFullUrl(<br />
'Special:Log',<br />
{type = 'protect', page = pagename},<br />
self:_getExpandedMessage('protection-log-display')<br />
)<br />
end<br />
end<br />
<br />
function Blurb:_makeTalkPageParameter()<br />
return string.format(<br />
'[[%s:%s#%s|%s]]',<br />
mw.site.namespaces[self._protectionObj.title.namespace].talk.name,<br />
self._protectionObj.title.text,<br />
self._args.section or 'top',<br />
self:_getExpandedMessage('talk-page-link-display')<br />
)<br />
end<br />
<br />
function Blurb:_makeTooltipBlurbParameter()<br />
if self._protectionObj:isTemporary() then<br />
return self:_getExpandedMessage('tooltip-blurb-expiry')<br />
else<br />
return self:_getExpandedMessage('tooltip-blurb-noexpiry')<br />
end<br />
end<br />
<br />
function Blurb:_makeTooltipFragmentParameter()<br />
if self._protectionObj:isTemporary() then<br />
return self:_getExpandedMessage('tooltip-fragment-expiry')<br />
else<br />
return self:_getExpandedMessage('tooltip-fragment-noexpiry')<br />
end<br />
end<br />
<br />
function Blurb:_makeVandalTemplateParameter()<br />
return require('Module:Vandal-m')._main{<br />
self._args.user or self._protectionObj.title.baseText<br />
}<br />
end<br />
<br />
-- Public methods --<br />
<br />
function Blurb:makeBannerText(key)<br />
-- Validate input.<br />
if not key or not Blurb.bannerTextFields[key] then<br />
error(string.format(<br />
'"%s" is not a valid banner config field',<br />
tostring(key)<br />
), 2)<br />
end<br />
<br />
-- Generate the text.<br />
local msg = self._protectionObj.bannerConfig[key]<br />
if type(msg) == 'string' then<br />
return self:_substituteParameters(msg)<br />
elseif type(msg) == 'function' then<br />
msg = msg(self._protectionObj, self._args)<br />
if type(msg) ~= 'string' then<br />
error(string.format(<br />
'bad output from banner config function with key "%s"'<br />
.. ' (expected string, got %s)',<br />
tostring(key),<br />
type(msg)<br />
), 4)<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- BannerTemplate class<br />
--------------------------------------------------------------------------------<br />
<br />
local BannerTemplate = {}<br />
BannerTemplate.__index = BannerTemplate<br />
<br />
function BannerTemplate.new(protectionObj, cfg)<br />
local obj = {}<br />
obj._cfg = cfg<br />
<br />
-- Set the image filename.<br />
local imageFilename = protectionObj.bannerConfig.image<br />
if imageFilename then<br />
obj._imageFilename = imageFilename<br />
else<br />
-- If an image filename isn't specified explicitly in the banner config,<br />
-- generate it from the protection status and the namespace.<br />
local action = protectionObj.action<br />
local level = protectionObj.level<br />
local namespace = protectionObj.title.namespace<br />
local reason = protectionObj.reason<br />
<br />
-- Deal with special cases first.<br />
if (<br />
namespace == 10<br />
or namespace == 828<br />
or reason and obj._cfg.indefImageReasons[reason]<br />
)<br />
and action == 'edit'<br />
and level == 'sysop'<br />
and not protectionObj:isTemporary()<br />
then<br />
-- Fully protected modules and templates get the special red "indef"<br />
-- padlock.<br />
obj._imageFilename = obj._cfg.msg['image-filename-indef']<br />
else<br />
-- Deal with regular protection types.<br />
local images = obj._cfg.images<br />
if images[action] then<br />
if images[action][level] then<br />
obj._imageFilename = images[action][level]<br />
elseif images[action].default then<br />
obj._imageFilename = images[action].default<br />
end<br />
end<br />
end<br />
end<br />
return setmetatable(obj, BannerTemplate)<br />
end<br />
<br />
function BannerTemplate:setImageWidth(width)<br />
self._imageWidth = width<br />
end<br />
<br />
function BannerTemplate:setImageTooltip(tooltip)<br />
self._imageCaption = tooltip<br />
end<br />
<br />
function BannerTemplate:renderImage()<br />
local filename = self._imageFilename<br />
or self._cfg.msg['image-filename-default']<br />
or 'Transparent.gif'<br />
return makeFileLink{<br />
file = filename,<br />
size = (self._imageWidth or 20) .. 'px',<br />
alt = self._imageAlt,<br />
link = self._imageLink,<br />
caption = self._imageCaption<br />
}<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Banner class<br />
--------------------------------------------------------------------------------<br />
<br />
local Banner = setmetatable({}, BannerTemplate)<br />
Banner.__index = Banner<br />
<br />
function Banner.new(protectionObj, blurbObj, cfg)<br />
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.<br />
obj:setImageWidth(40)<br />
obj:setImageTooltip(blurbObj:makeBannerText('alt')) -- Large banners use the alt text for the tooltip.<br />
obj._reasonText = blurbObj:makeBannerText('text')<br />
obj._explanationText = blurbObj:makeBannerText('explanation')<br />
obj._page = protectionObj.title.prefixedText -- Only makes a difference in testing.<br />
return setmetatable(obj, Banner)<br />
end<br />
<br />
function Banner:__tostring()<br />
-- Renders the banner.<br />
makeMessageBox = makeMessageBox or require('Module:Message box').main<br />
local reasonText = self._reasonText or error('no reason text set', 2)<br />
local explanationText = self._explanationText<br />
local mbargs = {<br />
page = self._page,<br />
type = 'protection',<br />
image = self:renderImage(),<br />
text = string.format(<br />
"'''%s'''%s",<br />
reasonText,<br />
explanationText and '<br />' .. explanationText or ''<br />
)<br />
}<br />
return makeMessageBox('mbox', mbargs)<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Padlock class<br />
--------------------------------------------------------------------------------<br />
<br />
local Padlock = setmetatable({}, BannerTemplate)<br />
Padlock.__index = Padlock<br />
<br />
function Padlock.new(protectionObj, blurbObj, cfg)<br />
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.<br />
obj:setImageWidth(20)<br />
obj:setImageTooltip(blurbObj:makeBannerText('tooltip'))<br />
obj._imageAlt = blurbObj:makeBannerText('alt')<br />
obj._imageLink = blurbObj:makeBannerText('link')<br />
obj._indicatorName = cfg.padlockIndicatorNames[protectionObj.action]<br />
or cfg.padlockIndicatorNames.default<br />
or 'pp-default'<br />
return setmetatable(obj, Padlock)<br />
end<br />
<br />
function Padlock:__tostring()<br />
local frame = mw.getCurrentFrame()<br />
-- The nowiki tag helps prevent whitespace at the top of articles.<br />
local nowiki = frame:extensionTag{name = 'nowiki'}<br />
local indicator = frame:extensionTag{<br />
name = 'indicator',<br />
args = {name = self._indicatorName},<br />
content = self:renderImage()<br />
}<br />
return nowiki .. indicator<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Exports<br />
--------------------------------------------------------------------------------<br />
<br />
local p = {}<br />
<br />
function p._exportClasses()<br />
-- This is used for testing purposes.<br />
return {<br />
Protection = Protection,<br />
Blurb = Blurb,<br />
BannerTemplate = BannerTemplate,<br />
Banner = Banner,<br />
Padlock = Padlock,<br />
}<br />
end<br />
<br />
function p._main(args, cfg, title)<br />
args = args or {}<br />
cfg = cfg or require(CONFIG_MODULE)<br />
<br />
local protectionObj = Protection.new(args, cfg, title)<br />
<br />
local ret = {}<br />
<br />
-- If a page's edit protection is equally or more restrictive than its<br />
-- protection from some other action, then don't bother displaying anything<br />
-- for the other action (except categories).<br />
if protectionObj.action == 'edit' or<br />
args.demolevel or<br />
not walkHierarchy(<br />
cfg.hierarchy,<br />
protectionObj.level<br />
)[effectiveProtectionLevel('edit', protectionObj.title)]<br />
then<br />
-- Initialise the blurb object<br />
local blurbObj = Blurb.new(protectionObj, args, cfg)<br />
<br />
-- Render the banner<br />
if protectionObj:isProtected() then<br />
ret[#ret + 1] = tostring(<br />
(yesno(args.small) and Padlock or Banner)<br />
.new(protectionObj, blurbObj, cfg)<br />
)<br />
end<br />
end<br />
<br />
-- Render the categories<br />
if yesno(args.category) ~= false then<br />
ret[#ret + 1] = protectionObj:makeCategoryLinks()<br />
end<br />
<br />
return table.concat(ret) <br />
end<br />
<br />
function p.main(frame, cfg)<br />
cfg = cfg or require(CONFIG_MODULE)<br />
<br />
-- Find default args, if any.<br />
local parent = frame.getParent and frame:getParent()<br />
local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')]<br />
<br />
-- Find user args, and use the parent frame if we are being called from a<br />
-- wrapper template.<br />
getArgs = getArgs or require('Module:Arguments').getArgs<br />
local userArgs = getArgs(frame, {<br />
parentOnly = defaultArgs,<br />
frameOnly = not defaultArgs<br />
})<br />
<br />
-- Build the args table. User-specified args overwrite default args.<br />
local args = {}<br />
for k, v in pairs(defaultArgs or {}) do<br />
args[k] = v<br />
end<br />
for k, v in pairs(userArgs) do<br />
args[k] = v<br />
end<br />
return p._main(args, cfg)<br />
end<br />
<br />
return p</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:No_globals&diff=60772Module:No globals2016-07-12T23:19:51Z<p>WikiSysop: 1 revision</p>
<hr />
<div>local mt = getmetatable(_G) or {}<br />
function mt.__index (t, k)<br />
if k ~= 'arg' then<br />
error('Tried to read nil global ' .. tostring(k), 2)<br />
end<br />
return nil<br />
end<br />
function mt.__newindex(t, k, v)<br />
if k ~= 'arg' then<br />
error('Tried to write global ' .. tostring(k), 2)<br />
end<br />
rawset(t, k, v)<br />
end<br />
setmetatable(_G, mt)</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Namespace_detect/data&diff=60770Module:Namespace detect/data2016-07-12T23:19:51Z<p>WikiSysop: 1 revision</p>
<hr />
<div>--------------------------------------------------------------------------------<br />
-- Namespace detect data --<br />
-- This module holds data for [[Module:Namespace detect]] to be loaded per --<br />
-- page, rather than per #invoke, for performance reasons. --<br />
--------------------------------------------------------------------------------<br />
<br />
local cfg = require('Module:Namespace detect/config')<br />
<br />
local function addKey(t, key, defaultKey)<br />
if key ~= defaultKey then<br />
t[#t + 1] = key<br />
end<br />
end<br />
<br />
-- Get a table of parameters to query for each default parameter name.<br />
-- This allows wikis to customise parameter names in the cfg table while<br />
-- ensuring that default parameter names will always work. The cfg table<br />
-- values can be added as a string, or as an array of strings.<br />
<br />
local defaultKeys = {<br />
'main',<br />
'talk',<br />
'other',<br />
'subjectns',<br />
'demospace',<br />
'demopage'<br />
}<br />
<br />
local argKeys = {}<br />
for i, defaultKey in ipairs(defaultKeys) do<br />
argKeys[defaultKey] = {defaultKey}<br />
end<br />
<br />
for defaultKey, t in pairs(argKeys) do<br />
local cfgValue = cfg[defaultKey]<br />
local cfgValueType = type(cfgValue)<br />
if cfgValueType == 'string' then<br />
addKey(t, cfgValue, defaultKey)<br />
elseif cfgValueType == 'table' then<br />
for i, key in ipairs(cfgValue) do<br />
addKey(t, key, defaultKey)<br />
end<br />
end<br />
cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more.<br />
end<br />
<br />
local function getParamMappings()<br />
--[[<br />
-- Returns a table of how parameter names map to namespace names. The keys<br />
-- are the actual namespace names, in lower case, and the values are the<br />
-- possible parameter names for that namespace, also in lower case. The<br />
-- table entries are structured like this:<br />
-- {<br />
-- [''] = {'main'},<br />
-- ['wikipedia'] = {'wikipedia', 'project', 'wp'},<br />
-- ...<br />
-- }<br />
--]]<br />
local mappings = {}<br />
local mainNsName = mw.site.subjectNamespaces[0].name<br />
mainNsName = mw.ustring.lower(mainNsName)<br />
mappings[mainNsName] = mw.clone(argKeys.main)<br />
mappings['talk'] = mw.clone(argKeys.talk)<br />
for nsid, ns in pairs(mw.site.subjectNamespaces) do<br />
if nsid ~= 0 then -- Exclude main namespace.<br />
local nsname = mw.ustring.lower(ns.name)<br />
local canonicalName = mw.ustring.lower(ns.canonicalName)<br />
mappings[nsname] = {nsname}<br />
if canonicalName ~= nsname then<br />
table.insert(mappings[nsname], canonicalName)<br />
end<br />
for _, alias in ipairs(ns.aliases) do<br />
table.insert(mappings[nsname], mw.ustring.lower(alias))<br />
end<br />
end<br />
end<br />
return mappings<br />
end<br />
<br />
return {<br />
argKeys = argKeys,<br />
cfg = cfg,<br />
mappings = getParamMappings()<br />
}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Namespace_detect/config&diff=60768Module:Namespace detect/config2016-07-12T23:19:51Z<p>WikiSysop: 1 revision</p>
<hr />
<div>--------------------------------------------------------------------------------<br />
-- Namespace detect configuration data --<br />
-- --<br />
-- This module stores configuration data for Module:Namespace detect. Here --<br />
-- you can localise the module to your wiki's language. --<br />
-- --<br />
-- To activate a configuration item, you need to uncomment it. This means --<br />
-- that you need to remove the text "-- " at the start of the line. --<br />
--------------------------------------------------------------------------------<br />
<br />
local cfg = {} -- Don't edit this line.<br />
<br />
--------------------------------------------------------------------------------<br />
-- Parameter names --<br />
-- These configuration items specify custom parameter names. Values added --<br />
-- here will work in addition to the default English parameter names. --<br />
-- To add one extra name, you can use this format: --<br />
-- --<br />
-- cfg.foo = 'parameter name' --<br />
-- --<br />
-- To add multiple names, you can use this format: --<br />
-- --<br />
-- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} --<br />
--------------------------------------------------------------------------------<br />
<br />
---- This parameter displays content for the main namespace:<br />
-- cfg.main = 'main'<br />
<br />
---- This parameter displays in talk namespaces:<br />
-- cfg.talk = 'talk'<br />
<br />
---- This parameter displays content for "other" namespaces (namespaces for which<br />
---- parameters have not been specified):<br />
-- cfg.other = 'other'<br />
<br />
---- This parameter makes talk pages behave as though they are the corresponding<br />
---- subject namespace. Note that this parameter is used with [[Module:Yesno]].<br />
---- Edit that module to change the default values of "yes", "no", etc.<br />
-- cfg.subjectns = 'subjectns'<br />
<br />
---- This parameter sets a demonstration namespace:<br />
-- cfg.demospace = 'demospace'<br />
<br />
---- This parameter sets a specific page to compare:<br />
cfg.demopage = 'page'<br />
<br />
--------------------------------------------------------------------------------<br />
-- Table configuration --<br />
-- These configuration items allow customisation of the "table" function, --<br />
-- used to generate a table of possible parameters in the module --<br />
-- documentation. --<br />
--------------------------------------------------------------------------------<br />
<br />
---- The header for the namespace column in the wikitable containing the list of<br />
---- possible subject-space parameters.<br />
-- cfg.wikitableNamespaceHeader = 'Namespace'<br />
<br />
---- The header for the wikitable containing the list of possible subject-space<br />
---- parameters.<br />
-- cfg.wikitableAliasesHeader = 'Aliases'<br />
<br />
--------------------------------------------------------------------------------<br />
-- End of configuration data --<br />
--------------------------------------------------------------------------------<br />
<br />
return cfg -- Don't edit this line.</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Message_box/configuration&diff=60766Module:Message box/configuration2016-07-12T23:19:51Z<p>WikiSysop: 1 revision</p>
<hr />
<div>--------------------------------------------------------------------------------<br />
-- Message box configuration --<br />
-- --<br />
-- This module contains configuration data for [[Module:Message box]]. --<br />
--------------------------------------------------------------------------------<br />
<br />
return {<br />
ambox = {<br />
types = {<br />
speedy = {<br />
class = 'ambox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'ambox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'ambox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'ambox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'ambox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'ambox-protection',<br />
image = 'Padlock-silver-medium.svg'<br />
},<br />
notice = {<br />
class = 'ambox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
allowBlankParams = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'},<br />
allowSmall = true,<br />
smallParam = 'left',<br />
smallClass = 'mbox-small-left',<br />
substCheck = true,<br />
classes = {'metadata', 'plainlinks', 'ambox'},<br />
imageEmptyCell = true,<br />
imageCheckBlank = true,<br />
imageSmallSize = '20x20px',<br />
imageCellDiv = true,<br />
useCollapsibleTextFields = true,<br />
imageRightNone = true,<br />
sectionDefault = 'article',<br />
allowMainspaceCategories = true,<br />
templateCategory = 'Article message templates',<br />
templateCategoryRequireName = true,<br />
templateErrorCategory = 'Article message templates with missing parameters',<br />
templateErrorParamsToCheck = {'issue', 'fix', 'subst'},<br />
removalNotice = '[[Help:Maintenance template removal|Learn how and when to remove this template message]]'<br />
},<br />
<br />
cmbox = {<br />
types = {<br />
speedy = {<br />
class = 'cmbox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'cmbox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'cmbox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'cmbox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'cmbox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'cmbox-protection',<br />
image = 'Padlock-silver-medium.svg'<br />
},<br />
notice = {<br />
class = 'cmbox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
showInvalidTypeError = true,<br />
classes = {'plainlinks', 'cmbox'},<br />
imageEmptyCell = true<br />
},<br />
<br />
fmbox = {<br />
types = {<br />
warning = {<br />
class = 'fmbox-warning',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
editnotice = {<br />
class = 'fmbox-editnotice',<br />
image = 'Information icon4.svg'<br />
},<br />
system = {<br />
class = 'fmbox-system',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'system',<br />
showInvalidTypeError = true,<br />
classes = {'plainlinks', 'fmbox'},<br />
imageEmptyCell = false,<br />
imageRightNone = false<br />
},<br />
<br />
imbox = {<br />
types = {<br />
speedy = {<br />
class = 'imbox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'imbox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'imbox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'imbox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'imbox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'imbox-protection',<br />
image = 'Padlock-silver-medium.svg'<br />
},<br />
license = {<br />
class = 'imbox-license licensetpl',<br />
image = 'Imbox license.png' -- @todo We need an SVG version of this<br />
},<br />
featured = {<br />
class = 'imbox-featured',<br />
image = 'Cscr-featured.svg'<br />
},<br />
notice = {<br />
class = 'imbox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
showInvalidTypeError = true,<br />
classes = {'imbox'},<br />
usePlainlinksParam = true,<br />
imageEmptyCell = true,<br />
below = true,<br />
templateCategory = 'File message boxes'<br />
},<br />
<br />
ombox = {<br />
types = {<br />
speedy = {<br />
class = 'ombox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'ombox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'ombox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'ombox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'ombox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'ombox-protection',<br />
image = 'Padlock-silver-medium.svg'<br />
},<br />
notice = {<br />
class = 'ombox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
showInvalidTypeError = true,<br />
classes = {'plainlinks', 'ombox'},<br />
allowSmall = true,<br />
imageEmptyCell = true,<br />
imageRightNone = true<br />
},<br />
<br />
tmbox = {<br />
types = {<br />
speedy = {<br />
class = 'tmbox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'tmbox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'tmbox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'tmbox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'tmbox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'tmbox-protection',<br />
image = 'Padlock-silver-medium.svg'<br />
},<br />
notice = {<br />
class = 'tmbox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
showInvalidTypeError = true,<br />
classes = {'plainlinks', 'tmbox'},<br />
allowSmall = true,<br />
imageRightNone = true,<br />
imageEmptyCell = true,<br />
imageEmptyCellStyle = true,<br />
templateCategory = 'Talk message boxes'<br />
}<br />
}</div>WikiSysophttps://public.kitware.com/Wiki/index.php?title=Module:Message_box&diff=60764Module:Message box2016-07-12T23:19:51Z<p>WikiSysop: 1 revision</p>
<hr />
<div>-- This is a meta-module for producing message box templates, including<br />
-- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}.<br />
<br />
-- Load necessary modules.<br />
require('Module:No globals')<br />
local getArgs<br />
local categoryHandler = require('Module:Category handler')._main<br />
local yesno = require('Module:Yesno')<br />
<br />
-- Get a language object for formatDate and ucfirst.<br />
local lang = mw.language.getContentLanguage()<br />
<br />
-- Define constants<br />
local CONFIG_MODULE = 'Module:Message box/configuration'<br />
<br />
--------------------------------------------------------------------------------<br />
-- Helper functions<br />
--------------------------------------------------------------------------------<br />
<br />
local function getTitleObject(...)<br />
-- Get the title object, passing the function through pcall<br />
-- in case we are over the expensive function count limit.<br />
local success, title = pcall(mw.title.new, ...)<br />
if success then<br />
return title<br />
end<br />
end<br />
<br />
local function union(t1, t2)<br />
-- Returns the union of two arrays.<br />
local vals = {}<br />
for i, v in ipairs(t1) do<br />
vals[v] = true<br />
end<br />
for i, v in ipairs(t2) do<br />
vals[v] = true<br />
end<br />
local ret = {}<br />
for k in pairs(vals) do<br />
table.insert(ret, k)<br />
end<br />
table.sort(ret)<br />
return ret<br />
end<br />
<br />
local function getArgNums(args, prefix)<br />
local nums = {}<br />
for k, v in pairs(args) do<br />
local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$')<br />
if num then<br />
table.insert(nums, tonumber(num))<br />
end<br />
end<br />
table.sort(nums)<br />
return nums<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Box class definition<br />
--------------------------------------------------------------------------------<br />
<br />
local MessageBox = {}<br />
MessageBox.__index = MessageBox<br />
<br />
function MessageBox.new(boxType, args, cfg)<br />
args = args or {}<br />
local obj = {}<br />
<br />
-- Set the title object and the namespace.<br />
obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()<br />
<br />
-- Set the config for our box type.<br />
obj.cfg = cfg[boxType]<br />
if not obj.cfg then<br />
local ns = obj.title.namespace<br />
-- boxType is "mbox" or invalid input<br />
if ns == 0 then<br />
obj.cfg = cfg.ambox -- main namespace<br />
elseif ns == 6 then<br />
obj.cfg = cfg.imbox -- file namespace<br />
elseif ns == 14 then<br />
obj.cfg = cfg.cmbox -- category namespace<br />
else<br />
local nsTable = mw.site.namespaces[ns]<br />
if nsTable and nsTable.isTalk then<br />
obj.cfg = cfg.tmbox -- any talk namespace<br />
else<br />
obj.cfg = cfg.ombox -- other namespaces or invalid input<br />
end<br />
end<br />
end<br />
<br />
-- Set the arguments, and remove all blank arguments except for the ones<br />
-- listed in cfg.allowBlankParams.<br />
do<br />
local newArgs = {}<br />
for k, v in pairs(args) do<br />
if v ~= '' then<br />
newArgs[k] = v<br />
end<br />
end<br />
for i, param in ipairs(obj.cfg.allowBlankParams or {}) do<br />
newArgs[param] = args[param]<br />
end<br />
obj.args = newArgs<br />
end<br />
<br />
-- Define internal data structure.<br />
obj.categories = {}<br />
obj.classes = {}<br />
<br />
return setmetatable(obj, MessageBox)<br />
end<br />
<br />
function MessageBox:addCat(ns, cat, sort)<br />
if not cat then<br />
return nil<br />
end<br />
if sort then<br />
cat = string.format('[[Category:%s|%s]]', cat, sort)<br />
else<br />
cat = string.format('[[Category:%s]]', cat)<br />
end<br />
self.categories[ns] = self.categories[ns] or {}<br />
table.insert(self.categories[ns], cat)<br />
end<br />
<br />
function MessageBox:addClass(class)<br />
if not class then<br />
return nil<br />
end<br />
table.insert(self.classes, class)<br />
end<br />
<br />
function MessageBox:setParameters()<br />
local args = self.args<br />
local cfg = self.cfg<br />
<br />
-- Get type data.<br />
self.type = args.type<br />
local typeData = cfg.types[self.type]<br />
self.invalidTypeError = cfg.showInvalidTypeError<br />
and self.type<br />
and not typeData<br />
typeData = typeData or cfg.types[cfg.default]<br />
self.typeClass = typeData.class<br />
self.typeImage = typeData.image<br />
<br />
-- Find if the box has been wrongly substituted.<br />
self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'<br />
<br />
-- Find whether we are using a small message box.<br />
self.isSmall = cfg.allowSmall and (<br />
cfg.smallParam and args.small == cfg.smallParam<br />
or not cfg.smallParam and yesno(args.small)<br />
)<br />
<br />
-- Add attributes, classes and styles.<br />
self.id = args.id<br />
self:addClass(<br />
cfg.usePlainlinksParam and yesno(args.plainlinks or true) and 'plainlinks'<br />
)<br />
for _, class in ipairs(cfg.classes or {}) do<br />
self:addClass(class)<br />
end<br />
if self.isSmall then<br />
self:addClass(cfg.smallClass or 'mbox-small')<br />
end<br />
self:addClass(self.typeClass)<br />
self:addClass(args.class)<br />
self.style = args.style<br />
self.attrs = args.attrs<br />
<br />
-- Set text style.<br />
self.textstyle = args.textstyle<br />
<br />
-- Find if we are on the template page or not. This functionality is only<br />
-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory<br />
-- and cfg.templateCategoryRequireName are set.<br />
self.useCollapsibleTextFields = cfg.useCollapsibleTextFields<br />
if self.useCollapsibleTextFields<br />
or cfg.templateCategory<br />
and cfg.templateCategoryRequireName<br />
then<br />
self.name = args.name<br />
if self.name then<br />
local templateName = mw.ustring.match(<br />
self.name,<br />
'^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$'<br />
) or self.name<br />
templateName = 'Template:' .. templateName<br />
self.templateTitle = getTitleObject(templateName)<br />
end<br />
self.isTemplatePage = self.templateTitle<br />
and mw.title.equals(self.title, self.templateTitle)<br />
end<br />
<br />
-- Process data for collapsible text fields. At the moment these are only<br />
-- used in {{ambox}}.<br />
if self.useCollapsibleTextFields then<br />
-- Get the self.issue value.<br />
if self.isSmall and args.smalltext then<br />
self.issue = args.smalltext<br />
else<br />
local sect<br />
if args.sect == '' then<br />
sect = 'This ' .. (cfg.sectionDefault or 'page')<br />
elseif type(args.sect) == 'string' then<br />
sect = 'This ' .. args.sect<br />
end<br />
local issue = args.issue<br />
issue = type(issue) == 'string' and issue ~= '' and issue or nil<br />
local text = args.text<br />
text = type(text) == 'string' and text or nil<br />
local issues = {}<br />
table.insert(issues, sect)<br />
table.insert(issues, issue)<br />
table.insert(issues, text)<br />
self.issue = table.concat(issues, ' ')<br />
end<br />
<br />
-- Get the self.talk value.<br />
local talk = args.talk<br />
-- Show talk links on the template page or template subpages if the talk<br />
-- parameter is blank.<br />
if talk == ''<br />
and self.templateTitle<br />
and (<br />
mw.title.equals(self.templateTitle, self.title)<br />
or self.title:isSubpageOf(self.templateTitle)<br />
)<br />
then<br />
talk = '#'<br />
elseif talk == '' then<br />
talk = nil<br />
end<br />
if talk then<br />
-- If the talk value is a talk page, make a link to that page. Else<br />
-- assume that it's a section heading, and make a link to the talk<br />
-- page of the current page with that section heading.<br />
local talkTitle = getTitleObject(talk)<br />
local talkArgIsTalkPage = true<br />
if not talkTitle or not talkTitle.isTalkPage then<br />
talkArgIsTalkPage = false<br />
talkTitle = getTitleObject(<br />
self.title.text,<br />
mw.site.namespaces[self.title.namespace].talk.id<br />
)<br />
end<br />
if talkTitle and talkTitle.exists then<br />
local talkText = 'Relevant discussion may be found on'<br />
if talkArgIsTalkPage then<br />
talkText = string.format(<br />
'%s [[%s|%s]].',<br />
talkText,<br />
talk,<br />
talkTitle.prefixedText<br />
)<br />
else<br />
talkText = string.format(<br />
'%s the [[%s#%s|talk page]].',<br />
talkText,<br />
talkTitle.prefixedText,<br />
talk<br />
)<br />
end<br />
self.talk = talkText<br />
end<br />
end<br />
<br />
-- Get other values.<br />
self.fix = args.fix ~= '' and args.fix or nil<br />
local date<br />
if args.date and args.date ~= '' then<br />
date = args.date<br />
elseif args.date == '' and self.isTemplatePage then<br />
date = lang:formatDate('F Y')<br />
end<br />
if date then<br />
self.date = string.format(" <small>''(%s)''</small>", date)<br />
end<br />
self.info = args.info<br />
if yesno(args.removalnotice) then<br />
self.removalNotice = cfg.removalNotice<br />
end<br />
end<br />
<br />
-- Set the non-collapsible text field. At the moment this is used by all box<br />
-- types other than ambox, and also by ambox when small=yes.<br />
if self.isSmall then<br />
self.text = args.smalltext or args.text<br />
else<br />
self.text = args.text<br />
end<br />
<br />
-- Set the below row.<br />
self.below = cfg.below and args.below<br />
<br />
-- General image settings.<br />
self.imageCellDiv = not self.isSmall and cfg.imageCellDiv<br />
self.imageEmptyCell = cfg.imageEmptyCell<br />
if cfg.imageEmptyCellStyle then<br />
self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px'<br />
end<br />
<br />
-- Left image settings.<br />
local imageLeft = self.isSmall and args.smallimage or args.image<br />
if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none'<br />
or not cfg.imageCheckBlank and imageLeft ~= 'none'<br />
then<br />
self.imageLeft = imageLeft<br />
if not imageLeft then<br />
local imageSize = self.isSmall<br />
and (cfg.imageSmallSize or '30x30px')<br />
or '40x40px'<br />
self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage<br />
or 'Imbox notice.png', imageSize)<br />
end<br />
end<br />
<br />
-- Right image settings.<br />
local imageRight = self.isSmall and args.smallimageright or args.imageright<br />
if not (cfg.imageRightNone and imageRight == 'none') then<br />
self.imageRight = imageRight<br />
end<br />
end<br />
<br />
function MessageBox:setMainspaceCategories()<br />
local args = self.args<br />
local cfg = self.cfg<br />
<br />
if not cfg.allowMainspaceCategories then<br />
return nil<br />
end<br />
<br />
local nums = {}<br />
for _, prefix in ipairs{'cat', 'category', 'all'} do<br />
args[prefix .. '1'] = args[prefix]<br />
nums = union(nums, getArgNums(args, prefix))<br />
end<br />
<br />
-- The following is roughly equivalent to the old {{Ambox/category}}.<br />
local date = args.date<br />
date = type(date) == 'string' and date<br />
local preposition = 'from'<br />
for _, num in ipairs(nums) do<br />
local mainCat = args['cat' .. tostring(num)]<br />
or args['category' .. tostring(num)]<br />
local allCat = args['all' .. tostring(num)]<br />
mainCat = type(mainCat) == 'string' and mainCat<br />
allCat = type(allCat) == 'string' and allCat<br />
if mainCat and date and date ~= '' then<br />
local catTitle = string.format('%s %s %s', mainCat, preposition, date)<br />
self:addCat(0, catTitle)<br />
catTitle = getTitleObject('Category:' .. catTitle)<br />
if not catTitle or not catTitle.exists then<br />
self:addCat(0, 'Articles with invalid date parameter in template')<br />
end<br />
elseif mainCat and (not date or date == '') then<br />
self:addCat(0, mainCat)<br />
end<br />
if allCat then<br />
self:addCat(0, allCat)<br />
end<br />
end<br />
end<br />
<br />
function MessageBox:setTemplateCategories()<br />
local args = self.args<br />
local cfg = self.cfg<br />
<br />
-- Add template categories.<br />
if cfg.templateCategory then<br />
if cfg.templateCategoryRequireName then<br />
if self.isTemplatePage then<br />
self:addCat(10, cfg.templateCategory)<br />
end<br />
elseif not self.title.isSubpage then<br />
self:addCat(10, cfg.templateCategory)<br />
end<br />
end<br />
<br />
-- Add template error categories.<br />
if cfg.templateErrorCategory then<br />
local templateErrorCategory = cfg.templateErrorCategory<br />
local templateCat, templateSort<br />
if not self.name and not self.title.isSubpage then<br />
templateCat = templateErrorCategory<br />
elseif self.isTemplatePage then<br />
local paramsToCheck = cfg.templateErrorParamsToCheck or {}<br />
local count = 0<br />
for i, param in ipairs(paramsToCheck) do<br />
if not args[param] then<br />
count = count + 1<br />
end<br />
end<br />
if count > 0 then<br />
templateCat = templateErrorCategory<br />
templateSort = tostring(count)<br />
end<br />
if self.categoryNums and #self.categoryNums > 0 then<br />
templateCat = templateErrorCategory<br />
templateSort = 'C'<br />
end<br />
end<br />
self:addCat(10, templateCat, templateSort)<br />
end<br />
end<br />
<br />
function MessageBox:setAllNamespaceCategories()<br />
-- Set categories for all namespaces.<br />
if self.invalidTypeError then<br />
local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText<br />
self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort)<br />
end<br />
if self.isSubstituted then<br />
self:addCat('all', 'Pages with incorrectly substituted templates')<br />
end<br />
end<br />
<br />
function MessageBox:setCategories()<br />
if self.title.namespace == 0 then<br />
self:setMainspaceCategories()<br />
elseif self.title.namespace == 10 then<br />
self:setTemplateCategories()<br />
end<br />
self:setAllNamespaceCategories()<br />
end<br />
<br />
function MessageBox:renderCategories()<br />
-- Convert category tables to strings and pass them through<br />
-- [[Module:Category handler]].<br />
return categoryHandler{<br />
main = table.concat(self.categories[0] or {}),<br />
template = table.concat(self.categories[10] or {}),<br />
all = table.concat(self.categories.all or {}),<br />
nocat = self.args.nocat,<br />
page = self.args.page<br />
}<br />
end<br />
<br />
function MessageBox:export()<br />
local root = mw.html.create()<br />
<br />
-- Add the subst check error.<br />
if self.isSubstituted and self.name then<br />
root:tag('b')<br />
:addClass('error')<br />
:wikitext(string.format(<br />
'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.',<br />
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')<br />
))<br />
end<br />
<br />
-- Create the box table.<br />
local boxTable = root:tag('table')<br />
boxTable:attr('id', self.id or nil)<br />
for i, class in ipairs(self.classes or {}) do<br />
boxTable:addClass(class or nil)<br />
end<br />
boxTable<br />
:cssText(self.style or nil)<br />
:attr('role', 'presentation')<br />
<br />
if self.attrs then<br />
boxTable:attr(self.attrs)<br />
end<br />
<br />
-- Add the left-hand image.<br />
local row = boxTable:tag('tr')<br />
if self.imageLeft then<br />
local imageLeftCell = row:tag('td'):addClass('mbox-image')<br />
if self.imageCellDiv then<br />
-- If we are using a div, redefine imageLeftCell so that the image<br />
-- is inside it. Divs use style="width: 52px;", which limits the<br />
-- image width to 52px. If any images in a div are wider than that,<br />
-- they may overlap with the text or cause other display problems.<br />
imageLeftCell = imageLeftCell:tag('div'):css('width', '52px')<br />
end<br />
imageLeftCell:wikitext(self.imageLeft or nil)<br />
elseif self.imageEmptyCell then<br />
-- Some message boxes define an empty cell if no image is specified, and<br />
-- some don't. The old template code in templates where empty cells are<br />
-- specified gives the following hint: "No image. Cell with some width<br />
-- or padding necessary for text cell to have 100% width."<br />
row:tag('td')<br />
:addClass('mbox-empty-cell')<br />
:cssText(self.imageEmptyCellStyle or nil)<br />
end<br />
<br />
-- Add the text.<br />
local textCell = row:tag('td'):addClass('mbox-text')<br />
if self.useCollapsibleTextFields then<br />
-- The message box uses advanced text parameters that allow things to be<br />
-- collapsible. At the moment, only ambox uses this.<br />
textCell:cssText(self.textstyle or nil)<br />
local textCellSpan = textCell:tag('span')<br />
textCellSpan<br />
:addClass('mbox-text-span')<br />
:wikitext(self.issue or nil)<br />
if (self.talk or self.fix) and not self.isSmall then<br />
textCellSpan:tag('span')<br />
:addClass('hide-when-compact')<br />
:wikitext(self.talk and (' ' .. self.talk) or nil)<br />
:wikitext(self.fix and (' ' .. self.fix) or nil)<br />
end<br />
textCellSpan:wikitext(self.date and (' ' .. self.date) or nil)<br />
if self.info and not self.isSmall then<br />
textCellSpan<br />
:tag('span')<br />
:addClass('hide-when-compact')<br />
:wikitext(self.info and (' ' .. self.info) or nil)<br />
end<br />
if self.removalNotice then<br />
textCellSpan:tag('small')<br />
:addClass('hide-when-compact')<br />
:tag('i')<br />
:wikitext(string.format(" (%s)", self.removalNotice))<br />
end<br />
else<br />
-- Default text formatting - anything goes.<br />
textCell<br />
:cssText(self.textstyle or nil)<br />
:wikitext(self.text or nil)<br />
end<br />
<br />
-- Add the right-hand image.<br />
if self.imageRight then<br />
local imageRightCell = row:tag('td'):addClass('mbox-imageright')<br />
if self.imageCellDiv then<br />
-- If we are using a div, redefine imageRightCell so that the image<br />
-- is inside it.<br />
imageRightCell = imageRightCell:tag('div'):css('width', '52px')<br />
end<br />
imageRightCell<br />
:wikitext(self.imageRight or nil)<br />
end<br />
<br />
-- Add the below row.<br />
if self.below then<br />
boxTable:tag('tr')<br />
:tag('td')<br />
:attr('colspan', self.imageRight and '3' or '2')<br />
:addClass('mbox-text')<br />
:cssText(self.textstyle or nil)<br />
:wikitext(self.below or nil)<br />
end<br />
<br />
-- Add error message for invalid type parameters.<br />
if self.invalidTypeError then<br />
root:tag('div')<br />
:css('text-align', 'center')<br />
:wikitext(string.format(<br />
'This message box is using an invalid "type=%s" parameter and needs fixing.',<br />
self.type or ''<br />
))<br />
end<br />
<br />
-- Add categories.<br />
root:wikitext(self:renderCategories() or nil)<br />
<br />
return tostring(root)<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Exports<br />
--------------------------------------------------------------------------------<br />
<br />
local p, mt = {}, {}<br />
<br />
function p._exportClasses()<br />
-- For testing.<br />
return {<br />
MessageBox = MessageBox<br />
}<br />
end<br />
<br />
function p.main(boxType, args, cfgTables)<br />
local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE))<br />
box:setParameters()<br />
box:setCategories()<br />
return box:export()<br />
end<br />
<br />
function mt.__index(t, k)<br />
return function (frame)<br />
if not getArgs then<br />
getArgs = require('Module:Arguments').getArgs<br />
end<br />
return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))<br />
end<br />
end<br />
<br />
return setmetatable(p, mt)</div>WikiSysop