|
|
Line 1: |
Line 1: |
| <mediawiki xmlns="http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-0.10.xsd" version="0.10" xml:lang="en">
| | {{warning}} Don't do that! |
| <siteinfo>
| |
| <sitename>MediaWiki</sitename>
| |
| <dbname>mediawikiwiki</dbname>
| |
| <base>https://www.mediawiki.org/wiki/MediaWiki</base>
| |
| <generator>MediaWiki 1.42.0-wmf.26</generator>
| |
| <case>first-letter</case>
| |
| <namespaces>
| |
| <namespace key="-2" case="first-letter">Media</namespace>
| |
| <namespace key="-1" case="first-letter">Special</namespace>
| |
| <namespace key="0" case="first-letter"/>
| |
| <namespace key="1" case="first-letter">Talk</namespace>
| |
| <namespace key="2" case="first-letter">User</namespace>
| |
| <namespace key="3" case="first-letter">User talk</namespace>
| |
| <namespace key="4" case="first-letter">Project</namespace>
| |
| <namespace key="5" case="first-letter">Project talk</namespace>
| |
| <namespace key="6" case="first-letter">File</namespace>
| |
| <namespace key="7" case="first-letter">File talk</namespace>
| |
| <namespace key="8" case="first-letter">MediaWiki</namespace>
| |
| <namespace key="9" case="first-letter">MediaWiki talk</namespace>
| |
| <namespace key="10" case="first-letter">Template</namespace>
| |
| <namespace key="11" case="first-letter">Template talk</namespace>
| |
| <namespace key="12" case="first-letter">Help</namespace>
| |
| <namespace key="13" case="first-letter">Help talk</namespace>
| |
| <namespace key="14" case="first-letter">Category</namespace>
| |
| <namespace key="15" case="first-letter">Category talk</namespace>
| |
| <namespace key="90" case="first-letter">Thread</namespace>
| |
| <namespace key="91" case="first-letter">Thread talk</namespace>
| |
| <namespace key="92" case="first-letter">Summary</namespace>
| |
| <namespace key="93" case="first-letter">Summary talk</namespace>
| |
| <namespace key="100" case="first-letter">Manual</namespace>
| |
| <namespace key="101" case="first-letter">Manual talk</namespace>
| |
| <namespace key="102" case="first-letter">Extension</namespace>
| |
| <namespace key="103" case="first-letter">Extension talk</namespace>
| |
| <namespace key="104" case="first-letter">API</namespace>
| |
| <namespace key="105" case="first-letter">API talk</namespace>
| |
| <namespace key="106" case="first-letter">Skin</namespace>
| |
| <namespace key="107" case="first-letter">Skin talk</namespace>
| |
| <namespace key="486" case="first-letter">Data</namespace>
| |
| <namespace key="487" case="first-letter">Data talk</namespace>
| |
| <namespace key="710" case="first-letter">TimedText</namespace>
| |
| <namespace key="711" case="first-letter">TimedText talk</namespace>
| |
| <namespace key="828" case="first-letter">Module</namespace>
| |
| <namespace key="829" case="first-letter">Module talk</namespace>
| |
| <namespace key="1198" case="first-letter">Translations</namespace>
| |
| <namespace key="1199" case="first-letter">Translations talk</namespace>
| |
| <namespace key="2600" case="first-letter">Topic</namespace>
| |
| <namespace key="5500" case="first-letter">Newsletter</namespace>
| |
| <namespace key="5501" case="first-letter">Newsletter talk</namespace>
| |
| </namespaces>
| |
| </siteinfo>
| |
| <page>
| |
| <title>Template:Warning</title>
| |
| <ns>10</ns>
| |
| <id>14126</id>
| |
| <revision>
| |
| <id>6389685</id>
| |
| <parentid>6389040</parentid>
| |
| <timestamp>2024-02-28T21:39:48Z</timestamp>
| |
| <contributor>
| |
| <username>Shirayuki</username>
| |
| <id>472859</id>
| |
| </contributor>
| |
| <comment>Marked this version for translation</comment>
| |
| <model>wikitext</model>
| |
| <format>text/x-wiki</format>
| |
| <text bytes="2335" xml:space="preserve"><languages/> <onlyinclude>{{#if: {{{msg|{{{1|}}}}}}|<table class="warning-message" style="background-color: #fee7e6; color:#333; border: 1px #d33 solid; box-sizing: border-box; margin: 0.5em 0; padding: 0.5em;"><tr><td style="white-space: nowrap; vertical-align: top;">}}<span style="position: relative; top: -2px;">[[File:OOjs_UI_icon_notice-destructive.svg|18px|alt=<translate><!--T:1--> Warning</translate>|link=]]</span> '''<translate><!--T:2--> Warning:</translate>''' {{#if: {{{msg|{{{1|}}}}}}|</td><td style="padding-{{dir|{{pagelang}}|right|left}}: 0.5em vertical-align: top;">{{{msg|{{{1|}}}}}}</td></tr></table>}}</onlyinclude> {{Documentation|content= <translate> == Usage == <!--T:3--> <!--T:4--> This template has two possible usages: <!--T:5--> # Will have the text flow below when the warning text is too long</translate> <translate> <!--T:6--> # Uses a table to indent the text. === Method 1 === <!--T:7--> </translate> <translate><!--T:8--> The following displays the warning icon and the word "Warning:".</translate> <translate><!--T:17--> You can follow this with whatever text/images/markup you like.</translate> <translate><!--T:9--> Wiki Code:</translate> <nowiki>{{warning}}</nowiki> <translate><!--T:10--> Don't do that!</translate> {{warning}} <translate><!--T:11--> Don't do that!</translate> <translate> === Method 2 === <!--T:12--> <!--T:13--> The following includes the text passed to the template, and uses a table to stop the text flowing round the icon. <!--T:14--> Wiki Code: </translate> <nowiki>{{warning|1=</nowiki><translate><!--T:15--> Here is a long warning, which is sufficiently wordy to run onto a second line (unless you have a really large screen!), which would normally cause it to wrap round the icon, but because we passed it as a parameter it keeps its left alignment straight.</translate><nowiki>}}</nowiki> {{warning|1=<translate><!--T:16--> Here is a long warning, which is sufficiently wordy to run onto a second line (unless you have a really large screen!), which would normally cause it to wrap round the icon, but because we passed it as a parameter it keeps its left alignment straight.</translate>}} <translate> == See also == <!--T:18--> </translate> * {{tl|Caution}} * {{tl|Fixtext}} * {{tl|Note}} * {{tl|Tip}} }} [[Category:Warning templates{{#translation:}}]]</text>
| |
| <sha1>flt6c6ub74t0zpplcnp4twc4xcna1ck</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Template:Pagelang</title>
| |
| <ns>10</ns>
| |
| <id>190171</id>
| |
| <revision>
| |
| <id>3503449</id>
| |
| <parentid>3497222</parentid>
| |
| <timestamp>2019-11-10T01:45:55Z</timestamp>
| |
| <contributor>
| |
| <username>Shirayuki</username>
| |
| <id>472859</id>
| |
| </contributor>
| |
| <comment>This template should return empty string if the pagename does not end with "/en" for consistency</comment>
| |
| <model>wikitext</model>
| |
| <format>text/x-wiki</format>
| |
| <text bytes="300" xml:space="preserve">{{#ifeq:{{#invoke:Template translation|getLanguageSubpage|{{{1|}}}}}|en |{{#ifeq:{{#titleparts:{{{1|{{PAGENAME}}}}}||-1}}|en |{{#invoke:Template translation|getLanguageSubpage|{{{1|}}}}} }} |{{#invoke:Template translation|getLanguageSubpage|{{{1|}}}}} }}<noinclude> {{Documentation}} </noinclude></text>
| |
| <sha1>mwhgv9bv6r6vtl8ip81ok1lic6e8zje</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Template:Dir</title>
| |
| <ns>10</ns>
| |
| <id>190173</id>
| |
| <revision>
| |
| <id>6017023</id>
| |
| <parentid>6016445</parentid>
| |
| <timestamp>2023-07-07T15:15:20Z</timestamp>
| |
| <contributor>
| |
| <username>Krinkle</username>
| |
| <id>135822</id>
| |
| </contributor>
| |
| <comment>revert imported revision by [[User:Billinghurst]] that broke the template and inserted "ltr" in random places on the wiki, e.g. [[Wikimedia Platform Engineering/MediaWiki Core Team]] displaying "ltr" instead of an arrow</comment>
| |
| <model>wikitext</model>
| |
| <format>text/x-wiki</format>
| |
| <text bytes="567" xml:space="preserve">{{#switch:{{lc:{{#if:{{{lang|}}}|{{{lang|}}}|{{#if:{{{1|}}}|{{{1|}}}|{{int:lang}}}}}}}} |aeb|aeb-arab|aic|ar|arc|arq|ary|arz|azb|bcc|bgn|bqi|bqp|ckb|ckb-arab|dv|en-rtl|fa|fa-af|glk|ha-arab|haz|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|nqo|ota|phn|pnb|prd|prs|ps|sd|sdh|skr|skr-arab|tg-arab|tly|ug|ug-arab|ur|uz-arab|xpu|ydd|yi ={{#ifeq:{{{rtl|}}}|{{{rtl|-}}}|{{{rtl|}}}|{{#ifeq:{{{2|}}}|{{{2|-}}}|{{{2|}}}|rtl}}}} |#default ={{#ifeq:{{{ltr|}}}|{{{ltr|-}}}|{{{ltr|}}}|{{#ifeq:{{{3|}}}|{{{3|-}}}|{{{3|}}}|ltr}}}} }}<noinclude>{{documentation}}</noinclude></text>
| |
| <sha1>5g5mx70w9kxwzp0yd1rnv4p6vpn76kn</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Module:Template translation</title>
| |
| <ns>828</ns>
| |
| <id>131816</id>
| |
| <revision>
| |
| <id>6016441</id>
| |
| <parentid>6016440</parentid>
| |
| <timestamp>2023-07-07T03:55:34Z</timestamp>
| |
| <contributor>
| |
| <username>Billinghurst</username>
| |
| <id>50983</id>
| |
| </contributor>
| |
| <minor/>
| |
| <comment>1 revision imported from [[:meta:Module:Template_translation]]</comment>
| |
| <model>Scribunto</model>
| |
| <format>text/plain</format>
| |
| <text bytes="11705" xml:space="preserve">local this = {} function this.checkLanguage(subpage, default) --[[Check first if there's an any invalid character that would cause the mw.language.isKnownLanguageTag function() to throw an exception: - all ASCII controls in [\000-\031\127], - double quote ("), sharp sign (#), ampersand (&), apostrophe ('), - slash (/), colon (:), semicolon (;), lower than (<), greater than (>), - brackets and braces ([, ], {, }), pipe (|), backslash (\\) All other characters are accepted, including space and all non-ASCII characters (including \192, which is invalid in UTF-8). --]] if mw.language.isValidCode(subpage) and mw.language.isKnownLanguageTag(subpage) --[[However "SupportedLanguages" are too restrictive, as they discard many valid BCP47 script variants (only because MediaWiki still does not define automatic transliterators for them, e.g. "en-dsrt" or "fr-brai" for French transliteration in Braille), and country variants, (useful in localized data, even if they are no longer used for translations, such as zh-cn, also useful for legacy codes). We want to avoid matching subpagenames containing any uppercase letter, (even if they are considered valid in BCP 47, in which they are case-insensitive; they are not "SupportedLanguages" for MediaWiki, so they are not "KnownLanguageTags" for MediaWiki). To be more restrictive, we exclude tags * for specific uses in template subpages and unusable as language tags; * that is not ASCII and not a lowercase letter, minus-hyphen, or digit, or does not start by a letter or does not finish by a letter or digit; * or that has subtags with more than 8 characters between hyphens; * or that has two hyphens. --]] or subpage ~= "doc" and subpage ~= "layout" and subpage ~= "button" and subpage ~= "buttons" and subpage ~= "sandbox" and subpage ~= "testcase" and subpage ~= "testcases" and string.find(subpage, "^[%l][%-%d%l]*[%d%l]$") ~= nil and string.find(subpage, "[%d%l][%d%l][%d%l][%d%l][%d%l][%d%l][%d%l][%d%l][%d%l]") == nil and string.find(subpage, "%-%-") == nil then return subpage end -- Otherwise there's currently no known language subpage return default end --[[Get the last subpage of an arbitrary page if it is a translation. To be used from templates. ]] function this.getLanguageSubpage(frame) local title = frame and frame.args[1] if not title or title == '' then title = mw.title.getCurrentTitle() end return this._getLanguageSubpage(title) end --[[Get the last subpage of an arbitrary page if it is a translation. To be used from Lua. ]] function this._getLanguageSubpage(title) if type(title) == 'string' then title = mw.title.new(title) end if not title then -- invalid title return nil end --[[This code does not work in all namespaces where the Translate tool works. -- It works in the main namespace on Meta because it allows subpages there -- It would not work in the main namespace of English Wikipedia (but the -- articles are monolignual on that wiki). -- On Meta-Wiki the main space uses subpages and its pages are translated. -- The Translate tool allows translatng pages in all namespaces, even if -- the namespace officially does not have subpages. -- On Meta-Wiki the Category namespace still does not have subpages enabled, -- even if they would be very useful for categorizing templates, that DO have -- subpages (for documentatio and tstboxes pages). This is a misconfiguration -- bug of Meta-Wiki. The work-around is to split the full title and then -- get the last titlepart. local subpage = title.subpageText --]] local titleparts = mw.text.split(title.fullText, '/') local subpage = titleparts[#titleparts] return this.checkLanguage(subpage, '') end --[[Get the last subpage of the current page if it is a translation. ]] function this.getCurrentLanguageSubpage() return this._getLanguageSubpage(mw.title.getCurrentTitle()) end --[[Get the first part of the language code of the subpage, before the '-'. --]] function this.getMainLanguageSubpage() parts = mw.text.split(this.getCurrentLanguageSubpage(), '-') return parts[1] end --[[Get the last subpage of the current frame if it is a translation. Not used locally. --]] function this.getFrameLanguageSubpage(frame) return this._getLanguageSubpage(frame:getParent():getTitle()) end --[[Get the language of the current page. Not used locally. --]] function this.getLanguage() local subpage = mw.title.getCurrentTitle().subpageText return this.checkLanguage(subpage, mw.language.getContentLanguage():getCode()) end --[[Get the language of the current frame. Not used locally. --]] function this.getFrameLanguage(frame) local titleparts = mw.text.split(frame:getParent():getTitle(), '/') local subpage = titleparts[#titleparts] return this.checkLanguage(subpage, mw.language.getContentLanguage():getCode()) end function this.title(namespace, basepagename, subpage) local message, title local pagename = basepagename if (subpage or '') ~= '' then pagename = pagename .. '/' .. subpage end local valid, title = xpcall(function() return mw.title.new(pagename, namespace) -- costly end, function(msg) -- catch undocumented exception (!?) -- thrown when namespace does not exist. The doc still -- says it should return a title, even in that case... message = msg end) if valid and title ~= nil and (title.id or 0) ~= 0 then return title end return { -- "pseudo" mw.title object with id = nil in case of error prefixedText = pagename, -- the only property we need below message = message -- only for debugging } end --[[If on a translation subpage (like Foobar/de), this function returns a given template in the same language, if the translation is available. Otherwise, the template is returned in its default language, without modification. This is aimed at replacing the current implementation of Template:TNTN. This version does not expand the returned template name: this solves the problem of self-recursion in TNT when translatable templates need themselves to transclude other translable templates (such as Tnavbar). --]] function this.getTranslatedTemplate(frame, withStatus) local args = frame.args local pagename = args['template'] --[[Check whether the pagename is actually in the Template namespace, or if we're transcluding a main-namespace page. (added for backward compatibility of Template:TNT) ]] local namespace, title = args['tntns'] or '' if namespace ~= '' then -- Checks for tntns parameter for custom ns. title = this.title(namespace, pagename) -- Costly else -- Supposes that set page is in ns10. namespace = 'Template' title = this.title(namespace, pagename) -- Costly if title.id == nil then -- not found in the Template namespace, assume the main namespace (for backward compatibility) namespace = '' title = this.title(namespace, pagename) -- Costly end end -- Get the last subpage and check if it matches a known language code. local subpage = args['uselang'] or '' if subpage == '' then subpage = this.getCurrentLanguageSubpage() end if subpage == '' then -- Check if a translation of the pagename exists in English local newtitle = this.title(namespace, pagename, 'en') -- Costly -- Use the translation when it exists if newtitle.id ~= nil then title = newtitle end else -- Check if a translation of the pagename exists in that language local newtitle = this.title(namespace, pagename, subpage) -- Costly if newtitle.id == nil then -- Check if a translation of the pagename exists in English newtitle = this.title(namespace, pagename, 'en') -- Costly end -- Use the translation when it exists if newtitle.id ~= nil then title = newtitle end end -- At this point the title should exist if withStatus then -- status returned to Lua function below return title.prefixedText, title.id ~= nil else -- returned directly to MediaWiki return title.prefixedText end end --[[If on a translation subpage (like Foobar/de), this function renders a given template in the same language, if the translation is available. Otherwise, the template is rendered in its default language, without modification. This is aimed at replacing the current implementation of Template:TNT. Note that translatable templates cannot transclude themselves other translatable templates, as it will recurse on TNT. Use TNTN instead to return only the effective template name to expand externally, with template parameters also provided externally. --]] function this.renderTranslatedTemplate(frame) local title, found = this.getTranslatedTemplate(frame, true) -- At this point the title should exist prior to performing the expansion -- of the template, otherwise render a red link to the missing page -- (resolved in its assumed namespace). If we don't tet this here, a -- script error would be thrown. Returning a red link is consistant with -- MediaWiki behavior when attempting to transclude inexistant templates. if not found then return '[[' .. title .. ']]' end -- Copy args pseudo-table to a proper table so we can feed it to expandTemplate. -- Then render the pagename. local args = frame.args local pargs = (frame:getParent() or {}).args local arguments = {} if (args['noshift'] or '') == '' then for k, v in pairs(pargs) do local n = tonumber(k) or 0 if n <= 0 then -- unnumbered args arguments[k] = v elseif n >= 2 then -- numbered args >= 2 need to be shifted arguments[n - 1] = v end end else -- special case where TNT is used as autotranslate -- (don't shift again what is shifted in the invokation) for k, v in pairs(pargs) do arguments[k] = v end end arguments['template'] = title -- override the existing parameter of the base template name supplied with the full name of the actual template expanded arguments['tntns'] = nil -- discard the specified namespace override arguments['uselang'] = args['uselang'] -- argument forwarded into parent frame arguments['noshift'] = args['noshift'] -- argument forwarded into parent frame return frame:expandTemplate{title = ':' .. title, args = arguments} end --[[A helper for mocking TNT in Special:TemplateSandbox. TNT breaks TemplateSandbox; mocking it with this method means templates won't be localized but at least TemplateSandbox substitutions will work properly. Won't work with complex uses. --]] function this.mockTNT(frame) local pargs = (frame:getParent() or {}).args local arguments = {} for k, v in pairs(pargs) do local n = tonumber(k) or 0 if n <= 0 then -- unnumbered args arguments[k] = v elseif n >= 2 then -- numbered args >= 2 need to be shifted arguments[n - 1] = v end end if not pargs[1] then return '' end return frame:expandTemplate{title = 'Template:' .. pargs[1], args = arguments} end return this</text>
| |
| <sha1>awvcrmp8lemwq049tlq1p4ae9mbphim</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Module:Message box</title>
| |
| <ns>828</ns>
| |
| <id>191976</id>
| |
| <revision>
| |
| <id>6090555</id>
| |
| <parentid>5820203</parentid>
| |
| <timestamp>2023-09-02T14:31:10Z</timestamp>
| |
| <contributor>
| |
| <username>Pppery</username>
| |
| <id>5901069</id>
| |
| </contributor>
| |
| <comment>Use SVG per edit request</comment>
| |
| <model>Scribunto</model>
| |
| <format>text/plain</format>
| |
| <text bytes="18558" xml:space="preserve">-- This is a meta-module for producing message box templates, including -- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}. -- Load necessary modules. require('strict') local getArgs local yesno = require('Module:Yesno') -- Get a language object for formatDate and ucfirst. local lang = mw.language.getContentLanguage() -- Define constants local CONFIG_MODULE = 'Module:Message box/configuration' local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'} local TEMPLATE_STYLES = 'Module:Message box/%s.css' -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function getTitleObject(...) -- Get the title object, passing the function through pcall -- in case we are over the expensive function count limit. local success, title = pcall(mw.title.new, ...) if success then return title end end local function union(t1, t2) -- Returns the union of two arrays. local vals = {} for i, v in ipairs(t1) do vals[v] = true end for i, v in ipairs(t2) do vals[v] = true end local ret = {} for k in pairs(vals) do table.insert(ret, k) end table.sort(ret) return ret end local function getArgNums(args, prefix) local nums = {} for k, v in pairs(args) do local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$') if num then table.insert(nums, tonumber(num)) end end table.sort(nums) return nums end -------------------------------------------------------------------------------- -- Box class definition -------------------------------------------------------------------------------- local MessageBox = {} MessageBox.__index = MessageBox function MessageBox.new(boxType, args, cfg) args = args or {} local obj = {} obj.boxType = boxType -- Set the title object and the namespace. obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle() -- Set the config for our box type. obj.cfg = cfg[boxType] if not obj.cfg then local ns = obj.title.namespace -- boxType is "mbox" or invalid input if args.demospace and args.demospace ~= '' then -- implement demospace parameter of mbox local demospace = string.lower(args.demospace) if DEMOSPACES[demospace] then -- use template from DEMOSPACES obj.cfg = cfg[DEMOSPACES[demospace]] obj.boxType = DEMOSPACES[demospace] elseif string.find( demospace, 'talk' ) then -- demo as a talk page obj.cfg = cfg.tmbox obj.boxType = 'tmbox' else -- default to ombox obj.cfg = cfg.ombox obj.boxType = 'ombox' end elseif ns == 0 then obj.cfg = cfg.ambox -- main namespace obj.boxType = 'ambox' elseif ns == 6 then obj.cfg = cfg.imbox -- file namespace obj.boxType = 'imbox' elseif ns == 14 then obj.cfg = cfg.cmbox -- category namespace obj.boxType = 'cmbox' else local nsTable = mw.site.namespaces[ns] if nsTable and nsTable.isTalk then obj.cfg = cfg.tmbox -- any talk namespace obj.boxType = 'tmbox' else obj.cfg = cfg.ombox -- other namespaces or invalid input obj.boxType = 'ombox' end end end -- Set the arguments, and remove all blank arguments except for the ones -- listed in cfg.allowBlankParams. do local newArgs = {} for k, v in pairs(args) do if v ~= '' then newArgs[k] = v end end for i, param in ipairs(obj.cfg.allowBlankParams or {}) do newArgs[param] = args[param] end obj.args = newArgs end -- Define internal data structure. obj.categories = {} obj.classes = {} -- For lazy loading of [[Module:Category handler]]. obj.hasCategories = false return setmetatable(obj, MessageBox) end function MessageBox:addCat(ns, cat, sort) if not cat then return nil end if sort then cat = string.format('[[Category:%s|%s]]', cat, sort) else cat = string.format('[[Category:%s]]', cat) end self.hasCategories = true self.categories[ns] = self.categories[ns] or {} table.insert(self.categories[ns], cat) end function MessageBox:addClass(class) if not class then return nil end self.classes[class] = 1 end function MessageBox:removeClass(class) if not class then return nil end self.classes[class] = nil end function MessageBox:setParameters() local args = self.args local cfg = self.cfg -- Get type data. self.type = args.type local typeData = cfg.types[self.type] self.invalidTypeError = cfg.showInvalidTypeError and self.type and not typeData typeData = typeData or cfg.types[cfg.default] self.typeClass = typeData.class self.typeImage = typeData.image -- Find if the box has been wrongly substituted. self.isSubstituted = cfg.substCheck and args.subst == 'SUBST' -- Find whether we are using a small message box. self.isSmall = cfg.allowSmall and ( cfg.smallParam and args.small == cfg.smallParam or not cfg.smallParam and yesno(args.small) ) -- Add attributes, classes and styles. self.id = args.id self.name = args.name for _, class in ipairs(cfg.classes or {}) do self:addClass(class) end if self.name then self:addClass('box-' .. string.gsub(self.name,' ','_')) end local plainlinks = yesno(args.plainlinks) if plainlinks == true then self:addClass('plainlinks') elseif plainlinks == false then self:removeClass('plainlinks') end if self.isSmall then self:addClass(cfg.smallClass or 'mbox-small') end self:addClass(self.typeClass) self:addClass(args.class) self.style = args.style self.attrs = args.attrs -- Set text style. self.textstyle = args.textstyle -- Find if we are on the template page or not. This functionality is only -- used if useCollapsibleTextFields is set, or if both cfg.templateCategory -- and cfg.templateCategoryRequireName are set. self.useCollapsibleTextFields = cfg.useCollapsibleTextFields if self.useCollapsibleTextFields or cfg.templateCategory and cfg.templateCategoryRequireName then if self.name then local templateName = mw.ustring.match( self.name, '^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$' ) or self.name templateName = 'Template:' .. templateName self.templateTitle = getTitleObject(templateName) end self.isTemplatePage = self.templateTitle and mw.title.equals(self.title, self.templateTitle) end -- Process data for collapsible text fields. At the moment these are only -- used in {{ambox}}. if self.useCollapsibleTextFields then -- Get the self.issue value. if self.isSmall and args.smalltext then self.issue = args.smalltext else local sect if args.sect == '' then sect = 'This ' .. (cfg.sectionDefault or 'page') elseif type(args.sect) == 'string' then sect = 'This ' .. args.sect end local issue = args.issue issue = type(issue) == 'string' and issue ~= '' and issue or nil local text = args.text text = type(text) == 'string' and text or nil local issues = {} table.insert(issues, sect) table.insert(issues, issue) table.insert(issues, text) self.issue = table.concat(issues, ' ') end -- Get the self.talk value. local talk = args.talk -- Show talk links on the template page or template subpages if the talk -- parameter is blank. if talk == '' and self.templateTitle and ( mw.title.equals(self.templateTitle, self.title) or self.title:isSubpageOf(self.templateTitle) ) then talk = '#' elseif talk == '' then talk = nil end if talk then -- If the talk value is a talk page, make a link to that page. Else -- assume that it's a section heading, and make a link to the talk -- page of the current page with that section heading. local talkTitle = getTitleObject(talk) local talkArgIsTalkPage = true if not talkTitle or not talkTitle.isTalkPage then talkArgIsTalkPage = false talkTitle = getTitleObject( self.title.text, mw.site.namespaces[self.title.namespace].talk.id ) end if talkTitle and talkTitle.exists then local talkText = 'Relevant discussion may be found on' if talkArgIsTalkPage then talkText = string.format( '%s [[%s|%s]].', talkText, talk, talkTitle.prefixedText ) else talkText = string.format( '%s the [[%s#%s|talk page]].', talkText, talkTitle.prefixedText, talk ) end self.talk = talkText end end -- Get other values. self.fix = args.fix ~= '' and args.fix or nil local date if args.date and args.date ~= '' then date = args.date elseif args.date == '' and self.isTemplatePage then date = lang:formatDate('F Y') end if date then self.date = string.format(" <small class='date-container'>''(<span class='date'>%s</span>)''</small>", date) end self.info = args.info if yesno(args.removalnotice) then self.removalNotice = cfg.removalNotice end end -- Set the non-collapsible text field. At the moment this is used by all box -- types other than ambox, and also by ambox when small=yes. if self.isSmall then self.text = args.smalltext or args.text else self.text = args.text end -- Set the below row. self.below = cfg.below and args.below -- General image settings. self.imageCellDiv = not self.isSmall and cfg.imageCellDiv self.imageEmptyCell = cfg.imageEmptyCell if cfg.imageEmptyCellStyle then self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px' end -- Left image settings. local imageLeft = self.isSmall and args.smallimage or args.image if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none' or not cfg.imageCheckBlank and imageLeft ~= 'none' then self.imageLeft = imageLeft if not imageLeft then local imageSize = self.isSmall and (cfg.imageSmallSize or '30x30px') or '40x40px' self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage or 'Information icon4.svg', imageSize) end end -- Right image settings. local imageRight = self.isSmall and args.smallimageright or args.imageright if not (cfg.imageRightNone and imageRight == 'none') then self.imageRight = imageRight end end function MessageBox:setMainspaceCategories() local args = self.args local cfg = self.cfg if not cfg.allowMainspaceCategories then return nil end local nums = {} for _, prefix in ipairs{'cat', 'category', 'all'} do args[prefix .. '1'] = args[prefix] nums = union(nums, getArgNums(args, prefix)) end -- The following is roughly equivalent to the old {{Ambox/category}}. local date = args.date date = type(date) == 'string' and date local preposition = 'from' for _, num in ipairs(nums) do local mainCat = args['cat' .. tostring(num)] or args['category' .. tostring(num)] local allCat = args['all' .. tostring(num)] mainCat = type(mainCat) == 'string' and mainCat allCat = type(allCat) == 'string' and allCat if mainCat and date and date ~= '' then local catTitle = string.format('%s %s %s', mainCat, preposition, date) self:addCat(0, catTitle) catTitle = getTitleObject('Category:' .. catTitle) if not catTitle or not catTitle.exists then self:addCat(0, 'Articles with invalid date parameter in template') end elseif mainCat and (not date or date == '') then self:addCat(0, mainCat) end if allCat then self:addCat(0, allCat) end end end function MessageBox:setTemplateCategories() local args = self.args local cfg = self.cfg -- Add template categories. if cfg.templateCategory then if cfg.templateCategoryRequireName then if self.isTemplatePage then self:addCat(10, cfg.templateCategory) end elseif not self.title.isSubpage then self:addCat(10, cfg.templateCategory) end end -- Add template error categories. if cfg.templateErrorCategory then local templateErrorCategory = cfg.templateErrorCategory local templateCat, templateSort if not self.name and not self.title.isSubpage then templateCat = templateErrorCategory elseif self.isTemplatePage then local paramsToCheck = cfg.templateErrorParamsToCheck or {} local count = 0 for i, param in ipairs(paramsToCheck) do if not args[param] then count = count + 1 end end if count > 0 then templateCat = templateErrorCategory templateSort = tostring(count) end if self.categoryNums and #self.categoryNums > 0 then templateCat = templateErrorCategory templateSort = 'C' end end self:addCat(10, templateCat, templateSort) end end function MessageBox:setAllNamespaceCategories() -- Set categories for all namespaces. if self.isSubstituted then self:addCat('all', 'Pages with incorrectly substituted templates') end end function MessageBox:setCategories() if self.title.namespace == 0 then self:setMainspaceCategories() elseif self.title.namespace == 10 then self:setTemplateCategories() end self:setAllNamespaceCategories() end function MessageBox:renderCategories() if not self.hasCategories then -- No categories added, no need to pass them to Category handler so, -- if it was invoked, it would return the empty string. -- So we shortcut and return the empty string. return "" end -- Convert category tables to strings and pass them through -- [[Module:Category handler]]. return require('Module:Category handler')._main{ main = table.concat(self.categories[0] or {}), template = table.concat(self.categories[10] or {}), all = table.concat(self.categories.all or {}), nocat = self.args.nocat, page = self.args.page } end function MessageBox:export() local root = mw.html.create() -- Add the subst check error. if self.isSubstituted and self.name then root:tag('b') :addClass('error') :wikitext(string.format( 'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.', mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}') )) end -- Add TemplateStyles root:wikitext(mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = TEMPLATE_STYLES:format(self.boxType) }, }) -- Create the box table. local boxTable -- Check for fmbox because not all interface messages have mw-parser-output -- which is necessary for TemplateStyles. Add the wrapper class if it is and -- then start the actual mbox, else start the mbox. if self.boxType == 'fmbox' then boxTable = root:tag('div') :addClass('mw-parser-output') :tag('table') else boxTable = root:tag('table') end boxTable:attr('id', self.id or nil) for class, _ in pairs(self.classes or {}) do boxTable:addClass(class or nil) end boxTable :cssText(self.style or nil) :attr('role', 'presentation') if self.attrs then boxTable:attr(self.attrs) end -- Add the left-hand image. local row = boxTable:tag('tr') if self.imageLeft then local imageLeftCell = row:tag('td'):addClass('mbox-image') if self.imageCellDiv then -- If we are using a div, redefine imageLeftCell so that the image -- is inside it. Divs use style="width: 52px;", which limits the -- image width to 52px. If any images in a div are wider than that, -- they may overlap with the text or cause other display problems. imageLeftCell = imageLeftCell:tag('div'):css('width', '52px') end imageLeftCell:wikitext(self.imageLeft or nil) elseif self.imageEmptyCell then -- Some message boxes define an empty cell if no image is specified, and -- some don't. The old template code in templates where empty cells are -- specified gives the following hint: "No image. Cell with some width -- or padding necessary for text cell to have 100% width." row:tag('td') :addClass('mbox-empty-cell') :cssText(self.imageEmptyCellStyle or nil) end -- Add the text. local textCell = row:tag('td'):addClass('mbox-text') if self.useCollapsibleTextFields then -- The message box uses advanced text parameters that allow things to be -- collapsible. At the moment, only ambox uses this. textCell:cssText(self.textstyle or nil) local textCellDiv = textCell:tag('div') textCellDiv :addClass('mbox-text-span') :wikitext(self.issue or nil) if (self.talk or self.fix) and not self.isSmall then textCellDiv:tag('span') :addClass('hide-when-compact') :wikitext(self.talk and (' ' .. self.talk) or nil) :wikitext(self.fix and (' ' .. self.fix) or nil) end textCellDiv:wikitext(self.date and (' ' .. self.date) or nil) if self.info and not self.isSmall then textCellDiv :tag('span') :addClass('hide-when-compact') :wikitext(self.info and (' ' .. self.info) or nil) end if self.removalNotice then textCellDiv:tag('small') :addClass('hide-when-compact') :tag('i') :wikitext(string.format(" (%s)", self.removalNotice)) end else -- Default text formatting - anything goes. textCell :cssText(self.textstyle or nil) :wikitext(self.text or nil) end -- Add the right-hand image. if self.imageRight then local imageRightCell = row:tag('td'):addClass('mbox-imageright') if self.imageCellDiv then -- If we are using a div, redefine imageRightCell so that the image -- is inside it. imageRightCell = imageRightCell:tag('div'):css('width', '52px') end imageRightCell :wikitext(self.imageRight or nil) end -- Add the below row. if self.below then boxTable:tag('tr') :tag('td') :attr('colspan', self.imageRight and '3' or '2') :addClass('mbox-text') :cssText(self.textstyle or nil) :wikitext(self.below or nil) end -- Add error message for invalid type parameters. if self.invalidTypeError then root:tag('div') :css('text-align', 'center') :wikitext(string.format( 'This message box is using an invalid "type=%s" parameter and needs fixing.', self.type or '' )) end -- Add categories. root:wikitext(self:renderCategories() or nil) return tostring(root) end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p, mt = {}, {} function p._exportClasses() -- For testing. return { MessageBox = MessageBox } end function p.main(boxType, args, cfgTables) local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE)) box:setParameters() box:setCategories() return box:export() end function mt.__index(t, k) return function (frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end return t.main(k, getArgs(frame, {trim = false, removeBlanks = false})) end end return setmetatable(p, mt)</text>
| |
| <sha1>0om3ofnhkpvg35wkzjv0yspy5u7joey</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Module:Yesno</title>
| |
| <ns>828</ns>
| |
| <id>191981</id>
| |
| <revision>
| |
| <id>3688812</id>
| |
| <parentid>3315904</parentid>
| |
| <timestamp>2020-03-01T02:09:18Z</timestamp>
| |
| <contributor>
| |
| <username>Minorax</username>
| |
| <id>17158316</id>
| |
| </contributor>
| |
| <minor/>
| |
| <comment>8 revisions imported from [[:meta:Module:Yesno]]</comment>
| |
| <model>Scribunto</model>
| |
| <format>text/plain</format>
| |
| <text bytes="745" xml:space="preserve">-- Function allowing for consistent treatment of boolean-like wikitext input. -- It works similarly to the template {{yesno}}. return function (val, default) -- If your wiki uses non-ascii characters for any of "yes", "no", etc., you -- should replace "val:lower()" with "mw.ustring.lower(val)" in the -- following line. val = type(val) == 'string' and val:lower() or val if val == nil then return nil elseif val == true or val == 'yes' or val == 'y' or val == 'true' or val == 't' or val == 'on' or tonumber(val) == 1 then return true elseif val == false or val == 'no' or val == 'n' or val == 'false' or val == 'f' or val == 'off' or tonumber(val) == 0 then return false else return default end end</text>
| |
| <sha1>swdskn7svew8i9wuydn9uj5l3r2ghcs</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Module:Arguments</title>
| |
| <ns>828</ns>
| |
| <id>191978</id>
| |
| <revision>
| |
| <id>3392121</id>
| |
| <parentid>3388613</parentid>
| |
| <timestamp>2019-09-02T12:39:11Z</timestamp>
| |
| <contributor>
| |
| <username>AKlapper (WMF)</username>
| |
| <id>790805</id>
| |
| </contributor>
| |
| <minor/>
| |
| <comment>4 revisions imported from [[:meta:Module:Arguments]]: See [[phab:T231001]]</comment>
| |
| <model>Scribunto</model>
| |
| <format>text/plain</format>
| |
| <text bytes="10054" xml:space="preserve">-- This module provides easy processing of arguments passed to Scribunto from -- #invoke. It is intended for use by other Lua modules, and should not be -- called from #invoke directly. local libraryUtil = require('libraryUtil') local checkType = libraryUtil.checkType local arguments = {} -- Generate four different tidyVal functions, so that we don't have to check the -- options every time we call it. local function tidyValDefault(key, val) if type(val) == 'string' then val = val:match('^%s*(.-)%s*$') if val == '' then return nil else return val end else return val end end local function tidyValTrimOnly(key, val) if type(val) == 'string' then return val:match('^%s*(.-)%s*$') else return val end end local function tidyValRemoveBlanksOnly(key, val) if type(val) == 'string' then if val:find('%S') then return val else return nil end else return val end end local function tidyValNoChange(key, val) return val end local function matchesTitle(given, title) local tp = type( given ) return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title end local translate_mt = { __index = function(t, k) return k end } function arguments.getArgs(frame, options) checkType('getArgs', 1, frame, 'table', true) checkType('getArgs', 2, options, 'table', true) frame = frame or {} options = options or {} --[[ -- Set up argument translation. --]] options.translate = options.translate or {} if getmetatable(options.translate) == nil then setmetatable(options.translate, translate_mt) end if options.backtranslate == nil then options.backtranslate = {} for k,v in pairs(options.translate) do options.backtranslate[v] = k end end if options.backtranslate and getmetatable(options.backtranslate) == nil then setmetatable(options.backtranslate, { __index = function(t, k) if options.translate[k] ~= k then return nil else return k end end }) end --[[ -- Get the argument tables. If we were passed a valid frame object, get the -- frame arguments (fargs) and the parent frame arguments (pargs), depending -- on the options set and on the parent frame's availability. If we weren't -- passed a valid frame object, we are being called from another Lua module -- or from the debug console, so assume that we were passed a table of args -- directly, and assign it to a new variable (luaArgs). --]] local fargs, pargs, luaArgs if type(frame.args) == 'table' and type(frame.getParent) == 'function' then if options.wrappers then --[[ -- The wrappers option makes Module:Arguments look up arguments in -- either the frame argument table or the parent argument table, but -- not both. This means that users can use either the #invoke syntax -- or a wrapper template without the loss of performance associated -- with looking arguments up in both the frame and the parent frame. -- Module:Arguments will look up arguments in the parent frame -- if it finds the parent frame's title in options.wrapper; -- otherwise it will look up arguments in the frame object passed -- to getArgs. --]] local parent = frame:getParent() if not parent then fargs = frame.args else local title = parent:getTitle():gsub('/sandbox$', '') local found = false if matchesTitle(options.wrappers, title) then found = true elseif type(options.wrappers) == 'table' then for _,v in pairs(options.wrappers) do if matchesTitle(v, title) then found = true break end end end -- We test for false specifically here so that nil (the default) acts like true. if found or options.frameOnly == false then pargs = parent.args end if not found or options.parentOnly == false then fargs = frame.args end end else -- options.wrapper isn't set, so check the other options. if not options.parentOnly then fargs = frame.args end if not options.frameOnly then local parent = frame:getParent() pargs = parent and parent.args or nil end end if options.parentFirst then fargs, pargs = pargs, fargs end else luaArgs = frame end -- Set the order of precedence of the argument tables. If the variables are -- nil, nothing will be added to the table, which is how we avoid clashes -- between the frame/parent args and the Lua args. local argTables = {fargs} argTables[#argTables + 1] = pargs argTables[#argTables + 1] = luaArgs --[[ -- Generate the tidyVal function. If it has been specified by the user, we -- use that; if not, we choose one of four functions depending on the -- options chosen. This is so that we don't have to call the options table -- every time the function is called. --]] local tidyVal = options.valueFunc if tidyVal then if type(tidyVal) ~= 'function' then error( "bad value assigned to option 'valueFunc'" .. '(function expected, got ' .. type(tidyVal) .. ')', 2 ) end elseif options.trim ~= false then if options.removeBlanks ~= false then tidyVal = tidyValDefault else tidyVal = tidyValTrimOnly end else if options.removeBlanks ~= false then tidyVal = tidyValRemoveBlanksOnly else tidyVal = tidyValNoChange end end --[[ -- Set up the args, metaArgs and nilArgs tables. args will be the one -- accessed from functions, and metaArgs will hold the actual arguments. Nil -- arguments are memoized in nilArgs, and the metatable connects all of them -- together. --]] local args, metaArgs, nilArgs, metatable = {}, {}, {}, {} setmetatable(args, metatable) local function mergeArgs(tables) --[[ -- Accepts multiple tables as input and merges their keys and values -- into one table. If a value is already present it is not overwritten; -- tables listed earlier have precedence. We are also memoizing nil -- values, which can be overwritten if they are 's' (soft). --]] for _, t in ipairs(tables) do for key, val in pairs(t) do if metaArgs[key] == nil and nilArgs[key] ~= 'h' then local tidiedVal = tidyVal(key, val) if tidiedVal == nil then nilArgs[key] = 's' else metaArgs[key] = tidiedVal end end end end end --[[ -- Define metatable behaviour. Arguments are memoized in the metaArgs table, -- and are only fetched from the argument tables once. Fetching arguments -- from the argument tables is the most resource-intensive step in this -- module, so we try and avoid it where possible. For this reason, nil -- arguments are also memoized, in the nilArgs table. Also, we keep a record -- in the metatable of when pairs and ipairs have been called, so we do not -- run pairs and ipairs on the argument tables more than once. We also do -- not run ipairs on fargs and pargs if pairs has already been run, as all -- the arguments will already have been copied over. --]] metatable.__index = function (t, key) --[[ -- Fetches an argument when the args table is indexed. First we check -- to see if the value is memoized, and if not we try and fetch it from -- the argument tables. When we check memoization, we need to check -- metaArgs before nilArgs, as both can be non-nil at the same time. -- If the argument is not present in metaArgs, we also check whether -- pairs has been run yet. If pairs has already been run, we return nil. -- This is because all the arguments will have already been copied into -- metaArgs by the mergeArgs function, meaning that any other arguments -- must be nil. --]] if type(key) == 'string' then key = options.translate[key] end local val = metaArgs[key] if val ~= nil then return val elseif metatable.donePairs or nilArgs[key] then return nil end for _, argTable in ipairs(argTables) do local argTableVal = tidyVal(key, argTable[key]) if argTableVal ~= nil then metaArgs[key] = argTableVal return argTableVal end end nilArgs[key] = 'h' return nil end metatable.__newindex = function (t, key, val) -- This function is called when a module tries to add a new value to the -- args table, or tries to change an existing value. if type(key) == 'string' then key = options.translate[key] end if options.readOnly then error( 'could not write to argument table key "' .. tostring(key) .. '"; the table is read-only', 2 ) elseif options.noOverwrite and args[key] ~= nil then error( 'could not write to argument table key "' .. tostring(key) .. '"; overwriting existing arguments is not permitted', 2 ) elseif val == nil then --[[ -- If the argument is to be overwritten with nil, we need to erase -- the value in metaArgs, so that __index, __pairs and __ipairs do -- not use a previous existing value, if present; and we also need -- to memoize the nil in nilArgs, so that the value isn't looked -- up in the argument tables if it is accessed again. --]] metaArgs[key] = nil nilArgs[key] = 'h' else metaArgs[key] = val end end local function translatenext(invariant) local k, v = next(invariant.t, invariant.k) invariant.k = k if k == nil then return nil elseif type(k) ~= 'string' or not options.backtranslate then return k, v else local backtranslate = options.backtranslate[k] if backtranslate == nil then -- Skip this one. This is a tail call, so this won't cause stack overflow return translatenext(invariant) else return backtranslate, v end end end metatable.__pairs = function () -- Called when pairs is run on the args table. if not metatable.donePairs then mergeArgs(argTables) metatable.donePairs = true end return translatenext, { t = metaArgs } end local function inext(t, i) -- This uses our __index metamethod local v = t[i + 1] if v ~= nil then return i + 1, v end end metatable.__ipairs = function (t) -- Called when ipairs is run on the args table. return inext, t, 0 end return args end return arguments</text>
| |
| <sha1>5qx9tzlul9ser30uxj9nbasjt92cevn</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Template:Documentation</title>
| |
| <ns>10</ns>
| |
| <id>20803</id>
| |
| <revision>
| |
| <id>6074873</id>
| |
| <parentid>5001084</parentid>
| |
| <timestamp>2023-08-20T02:47:59Z</timestamp>
| |
| <contributor>
| |
| <username>Shirayuki</username>
| |
| <id>472859</id>
| |
| </contributor>
| |
| <minor/>
| |
| <model>wikitext</model>
| |
| <format>text/x-wiki</format>
| |
| <text bytes="2050" xml:space="preserve"><noinclude> <languages/> </noinclude><includeonly>{{#invoke:documentation|main|_content={{ {{#invoke:documentation|contentTitle}}}}}}</includeonly><noinclude> {{documentation|content= {{Lua|Module:Documentation}} <translate><!--T:12--> This template automatically displays a documentation box like the one you are seeing now, of which the content is sometimes transcluded from another page.</translate> <translate><!--T:13--> It is intended for pages which are [[<tvar name=1>Special:MyLanguage/Help:Transclusion</tvar>|transcluded]] in other pages, i.e. templates, whether in the template namespace or not.</translate> <translate> ==Usage== <!--T:2--> ===Customising display=== <!--T:3--> <!--T:4--> Overrides exist to customise the output in special cases: </translate> * <nowiki>{{</nowiki>documentation{{!}}'''heading'''=<nowiki>}}</nowiki> - <translate><!--T:5--> change the text of the "documentation" heading.</translate> <translate><!--T:10--> If this is set to blank, the entire heading line (including the first [edit] link) will also disappear.</translate> <translate> ==Rationale== <!--T:6--> </translate> <translate><!--T:7--> This template allows any page to use any documentation page, and makes it possible to protect templates while allowing anyone to edit the template's documentation and categories.</translate> <translate><!--T:8--> It also reduces server resources by circumventing a [[w:Wikipedia:Template limits|technical limitation of templates]] (see a [[<tvar name=1>:en:Special:Diff/69888944</tvar>|developer's explanation]]).</translate> <translate> ==See also== <!--T:9--> </translate> * <translate><!--T:14--> [[w:Template:Documentation subpage]]</translate> * {{tim|Documentation}} * <translate><!--T:11--> [[w:Wikipedia:Template documentation]]</translate> }} [[Category:Formatting templates{{#translation:}}|Template documentation]] [[Category:Template documentation{{#translation:}}| ]] </noinclude><includeonly>{{#if:{{{content|}}}| [[Category:Template documentation pages{{#translation:}}]] }}</includeonly></text>
| |
| <sha1>mnjbqg9a4m2i4mxjdkm5h49y7rfl6lp</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Template:Documentation/en</title>
| |
| <ns>10</ns>
| |
| <id>952042</id>
| |
| <revision>
| |
| <id>6074882</id>
| |
| <parentid>5003793</parentid>
| |
| <timestamp>2023-08-20T02:48:20Z</timestamp>
| |
| <contributor>
| |
| <username>FuzzyBot</username>
| |
| <id>451990</id>
| |
| </contributor>
| |
| <comment>Updating to match new version of source page</comment>
| |
| <model>wikitext</model>
| |
| <format>text/x-wiki</format>
| |
| <text bytes="1603" xml:space="preserve"><noinclude> <languages/> </noinclude><includeonly>{{#invoke:documentation|main|_content={{ {{#invoke:documentation|contentTitle}}}}}}</includeonly><noinclude> {{documentation|content= {{Lua|Module:Documentation}} This template automatically displays a documentation box like the one you are seeing now, of which the content is sometimes transcluded from another page. It is intended for pages which are [[Special:MyLanguage/Help:Transclusion|transcluded]] in other pages, i.e. templates, whether in the template namespace or not. ==Usage== ===Customising display=== Overrides exist to customise the output in special cases: * <nowiki>{{</nowiki>documentation{{!}}'''heading'''=<nowiki>}}</nowiki> - change the text of the "documentation" heading. If this is set to blank, the entire heading line (including the first [edit] link) will also disappear. ==Rationale== This template allows any page to use any documentation page, and makes it possible to protect templates while allowing anyone to edit the template's documentation and categories. It also reduces server resources by circumventing a [[w:Wikipedia:Template limits|technical limitation of templates]] (see a [[:en:Special:Diff/69888944|developer's explanation]]). ==See also== * [[w:Template:Documentation subpage]] * {{tim|Documentation}} * [[w:Wikipedia:Template documentation]] }} [[Category:Formatting templates{{#translation:}}|Template documentation]] [[Category:Template documentation{{#translation:}}| ]] </noinclude><includeonly>{{#if:{{{content|}}}| [[Category:Template documentation pages{{#translation:}}]] }}</includeonly></text>
| |
| <sha1>60geae1hw4mwpyi2sqakvfwhghu0iei</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Module:Documentation</title>
| |
| <ns>828</ns>
| |
| <id>191985</id>
| |
| <revision>
| |
| <id>5775458</id>
| |
| <parentid>4731711</parentid>
| |
| <timestamp>2023-02-14T16:27:01Z</timestamp>
| |
| <contributor>
| |
| <username>Uzume</username>
| |
| <id>222223</id>
| |
| </contributor>
| |
| <comment>cherry pick Module wikitext support from [[w:en:Module:Documentation]]</comment>
| |
| <model>Scribunto</model>
| |
| <format>text/plain</format>
| |
| <text bytes="36079" xml:space="preserve">-- This module implements {{documentation}}. -- Get required modules. local getArgs = require('Module:Arguments').getArgs local messageBox = require('Module:Message box') -- Get the config table. local cfg = mw.loadData('Module:Documentation/config') local i18n = mw.loadData('Module:Documentation/i18n') local p = {} -- Often-used functions. local ugsub = mw.ustring.gsub ---------------------------------------------------------------------------- -- Helper functions -- -- These are defined as local functions, but are made available in the p -- table for testing purposes. ---------------------------------------------------------------------------- local function message(cfgKey, valArray, expectType) --[[ -- Gets a message from the cfg table and formats it if appropriate. -- The function raises an error if the value from the cfg table is not -- of the type expectType. The default type for expectType is 'string'. -- If the table valArray is present, strings such as $1, $2 etc. in the -- message are substituted with values from the table keys [1], [2] etc. -- For example, if the message "foo-message" had the value 'Foo $2 bar $1.', -- message('foo-message', {'baz', 'qux'}) would return "Foo qux bar baz." --]] local msg = cfg[cfgKey] expectType = expectType or 'string' if type(msg) ~= expectType then error(require('Module:TNT').format('I18n/Documentation', 'cfg-error-msg-type', cfgKey, expectType, type(msg)), 2) end if not valArray then return msg end local function getMessageVal(match) match = tonumber(match) return valArray[match] or error(require('Module:TNT').format('I18n/Documentation', 'cfg-error-msg-empty', '$' .. match, cfgKey), 4) end local ret = ugsub(msg, '$([1-9][0-9]*)', getMessageVal) return ret end p.message = message local function makeWikilink(page, display) if display then return mw.ustring.format('[[%s|%s]]', page, display) else return mw.ustring.format('[[%s]]', page) end end p.makeWikilink = makeWikilink local function makeCategoryLink(cat, sort) local catns = mw.site.namespaces[14].name return makeWikilink(catns .. ':' .. cat, sort) end p.makeCategoryLink = makeCategoryLink local function makeUrlLink(url, display) return mw.ustring.format('[%s %s]', url, display) end p.makeUrlLink = makeUrlLink local function makeToolbar(...) local ret = {} local lim = select('#', ...) if lim < 1 then return nil end for i = 1, lim do ret[#ret + 1] = select(i, ...) end return '<small style="font-style: normal;">(' .. table.concat(ret, ' | ') .. ')</small>' end p.makeToolbar = makeToolbar ---------------------------------------------------------------------------- -- Argument processing ---------------------------------------------------------------------------- local function makeInvokeFunc(funcName) return function (frame) local args = getArgs(frame, { valueFunc = function (key, value) if type(value) == 'string' then value = value:match('^%s*(.-)%s*$') -- Remove whitespace. if key == 'heading' or value ~= '' then return value else return nil end else return value end end }) return p[funcName](args) end end ---------------------------------------------------------------------------- -- Load TemplateStyles ---------------------------------------------------------------------------- p.main = function(frame) local parent = frame.getParent(frame) local output = p._main(parent.args) return frame:extensionTag{ name='templatestyles', args = { src= message('templatestyles-scr') } } .. output end ---------------------------------------------------------------------------- -- Main function ---------------------------------------------------------------------------- function p._main(args) --[[ -- This function defines logic flow for the module. -- @args - table of arguments passed by the user -- -- Messages: -- 'main-div-id' --> 'template-documentation' -- 'main-div-classes' --> 'template-documentation iezoomfix' --]] local env = p.getEnvironment(args) local root = mw.html.create() root :wikitext(p._getModuleWikitext(args, env)) :wikitext(p.protectionTemplate(env)) :wikitext(p.sandboxNotice(args, env)) -- This div tag is from {{documentation/start box}}, but moving it here -- so that we don't have to worry about unclosed tags. :tag('div') :attr('id', message('main-div-id')) :addClass(message('main-div-class')) :wikitext(p._startBox(args, env)) :wikitext(p._content(args, env)) :done() :wikitext(p._endBox(args, env)) :wikitext(p.addTrackingCategories(env)) return tostring(root) end ---------------------------------------------------------------------------- -- Environment settings ---------------------------------------------------------------------------- function p.getEnvironment(args) --[[ -- Returns a table with information about the environment, including title objects and other namespace- or -- path-related data. -- @args - table of arguments passed by the user -- -- Title objects include: -- env.title - the page we are making documentation for (usually the current title) -- env.templateTitle - the template (or module, file, etc.) -- env.docTitle - the /doc subpage. -- env.sandboxTitle - the /sandbox subpage. -- env.testcasesTitle - the /testcases subpage. -- env.printTitle - the print version of the template, located at the /Print subpage. -- -- Data includes: -- env.protectionLevels - the protection levels table of the title object. -- env.subjectSpace - the number of the title's subject namespace. -- env.docSpace - the number of the namespace the title puts its documentation in. -- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace. -- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template. -- -- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value -- returned will be nil. --]] local env, envFuncs = {}, {} -- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value -- returned by that function is memoized in the env table so that we don't call any of the functions -- more than once. (Nils won't be memoized.) setmetatable(env, { __index = function (t, key) local envFunc = envFuncs[key] if envFunc then local success, val = pcall(envFunc) if success then env[key] = val -- Memoise the value. return val end end return nil end }) function envFuncs.title() -- The title object for the current page, or a test page passed with args.page. local title local titleArg = args.page if titleArg then title = mw.title.new(titleArg) else title = mw.title.getCurrentTitle() end return title end function envFuncs.templateTitle() --[[ -- The template (or module, etc.) title object. -- Messages: -- 'sandbox-subpage' --> 'sandbox' -- 'testcases-subpage' --> 'testcases' --]] local subjectSpace = env.subjectSpace local title = env.title local subpage = title.subpageText if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then return mw.title.makeTitle(subjectSpace, title.baseText) else return mw.title.makeTitle(subjectSpace, title.text) end end function envFuncs.docTitle() --[[ -- Title object of the /doc subpage. -- Messages: -- 'doc-subpage' --> 'doc' --]] local title = env.title local docname = args[1] -- User-specified doc page. local docpage if docname then docpage = docname else docpage = env.docpageBase .. '/' .. message('doc-subpage') end return mw.title.new(docpage) end function envFuncs.sandboxTitle() --[[ -- Title object for the /sandbox subpage. -- Messages: -- 'sandbox-subpage' --> 'sandbox' --]] return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage')) end function envFuncs.testcasesTitle() --[[ -- Title object for the /testcases subpage. -- Messages: -- 'testcases-subpage' --> 'testcases' --]] return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage')) end function envFuncs.printTitle() --[[ -- Title object for the /Print subpage. -- Messages: -- 'print-subpage' --> 'Print' --]] return env.templateTitle:subPageTitle(message('print-subpage')) end function envFuncs.protectionLevels() -- The protection levels table of the title object. return env.title.protectionLevels end function envFuncs.subjectSpace() -- The subject namespace number. return mw.site.namespaces[env.title.namespace].subject.id end function envFuncs.docSpace() -- The documentation namespace number. For most namespaces this is the same as the -- subject namespace. However, pages in the Article, File, MediaWiki or Category -- namespaces must have their /doc, /sandbox and /testcases pages in talk space. local subjectSpace = env.subjectSpace if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then return subjectSpace + 1 else return subjectSpace end end function envFuncs.docpageBase() -- The base page of the /doc, /sandbox, and /testcases subpages. -- For some namespaces this is the talk page, rather than the template page. local templateTitle = env.templateTitle local docSpace = env.docSpace local docSpaceText = mw.site.namespaces[docSpace].name -- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon. return docSpaceText .. ':' .. templateTitle.text end function envFuncs.compareUrl() -- Diff link between the sandbox and the main template using [[Special:ComparePages]]. local templateTitle = env.templateTitle local sandboxTitle = env.sandboxTitle if templateTitle.exists and sandboxTitle.exists then local compareUrl = mw.uri.fullUrl( 'Special:ComparePages', {page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText} ) return tostring(compareUrl) else return nil end end return env end ---------------------------------------------------------------------------- -- Auxiliary templates ---------------------------------------------------------------------------- p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext') function p._getModuleWikitext(args, env) local currentTitle = mw.title.getCurrentTitle() if currentTitle.contentModel ~= 'Scribunto' then return end pcall(require, currentTitle.prefixedText) -- if it fails, we don't care local moduleWikitext = package.loaded["Module:Module wikitext"] if moduleWikitext then return moduleWikitext.main() end end function p.sandboxNotice(args, env) --[=[ -- Generates a sandbox notice for display above sandbox pages. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'sandbox-notice-image' --> '[[Image:Sandbox.svg|50px|alt=|link=]]' -- 'sandbox-notice-blurb' --> 'This is the $1 for $2.' -- 'sandbox-notice-diff-blurb' --> 'This is the $1 for $2 ($3).' -- 'sandbox-notice-pagetype-template' --> '[[w:Wikipedia:Template test cases|template sandbox]] page' -- 'sandbox-notice-pagetype-module' --> '[[w:Wikipedia:Template test cases|module sandbox]] page' -- 'sandbox-notice-pagetype-other' --> 'sandbox page' -- 'sandbox-notice-compare-link-display' --> 'diff' -- 'sandbox-notice-testcases-blurb' --> 'See also the companion subpage for $1.' -- 'sandbox-notice-testcases-link-display' --> 'test cases' -- 'sandbox-category' --> 'Template sandboxes' --]=] local title = env.title local sandboxTitle = env.sandboxTitle local templateTitle = env.templateTitle local subjectSpace = env.subjectSpace if not (subjectSpace and title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then return nil end -- Build the table of arguments to pass to {{ombox}}. We need just two fields, "image" and "text". local omargs = {} omargs.image = message('sandbox-notice-image') -- Get the text. We start with the opening blurb, which is something like -- "This is the template sandbox for [[Template:Foo]] (diff)." local text = '' local frame = mw.getCurrentFrame() local isPreviewing = frame:preprocess('{{REVISIONID}}') == '' -- True if the page is being previewed. local pagetype if subjectSpace == 10 then pagetype = message('sandbox-notice-pagetype-template') elseif subjectSpace == 828 then pagetype = message('sandbox-notice-pagetype-module') else pagetype = message('sandbox-notice-pagetype-other') end local templateLink = makeWikilink(templateTitle.prefixedText) local compareUrl = env.compareUrl if isPreviewing or not compareUrl then text = text .. message('sandbox-notice-blurb', {pagetype, templateLink}) else local compareDisplay = message('sandbox-notice-compare-link-display') local compareLink = makeUrlLink(compareUrl, compareDisplay) text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink}) end -- Get the test cases page blurb if the page exists. This is something like -- "See also the companion subpage for [[Template:Foo/testcases|test cases]]." local testcasesTitle = env.testcasesTitle if testcasesTitle and testcasesTitle.exists then if testcasesTitle.contentModel == "Scribunto" then local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink}) else local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display') local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay) text = text .. '<br />' .. message('sandbox-notice-testcases-blurb', {testcasesLink}) end end -- Add the sandbox to the sandbox category. text = text .. makeCategoryLink(message('sandbox-category')) omargs.text = text omargs.class = message('sandbox-class') local ret = '<div style="clear: both;"></div>' ret = ret .. messageBox.main('ombox', omargs) return ret end function p.protectionTemplate(env) -- Generates the padlock icon in the top right. -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'protection-template' --> 'pp-template' -- 'protection-template-args' --> {docusage = 'yes'} local title = env.title local protectionLevels local protectionTemplate = message('protection-template') local namespace = title.namespace if not (protectionTemplate and (namespace == 10 or namespace == 828)) then -- Don't display the protection template if we are not in the template or module namespaces. return nil end protectionLevels = env.protectionLevels if not protectionLevels then return nil end local editLevels = protectionLevels.edit local moveLevels = protectionLevels.move if moveLevels and moveLevels[1] == 'sysop' or editLevels and editLevels[1] then -- The page is full-move protected, or full, template, or semi-protected. local frame = mw.getCurrentFrame() return frame:expandTemplate{title = protectionTemplate, args = message('protection-template-args', nil, 'table')} else return nil end end ---------------------------------------------------------------------------- -- Start box ---------------------------------------------------------------------------- p.startBox = makeInvokeFunc('_startBox') function p._startBox(args, env) --[[ -- This function generates the start box. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make -- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox -- which generate the box HTML. --]] env = env or p.getEnvironment(args) local links local content = args.content if not content then -- No need to include the links if the documentation is on the template page itself. local linksData = p.makeStartBoxLinksData(args, env) if linksData then links = p.renderStartBoxLinks(linksData) end end -- Generate the start box html. local data = p.makeStartBoxData(args, env, links) if data then return p.renderStartBox(data) else -- User specified no heading. return nil end end function p.makeStartBoxLinksData(args, env) --[[ -- Does initial processing of data to make the [view] [edit] [history] [purge] links. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'view-link-display' --> 'view' -- 'edit-link-display' --> 'edit' -- 'history-link-display' --> 'history' -- 'purge-link-display' --> 'purge' -- 'file-docpage-preload' --> 'Template:Documentation/preload-filespace' -- 'module-preload' --> 'Template:Documentation/preload-module-doc' -- 'docpage-preload' --> 'Template:Documentation/preload' -- 'create-link-display' --> 'create' --]] local subjectSpace = env.subjectSpace local title = env.title local docTitle = env.docTitle if not title or not docTitle then return nil end if docTitle.isRedirect then docTitle = docTitle.redirectTarget end local data = {} data.title = title data.docTitle = docTitle -- View, display, edit, and purge links if /doc exists. data.viewLinkDisplay = i18n['view-link-display'] data.editLinkDisplay = i18n['edit-link-display'] data.historyLinkDisplay = i18n['history-link-display'] data.purgeLinkDisplay = i18n['purge-link-display'] -- Create link if /doc doesn't exist. local preload = args.preload if not preload then if subjectSpace == 6 then -- File namespace preload = message('file-docpage-preload') elseif subjectSpace == 828 then -- Module namespace preload = message('module-preload') else preload = message('docpage-preload') end end data.preload = preload data.createLinkDisplay = i18n['create-link-display'] return data end function p.renderStartBoxLinks(data) --[[ -- Generates the [view][edit][history][purge] or [create] links from the data table. -- @data - a table of data generated by p.makeStartBoxLinksData --]] local function escapeBrackets(s) -- Escapes square brackets with HTML entities. s = s:gsub('%[', '[') -- Replace square brackets with HTML entities. s = s:gsub('%]', ']') return s end local ret local docTitle = data.docTitle local title = data.title if docTitle.exists then local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay) local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay) local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay) local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay) ret = '[%s] [%s] [%s] [%s]' ret = escapeBrackets(ret) ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink) else local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay) ret = '[%s]' ret = escapeBrackets(ret) ret = mw.ustring.format(ret, createLink) end return ret end function p.makeStartBoxData(args, env, links) --[=[ -- Does initial processing of data to pass to the start-box render function, p.renderStartBox. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error. -- -- Messages: -- 'documentation-icon-wikitext' --> '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=Documentation icon]]' -- 'template-namespace-heading' --> 'Template documentation' -- 'module-namespace-heading' --> 'Module documentation' -- 'file-namespace-heading' --> 'Summary' -- 'other-namespaces-heading' --> 'Documentation' -- 'start-box-linkclasses' --> 'mw-editsection-like plainlinks' -- 'start-box-link-id' --> 'doc_editlinks' -- 'testcases-create-link-display' --> 'create' --]=] local subjectSpace = env.subjectSpace if not subjectSpace then -- Default to an "other namespaces" namespace, so that we get at least some output -- if an error occurs. subjectSpace = 2 end local data = {} -- Heading local heading = args.heading -- Blank values are not removed. if heading == '' then -- Don't display the start box if the heading arg is defined but blank. return nil end if heading then data.heading = heading elseif subjectSpace == 10 then -- Template namespace data.heading = i18n['template-namespace-heading'] elseif subjectSpace == 828 then -- Module namespace data.heading = i18n['module-namespace-heading'] elseif subjectSpace == 6 then -- File namespace data.heading = i18n['file-namespace-heading'] else data.heading = i18n['other-namespaces-heading'] end -- Data for the [view][edit][history][purge] or [create] links. if links then data.linksClass = message('start-box-linkclasses') data.linksId = message('start-box-link-id') data.links = links end return data end function p.renderStartBox(data) -- Renders the start box html. -- @data - a table of data generated by p.makeStartBoxData. local sbox = mw.html.create('div') sbox :addClass(message('header-div-class')) :tag('div') :addClass(message('heading-div-class')) :wikitext(data.heading) local links = data.links if links then sbox :tag('div') :addClass(data.linksClass) :attr('id', data.linksId) :wikitext(links) end return tostring(sbox) end ---------------------------------------------------------------------------- -- Documentation content ---------------------------------------------------------------------------- p.content = makeInvokeFunc('_content') function p._content(args, env) -- Displays the documentation contents -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment env = env or p.getEnvironment(args) local docTitle = env.docTitle local content = args.content if not content and docTitle and docTitle.exists then content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle} end -- The line breaks below are necessary so that "=== Headings ===" at the start and end -- of docs are interpreted correctly. local cbox = mw.html.create('div') cbox :addClass(message('content-div-class')) :wikitext('\n' .. (content or '') .. '\n') return tostring(cbox) end p.contentTitle = makeInvokeFunc('_contentTitle') function p._contentTitle(args, env) env = env or p.getEnvironment(args) local docTitle = env.docTitle if not args.content and docTitle and docTitle.exists then return docTitle.prefixedText else return '' end end ---------------------------------------------------------------------------- -- End box ---------------------------------------------------------------------------- p.endBox = makeInvokeFunc('_endBox') function p._endBox(args, env) --[=[ -- This function generates the end box (also known as the link box). -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment --]=] -- Get environment data. env = env or p.getEnvironment(args) local subjectSpace = env.subjectSpace local docTitle = env.docTitle if not subjectSpace or not docTitle then return nil end -- Check whether we should output the end box at all. Add the end -- box by default if the documentation exists or if we are in the -- user, module or template namespaces. local linkBox = args['link box'] if linkBox == 'off' or not ( docTitle.exists or subjectSpace == 2 or subjectSpace == 828 or subjectSpace == 10 ) then return nil end -- Assemble the footer text field. local text = '' if linkBox then text = text .. linkBox else text = text .. (p.makeDocPageBlurb(args, env) or '') -- "This documentation is transcluded from [[Foo]]." if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then -- We are in the user, template or module namespaces. -- Add sandbox and testcases links. -- "Editors can experiment in this template's sandbox and testcases pages." text = text .. (p.makeExperimentBlurb(args, env) or '') text = text .. '<br />' if not args.content and not args[1] then -- "Please add categories to the /doc subpage." -- Don't show this message with inline docs or with an explicitly specified doc page, -- as then it is unclear where to add the categories. text = text .. (p.makeCategoriesBlurb(args, env) or '') end text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --"Subpages of this template" local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates. if printBlurb then text = text .. '<br />' .. printBlurb end end end local ebox = mw.html.create('div') ebox :addClass(message('footer-div-class')) :wikitext(text) return tostring(ebox) end function p.makeDocPageBlurb(args, env) --[=[ -- Makes the blurb "This documentation is transcluded from [[Template:Foo]] (edit, history)". -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'edit-link-display' --> 'edit' -- 'history-link-display' --> 'history' -- 'transcluded-from-blurb' --> -- 'The above [[w:Wikipedia:Template documentation|documentation]] -- is [[w:Wikipedia:Transclusion|transcluded]] from $1.' -- 'module-preload' --> 'Template:Documentation/preload-module-doc' -- 'create-link-display' --> 'create' -- 'create-module-doc-blurb' --> -- 'You might want to $1 a documentation page for this [[w:Wikipedia:Lua|Scribunto module]].' --]=] local docTitle = env.docTitle if not docTitle or args.content then return nil end local ret if docTitle.exists then -- /doc exists; link to it. local docLink = makeWikilink(docTitle.prefixedText) local editUrl = docTitle:fullUrl{action = 'edit'} local editDisplay = i18n['edit-link-display'] local editLink = makeUrlLink(editUrl, editDisplay) local historyUrl = docTitle:fullUrl{action = 'history'} local historyDisplay = i18n['history-link-display'] local historyLink = makeUrlLink(historyUrl, historyDisplay) ret = message('transcluded-from-blurb', {docLink}) .. ' ' .. makeToolbar(editLink, historyLink) .. '<br />' elseif env.subjectSpace == 828 then -- /doc does not exist; ask to create it. local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')} local createDisplay = i18n['create-link-display'] local createLink = makeUrlLink(createUrl, createDisplay) ret = message('create-module-doc-blurb', {createLink}) .. '<br />' end return ret end function p.makeExperimentBlurb(args, env) --[[ -- Renders the text "Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages." -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'sandbox-link-display' --> 'sandbox' -- 'sandbox-edit-link-display' --> 'edit' -- 'compare-link-display' --> 'diff' -- 'module-sandbox-preload' --> 'Template:Documentation/preload-module-sandbox' -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' -- 'sandbox-create-link-display' --> 'create' -- 'mirror-edit-summary' --> 'Create sandbox version of $1' -- 'mirror-link-display' --> 'mirror' -- 'mirror-link-preload' --> 'Template:Documentation/mirror' -- 'sandbox-link-display' --> 'sandbox' -- 'testcases-link-display' --> 'testcases' -- 'testcases-edit-link-display'--> 'edit' -- 'template-sandbox-preload' --> 'Template:Documentation/preload-sandbox' -- 'testcases-create-link-display' --> 'create' -- 'testcases-link-display' --> 'testcases' -- 'testcases-edit-link-display' --> 'edit' -- 'module-testcases-preload' --> 'Template:Documentation/preload-module-testcases' -- 'template-testcases-preload' --> 'Template:Documentation/preload-testcases' -- 'experiment-blurb-module' --> 'Editors can experiment in this module's $1 and $2 pages.' -- 'experiment-blurb-template' --> 'Editors can experiment in this template's $1 and $2 pages.' --]] local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle local sandboxTitle = env.sandboxTitle local testcasesTitle = env.testcasesTitle local templatePage = templateTitle.prefixedText if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then return nil end -- Make links. local sandboxLinks, testcasesLinks if sandboxTitle.exists then local sandboxPage = sandboxTitle.prefixedText local sandboxDisplay = message('sandbox-link-display') local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay) local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'} local sandboxEditDisplay = message('sandbox-edit-link-display') local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay) local compareUrl = env.compareUrl local compareLink if compareUrl then local compareDisplay = message('compare-link-display') compareLink = makeUrlLink(compareUrl, compareDisplay) end sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink) else local sandboxPreload if subjectSpace == 828 then sandboxPreload = message('module-sandbox-preload') else sandboxPreload = message('template-sandbox-preload') end local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload} local sandboxCreateDisplay = message('sandbox-create-link-display') local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay) local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)}) local mirrorPreload = message('mirror-link-preload') local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary} local mirrorDisplay = message('mirror-link-display') local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay) sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink) end if testcasesTitle.exists then local testcasesPage = testcasesTitle.prefixedText local testcasesDisplay = message('testcases-link-display') local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay) local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'} local testcasesEditDisplay = message('testcases-edit-link-display') local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay) testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink) else local testcasesPreload if subjectSpace == 828 then testcasesPreload = message('module-testcases-preload') else testcasesPreload = message('template-testcases-preload') end local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload} local testcasesCreateDisplay = message('testcases-create-link-display') local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay) testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink) end local messageName if subjectSpace == 828 then messageName = 'experiment-blurb-module' else messageName = 'experiment-blurb-template' end return message(messageName, {sandboxLinks, testcasesLinks}) end function p.makeCategoriesBlurb(args, env) --[[ -- Generates the text "Please add categories to the /doc subpage." -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'doc-link-display' --> '/doc' -- 'add-categories-blurb' --> 'Please add categories to the $1 subpage.' --]] local docTitle = env.docTitle if not docTitle then return nil end local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display')) return message('add-categories-blurb', {docPathLink}) end function p.makeSubpagesBlurb(args, env) --[[ -- Generates the "Subpages of this template" link. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'template-pagetype' --> 'template' -- 'module-pagetype' --> 'module' -- 'default-pagetype' --> 'page' -- 'subpages-link-display' --> 'Subpages of this $1' --]] local subjectSpace = env.subjectSpace local templateTitle = env.templateTitle if not subjectSpace or not templateTitle then return nil end local pagetype if subjectSpace == 10 then pagetype = message('template-pagetype') elseif subjectSpace == 828 then pagetype = message('module-pagetype') else pagetype = message('default-pagetype') end local subpagesLink = makeWikilink( 'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/', message('subpages-link-display', {pagetype}) ) return message('subpages-blurb', {subpagesLink}) end function p.makePrintBlurb(args, env) --[=[ -- Generates the blurb displayed when there is a print version of the template available. -- @args - a table of arguments passed by the user -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- -- Messages: -- 'print-link-display' --> '/Print' -- 'print-blurb' --> 'A [[Help:Books/for experts#Improving the book layout|print version]]' -- .. ' of this template exists at $1.' -- .. ' If you make a change to this template, please update the print version as well.' -- 'display-print-category' --> true -- 'print-category' --> 'Templates with print versions' --]=] local printTitle = env.printTitle if not printTitle then return nil end local ret if printTitle.exists then local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display')) ret = message('print-blurb', {printLink}) local displayPrintCategory = message('display-print-category', nil, 'boolean') if displayPrintCategory then ret = ret .. makeCategoryLink(message('print-category')) end end return ret end ---------------------------------------------------------------------------- -- Tracking categories ---------------------------------------------------------------------------- function p.addTrackingCategories(env) --[[ -- Check if {{documentation}} is transcluded on a /doc or /testcases page. -- @env - environment table containing title objects, etc., generated with p.getEnvironment -- Messages: -- 'display-strange-usage-category' --> true -- 'doc-subpage' --> 'doc' -- 'testcases-subpage' --> 'testcases' -- 'strange-usage-category' --> 'Wikipedia pages with strange ((documentation)) usage' -- -- /testcases pages in the module namespace are not categorised, as they may have -- {{documentation}} transcluded automatically. --]] local title = env.title local subjectSpace = env.subjectSpace if not title or not subjectSpace then return nil end local subpage = title.subpageText local ret = '' if message('display-strange-usage-category', nil, 'boolean') and ( subpage == message('doc-subpage') or subjectSpace ~= 828 and subpage == message('testcases-subpage') ) then ret = ret .. makeCategoryLink(message('strange-usage-category')) end return ret end return p</text>
| |
| <sha1>1ngo52yvg28x5k486loxndzvf0dgs5k</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Module:Documentation/config</title>
| |
| <ns>828</ns>
| |
| <id>191986</id>
| |
| <revision>
| |
| <id>6372414</id>
| |
| <parentid>5820213</parentid>
| |
| <timestamp>2024-02-17T14:43:52Z</timestamp>
| |
| <contributor>
| |
| <username>Uzume</username>
| |
| <id>222223</id>
| |
| </contributor>
| |
| <minor/>
| |
| <comment>consistent ns refs</comment>
| |
| <model>Scribunto</model>
| |
| <format>text/plain</format>
| |
| <text bytes="17768" xml:space="preserve">---------------------------------------------------------------------------------------------------- -- -- Configuration for Module:Documentation -- -- Here you can set the values of the parameters and messages used in Module:Documentation to -- localise it to your wiki and your language. Unless specified otherwise, values given here -- should be string values. ---------------------------------------------------------------------------------------------------- local _format = require('Module:TNT').format local function format(id) return _format('I18n/Documentation', id) end local cfg = {} -- Do not edit this line. cfg['templatestyles-scr'] = 'Module:Documentation/styles.css' ---------------------------------------------------------------------------------------------------- -- Protection template configuration ---------------------------------------------------------------------------------------------------- -- cfg['protection-template'] -- The name of the template that displays the protection icon (a padlock on enwiki). cfg['protection-template'] = 'pp-template' -- cfg['protection-reason-edit'] -- The protection reason for edit-protected templates to pass to -- [[Module:Protection banner]]. cfg['protection-reason-edit'] = 'template' --[[ -- cfg['protection-template-args'] -- Any arguments to send to the protection template. This should be a Lua table. -- For example, if the protection template is "pp-template", and the wikitext template invocation -- looks like "{{pp-template|docusage=yes}}", then this table should look like "{docusage = 'yes'}". --]] cfg['protection-template-args'] = {docusage = 'yes'} --[[ ---------------------------------------------------------------------------------------------------- -- Sandbox notice configuration -- -- On sandbox pages the module can display a template notifying users that the current page is a -- sandbox, and the location of test cases pages, etc. The module decides whether the page is a -- sandbox or not based on the value of cfg['sandbox-subpage']. The following settings configure the -- messages that the notices contains. ---------------------------------------------------------------------------------------------------- --]] -- cfg['sandbox-notice-image'] -- The image displayed in the sandbox notice. cfg['sandbox-notice-image'] = '[[File:Edit In Sandbox Icon - Color.svg|40px|alt=|link=]]' --[[ -- cfg['sandbox-notice-pagetype-template'] -- cfg['sandbox-notice-pagetype-module'] -- cfg['sandbox-notice-pagetype-other'] -- The page type of the sandbox page. The message that is displayed depends on the current subject -- namespace. This message is used in either cfg['sandbox-notice-blurb'] or -- cfg['sandbox-notice-diff-blurb']. --]] cfg['sandbox-notice-pagetype-template'] = format('sandbox-notice-pagetype-template') cfg['sandbox-notice-pagetype-module'] = format('sandbox-notice-pagetype-module') cfg['sandbox-notice-pagetype-other'] = format('sandbox-notice-pagetype-other') --[[ -- cfg['sandbox-notice-blurb'] -- cfg['sandbox-notice-diff-blurb'] -- cfg['sandbox-notice-diff-display'] -- Either cfg['sandbox-notice-blurb'] or cfg['sandbox-notice-diff-blurb'] is the opening sentence -- of the sandbox notice. The latter has a diff link, but the former does not. $1 is the page -- type, which is either cfg['sandbox-notice-pagetype-template'], -- cfg['sandbox-notice-pagetype-module'] or cfg['sandbox-notice-pagetype-other'] depending what -- namespace we are in. $2 is a link to the main template page, and $3 is a diff link between -- the sandbox and the main template. The display value of the diff link is set by -- cfg['sandbox-notice-compare-link-display']. --]] cfg['sandbox-notice-blurb'] = format('sandbox-notice-blurb') cfg['sandbox-notice-diff-blurb'] = format('sandbox-notice-diff-blurb') cfg['sandbox-notice-compare-link-display'] = format('sandbox-notice-compare-link-display') --[[ -- cfg['sandbox-notice-testcases-blurb'] -- cfg['sandbox-notice-testcases-link-display'] -- cfg['sandbox-notice-testcases-run-blurb'] -- cfg['sandbox-notice-testcases-run-link-display'] -- cfg['sandbox-notice-testcases-blurb'] is a sentence notifying the user that there is a test cases page -- corresponding to this sandbox that they can edit. $1 is a link to the test cases page. -- cfg['sandbox-notice-testcases-link-display'] is the display value for that link. -- cfg['sandbox-notice-testcases-run-blurb'] is a sentence notifying the user that there is a test cases page -- corresponding to this sandbox that they can edit, along with a link to run it. $1 is a link to the test -- cases page, and $2 is a link to the page to run it. -- cfg['sandbox-notice-testcases-run-link-display'] is the display value for the link to run the test -- cases. --]] cfg['sandbox-notice-testcases-blurb'] = format('sandbox-notice-testcases-blurb') cfg['sandbox-notice-testcases-link-display'] = format('sandbox-notice-testcases-link-display') cfg['sandbox-notice-testcases-run-blurb'] = format('sandbox-notice-testcases-run-blurb') cfg['sandbox-notice-testcases-run-link-display'] = format('sandbox-notice-testcases-run-link-display') -- cfg['sandbox-category'] -- A category to add to all template sandboxes. cfg['sandbox-category'] = 'Template sandboxes' ---------------------------------------------------------------------------------------------------- -- Start box configuration ---------------------------------------------------------------------------------------------------- -- cfg['documentation-icon-wikitext'] -- The wikitext for the icon shown at the top of the template. cfg['documentation-icon-wikitext'] = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=Documentation icon]]' ---------------------------------------------------------------------------------------------------- -- Link box (end box) configuration ---------------------------------------------------------------------------------------------------- -- cfg['transcluded-from-blurb'] -- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page. cfg['transcluded-from-blurb'] = format('transcluded-from-blurb') --[[ -- cfg['create-module-doc-blurb'] -- Notice displayed in the module namespace when the documentation subpage does not exist. -- $1 is a link to create the documentation page with the preload cfg['module-preload'] and the -- display cfg['create-link-display']. --]] cfg['create-module-doc-blurb'] = format('create-module-doc-blurb') ---------------------------------------------------------------------------------------------------- -- Experiment blurb configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['experiment-blurb-template'] -- cfg['experiment-blurb-module'] -- The experiment blurb is the text inviting editors to experiment in sandbox and test cases pages. -- It is only shown in the template and module namespaces. With the default English settings, it -- might look like this: -- -- Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. -- -- In this example, "sandbox", "edit", "diff", "testcases", and "edit" would all be links. -- -- There are two versions, cfg['experiment-blurb-template'] and cfg['experiment-blurb-module'], depending -- on what namespace we are in. -- -- Parameters: -- -- $1 is a link to the sandbox page. If the sandbox exists, it is in the following format: -- -- cfg['sandbox-link-display'] (cfg['sandbox-edit-link-display'] | cfg['compare-link-display']) -- -- If the sandbox doesn't exist, it is in the format: -- -- cfg['sandbox-link-display'] (cfg['sandbox-create-link-display'] | cfg['mirror-link-display']) -- -- The link for cfg['sandbox-create-link-display'] link preloads the page with cfg['template-sandbox-preload'] -- or cfg['module-sandbox-preload'], depending on the current namespace. The link for cfg['mirror-link-display'] -- loads a default edit summary of cfg['mirror-edit-summary']. -- -- $2 is a link to the test cases page. If the test cases page exists, it is in the following format: -- -- cfg['testcases-link-display'] (cfg['testcases-edit-link-display']) -- -- If the test cases page doesn't exist, it is in the format: -- -- cfg['testcases-link-display'] (cfg['testcases-create-link-display']) -- -- If the test cases page doesn't exist, the link for cfg['testcases-create-link-display'] preloads the -- page with cfg['template-testcases-preload'] or cfg['module-testcases-preload'], depending on the current -- namespace. --]] cfg['experiment-blurb-template'] = format('experiment-blurb-template') cfg['experiment-blurb-module'] = format('experiment-blurb-module') ---------------------------------------------------------------------------------------------------- -- Sandbox link configuration ---------------------------------------------------------------------------------------------------- -- cfg['sandbox-subpage'] -- The name of the template subpage typically used for sandboxes. cfg['sandbox-subpage'] = 'sandbox' -- cfg['template-sandbox-preload'] -- Preload file for template sandbox pages. cfg['template-sandbox-preload'] = 'Template:Documentation/preload-sandbox' -- cfg['module-sandbox-preload'] -- Preload file for Lua module sandbox pages. cfg['module-sandbox-preload'] = 'Template:Documentation/preload-module-sandbox' -- cfg['sandbox-link-display'] -- The text to display for "sandbox" links. cfg['sandbox-link-display'] = format('sandbox-link-display') -- cfg['sandbox-edit-link-display'] -- The text to display for sandbox "edit" links. cfg['sandbox-edit-link-display'] = format('sandbox-edit-link-display') -- cfg['sandbox-create-link-display'] -- The text to display for sandbox "create" links. cfg['sandbox-create-link-display'] = format('sandbox-create-link-display') -- cfg['compare-link-display'] -- The text to display for "compare" links. cfg['compare-link-display'] = format('compare-link-display') -- cfg['mirror-edit-summary'] -- The default edit summary to use when a user clicks the "mirror" link. $1 is a wikilink to the -- template page. cfg['mirror-edit-summary'] = 'Create sandbox version of $1' -- cfg['mirror-link-display'] -- The text to display for "mirror" links. cfg['mirror-link-display'] = format('mirror-link-display') -- cfg['mirror-link-preload'] -- The page to preload when a user clicks the "mirror" link. cfg['mirror-link-preload'] = 'Template:Documentation/mirror' ---------------------------------------------------------------------------------------------------- -- Test cases link configuration ---------------------------------------------------------------------------------------------------- -- cfg['testcases-subpage'] -- The name of the template subpage typically used for test cases. cfg['testcases-subpage'] = 'testcases' -- cfg['template-testcases-preload'] -- Preload file for template test cases pages. cfg['template-testcases-preload'] = 'Template:Documentation/preload-testcases' -- cfg['module-testcases-preload'] -- Preload file for Lua module test cases pages. cfg['module-testcases-preload'] = 'Template:Documentation/preload-module-testcases' -- cfg['testcases-link-display'] -- The text to display for "testcases" links. cfg['testcases-link-display'] = format('testcases-link-display') -- cfg['testcases-edit-link-display'] -- The text to display for test cases "edit" links. cfg['testcases-edit-link-display'] = format('testcases-edit-link-display') -- cfg['testcases-create-link-display'] -- The text to display for test cases "create" links. cfg['testcases-create-link-display'] = format('testcases-create-link-display') ---------------------------------------------------------------------------------------------------- -- Add categories blurb configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['add-categories-blurb'] -- Text to direct users to add categories to the /doc subpage. Not used if the "content" or -- "docname fed" arguments are set, as then it is not clear where to add the categories. $1 is a -- link to the /doc subpage with a display value of cfg['doc-link-display']. --]] cfg['add-categories-blurb'] = format('add-categories-blurb') -- cfg['doc-link-display'] -- The text to display when linking to the /doc subpage. cfg['doc-link-display'] = '/doc' ---------------------------------------------------------------------------------------------------- -- Subpages link configuration ---------------------------------------------------------------------------------------------------- --[[ -- cfg['subpages-blurb'] -- The "Subpages of this template" blurb. $1 is a link to the main template's subpages with a -- display value of cfg['subpages-link-display']. In the English version this blurb is simply -- the link followed by a period, and the link display provides the actual text. --]] cfg['subpages-blurb'] = format('subpages-blurb') --[[ -- cfg['subpages-link-display'] -- The text to display for the "subpages of this page" link. $1 is cfg['template-pagetype'], -- cfg['module-pagetype'] or cfg['default-pagetype'], depending on whether the current page is in -- the template namespace, the module namespace, or another namespace. --]] cfg['subpages-link-display'] = format('subpages-link-display') -- cfg['template-pagetype'] -- The pagetype to display for template pages. cfg['template-pagetype'] = format('template-pagetype') -- cfg['module-pagetype'] -- The pagetype to display for Lua module pages. cfg['module-pagetype'] = format('module-pagetype') -- cfg['default-pagetype'] -- The pagetype to display for pages other than templates or Lua modules. cfg['default-pagetype'] = format('default-pagetype') ---------------------------------------------------------------------------------------------------- -- Doc link configuration ---------------------------------------------------------------------------------------------------- -- cfg['doc-subpage'] -- The name of the subpage typically used for documentation pages. cfg['doc-subpage'] = 'doc' -- cfg['file-docpage-preload'] -- Preload file for documentation page in the file namespace. cfg['file-docpage-preload'] = 'Template:Documentation/preload-filespace' -- cfg['docpage-preload'] -- Preload file for template documentation pages in all namespaces. cfg['docpage-preload'] = 'Template:Documentation/preload' -- cfg['module-preload'] -- Preload file for Lua module documentation pages. cfg['module-preload'] = 'Template:Documentation/preload-module-doc' ---------------------------------------------------------------------------------------------------- -- Print version configuration ---------------------------------------------------------------------------------------------------- -- cfg['print-subpage'] -- The name of the template subpage used for print versions. cfg['print-subpage'] = 'Print' -- cfg['print-link-display'] -- The text to display when linking to the /Print subpage. cfg['print-link-display'] = '/Print' -- cfg['print-blurb'] -- Text to display if a /Print subpage exists. $1 is a link to the subpage with a display value of cfg['print-link-display']. cfg['print-blurb'] = format('print-blurb') -- cfg['display-print-category'] -- Set to true to enable output of cfg['print-category'] if a /Print subpage exists. -- This should be a boolean value (either true or false). cfg['display-print-category'] = true -- cfg['print-category'] -- Category to output if cfg['display-print-category'] is set to true, and a /Print subpage exists. cfg['print-category'] = 'Templates with print versions' ---------------------------------------------------------------------------------------------------- -- HTML and CSS configuration ---------------------------------------------------------------------------------------------------- -- cfg['main-div-id'] -- The "id" attribute of the main HTML "div" tag. cfg['main-div-id'] = 'template-documentation' -- cfg['main-div-classes'] -- The CSS classes added to the main HTML "div" tag. cfg['main-div-class'] = 'ts-doc-doc' cfg['header-div-class'] = 'ts-doc-header' cfg['heading-div-class'] = 'ts-doc-heading' cfg['content-div-class'] = 'ts-doc-content' cfg['footer-div-class'] = 'ts-doc-footer plainlinks' cfg['sandbox-class'] = 'ts-doc-sandbox' -- cfg['start-box-linkclasses'] -- The CSS classes used for the [view][edit][history] or [create] links in the start box. cfg['start-box-linkclasses'] = 'ts-tlinks-tlinks mw-editsection-like plainlinks' -- cfg['start-box-link-id'] -- The HTML "id" attribute for the links in the start box. cfg['start-box-link-id'] = 'doc_editlinks' ---------------------------------------------------------------------------------------------------- -- Tracking category configuration ---------------------------------------------------------------------------------------------------- -- cfg['display-strange-usage-category'] -- Set to true to enable output of cfg['strange-usage-category'] if the module is used on a /doc subpage -- or a /testcases subpage. This should be a boolean value (either true or false). cfg['display-strange-usage-category'] = false -- cfg['strange-usage-category'] -- Category to output if cfg['display-strange-usage-category'] is set to true and the module is used on a -- /doc subpage or a /testcases subpage. cfg['strange-usage-category'] = 'Pages with strange ((documentation)) usage' --[[ ---------------------------------------------------------------------------------------------------- -- End configuration -- -- Don't edit anything below this line. ---------------------------------------------------------------------------------------------------- --]] return cfg</text>
| |
| <sha1>5berregixbtstllxzma5vusz2r1e82g</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Module:TNT</title>
| |
| <ns>828</ns>
| |
| <id>649383</id>
| |
| <revision>
| |
| <id>5750914</id>
| |
| <parentid>5021938</parentid>
| |
| <timestamp>2023-02-02T01:14:59Z</timestamp>
| |
| <contributor>
| |
| <username>ExE Boss</username>
| |
| <id>892897</id>
| |
| </contributor>
| |
| <comment>Only use the `zzz123` workaround for integer‑only parameter names</comment>
| |
| <model>Scribunto</model>
| |
| <format>text/plain</format>
| |
| <text bytes="6571" xml:space="preserve">-- -- INTRO: (!!! DO NOT RENAME THIS PAGE !!!) -- This module allows any template or module to be copy/pasted between -- wikis without any translation changes. All translation text is stored -- in the global Data:*.tab pages on Commons, and used everywhere. -- -- SEE: https://www.mediawiki.org/wiki/Multilingual_Templates_and_Modules -- -- ATTENTION: -- Please do NOT rename this module - it has to be identical on all wikis. -- This code is maintained at https://www.mediawiki.org/wiki/Module:TNT -- Please do not modify it anywhere else, as it may get copied and override your changes. -- Suggestions can be made at https://www.mediawiki.org/wiki/Module_talk:TNT -- -- DESCRIPTION: -- The "msg" function uses a Commons dataset to translate a message -- with a given key (e.g. source-table), plus optional arguments -- to the wiki markup in the current content language. -- Use lang=xx to set language. Example: -- -- {{#invoke:TNT | msg -- | I18n/Template:Graphs.tab <!-- https://commons.wikimedia.org/wiki/Data:I18n/Template:Graphs.tab --> -- | source-table <!-- uses a translation message with id = "source-table" --> -- | param1 }} <!-- optional parameter --> -- -- -- The "doc" function will generate the <templatedata> parameter documentation for templates. -- This way all template parameters can be stored and localized in a single Commons dataset. -- NOTE: "doc" assumes that all documentation is located in Data:Templatedata/* on Commons. -- -- {{#invoke:TNT | doc | Graph:Lines }} -- uses https://commons.wikimedia.org/wiki/Data:Templatedata/Graph:Lines.tab -- if the current page is Template:Graph:Lines/doc -- local p = {} local i18nDataset = 'I18n/Module:TNT.tab' -- Forward declaration of the local functions local sanitizeDataset, loadData, link, formatMessage function p.msg(frame) local dataset, id local params = {} local lang = nil for k, v in pairs(frame.args) do if k == 1 then dataset = mw.text.trim(v) elseif k == 2 then id = mw.text.trim(v) elseif type(k) == 'number' then params[k - 2] = mw.text.trim(v) elseif k == 'lang' and v ~= '_' then lang = mw.text.trim(v) end end return formatMessage(dataset, id, params, lang) end -- Identical to p.msg() above, but used from other lua modules -- Parameters: name of dataset, message key, optional arguments -- Example with 2 params: format('I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset') function p.format(dataset, key, ...) local checkType = require('libraryUtil').checkType checkType('format', 1, dataset, 'string') checkType('format', 2, key, 'string') return formatMessage(dataset, key, {...}) end -- Identical to p.msg() above, but used from other lua modules with the language param -- Parameters: language code, name of dataset, message key, optional arguments -- Example with 2 params: formatInLanguage('es', I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset') function p.formatInLanguage(lang, dataset, key, ...) local checkType = require('libraryUtil').checkType checkType('formatInLanguage', 1, lang, 'string') checkType('formatInLanguage', 2, dataset, 'string') checkType('formatInLanguage', 3, key, 'string') return formatMessage(dataset, key, {...}, lang) end -- Obsolete function that adds a 'c:' prefix to the first param. -- "Sandbox/Sample.tab" -> 'c:Data:Sandbox/Sample.tab' function p.link(frame) return link(frame.args[1]) end function p.doc(frame) local dataset = 'Templatedata/' .. sanitizeDataset(frame.args[1]) return frame:extensionTag('templatedata', p.getTemplateData(dataset)) .. formatMessage(i18nDataset, 'edit_doc', {link(dataset)}) end function p.getTemplateData(dataset) -- TODO: add '_' parameter once lua starts reindexing properly for "all" languages local data = loadData(dataset) local names = {} for _, field in ipairs(data.schema.fields) do table.insert(names, field.name) end local numOnly = true local params = {} local paramOrder = {} for _, row in ipairs(data.data) do local newVal = {} local name = nil for pos, columnName in ipairs(names) do if columnName == 'name' then name = row[pos] else newVal[columnName] = row[pos] end end if name then if ( (type(name) ~= "number") and ( (type(name) ~= "string") or not string.match(name, "^%d+$") ) ) then numOnly = false end params[name] = newVal table.insert(paramOrder, name) end end -- Work around json encoding treating {"1":{...}} as an [{...}] if numOnly then params['zzz123']='' end local json = mw.text.jsonEncode({ params=params, paramOrder=paramOrder, description=data.description, }) if numOnly then json = string.gsub(json,'"zzz123":"",?', "") end return json end -- Local functions sanitizeDataset = function(dataset) if not dataset then return nil end dataset = mw.text.trim(dataset) if dataset == '' then return nil elseif string.sub(dataset,-4) ~= '.tab' then return dataset .. '.tab' else return dataset end end loadData = function(dataset, lang) dataset = sanitizeDataset(dataset) if not dataset then error(formatMessage(i18nDataset, 'error_no_dataset', {})) end -- Give helpful error to thirdparties who try and copy this module. if not mw.ext or not mw.ext.data or not mw.ext.data.get then error(string.format([['''Missing JsonConfig extension, or not properly configured; Cannot load https://commons.wikimedia.org/wiki/Data:%s. See https://www.mediawiki.org/wiki/Extension:JsonConfig#Supporting_Wikimedia_templates''']], dataset)) end local data = mw.ext.data.get(dataset, lang) if data == false then if dataset == i18nDataset then -- Prevent cyclical calls error('Missing Commons dataset ' .. i18nDataset) else error(formatMessage(i18nDataset, 'error_bad_dataset', {link(dataset)})) end end return data end -- Given a dataset name, convert it to a title with the 'commons:data:' prefix link = function(dataset) return 'c:Data:' .. mw.text.trim(dataset or '') end formatMessage = function(dataset, key, params, lang) for _, row in pairs(loadData(dataset, lang).data) do local id, msg = unpack(row) if id == key then local result = mw.message.newRawMessage(msg, unpack(params or {})) return result:plain() end end if dataset == i18nDataset then -- Prevent cyclical calls error('Invalid message key "' .. key .. '"') else error(formatMessage(i18nDataset, 'error_bad_msgkey', {key, link(dataset)})) end end return p</text>
| |
| <sha1>r7hn49mbqg5sfa9i7l9l3ts62h7gy7u</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Module:Documentation/i18n</title>
| |
| <ns>828</ns>
| |
| <id>933426</id>
| |
| <revision>
| |
| <id>3580736</id>
| |
| <parentid>3580735</parentid>
| |
| <timestamp>2019-12-28T03:33:21Z</timestamp>
| |
| <contributor>
| |
| <username>94rain</username>
| |
| <id>14443205</id>
| |
| </contributor>
| |
| <minor/>
| |
| <comment>Protected "[[Module:Documentation/i18n]]": Highly visible page or template ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only administrators] (indefinite))</comment>
| |
| <model>Scribunto</model>
| |
| <format>text/plain</format>
| |
| <text bytes="1691" xml:space="preserve">local format = require('Module:TNT').format local i18n = {} i18n['cfg-error-msg-type'] = format('I18n/Documentation', 'cfg-error-msg-type') i18n['cfg-error-msg-empty'] = format('I18n/Documentation', 'cfg-error-msg-empty') -- cfg['template-namespace-heading'] -- The heading shown in the template namespace. i18n['template-namespace-heading'] = format('I18n/Documentation', 'template-namespace-heading') -- cfg['module-namespace-heading'] -- The heading shown in the module namespace. i18n['module-namespace-heading'] = format('I18n/Documentation', 'module-namespace-heading') -- cfg['file-namespace-heading'] -- The heading shown in the file namespace. i18n['file-namespace-heading'] = format('I18n/Documentation', 'file-namespace-heading') -- cfg['other-namespaces-heading'] -- The heading shown in other namespaces. i18n['other-namespaces-heading'] = format('I18n/Documentation', 'other-namespaces-heading') -- cfg['view-link-display'] -- The text to display for "view" links. i18n['view-link-display'] = format('I18n/Documentation', 'view-link-display') -- cfg['edit-link-display'] -- The text to display for "edit" links. i18n['edit-link-display'] = format('I18n/Documentation', 'edit-link-display') -- cfg['history-link-display'] -- The text to display for "history" links. i18n['history-link-display'] = format('I18n/Documentation', 'history-link-display') -- cfg['purge-link-display'] -- The text to display for "purge" links. i18n['purge-link-display'] = format('I18n/Documentation', 'purge-link-display') -- cfg['create-link-display'] -- The text to display for "create" links. i18n['create-link-display'] = format('I18n/Documentation', 'create-link-display') return i18n</text>
| |
| <sha1>i27qt76cptbbpjtsh3j4x87t48x7xds</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Module:Documentation/styles.css</title>
| |
| <ns>828</ns>
| |
| <id>933326</id>
| |
| <revision>
| |
| <id>6368760</id>
| |
| <parentid>6368725</parentid>
| |
| <timestamp>2024-02-14T19:17:05Z</timestamp>
| |
| <contributor>
| |
| <username>Jdlrobson</username>
| |
| <id>446645</id>
| |
| </contributor>
| |
| <model>sanitized-css</model>
| |
| <format>text/css</format>
| |
| <text bytes="1587" xml:space="preserve">.ts-doc-sandbox .mbox-image { padding:.75em 0 .75em .75em; } .ts-doc-doc { clear: both; background-color: #eaf3ff; color: #333; border: 1px solid #a3caff; margin-top: 1em; border-top-left-radius: 2px; border-top-right-radius: 2px; } .ts-doc-header { background-color: #c2dcff; color: #333; padding: .642857em 1em .5em; border-top-left-radius: 2px; border-top-right-radius: 2px; } .ts-doc-heading { display: inline-block; padding-left: 30px; background: center left / 24px 24px no-repeat; /* @noflip */ background-image: url( //upload.wikimedia.org/wikipedia/commons/f/fb/OOjs_UI_icon_puzzle-ltr.svg ); height: 24px; line-height: 24px; font-size: 13px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; } .ts-doc-header .ts-tlinks-tlinks { line-height: 24px; margin-left: 0; } .ts-doc-header .ts-tlinks-tlinks a.external { color: #0645ad; } .ts-doc-header .ts-tlinks-tlinks a.external:visited { color: #0b0080; } .ts-doc-header .ts-tlinks-tlinks a.external:active { color: #faa700; } .ts-doc-content { padding: .214286em 1em; } .ts-doc-content:after { content: ''; clear: both; display: block; } .ts-doc-content > :first-child { margin-top: .5em; } .ts-doc-content > :last-child { margin-bottom: .5em; } .ts-doc-footer { background-color: #eaf3ff; color: #333; border: 1px solid #a3caff; padding: .214286em 1em; margin-top: .214286em; font-style: italic; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; } @media all and (min-width: 720px) { .ts-doc-header .ts-tlinks-tlinks { float: right; } }</text>
| |
| <sha1>6gatarb3ltz1e79gepv9ii7802chyyr</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Template:Warning/en</title>
| |
| <ns>10</ns>
| |
| <id>499576</id>
| |
| <revision>
| |
| <id>6389695</id>
| |
| <parentid>6368217</parentid>
| |
| <timestamp>2024-02-28T21:39:55Z</timestamp>
| |
| <contributor>
| |
| <username>FuzzyBot</username>
| |
| <id>451990</id>
| |
| </contributor>
| |
| <comment>Updating to match new version of source page</comment>
| |
| <model>wikitext</model>
| |
| <format>text/x-wiki</format>
| |
| <text bytes="1822" xml:space="preserve"><languages/> <onlyinclude>{{#if: {{{msg|{{{1|}}}}}}|<table class="warning-message" style="background-color: #fee7e6; color:#333; border: 1px #d33 solid; box-sizing: border-box; margin: 0.5em 0; padding: 0.5em;"><tr><td style="white-space: nowrap; vertical-align: top;">}}<span style="position: relative; top: -2px;">[[File:OOjs_UI_icon_notice-destructive.svg|18px|alt=Warning|link=]]</span> '''Warning:''' {{#if: {{{msg|{{{1|}}}}}}|</td><td style="padding-{{dir|{{pagelang}}|right|left}}: 0.5em vertical-align: top;">{{{msg|{{{1|}}}}}}</td></tr></table>}}</onlyinclude> {{Documentation|content= == Usage == This template has two possible usages: # Will have the text flow below when the warning text is too long # Uses a table to indent the text. === Method 1 === The following displays the warning icon and the word "Warning:". You can follow this with whatever text/images/markup you like. Wiki Code: <nowiki>{{warning}}</nowiki> Don't do that! {{warning}} Don't do that! === Method 2 === The following includes the text passed to the template, and uses a table to stop the text flowing round the icon. Wiki Code: <nowiki>{{warning|1=</nowiki>Here is a long warning, which is sufficiently wordy to run onto a second line (unless you have a really large screen!), which would normally cause it to wrap round the icon, but because we passed it as a parameter it keeps its left alignment straight.<nowiki>}}</nowiki> {{warning|1=Here is a long warning, which is sufficiently wordy to run onto a second line (unless you have a really large screen!), which would normally cause it to wrap round the icon, but because we passed it as a parameter it keeps its left alignment straight.}} == See also == * {{tl|Caution}} * {{tl|Fixtext}} * {{tl|Note}} * {{tl|Tip}} }} [[Category:Warning templates{{#translation:}}]]</text>
| |
| <sha1>jxouvgosyieu9tp4187q77xogue5kyn</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Template:((</title>
| |
| <ns>10</ns>
| |
| <id>69341</id>
| |
| <revision>
| |
| <id>6440162</id>
| |
| <parentid>5503588</parentid>
| |
| <timestamp>2024-04-02T12:55:58Z</timestamp>
| |
| <contributor>
| |
| <username>Number 3434</username>
| |
| <id>17920745</id>
| |
| </contributor>
| |
| <minor/>
| |
| <comment>Categories should be put in the <code>[[/doc]]</code> page</comment>
| |
| <model>wikitext</model>
| |
| <format>text/x-wiki</format>
| |
| <text bytes="48" xml:space="preserve"><onlyinclude>{{</onlyinclude> {{documentation}}</text>
| |
| <sha1>l1p40lttd81cgbxftk011zwhyur6utx</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Template:))</title>
| |
| <ns>10</ns>
| |
| <id>69340</id>
| |
| <revision>
| |
| <id>6440164</id>
| |
| <parentid>6440163</parentid>
| |
| <timestamp>2024-04-02T12:57:00Z</timestamp>
| |
| <contributor>
| |
| <username>Number 3434</username>
| |
| <id>17920745</id>
| |
| </contributor>
| |
| <minor/>
| |
| <model>wikitext</model>
| |
| <format>text/x-wiki</format>
| |
| <text bytes="48" xml:space="preserve"><onlyinclude>}}</onlyinclude> {{documentation}}</text>
| |
| <sha1>slmr8fpwrqkg51fj5yum319dsynievf</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Template:Tl</title>
| |
| <ns>10</ns>
| |
| <id>12644</id>
| |
| <revision>
| |
| <id>5086545</id>
| |
| <parentid>4412922</parentid>
| |
| <timestamp>2022-02-26T04:13:26Z</timestamp>
| |
| <contributor>
| |
| <username>Shirayuki</username>
| |
| <id>472859</id>
| |
| </contributor>
| |
| <minor/>
| |
| <model>wikitext</model>
| |
| <format>text/x-wiki</format>
| |
| <text bytes="156" xml:space="preserve">{{((}}[[Template:{{{1}}}|{{{1}}}]]{{))}}<noinclude> {{documentation}} <!-- Categories go on the /doc subpage and interwikis go on Wikidata. --> </noinclude></text>
| |
| <sha1>2da3r0k842ffxrfa0gjveb2ng7p4shn</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Template:Pp-template</title>
| |
| <ns>10</ns>
| |
| <id>196530</id>
| |
| <revision>
| |
| <id>6011441</id>
| |
| <parentid>6011438</parentid>
| |
| <timestamp>2023-07-01T13:40:33Z</timestamp>
| |
| <contributor>
| |
| <username>Clump</username>
| |
| <id>81610</id>
| |
| </contributor>
| |
| <minor/>
| |
| <comment>Protected "[[Template:Pp-template]]": Counter-productive edit warring ([Edit=Allow only autoconfirmed users] (expires 13:40, 1 August 2023 (UTC)) [Move=Allow only autoconfirmed users] (expires 13:40, 1 August 2023 (UTC)))</comment>
| |
| <model>wikitext</model>
| |
| <format>text/x-wiki</format>
| |
| <text bytes="968" xml:space="preserve"><includeonly>{{#switch:{{#invoke:Effective protection level|edit|{{FULLPAGENAME}}}} |*=[[Category:Pages with incorrect protection templates]] |autoconfirmed={{#tag:indicator|[[File:Semi-protection-shackle-no-text.svg|20px|link=Project:Protected page|alt=Permanently protected {{module other|module|template}}|This high-risk {{module other|module|template}} is permanently semi-protected to prevent vandalism]]|name="pp-default"}}[[Category:{{module other|Modules subject to page protection|Semi-protected templates}}|{{PAGENAME}}]] |sysop={{#tag:indicator|[[File:Full-protection-shackle-no-text.svg|20px|link=Project:Protected page|alt=Permanently protected {{module other|module|template}}|This high-risk {{module other|module|template}} is permanently protected to prevent vandalism]]|name="pp-default"}}[[Category:{{module other|Modules subject to page protection|Fully protected templates}}|{{PAGENAME}}]] }}</includeonly><noinclude> {{Documentation}} </noinclude></text>
| |
| <sha1>1wg40a9glb5fvibrfn0q0ofktx6v8yl</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Template:Module other</title>
| |
| <ns>10</ns>
| |
| <id>156427</id>
| |
| <revision>
| |
| <id>6095366</id>
| |
| <parentid>6095265</parentid>
| |
| <timestamp>2023-09-07T15:12:29Z</timestamp>
| |
| <contributor>
| |
| <username>Clump</username>
| |
| <id>81610</id>
| |
| </contributor>
| |
| <minor/>
| |
| <comment>Reverted edits by [[Special:Contribs/106.216.224.165|106.216.224.165]] ([[User talk:106.216.224.165|talk]]) to last version by Clump</comment>
| |
| <model>wikitext</model>
| |
| <format>text/x-wiki</format>
| |
| <text bytes="429" xml:space="preserve">{{#switch: <!--If no or empty "demospace" parameter then detect namespace--> {{#if:{{{demospace|}}} | {{lc: {{{demospace}}} }} <!--Use lower case "demospace"--> | {{#ifeq:{{NAMESPACE}}|{{ns:Module}} | module | other }} }} | module = {{{1|}}} | other | #default = {{{2|}}} }}<!--End switch--><noinclude> {{documentation}} <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude></text>
| |
| <sha1>aj2arq2ulw1m2bv93xsf898z3pm3q5l</sha1>
| |
| </revision>
| |
| </page>
| |
| <page>
| |
| <title>Module:Effective protection level</title>
| |
| <ns>828</ns>
| |
| <id>317693</id>
| |
| <revision>
| |
| <id>6081199</id>
| |
| <parentid>6081185</parentid>
| |
| <timestamp>2023-08-25T18:27:30Z</timestamp>
| |
| <contributor>
| |
| <username>Clump</username>
| |
| <id>81610</id>
| |
| </contributor>
| |
| <minor/>
| |
| <comment>Reverted edits by [[Special:Contribs/2600:1010:B06E:8ABA:3C2F:311A:6FCA:8A5|2600:1010:B06E:8ABA:3C2F:311A:6FCA:8A5]] ([[User talk:2600:1010:B06E:8ABA:3C2F:311A:6FCA:8A5|talk]]) to last version by Tegel</comment>
| |
| <model>Scribunto</model>
| |
| <format>text/plain</format>
| |
| <text bytes="2408" xml:space="preserve">local p = {} -- Returns the permission required to perform a given action on a given title. -- If no title is specified, the title of the page being displayed is used. function p._main(action, pagename) local title if type(pagename) == 'table' and pagename.prefixedText then title = pagename elseif pagename then title = mw.title.new(pagename) else title = mw.title.getCurrentTitle() end pagename = title.prefixedText if action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' then error( 'First parameter must be one of edit, move, create, upload', 2 ) end if title.namespace == 8 then -- MediaWiki namespace if title.contentModel == 'javascript' or title.contentModel == 'css' then -- site JS or CSS page return 'interfaceadmin' else -- any non-JS/CSS MediaWiki page return 'sysop' end elseif title.namespace == 2 and title.isSubpage then if title.contentModel == 'javascript' or title.contentModel == 'css' then -- user JS or CSS page return 'interfaceadmin' elseif title.contentModel == 'json' then -- user JSON page return 'sysop' end end local level = title.protectionLevels[action] and title.protectionLevels[action][1] if level == 'sysop' or level == 'editprotected' then return 'sysop' elseif title.cascadingProtection.restrictions[action] and title.cascadingProtection.restrictions[action][1] then -- used by a cascading-protected page return 'sysop' elseif action == 'move' then local blacklistentry = mw.ext.TitleBlacklist.test('edit', pagename) -- Testing action edit is correct, since this is for the source page. The target page name gets tested with action move. if blacklistentry and not blacklistentry.params.autoconfirmed then return 'sysop' elseif title.namespace == 6 then return 'sysop' else return 'autoconfirmed' end end local blacklistentry = mw.ext.TitleBlacklist.test(action, pagename) if blacklistentry then if not blacklistentry.params.autoconfirmed then return 'sysop' else return 'autoconfirmed' end elseif level == 'editsemiprotected' then -- create-semiprotected pages return this for some reason return 'autoconfirmed' elseif level then return level elseif action == 'upload' then return 'uploader' else return '*' end end setmetatable(p, { __index = function(t, k) return function(frame) return t._main(k, frame.args[1]) end end }) return p</text>
| |
| <sha1>094svr8l8ofw2hfaisud6zq212rceum</sha1>
| |
| </revision>
| |
| </page>
| |
| </mediawiki>
| |