Wikivoyage svwikivoyage https://sv.wikivoyage.org/wiki/Huvudsida MediaWiki 1.47.0-wmf.5 first-letter Media Special Diskussion Användare Användardiskussion Wikivoyage Wikivoyagediskussion Fil Fildiskussion MediaWiki MediaWiki-diskussion Mall Malldiskussion Hjälp Hjälpdiskussion Kategori Kategoridiskussion TimedText TimedText talk Modul Moduldiskussion Event Event talk Tokyo/Akihabara 0 1782 97218 89732 2026-06-07T08:51:42Z Tommy Kronkvist 2826 Rättstavning och uppdatering, bland annat av externa länkar. (Arbete pågår med mallar importerade från Meta-Wiki, och kommer att förfärdigas om ett par dagar. 97218 wikitext text/x-wiki {{IsIn|Tokyo_(prefektur)}} '''Akihabara''' är i är en stadsdel i [[Tokyo]], [[Japan]]s huvudstad. Akihabara har fått epitetet "elektriska staden" och är Tokyos shoppingcenter för hemelektronik, tv-spel och el-prylar. Huvudgatan ''Chuo-dori'' är pulsådern genom Akihabara och ifrån den sprider sig affärerna ut på sidogatorna. ==Ta sig dit== '''Med tåg''' *Yamanote-linjen, Keihin-Tohoku-linjen och Sōbu-linjen går via Akihabara. '''Med tunnelbana''' *Hibiya-linjen går via Akihabara. ==Förflyttning== {{bidrag saknas}} ==Att se== *Tokyo Anime Center [https://www.animecenter.jp/] {{Död länk}} håller utställningar och visningar av det senaste inom japansk animation och tv-spel. Centret fungerar dessutom som en informationscentral för den som vill ha koll på det senaste som händer i Akihabara. ==Att göra== * Aso Bit City. Även om det knappast kan klassas som "sport" så säljer den här affären bara leksaksvapen, och det finns en inomhusskjutbana för den som vill pröva. ¥335 för halvtimmes skjutning plus ¥325 för att hyra ett vapen. (Prisuppgift från 2006, så troligen något dyrare idag.) ==Nöjesliv== Akihabara dör ut när affärerna stänger och det är ganska folktomt på nätterna. Passa gärna på att köa med andra glada japaner dagarna innan något nytt stort tv-spel eller konsol ska släppas. ==Köpa== [[Fil:Akihabara picture2.jpg|miniatyr|300px|Gatuscen från Akihabara.]] Elektronik, leksaker, tv-spel och åter elektronik. Passa på att köpa saker som är dyra i [[Sverige]] till mycket bra priser. Akihabara är shoppingparadiset för teknikintresserade, filmfantaster och spelfanatiker. Ja, oavsett vilket nördhobby man har lär det finnas en butik som säljer det man vill ha. Här finns även flera affärer som säljer taxfree för utländska besökare, men har man inte passet med får man betala standard-pris. De stora kedjorna ligger på Chuo-dori men vill man hitta de lite mer underliga butikerna ska man gå neråt på sidogatorna. Här kan man även pruta ned priserna något men räkna inte med att bli särskilt bra förstådd på [[Engelsk parlör|engelska]]. De största taxfree-affärerna tar VISA-kort men annars är det kontanter som gäller. Det finns inga automater i Akihabara som accepterar utländska VISA-kort så att ta med sig kontanter rekommenderas starkt. <div style="font-size: 16px">'''Varuhus'''</div> *'''LaOX Duty Free''' [https://www.laox.co.jp/en/] (på Chuo-dori nära [[JR East|JR]]-stationen), är en affär som säljer kvalitetselektronik som tax-free. Cirka 5–10&nbsp;% billigare än marknadspriset. Glöm inte att ta med passet för att kunna erhålla "skatterabatten". *'''Yodobashi Camera''', makalöst stort varuhus i nio våningar som säljer alla möjliga sorters elektronik, specialiserad på kameror och audio/video-utrustning. Lyckas du skaffa medlemskort får du 10–20&nbsp;% rabatt som läggs på kortet, att använda till nästa köp. Yodobashi Camera ligger öster om järnvägsstationen, till skillnad från det mesta som ligger till väster. <div style="font-size: 16px">'''Marknader'''</div> [[Fil:Akihabara LightShop.JPG|miniatyr|Lampförsäljare i Radio City.]] *'''Radio City''', (precis utanför JR-stationen), två-vånings elektronik-marknad som är fullpackad med små affärer som alla har sitt specialutbud, LED-lampor, voltmetrar, mini-kameror, sladdar och el-tillbehör är bara ett fragment av vad som erbjuds här. Himmelriket för gör-det-självaren. Se även till att inte glömma köpa kontaktomvandlare till svensk standard så att de nya prylar går att använda hemma i Sverige. ==Mat och dryck== I Akihabara finns främst snabbmatsresturanger. På den norra sidan, under järnvägsbron över huvudgatan, finns ett antal bra matställen. *'''Tenya''' [https://www.tenya.co.jp/english/] (てんや), (ett par kvarter ned på ''Chuo-dori'' mot ''Metro Suehirocho''), Tenya är en snabbmatsresturang som specialiserat sig på billig ''tempura''. En stor skål kostar omkring ¥1&nbsp;000 (ca&nbsp;60&nbsp;SEK), vilket minst sagt är billigt. (Priser per 2026.) ==Boende== *Akihabara Washington Hotel [https://www.wh-rsv.com/english/akihabara/] är ett mellanklasshotell nära Akihabara-stationen. ==Evenemang== På söndagar stängs huvudgatan i Akihabara av och förvandlas till ett eldorado av gatuartister och marknadsstånd. ==Kommunikation== Det är mindre vanligt att butikspersonal talar engelska, även om det ofta finns någon de kan tillkalla. I duty-free affärerna talar personalen god engelska. ==Säkerhet== {{bidrag saknas}} ==Externa länkar== {{bidrag saknas}} {{Sidfot}} [[Kategori:Artiklar med länk till Commons|Category:Akihabara]] [[Kategori:Kontroll 2026 juni]] ntk3lt90nyom823fmnm7kzdn6s4hnx6 MediaWiki:Sitenotice 8 6081 97040 96975 2026-06-06T13:24:24Z Tommy Kronkvist 2826 Uppdaterade. 97040 wikitext text/x-wiki <div style="text-align:center;"> <span style="font-size:1.2em;font-weight:bold;">Nu är det äntligen sommar i så gott som hela vårt avlånga land!<br>Varför inte [[Wikivoyage:Hur man startar en ny artikel|skriva några rader]] om en resa du planerar, eller gjort tidigare?</span> </div> <div style="text-align:center;"> [[Wikivoyage:Välkomna, Wikipedianer|Välkomna, Wikipedianer]] - [[Wikivoyage:Regler och riktlinjer|Regler och riktlinjer]] - [[Wikivoyage:Vad Wikivoyage är och inte är|Vad Wikivoyage är och inte är]]</span> </div> gfv3dhafbmh9q183404syc85rmkae0i Modul:Yesno 828 11407 97057 94586 2025-04-17T05:49:27Z Veritas Sapientiae 11379 3 revisions imported from [[:commons:Module:Yesno]] 94477 Scribunto text/plain -- 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 swdskn7svew8i9wuydn9uj5l3r2ghcs 97058 97057 2025-04-17T06:11:28Z Veritas Sapientiae 11379 Restored revision 18957710 by [[Special:Contributions/Vogone|Vogone]] ([[User talk:Vogone|talk]])([[:m:User:Xiplus/TwinkleGlobal|TwinkleGlobal]]) 97058 Scribunto text/plain -- 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 tonumber(val) == 1 then return true elseif val == false or val == 'no' or val == 'n' or val == 'false' or val == 'f' or tonumber(val) == 0 then return false else return default end end 266x81qzpz9iq1b5gft4zsdy5qzbnwi 97059 97058 2025-04-17T07:33:17Z Svartava 11607 Restored revision 22268274 by [[Special:Contributions/GeneralNotability|GeneralNotability]] ([[User talk:GeneralNotability|talk]]) 97059 Scribunto text/plain -- 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 swdskn7svew8i9wuydn9uj5l3r2ghcs 97060 97059 2025-04-27T20:15:12Z Pppery 12444 Protected "[[Module:Yesno]]" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97059 Scribunto text/plain -- 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 swdskn7svew8i9wuydn9uj5l3r2ghcs 97061 97060 2026-06-07T08:43:22Z Tommy Kronkvist 2826 4 versioner importerades från [[:meta:Module:Yesno]] 97059 Scribunto text/plain -- 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 swdskn7svew8i9wuydn9uj5l3r2ghcs Modul:Arguments 828 11408 97062 94589 2025-04-17T05:49:28Z Veritas Sapientiae 11379 5 revisions imported from [[:commons:Module:Arguments]] 84678 Scribunto text/plain -- 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 5qx9tzlul9ser30uxj9nbasjt92cevn 97063 97062 2025-04-27T20:14:11Z Pppery 12444 Protected "[[Module:Arguments]]" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 84678 Scribunto text/plain -- 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 5qx9tzlul9ser30uxj9nbasjt92cevn 97064 97063 2026-06-07T08:43:22Z Tommy Kronkvist 2826 2 versioner importerades från [[:meta:Module:Arguments]] 84678 Scribunto text/plain -- 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 5qx9tzlul9ser30uxj9nbasjt92cevn Wikivoyage:GUS2Wiki 4 11501 97041 97039 2026-06-06T17:57:54Z Alexis Jazz 8414 Updating gadget usage statistics from [[Special:GadgetUsage]] ([[phab:T121049]]) 97041 wikitext text/x-wiki {{#ifexist:Project:GUS2Wiki/top|{{/top}}|This page provides a historical record of [[Special:GadgetUsage]] through its page history. To get the data in CSV format, see wikitext. To customize this message or add categories, create [[/top]].}} Följande data är cachad och uppdaterades senast 2026-06-04T19:44:37Z. Maximalt {{PLURAL:5000|ett|5000}} resultat finns {{PLURAL:5000|tillgängligt|tillgängliga}} i cachen. {| class="sortable wikitable" ! Finess !! data-sort-type="number" | Antal användare !! data-sort-type="number" | Aktiva användare |- |RTRC || 5 || 1 |} * [[Special:GadgetUsage]] * [[m:Meta:GUS2Wiki/Script|GUS2Wiki]] <!-- data in CSV format: RTRC,5,1 --> kptt94tjbhmo96bl9mtkd2i3t6iizuj Kategori:Kontroll 2026 juni 14 11883 97042 2026-06-07T08:08:24Z Tommy Kronkvist 2826 Ny kvalitetskontrollkategori. 97042 wikitext text/x-wiki __HIDDENCAT__ [[Kategori:Kvalitetskontroll]] ftt7pcd5hh4yw2hzwgd92cayaip9ypg Mall:Dead link 10 11884 97043 2012-06-04T11:05:45Z Bennylin 3180 dead link 97043 wikitext text/x-wiki {{Fix | subst = <includeonly>{{subst:</includeonly><includeonly>substcheck}}</includeonly> | special = <sup class="noprint Inline-Template"><span title="{{{title|}}}{{#if:{{{date|}}}|&nbsp;since {{{date}}}}}" style="white-space: nowrap;">&#91;<i>{{#if: {{{url|}}}|[http://web.archive.org/web/*/{{{url|}}} dead link]|[[w:Wikipedia:Link rot|dead link]]}}</i>&#93;</span></sup> | date = {{{date|}}} | cat = [[Category:All articles with dead external links]] | cat-date = Category:Articles with dead external links}} rximagtivjdk3p5ikw5cqbqp1jsv485 97044 97043 2014-05-14T05:28:10Z Verdy p 6875 97044 wikitext text/x-wiki {{Fix | subst = <includeonly>{{subst:</includeonly><includeonly>substcheck}}</includeonly> | special = <sup class="noprint Inline-Template" style="white-space:nowrap" title="{{{title|}}}{{#if: {{{date|}}} | &#32;since {{{date|}}} }}">&#91;<i>{{#if: {{{url|}}} | [http://web.archive.org/web/*/{{{url|}}} dead link] | [[w:en;Wikipedia:Link rot|dead link]] }}</i>&#93;</sup> | date = {{{date|}}} | cat = [[Category:All articles with dead external links]] | cat-date = Category:Articles with dead external links }} 1d6o5efy621useq2nxi3dy39aakki76 97045 2009-01-14T21:22:17Z Deerstop 13023 [[COM:AES|←]]Created page with '<sup>''<nowiki>[</nowiki>[[:en:WP:Dead external links|dead link]]<nowiki>]</nowiki>''</sup>' 97045 wikitext text/x-wiki <sup>''<nowiki>[</nowiki>[[:en:WP:Dead external links|dead link]]<nowiki>]</nowiki>''</sup> kxvekgifd77smucj2bu0di0svasprpz 97046 97045 2009-04-23T13:07:10Z BotMultichill 13024 Please categorize this template 97046 wikitext text/x-wiki <sup>''<nowiki>[</nowiki>[[:en:WP:Dead external links|dead link]]<nowiki>]</nowiki>''</sup><noinclude>{{Uncategorized|year=2009|month=April|day=23}}</noinclude> 58i2jjbhx5y47tgonv2vgil6vwmxvtl 97047 97046 2009-07-23T05:33:05Z BomBom 13025 categorized 97047 wikitext text/x-wiki <sup>''<nowiki>[</nowiki>[[:en:WP:Dead external links|dead link]]<nowiki>]</nowiki>''</sup> <noinclude>[[Category:Marker templates|{{PAGENAME}}]]</noinclude> 1hcuwoppfsd59r5hd09m1o5t0ycnter 97048 97047 2009-08-11T17:34:05Z Falcorian 13026 This template is causing some issues with Commons:Licensing#Japan... Trying to fix it by moving to one line... 97048 wikitext text/x-wiki <sup>''<nowiki>[</nowiki>[[:en:WP:Dead external links|dead link]]<nowiki>]</nowiki>''</sup><noinclude>[[Category:Marker templates|{{PAGENAME}}]]</noinclude> r27n5egkh7kapoab3snibdqswdsbwsp 97049 97048 2011-06-16T20:34:17Z Rd232 13027 {{Please Internationalise}} 97049 wikitext text/x-wiki <sup>''<nowiki>[</nowiki>[[:en:WP:Dead external links|dead link]]<nowiki>]</nowiki>''</sup><noinclude>[[Category:Marker templates|{{PAGENAME}}]] ---- {{Please Internationalise}}</noinclude> 8u21aa7cagufwe29cvh5x4kx4qhky1z 97050 97043 2012-12-30T04:26:11Z Sreejithk2000 12431 Added LangSwitch 97050 wikitext text/x-wiki <sup>''<nowiki>[</nowiki>[[:en:WP:Dead external links|{{LangSwitch |en=dead link |ml=നിലവിലില്ലാത്ത കണ്ണി |lang={{{lang|}}} }}]]<nowiki>]</nowiki>''</sup><noinclude>[[Category:Marker templates|{{PAGENAME}}]] ---- </noinclude> a5cpx1a6d5uvft49ncmyirp3rxzh5dq 97051 97050 2013-08-06T12:03:55Z TintoMeches 13028 added Italian translation 97051 wikitext text/x-wiki <sup>''<nowiki>[</nowiki>[[:en:WP:Dead external links|{{LangSwitch |en=dead link |it=collegamento interrotto |ml=നിലവിലില്ലാത്ത കണ്ണി |lang={{{lang|}}} }}]]<nowiki>]</nowiki>''</sup><noinclude>[[Category:Marker templates|{{PAGENAME}}]] ---- </noinclude> c491n5xxbng49tvmacv164lquporshi 97052 97044 2014-09-29T21:58:19Z Sreejithk2000 12431 Fulfilling [[Template:Edit request|edit request]] by [[User:Praveenp|Praveenp]]. Thanks for helping! 97052 wikitext text/x-wiki <sup class="noprint Inline-Template"><span style="white-space: nowrap;">[<i>{{#if: {{{url|}}}|[http://web.archive.org/web/*/{{{url|}}} <span title="{{{title|}}}{{#if:{{{date|}}}| since {{{date}}}}}">{{LangSwitch |en=dead link |it=collegamento interrotto |ml=നിലവിലില്ലാത്ത കണ്ണി |lang={{{lang|}}} }}</span>]|[[:en:WP:Dead external links|<span title="{{{title|}}}{{#if:{{{date|}}}| since {{{date}}}}}">{{LangSwitch |en=dead link |it=collegamento interrotto |ml=നിലവിലില്ലാത്ത കണ്ണി |lang={{{lang|}}} }}</span>]]}}</i>]</span></sup> <noinclude>[[Category:Marker templates|{{PAGENAME}}]] ---- </noinclude> if0q4u3ymylon47ly0n9zs9ldt9oj6m 97053 97052 2014-11-08T13:11:34Z LX 13029 Since this template is intended to be used inline, it should not introduce any line breaks. 97053 wikitext text/x-wiki <sup class="noprint Inline-Template"><span style="white-space: nowrap;">[<i>{{#if: {{{url|}}}|[http://web.archive.org/web/*/{{{url|}}} <span title="{{{title|}}}{{#if:{{{date|}}}| since {{{date}}}}}">{{LangSwitch |en=dead link |it=collegamento interrotto |ml=നിലവിലില്ലാത്ത കണ്ണി |lang={{{lang|}}} }}</span>]|[[:en:WP:Dead external links|<span title="{{{title|}}}{{#if:{{{date|}}}| since {{{date}}}}}">{{LangSwitch |en=dead link |it=collegamento interrotto |ml=നിലവിലില്ലാത്ത കണ്ണി |lang={{{lang|}}} }}</span>]]}}</i>]</span></sup><noinclude> [[Category:Marker templates|{{PAGENAME}}]] </noinclude> 2mph990e7rmwltek62vyn0jgma4byhk 97054 97053 2015-04-22T10:46:10Z MarcoAurelio 2560 9 revisions imported from [[:commons:Template:Dead_link]]: per [[Special:Permalink/11924780#Template:Authority_control|request]] 97053 wikitext text/x-wiki <sup class="noprint Inline-Template"><span style="white-space: nowrap;">[<i>{{#if: {{{url|}}}|[http://web.archive.org/web/*/{{{url|}}} <span title="{{{title|}}}{{#if:{{{date|}}}| since {{{date}}}}}">{{LangSwitch |en=dead link |it=collegamento interrotto |ml=നിലവിലില്ലാത്ത കണ്ണി |lang={{{lang|}}} }}</span>]|[[:en:WP:Dead external links|<span title="{{{title|}}}{{#if:{{{date|}}}| since {{{date}}}}}">{{LangSwitch |en=dead link |it=collegamento interrotto |ml=നിലവിലില്ലാത്ത കണ്ണി |lang={{{lang|}}} }}</span>]]}}</i>]</span></sup><noinclude> [[Category:Marker templates|{{PAGENAME}}]] </noinclude> 2mph990e7rmwltek62vyn0jgma4byhk 97055 97054 2015-04-22T15:36:08Z Glaisher 3453 rv preimport with minor fix 97055 wikitext text/x-wiki {{Fix | subst = <includeonly>{{subst:</includeonly><includeonly>substcheck}}</includeonly> | special = <sup class="noprint Inline-Template" style="white-space:nowrap" title="{{{title|}}}{{#if: {{{date|}}} | &#32;since {{{date|}}} }}">&#91;<i>{{#if: {{{url|}}} | [http://web.archive.org/web/*/{{{url|}}} dead link] | [[w:en:Wikipedia:Link rot|dead link]] }}</i>&#93;</sup> | date = {{{date|}}} | cat = [[Category:All articles with dead external links]] | cat-date = Category:Articles with dead external links }} ajp8b5yyg6ipyq5pwpdx104034r0nef 97056 97055 2026-06-07T08:43:21Z Tommy Kronkvist 2826 13 versioner importerades från [[:meta:Template:Dead_link]] 97055 wikitext text/x-wiki {{Fix | subst = <includeonly>{{subst:</includeonly><includeonly>substcheck}}</includeonly> | special = <sup class="noprint Inline-Template" style="white-space:nowrap" title="{{{title|}}}{{#if: {{{date|}}} | &#32;since {{{date|}}} }}">&#91;<i>{{#if: {{{url|}}} | [http://web.archive.org/web/*/{{{url|}}} dead link] | [[w:en:Wikipedia:Link rot|dead link]] }}</i>&#93;</sup> | date = {{{date|}}} | cat = [[Category:All articles with dead external links]] | cat-date = Category:Articles with dead external links }} ajp8b5yyg6ipyq5pwpdx104034r0nef Modul:Category handler 828 11885 97065 2013-06-25T09:13:19Z Mr. Stradivarius 12371 start a replacement for [[Template:Category handler]] 97065 Scribunto text/plain local basepageSubpage = require('Module:Basepage subpage').main -- Configuration data. local cfg = {} cfg.nocat = 'nocat' cfg.categories = 'categories' cfg.subpage = 'subpage' cfg.page = 'page' cfg.category2 = 'category2' cfg.all = 'all' cfg.main = 'main' cfg.other = 'other' -- Module start. local p = {} local args = {} -- Get the page object. This will return the page object for the page -- specified, or nil if there are errors in the title or if the -- expensive function count has been exceeded. local function getPageObject() -- Get the title object for args.page if it is specified. Otherwise -- get the title object for the current page. if args[cfg.page] then -- Get the page object, passing the function through pcall -- in case we are over the expensive function count limit. local noError, pageObject = pcall(mw.title.new, args[cfg.page]) if not noError then return nil else return pageObject end else return mw.title.getCurrentTitle() end end -- Find whether we need to return a category or not. local function needsCategory( pageObject ) if not pageObject then return end if args[cfg.nocat] == 'true' or ( args[cfg.category2] and args[cfg.category2] ~= 'yes' ) or ( args[cfg.subpage] == 'no' and pageObject.isSubpage ) or ( args[cfg.subpage] == 'only' and not pageObject.isSubpage ) then return false else return true end end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck() if args[cfg.nocat] == 'false' or args[cfg.categories] == 'yes' or args[cfg.category2] == 'yes' then return false else return true end end local function _main() local pageObject = getPageObject() if not needsCategory( pageObject ) then return end return needsBlacklistCheck() end -- Process the arguments. function p.main(frame) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs( frame.args ) do origArgs = frame.args break end else origArgs = frame end -- The following don't need blank values preserved: -- nocat -- categories -- subpage -- page -- positional parameters (1-10) -- The following *do* need blank values preserved -- category2 -- all -- other -- main -- all the namespace parameters -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". for k, v in pairs(origArgs) do v = mw.text.trim(v) -- Trim whitespace. if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". local lowercase = { cfg.nocat, cfg.categories, cfg.category2, cfg.subpage } for _, v in ipairs( lowercase ) do if args[v] then args[v] = mw.ustring.lower( args[v] ) end end return _main() end return p ixr29g62wrzp40pg37euy7fm8o66fz5 97066 97065 2013-06-25T10:39:10Z Mr. Stradivarius 12371 add blacklist check 97066 Scribunto text/plain -- Configuration data. local cfg = {} cfg.nocat = 'nocat' cfg.categories = 'categories' cfg.subpage = 'subpage' cfg.page = 'page' cfg.category2 = 'category2' cfg.all = 'all' cfg.main = 'main' cfg.other = 'other' -- The categorisation blacklist. Pages that match Lua patterns in this -- list will not be categorised unless the appropriate options are set. -- If the namespace name has a space in, it must be written with an -- underscore, e.g. "Wikipedia_talk". Other parts of the title can have -- either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', '/[aA]rchive' -- Don't categorise archives. } -- Module start. local p = {} local args = {} -- Get the page object. This will return the page object for the page -- specified, or nil if there are errors in the title or if the -- expensive function count has been exceeded. local function getPageObject() -- Get the title object for args.page if it is specified. Otherwise -- get the title object for the current page. if args[cfg.page] then -- Get the page object, passing the function through pcall -- in case we are over the expensive function count limit. local noError, pageObject = pcall(mw.title.new, args[cfg.page]) if not noError then return nil else return pageObject end else return mw.title.getCurrentTitle() end end -- Find whether we need to return a category or not. local function needsCategory( pageObject ) if not pageObject then return end if args[cfg.nocat] == 'true' or ( args[cfg.category2] and args[cfg.category2] ~= 'yes' ) or ( args[cfg.subpage] == 'no' and pageObject.isSubpage ) or ( args[cfg.subpage] == 'only' and not pageObject.isSubpage ) then return false else return true end end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck() if args[cfg.nocat] == 'false' or args[cfg.categories] == 'yes' or args[cfg.category2] == 'yes' then return false else return true end end -- Searches the blacklist to find a match with the page object. The -- string searched is the namespace plus the title, including subpages. -- Returns true if there is a match, otherwise returns false. local function findBlacklistMatch(pageObject) if not pageObject then return end -- Get the title to check. local title = pageObject.nsText -- Get the namespace. -- Append a colon if the namespace isn't the blank string. if #title > 0 then title = title .. ':' .. pageObject.text else title = pageObject.text end -- Check the blacklist. for i, pattern in ipairs( cfg.blacklist ) do if mw.ustring.match( title, pattern ) then return true end end return false end local function _main() local pageObject = getPageObject() if not needsCategory( pageObject ) then return end if needsBlacklistCheck() then return findBlacklistMatch( pageObject ) end end -- Process the arguments. function p.main(frame) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs( frame.args ) do origArgs = frame.args break end else origArgs = frame end -- The following don't need blank values preserved: -- nocat -- categories -- subpage -- page -- positional parameters (1-10) -- The following *do* need blank values preserved -- category2 -- all -- other -- main -- all the namespace parameters -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". for k, v in pairs(origArgs) do v = mw.text.trim(v) -- Trim whitespace. if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". local lowercase = { cfg.nocat, cfg.categories, cfg.category2, cfg.subpage } for _, v in ipairs( lowercase ) do if args[v] then args[v] = mw.ustring.lower( args[v] ) end end return _main() end return p 9wzw0p39kbm77vkka175anqkogby6rq 97067 97066 2013-07-01T09:36:56Z Mr. Stradivarius 12371 add the rest of the features, improve the comments 97067 Scribunto text/plain ---------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template -- -- in Lua, with a few improvements: all namespaces and all -- -- namespace aliases are supported, and namespace names are -- -- detected automatically for the local wiki. This module -- -- requires [[Module:Namespace detect]] to be available on -- -- the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set -- -- here. -- ---------------------------------------------------------------------- local cfg = {} -- cfg.nocat is the parameter name to suppress categorisation. -- cfg.nocatTrue is the value to suppress categorisation, and -- cfg.nocatFalse is the value to both categorise and to skip the -- blacklist check. cfg.nocat = 'nocat' cfg.nocatTrue = 'true' cfg.nocatFalse = 'false' -- The parameter name for the legacy "categories" parameter. cfg.categories = 'categories' cfg.categoriesYes = 'yes' -- The parameter name for the legacy "category2" parameter. This -- skips the blacklist if set to the cfg.category2Yes value, and -- suppresses categorisation if present but equal to anything other -- than cfg.category2Yes. cfg.category2 = 'category2' cfg.category2Yes = 'yes' -- cfg.subpage is the parameter name to specify how to behave on -- subpages. cfg.subpageNo is the value to specify to not -- categorise on subpages; cfg.only is the value to specify to only -- categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for -- the namespace that is detected. This must be the same as the -- cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current -- page; used for testing and demonstration. This must be the same -- as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this -- list will not be categorised unless the appropriate options are set. -- If the namespace name has a space in, it must be written with an -- underscore, e.g. "Wikipedia_talk". Other parts of the title can have -- either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. cfg.defaultNamespaces = { 0, -- Main 6, -- File 12, -- Help 14 -- Category } ---------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------- -- Get dependent modules and declare the table of functions that we will -- return. local NamespaceDetect = require('Module:Namespace detect') local p = {} ---------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want -- -- to be accessible from other modules. -- ---------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory( pageObject, args ) -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so choose the best -- default for being over the expensive function limit, i.e. categorise the page. if not pageObject then return true end -- Only categorise if the relevant options are set. if args[cfg.nocat] == cfg.nocatTrue or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes ) or ( args[cfg.subpage] == cfg.subpageNo and pageObject.isSubpage ) or ( args[cfg.subpage] == cfg.subpageOnly and not pageObject.isSubpage ) then return false else return true end end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck( args ) if args[cfg.nocat] == cfg.nocatFalse or args[cfg.categories] == cfg.categoriesYes or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Searches the blacklist to find a match with the page object. The -- string searched is the namespace plus the title, including subpages. -- Returns true if there is a match, otherwise returns false. local function findBlacklistMatch( pageObject ) if not pageObject then return end -- Get the title to check. local title = pageObject.nsText -- Get the namespace. -- Append a colon if the namespace isn't the blank string. if #title > 0 then title = title .. ':' .. pageObject.text else title = pageObject.text end -- Check the blacklist. for i, pattern in ipairs( cfg.blacklist ) do if mw.ustring.match( title, pattern ) then return true end end return false end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist( mappings, args ) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs( mappings ) do for i, param in ipairs( params ) do if args[param] then return true end end end return false end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. local function _main( args ) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = NamespaceDetect.getPageObject() local mappings = NamespaceDetect.getParamMappings() -- Check if we need a category or not, and return nothing if not. if not needsCategory( pageObject, args ) then return end local ret = '' -- The string to return. if needsBlacklistCheck( args ) and not findBlacklistMatch( pageObject ) then if not nsParamsExist( mappings, args ) then -- No namespace parameters exist; basic usage. local ndargs = {} for _, nsid in ipairs( cfg.defaultNamespaces ) do ndargs[ mw.ustring.lower( mw.site.namespaces[ nsid ].name ) ] = args[1] end ndargs.page = args.page local ndresult = NamespaceDetect.main( ndargs ) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. if args.all then ret = ret .. args.all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs( mappings ) do for _, param in ipairs( params ) do ndargs[param] = args[param] or args[cfg.other] or nil end end if args.other then ndargs.other = args.other end if args.page then ndargs.page = args.page end local data = NamespaceDetect.main( ndargs ) -- Work out what to return based on the result of the namespace -- detect call. local datanum = tonumber( data ) if type( datanum ) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor( datanum ) == datanum and args[datanum] then ret = ret .. args[ datanum ] end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end ---------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them -- -- to be accessible from #invoke and from other Lua modules. -- -- At the moment only the main function is here. It processes -- -- the arguments and passes them to the _main function. -- ---------------------------------------------------------------------- function p.main( frame ) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs( frame.args ) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs( origArgs ) do v = mw.text.trim(v) -- Trim whitespace. if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = { cfg.nocat, cfg.categories, cfg.category2, cfg.subpage } for _, v in ipairs( lowercase ) do if args[v] then args[v] = mw.ustring.lower( args[v] ) end end return _main( args ) end return p qe2537tpsg2ru68213drhaiotoklz0s 97068 97067 2013-07-01T11:36:15Z Mr. Stradivarius 12371 pass through page parameter to [[Module:Namespace detect]], tweak comments a bit 97068 Scribunto text/plain ---------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template -- -- in Lua, with a few improvements: all namespaces and all -- -- namespace aliases are supported, and namespace names are -- -- detected automatically for the local wiki. This module -- -- requires [[Module:Namespace detect]] to be available on -- -- the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set -- -- here. -- ---------------------------------------------------------------------- local cfg = {} -- cfg.nocat is the parameter name to suppress categorisation. -- cfg.nocatTrue is the value to suppress categorisation, and -- cfg.nocatFalse is the value to both categorise and to skip the -- blacklist check. cfg.nocat = 'nocat' cfg.nocatTrue = 'true' cfg.nocatFalse = 'false' -- The parameter name for the legacy "categories" parameter. cfg.categories = 'categories' cfg.categoriesYes = 'yes' -- The parameter name for the legacy "category2" parameter. This -- skips the blacklist if set to the cfg.category2Yes value, and -- suppresses categorisation if present but equal to anything other -- than cfg.category2Yes. cfg.category2 = 'category2' cfg.category2Yes = 'yes' -- cfg.subpage is the parameter name to specify how to behave on -- subpages. cfg.subpageNo is the value to specify to not -- categorise on subpages; cfg.only is the value to specify to only -- categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for -- the namespace that is detected. This must be the same as the -- cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current -- page; used for testing and demonstration. This must be the same -- as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this -- list will not be categorised unless any of the following options are -- set: "nocat=false", "categories=yes", or "category2=yes". -- If the namespace name has a space in, it must be written with an -- underscore, e.g. "Wikipedia_talk". Other parts of the title can have -- either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. cfg.defaultNamespaces = { 0, -- Main 6, -- File 12, -- Help 14 -- Category } ---------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------- -- Get dependent modules and declare the table of functions that we will -- return. local NamespaceDetect = require('Module:Namespace detect') local p = {} ---------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want -- -- to be accessible from other modules. -- ---------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory( pageObject, args ) -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so choose the best -- default for being over the expensive function limit, i.e. categorise the page. if not pageObject then return true end -- Only categorise if the relevant options are set. if args[cfg.nocat] == cfg.nocatTrue or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes ) or ( args[cfg.subpage] == cfg.subpageNo and pageObject.isSubpage ) or ( args[cfg.subpage] == cfg.subpageOnly and not pageObject.isSubpage ) then return false else return true end end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck( args ) if args[cfg.nocat] == cfg.nocatFalse or args[cfg.categories] == cfg.categoriesYes or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Searches the blacklist to find a match with the page object. The -- string searched is the namespace plus the title, including subpages. -- Returns true if there is a match, otherwise returns false. local function findBlacklistMatch( pageObject ) if not pageObject then return end -- Get the title to check. local title = pageObject.nsText -- Get the namespace. -- Append a colon if the namespace isn't the blank string. if #title > 0 then title = title .. ':' .. pageObject.text else title = pageObject.text end -- Check the blacklist. for i, pattern in ipairs( cfg.blacklist ) do if mw.ustring.match( title, pattern ) then return true end end return false end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist( mappings, args ) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs( mappings ) do for i, param in ipairs( params ) do if args[param] then return true end end end return false end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. local function _main( args ) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = NamespaceDetect.getPageObject( args[cfg.page] ) local mappings = NamespaceDetect.getParamMappings() -- Check if we need a category or not, and return nothing if not. if not needsCategory( pageObject, args ) then return end local ret = '' -- The string to return. if needsBlacklistCheck( args ) and not findBlacklistMatch( pageObject ) then if not nsParamsExist( mappings, args ) then -- No namespace parameters exist; basic usage. local ndargs = {} for _, nsid in ipairs( cfg.defaultNamespaces ) do ndargs[ mw.ustring.lower( mw.site.namespaces[ nsid ].name ) ] = args[1] end ndargs.page = args.page local ndresult = NamespaceDetect.main( ndargs ) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. if args.all then ret = ret .. args.all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs( mappings ) do for _, param in ipairs( params ) do ndargs[param] = args[param] or args[cfg.other] or nil end end if args.other then ndargs.other = args.other end if args.page then ndargs.page = args.page end local data = NamespaceDetect.main( ndargs ) -- Work out what to return based on the result of the namespace -- detect call. local datanum = tonumber( data ) if type( datanum ) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor( datanum ) == datanum and args[datanum] then ret = ret .. args[ datanum ] end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end ---------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them -- -- to be accessible from #invoke and from other Lua modules. -- -- At the moment only the main function is here. It processes -- -- the arguments and passes them to the _main function. -- ---------------------------------------------------------------------- function p.main( frame ) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs( frame.args ) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs( origArgs ) do v = mw.text.trim(v) -- Trim whitespace. if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = { cfg.nocat, cfg.categories, cfg.category2, cfg.subpage } for _, v in ipairs( lowercase ) do if args[v] then args[v] = mw.ustring.lower( args[v] ) end end return _main( args ) end return p 54oyzmsiqbmx86qgk5tb3aedbm8ipud 97069 97068 2013-07-01T12:01:45Z Mr. Stradivarius 12371 fix default parameter main namespace bug 97069 Scribunto text/plain ---------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template -- -- in Lua, with a few improvements: all namespaces and all -- -- namespace aliases are supported, and namespace names are -- -- detected automatically for the local wiki. This module -- -- requires [[Module:Namespace detect]] to be available on -- -- the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set -- -- here. -- ---------------------------------------------------------------------- local cfg = {} -- cfg.nocat is the parameter name to suppress categorisation. -- cfg.nocatTrue is the value to suppress categorisation, and -- cfg.nocatFalse is the value to both categorise and to skip the -- blacklist check. cfg.nocat = 'nocat' cfg.nocatTrue = 'true' cfg.nocatFalse = 'false' -- The parameter name for the legacy "categories" parameter. cfg.categories = 'categories' cfg.categoriesYes = 'yes' -- The parameter name for the legacy "category2" parameter. This -- skips the blacklist if set to the cfg.category2Yes value, and -- suppresses categorisation if present but equal to anything other -- than cfg.category2Yes. cfg.category2 = 'category2' cfg.category2Yes = 'yes' -- cfg.subpage is the parameter name to specify how to behave on -- subpages. cfg.subpageNo is the value to specify to not -- categorise on subpages; cfg.only is the value to specify to only -- categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for -- the namespace that is detected. This must be the same as the -- cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current -- page; used for testing and demonstration. This must be the same -- as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this -- list will not be categorised unless any of the following options are -- set: "nocat=false", "categories=yes", or "category2=yes". -- If the namespace name has a space in, it must be written with an -- underscore, e.g. "Wikipedia_talk". Other parts of the title can have -- either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They -- should be in the format of parameter names accepted by -- [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------- -- Get dependent modules and declare the table of functions that we will -- return. local NamespaceDetect = require('Module:Namespace detect') local p = {} ---------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want -- -- to be accessible from other modules. -- ---------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory( pageObject, args ) -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so choose the best -- default for being over the expensive function limit, i.e. categorise the page. if not pageObject then return true end -- Only categorise if the relevant options are set. if args[cfg.nocat] == cfg.nocatTrue or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes ) or ( args[cfg.subpage] == cfg.subpageNo and pageObject.isSubpage ) or ( args[cfg.subpage] == cfg.subpageOnly and not pageObject.isSubpage ) then return false else return true end end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck( args ) if args[cfg.nocat] == cfg.nocatFalse or args[cfg.categories] == cfg.categoriesYes or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Searches the blacklist to find a match with the page object. The -- string searched is the namespace plus the title, including subpages. -- Returns true if there is a match, otherwise returns false. local function findBlacklistMatch( pageObject ) if not pageObject then return end -- Get the title to check. local title = pageObject.nsText -- Get the namespace. -- Append a colon if the namespace isn't the blank string. if #title > 0 then title = title .. ':' .. pageObject.text else title = pageObject.text end -- Check the blacklist. for i, pattern in ipairs( cfg.blacklist ) do if mw.ustring.match( title, pattern ) then return true end end return false end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist( mappings, args ) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs( mappings ) do for i, param in ipairs( params ) do if args[param] then return true end end end return false end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. local function _main( args ) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = NamespaceDetect.getPageObject( args[cfg.page] ) local mappings = NamespaceDetect.getParamMappings() -- Check if we need a category or not, and return nothing if not. if not needsCategory( pageObject, args ) then return end local ret = '' -- The string to return. if needsBlacklistCheck( args ) and not findBlacklistMatch( pageObject ) then if not nsParamsExist( mappings, args ) then -- No namespace parameters exist; basic usage. Pass args[1] to -- [[Module:Namespace detect]] using the default namespace -- parameters, and return the result. local ndargs = {} for _, ndarg in ipairs( cfg.defaultNamespaces ) do ndargs[ndarg] = args[1] end ndargs.page = args.page local ndresult = NamespaceDetect.main( ndargs ) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. if args.all then ret = ret .. args.all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs( mappings ) do for _, param in ipairs( params ) do ndargs[param] = args[param] or args[cfg.other] or nil end end if args.other then ndargs.other = args.other end if args.page then ndargs.page = args.page end local data = NamespaceDetect.main( ndargs ) -- Work out what to return based on the result of the namespace -- detect call. local datanum = tonumber( data ) if type( datanum ) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor( datanum ) == datanum and args[datanum] then ret = ret .. args[ datanum ] end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end ---------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them -- -- to be accessible from #invoke and from other Lua modules. -- -- At the moment only the main function is here. It processes -- -- the arguments and passes them to the _main function. -- ---------------------------------------------------------------------- function p.main( frame ) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs( frame.args ) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs( origArgs ) do v = mw.text.trim(v) -- Trim whitespace. if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = { cfg.nocat, cfg.categories, cfg.category2, cfg.subpage } for _, v in ipairs( lowercase ) do if args[v] then args[v] = mw.ustring.lower( args[v] ) end end return _main( args ) end return p t95d92fjzfjd9nptqjufq7172vd3dse 97070 97069 2013-07-01T12:26:30Z Mr. Stradivarius 12371 fix blacklist-checking bug 97070 Scribunto text/plain ---------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template -- -- in Lua, with a few improvements: all namespaces and all -- -- namespace aliases are supported, and namespace names are -- -- detected automatically for the local wiki. This module -- -- requires [[Module:Namespace detect]] to be available on -- -- the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set -- -- here. -- ---------------------------------------------------------------------- local cfg = {} -- cfg.nocat is the parameter name to suppress categorisation. -- cfg.nocatTrue is the value to suppress categorisation, and -- cfg.nocatFalse is the value to both categorise and to skip the -- blacklist check. cfg.nocat = 'nocat' cfg.nocatTrue = 'true' cfg.nocatFalse = 'false' -- The parameter name for the legacy "categories" parameter. cfg.categories = 'categories' cfg.categoriesYes = 'yes' -- The parameter name for the legacy "category2" parameter. This -- skips the blacklist if set to the cfg.category2Yes value, and -- suppresses categorisation if present but equal to anything other -- than cfg.category2Yes. cfg.category2 = 'category2' cfg.category2Yes = 'yes' -- cfg.subpage is the parameter name to specify how to behave on -- subpages. cfg.subpageNo is the value to specify to not -- categorise on subpages; cfg.only is the value to specify to only -- categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for -- the namespace that is detected. This must be the same as the -- cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current -- page; used for testing and demonstration. This must be the same -- as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this -- list will not be categorised unless any of the following options are -- set: "nocat=false", "categories=yes", or "category2=yes". -- If the namespace name has a space in, it must be written with an -- underscore, e.g. "Wikipedia_talk". Other parts of the title can have -- either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They -- should be in the format of parameter names accepted by -- [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------- -- Get dependent modules and declare the table of functions that we will -- return. local NamespaceDetect = require('Module:Namespace detect') local p = {} ---------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want -- -- to be accessible from other modules. -- ---------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory( pageObject, args ) -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so choose the best -- default for being over the expensive function limit, i.e. categorise the page. if not pageObject then return true end -- Only categorise if the relevant options are set. if args[cfg.nocat] == cfg.nocatTrue or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes ) or ( args[cfg.subpage] == cfg.subpageNo and pageObject.isSubpage ) or ( args[cfg.subpage] == cfg.subpageOnly and not pageObject.isSubpage ) then return false else return true end end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck( args ) if args[cfg.nocat] == cfg.nocatFalse or args[cfg.categories] == cfg.categoriesYes or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Searches the blacklist to find a match with the page object. The -- string searched is the namespace plus the title, including subpages. -- Returns true if there is a match, otherwise returns false. local function findBlacklistMatch( pageObject ) if not pageObject then return end -- Get the title to check. local title = pageObject.nsText -- Get the namespace. -- Append a colon if the namespace isn't the blank string. if #title > 0 then title = title .. ':' .. pageObject.text else title = pageObject.text end -- Check the blacklist. for i, pattern in ipairs( cfg.blacklist ) do if mw.ustring.match( title, pattern ) then return true end end return false end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist( mappings, args ) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs( mappings ) do for i, param in ipairs( params ) do if args[param] then return true end end end return false end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. local function _main( args ) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = NamespaceDetect.getPageObject( args[cfg.page] ) local mappings = NamespaceDetect.getParamMappings() -- Check if we need a category or not, and return nothing if not. if not needsCategory( pageObject, args ) then return end local ret = '' -- The string to return. -- Check blacklist if necessary. if not needsBlacklistCheck( args ) or not findBlacklistMatch( pageObject ) then if not nsParamsExist( mappings, args ) then -- No namespace parameters exist; basic usage. Pass args[1] to -- [[Module:Namespace detect]] using the default namespace -- parameters, and return the result. local ndargs = {} for _, ndarg in ipairs( cfg.defaultNamespaces ) do ndargs[ndarg] = args[1] end ndargs.page = args.page local ndresult = NamespaceDetect.main( ndargs ) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. if args.all then ret = ret .. args.all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs( mappings ) do for _, param in ipairs( params ) do ndargs[param] = args[param] or args[cfg.other] or nil end end if args.other then ndargs.other = args.other end if args.page then ndargs.page = args.page end local data = NamespaceDetect.main( ndargs ) -- Work out what to return based on the result of the namespace -- detect call. local datanum = tonumber( data ) if type( datanum ) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor( datanum ) == datanum and args[datanum] then ret = ret .. args[ datanum ] end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end ---------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them -- -- to be accessible from #invoke and from other Lua modules. -- -- At the moment only the main function is here. It processes -- -- the arguments and passes them to the _main function. -- ---------------------------------------------------------------------- function p.main( frame ) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs( frame.args ) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs( origArgs ) do v = mw.text.trim(v) -- Trim whitespace. if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = { cfg.nocat, cfg.categories, cfg.category2, cfg.subpage } for _, v in ipairs( lowercase ) do if args[v] then args[v] = mw.ustring.lower( args[v] ) end end return _main( args ) end return p 60ukb7hunafelz2lcr1u9nh6srweyr1 97071 97070 2013-07-01T12:39:33Z Mr. Stradivarius 12371 add support for "categories=no" and "category2=¬" 97071 Scribunto text/plain ---------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template -- -- in Lua, with a few improvements: all namespaces and all -- -- namespace aliases are supported, and namespace names are -- -- detected automatically for the local wiki. This module -- -- requires [[Module:Namespace detect]] to be available on -- -- the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set -- -- here. -- ---------------------------------------------------------------------- local cfg = {} -- cfg.nocat is the parameter name to suppress categorisation. -- cfg.nocatTrue is the value to suppress categorisation, and -- cfg.nocatFalse is the value to both categorise and to skip the -- blacklist check. cfg.nocat = 'nocat' cfg.nocatTrue = 'true' cfg.nocatFalse = 'false' -- The parameter name for the legacy "categories" parameter. This -- skips the blacklist if set to the cfg.category2Yes value, and -- suppresses categorisation if set to the cfg.categoriesNo value. cfg.categories = 'categories' cfg.categoriesYes = 'yes' cfg.categoriesNo = 'no' -- The parameter name for the legacy "category2" parameter. This -- skips the blacklist if set to the cfg.category2Yes value, and -- suppresses categorisation if present but equal to anything other -- than cfg.category2Yes or cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- cfg.subpage is the parameter name to specify how to behave on -- subpages. cfg.subpageNo is the value to specify to not -- categorise on subpages; cfg.only is the value to specify to only -- categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for -- the namespace that is detected. This must be the same as the -- cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current -- page; used for testing and demonstration. This must be the same -- as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this -- list will not be categorised unless any of the following options are -- set: "nocat=false", "categories=yes", or "category2=yes". -- If the namespace name has a space in, it must be written with an -- underscore, e.g. "Wikipedia_talk". Other parts of the title can have -- either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They -- should be in the format of parameter names accepted by -- [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------- -- Get dependent modules and declare the table of functions that we will -- return. local NamespaceDetect = require('Module:Namespace detect') local p = {} ---------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want -- -- to be accessible from other modules. -- ---------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory( pageObject, args ) -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so choose the best -- default for being over the expensive function limit, i.e. categorise the page. if not pageObject then return true end -- Only categorise if the relevant options are set. if args[cfg.nocat] == cfg.nocatTrue or args[cfg.categories] == cfg.categoriesNo or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes and args[cfg.category2] ~= cfg.category2Negative ) or ( args[cfg.subpage] == cfg.subpageNo and pageObject.isSubpage ) or ( args[cfg.subpage] == cfg.subpageOnly and not pageObject.isSubpage ) then return false else return true end end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck( args ) if args[cfg.nocat] == cfg.nocatFalse or args[cfg.categories] == cfg.categoriesYes or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Searches the blacklist to find a match with the page object. The -- string searched is the namespace plus the title, including subpages. -- Returns true if there is a match, otherwise returns false. local function findBlacklistMatch( pageObject ) if not pageObject then return end -- Get the title to check. local title = pageObject.nsText -- Get the namespace. -- Append a colon if the namespace isn't the blank string. if #title > 0 then title = title .. ':' .. pageObject.text else title = pageObject.text end -- Check the blacklist. for i, pattern in ipairs( cfg.blacklist ) do if mw.ustring.match( title, pattern ) then return true end end return false end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist( mappings, args ) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs( mappings ) do for i, param in ipairs( params ) do if args[param] then return true end end end return false end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. local function _main( args ) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = NamespaceDetect.getPageObject( args[cfg.page] ) local mappings = NamespaceDetect.getParamMappings() -- Check if we need a category or not, and return nothing if not. if not needsCategory( pageObject, args ) then return end local ret = '' -- The string to return. -- Check blacklist if necessary. if not needsBlacklistCheck( args ) or not findBlacklistMatch( pageObject ) then if not nsParamsExist( mappings, args ) then -- No namespace parameters exist; basic usage. Pass args[1] to -- [[Module:Namespace detect]] using the default namespace -- parameters, and return the result. local ndargs = {} for _, ndarg in ipairs( cfg.defaultNamespaces ) do ndargs[ndarg] = args[1] end ndargs.page = args.page local ndresult = NamespaceDetect.main( ndargs ) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. if args.all then ret = ret .. args.all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs( mappings ) do for _, param in ipairs( params ) do ndargs[param] = args[param] or args[cfg.other] or nil end end if args.other then ndargs.other = args.other end if args.page then ndargs.page = args.page end local data = NamespaceDetect.main( ndargs ) -- Work out what to return based on the result of the namespace -- detect call. local datanum = tonumber( data ) if type( datanum ) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor( datanum ) == datanum and args[datanum] then ret = ret .. args[ datanum ] end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end ---------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them -- -- to be accessible from #invoke and from other Lua modules. -- -- At the moment only the main function is here. It processes -- -- the arguments and passes them to the _main function. -- ---------------------------------------------------------------------- function p.main( frame ) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs( frame.args ) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs( origArgs ) do v = mw.text.trim(v) -- Trim whitespace. if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = { cfg.nocat, cfg.categories, cfg.category2, cfg.subpage } for _, v in ipairs( lowercase ) do if args[v] then args[v] = mw.ustring.lower( args[v] ) end end return _main( args ) end return p ctso90vew7d92304nmyqub2efds8vrb 97072 97071 2013-07-01T13:16:12Z Mr. Stradivarius 12371 better fallback behaviour if we are over the expensive function count 97072 Scribunto text/plain ---------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template -- -- in Lua, with a few improvements: all namespaces and all -- -- namespace aliases are supported, and namespace names are -- -- detected automatically for the local wiki. This module -- -- requires [[Module:Namespace detect]] to be available on -- -- the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set -- -- here. -- ---------------------------------------------------------------------- local cfg = {} -- cfg.nocat is the parameter name to suppress categorisation. -- cfg.nocatTrue is the value to suppress categorisation, and -- cfg.nocatFalse is the value to both categorise and to skip the -- blacklist check. cfg.nocat = 'nocat' cfg.nocatTrue = 'true' cfg.nocatFalse = 'false' -- The parameter name for the legacy "categories" parameter. This -- skips the blacklist if set to the cfg.category2Yes value, and -- suppresses categorisation if set to the cfg.categoriesNo value. cfg.categories = 'categories' cfg.categoriesYes = 'yes' cfg.categoriesNo = 'no' -- The parameter name for the legacy "category2" parameter. This -- skips the blacklist if set to the cfg.category2Yes value, and -- suppresses categorisation if present but equal to anything other -- than cfg.category2Yes or cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- cfg.subpage is the parameter name to specify how to behave on -- subpages. cfg.subpageNo is the value to specify to not -- categorise on subpages; cfg.only is the value to specify to only -- categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for -- the namespace that is detected. This must be the same as the -- cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current -- page; used for testing and demonstration. This must be the same -- as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this -- list will not be categorised unless any of the following options are -- set: "nocat=false", "categories=yes", or "category2=yes". -- If the namespace name has a space in, it must be written with an -- underscore, e.g. "Wikipedia_talk". Other parts of the title can have -- either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They -- should be in the format of parameter names accepted by -- [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------- -- Get [[Module:Namespace detect]] and declare the table of functions -- that we will return. local NamespaceDetect = require('Module:Namespace detect') local p = {} ---------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want -- -- to be accessible from other modules. -- ---------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory( pageObject, args ) -- Don't categorise if the relevant options are set. if args[cfg.nocat] == cfg.nocatTrue or args[cfg.categories] == cfg.categoriesNo or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes and args[cfg.category2] ~= cfg.category2Negative ) then return false end -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so we choose the best -- fallback for being over the expensive function limit. The fallback behaviour -- of the old template was to assume the page was not a subpage, so we will do -- the same here. if args[cfg.subpage] == cfg.subpageNo and pageObject and pageObject.isSubpage then return false end if args[cfg.subpage] == cfg.subpageOnly and (not pageObject or (pageObject and not pageObject.isSubpage) ) then return false end return true end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck( args ) if args[cfg.nocat] == cfg.nocatFalse or args[cfg.categories] == cfg.categoriesYes or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Searches the blacklist to find a match with the page object. The -- string searched is the namespace plus the title, including subpages. -- Returns true if there is a match, otherwise returns false. local function findBlacklistMatch( pageObject ) if not pageObject then return end -- Get the title to check. local title = pageObject.nsText -- Get the namespace. -- Append a colon if the namespace isn't the blank string. if #title > 0 then title = title .. ':' .. pageObject.text else title = pageObject.text end -- Check the blacklist. for i, pattern in ipairs( cfg.blacklist ) do if mw.ustring.match( title, pattern ) then return true end end return false end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist( mappings, args ) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs( mappings ) do for i, param in ipairs( params ) do if args[param] then return true end end end return false end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. local function _main( args ) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = NamespaceDetect.getPageObject( args[cfg.page] ) local mappings = NamespaceDetect.getParamMappings() -- Check if we need a category or not, and return nothing if not. if not needsCategory( pageObject, args ) then return end local ret = '' -- The string to return. -- Check blacklist if necessary. if not needsBlacklistCheck( args ) or not findBlacklistMatch( pageObject ) then if not nsParamsExist( mappings, args ) then -- No namespace parameters exist; basic usage. Pass args[1] to -- [[Module:Namespace detect]] using the default namespace -- parameters, and return the result. local ndargs = {} for _, ndarg in ipairs( cfg.defaultNamespaces ) do ndargs[ndarg] = args[1] end ndargs.page = args.page local ndresult = NamespaceDetect.main( ndargs ) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. if args.all then ret = ret .. args.all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs( mappings ) do for _, param in ipairs( params ) do ndargs[param] = args[param] or args[cfg.other] or nil end end if args.other then ndargs.other = args.other end if args.page then ndargs.page = args.page end local data = NamespaceDetect.main( ndargs ) -- Work out what to return based on the result of the namespace -- detect call. local datanum = tonumber( data ) if type( datanum ) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor( datanum ) == datanum and args[datanum] then ret = ret .. args[ datanum ] end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end ---------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them -- -- to be accessible from #invoke and from other Lua modules. -- -- At the moment only the main function is here. It processes -- -- the arguments and passes them to the _main function. -- ---------------------------------------------------------------------- function p.main( frame ) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs( frame.args ) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs( origArgs ) do v = mw.text.trim(v) -- Trim whitespace. if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = { cfg.nocat, cfg.categories, cfg.category2, cfg.subpage } for _, v in ipairs( lowercase ) do if args[v] then args[v] = mw.ustring.lower( args[v] ) end end return _main( args ) end return p ojewnx5xrmhthg8gm7p1lotvwglzkk6 97073 97072 2013-08-01T14:34:28Z Mr. Stradivarius 12371 tweak blacklist - on matching subpages, don't match "basepage/", only "basepage/foo" 97073 Scribunto text/plain ---------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template -- -- in Lua, with a few improvements: all namespaces and all -- -- namespace aliases are supported, and namespace names are -- -- detected automatically for the local wiki. This module -- -- requires [[Module:Namespace detect]] to be available on -- -- the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set -- -- here. -- ---------------------------------------------------------------------- local cfg = {} -- cfg.nocat is the parameter name to suppress categorisation. -- cfg.nocatTrue is the value to suppress categorisation, and -- cfg.nocatFalse is the value to both categorise and to skip the -- blacklist check. cfg.nocat = 'nocat' cfg.nocatTrue = 'true' cfg.nocatFalse = 'false' -- The parameter name for the legacy "categories" parameter. This -- skips the blacklist if set to the cfg.category2Yes value, and -- suppresses categorisation if set to the cfg.categoriesNo value. cfg.categories = 'categories' cfg.categoriesYes = 'yes' cfg.categoriesNo = 'no' -- The parameter name for the legacy "category2" parameter. This -- skips the blacklist if set to the cfg.category2Yes value, and -- suppresses categorisation if present but equal to anything other -- than cfg.category2Yes or cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- cfg.subpage is the parameter name to specify how to behave on -- subpages. cfg.subpageNo is the value to specify to not -- categorise on subpages; cfg.only is the value to specify to only -- categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for -- the namespace that is detected. This must be the same as the -- cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current -- page; used for testing and demonstration. This must be the same -- as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this -- list will not be categorised unless any of the following options are -- set: "nocat=false", "categories=yes", or "category2=yes". -- If the namespace name has a space in, it must be written with an -- underscore, e.g. "Wikipedia_talk". Other parts of the title can have -- either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They -- should be in the format of parameter names accepted by -- [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------- -- Get [[Module:Namespace detect]] and declare the table of functions -- that we will return. local NamespaceDetect = require('Module:Namespace detect') local p = {} ---------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want -- -- to be accessible from other modules. -- ---------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory( pageObject, args ) -- Don't categorise if the relevant options are set. if args[cfg.nocat] == cfg.nocatTrue or args[cfg.categories] == cfg.categoriesNo or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes and args[cfg.category2] ~= cfg.category2Negative ) then return false end -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so we choose the best -- fallback for being over the expensive function limit. The fallback behaviour -- of the old template was to assume the page was not a subpage, so we will do -- the same here. if args[cfg.subpage] == cfg.subpageNo and pageObject and pageObject.isSubpage then return false end if args[cfg.subpage] == cfg.subpageOnly and (not pageObject or (pageObject and not pageObject.isSubpage) ) then return false end return true end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck( args ) if args[cfg.nocat] == cfg.nocatFalse or args[cfg.categories] == cfg.categoriesYes or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Searches the blacklist to find a match with the page object. The -- string searched is the namespace plus the title, including subpages. -- Returns true if there is a match, otherwise returns false. local function findBlacklistMatch( pageObject ) if not pageObject then return end -- Get the title to check. local title = pageObject.nsText -- Get the namespace. -- Append a colon if the namespace isn't the blank string. if #title > 0 then title = title .. ':' .. pageObject.text else title = pageObject.text end -- Check the blacklist. for i, pattern in ipairs( cfg.blacklist ) do if mw.ustring.match( title, pattern ) then return true end end return false end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist( mappings, args ) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs( mappings ) do for i, param in ipairs( params ) do if args[param] then return true end end end return false end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. local function _main( args ) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = NamespaceDetect.getPageObject( args[cfg.page] ) local mappings = NamespaceDetect.getParamMappings() -- Check if we need a category or not, and return nothing if not. if not needsCategory( pageObject, args ) then return end local ret = '' -- The string to return. -- Check blacklist if necessary. if not needsBlacklistCheck( args ) or not findBlacklistMatch( pageObject ) then if not nsParamsExist( mappings, args ) then -- No namespace parameters exist; basic usage. Pass args[1] to -- [[Module:Namespace detect]] using the default namespace -- parameters, and return the result. local ndargs = {} for _, ndarg in ipairs( cfg.defaultNamespaces ) do ndargs[ndarg] = args[1] end ndargs.page = args.page local ndresult = NamespaceDetect.main( ndargs ) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. if args.all then ret = ret .. args.all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs( mappings ) do for _, param in ipairs( params ) do ndargs[param] = args[param] or args[cfg.other] or nil end end if args.other then ndargs.other = args.other end if args.page then ndargs.page = args.page end local data = NamespaceDetect.main( ndargs ) -- Work out what to return based on the result of the namespace -- detect call. local datanum = tonumber( data ) if type( datanum ) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor( datanum ) == datanum and args[datanum] then ret = ret .. args[ datanum ] end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end ---------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them -- -- to be accessible from #invoke and from other Lua modules. -- -- At the moment only the main function is here. It processes -- -- the arguments and passes them to the _main function. -- ---------------------------------------------------------------------- function p.main( frame ) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs( frame.args ) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs( origArgs ) do v = mw.text.trim(v) -- Trim whitespace. if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = { cfg.nocat, cfg.categories, cfg.category2, cfg.subpage } for _, v in ipairs( lowercase ) do if args[v] then args[v] = mw.ustring.lower( args[v] ) end end return _main( args ) end return p fo6svf61jaj7v7x0b7ylgm4wrgz9yzk 97074 97073 2013-09-26T12:50:02Z Mr. Stradivarius 12371 update to use [[Module:Yesno]] and to allow it to play nicely with other Lua modules 97074 Scribunto text/plain ---------------------------------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, with a few improvements: all -- -- namespaces and all namespace aliases are supported, and namespace names are detected -- -- automatically for the local wiki. This module requires [[Module:Namespace detect]] and -- -- [[Module:Yesno]] to be available on the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set here. -- ---------------------------------------------------------------------------------------------------------- local cfg = {} -- The following config values set the names of parameters that suppress categorisation. They are used -- with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed cfg.nocat = 'nocat' cfg.categories = 'categories' -- The parameter name for the legacy "category2" parameter. This skips the blacklist if set to the -- cfg.category2Yes value, and suppresses categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = 'Ê' -- cfg.subpage is the parameter name to specify how to behave on subpages. cfg.subpageNo is the value to -- specify to not categorise on subpages; cfg.only is the value to specify to only categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for the namespace that is detected. This -- must be the same as the cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current page; used for testing and -- demonstration. This must be the same as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this list will not be categorised. -- (However, see the explanation of cfg.nocat, cfg.categories and cfg.category2 for some exceptions.) -- If the namespace name has a space in, it must be written with an underscore, e.g. "Wikipedia_talk". -- Other parts of the title can have either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They should be in the format of parameter -- names accepted by [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------------- -- Get dependent modules local nsDetect = require('Module:Namespace detect') local yesno = require('Module:Yesno') ---------------------------------------------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want to be accessible from other modules. -- ---------------------------------------------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory(pageObject, args) -- Don't categorise if the relevant options are set. if yesno(args[cfg.nocat]) or yesno(args[cfg.categories]) == false or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes and args[cfg.category2] ~= cfg.category2Negative ) then return false end -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so we choose the best -- fallback for being over the expensive function limit. The fallback behaviour -- of the old template was to assume the page was not a subpage, so we will do -- the same here. if args[cfg.subpage] == cfg.subpageNo and pageObject and pageObject.isSubpage then return false end if args[cfg.subpage] == cfg.subpageOnly and (not pageObject or (pageObject and not pageObject.isSubpage)) then return false end return true end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck(args) if yesno(args[cfg.nocat]) == false or yesno(args[cfg.categories]) == true or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist(mappings, args) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if args[param] then return true end end end return false end ---------------------------------------------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them to be accessible from #invoke and -- -- from other Lua modules. -- ---------------------------------------------------------------------------------------------------------- local p = {} -- Find if a string matches the blacklist. Returns the match if one is found, or nil otherwise. -- Input should be a page title with a namespace prefix, e.g. "Wikipedia talk:Articles for deletion". function p.matchesBlacklist(page) if type(page) ~= 'string' then return end for i, pattern in ipairs(cfg.blacklist) do local match = mw.ustring.match(page, pattern) if match then return match end end end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. function p._main(args) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = nsDetect.getPageObject(args[cfg.page]) local mappings = nsDetect.getParamMappings() if not needsCategory(pageObject, args) then return end local ret = '' -- Check blacklist if necessary. if not needsBlacklistCheck(args) or not p.matchesBlacklist(pageObject.prefixedText) then if not nsParamsExist(mappings, args) then -- No namespace parameters exist; basic usage. Pass args[1] to -- [[Module:Namespace detect]] using the default namespace -- parameters, and return the result. local ndargs = {} for _, ndarg in ipairs(cfg.defaultNamespaces) do ndargs[ndarg] = args[1] end ndargs.page = args.page local ndresult = nsDetect.main(ndargs) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. if args.all then ret = ret .. args.all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs(mappings) do for _, param in ipairs(params) do ndargs[param] = args[param] or args[cfg.other] or nil end end if args.other then ndargs.other = args.other end if args.page then ndargs.page = args.page end local data = nsDetect.main(ndargs) -- Work out what to return based on the result of the namespace detect call. local datanum = tonumber(data) if type(datanum) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor(datanum) == datanum and args[datanum] then ret = ret .. args[datanum] end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end function p.main(frame) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs(frame.args) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs(origArgs) do if type(v) == 'string' then v = mw.text.trim(v) -- Trim whitespace. end if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = {cfg.nocat, cfg.categories, cfg.category2, cfg.subpage} for _, v in ipairs(lowercase) do local argVal = args[v] if type(argVal) == 'string' then args[v] = mw.ustring.lower(argVal) end end return p._main(args) end return p agbzxmmeh1j6femavsdmuufo86pp0qi 97075 97074 2013-09-26T12:54:27Z Mr. Stradivarius 12371 hmm, looks like the computer I was editing this on doesn't like the negation symbol 97075 Scribunto text/plain ---------------------------------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, with a few improvements: all -- -- namespaces and all namespace aliases are supported, and namespace names are detected -- -- automatically for the local wiki. This module requires [[Module:Namespace detect]] and -- -- [[Module:Yesno]] to be available on the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set here. -- ---------------------------------------------------------------------------------------------------------- local cfg = {} -- The following config values set the names of parameters that suppress categorisation. They are used -- with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed cfg.nocat = 'nocat' cfg.categories = 'categories' -- The parameter name for the legacy "category2" parameter. This skips the blacklist if set to the -- cfg.category2Yes value, and suppresses categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- cfg.subpage is the parameter name to specify how to behave on subpages. cfg.subpageNo is the value to -- specify to not categorise on subpages; cfg.only is the value to specify to only categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for the namespace that is detected. This -- must be the same as the cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current page; used for testing and -- demonstration. This must be the same as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this list will not be categorised. -- (However, see the explanation of cfg.nocat, cfg.categories and cfg.category2 for some exceptions.) -- If the namespace name has a space in, it must be written with an underscore, e.g. "Wikipedia_talk". -- Other parts of the title can have either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They should be in the format of parameter -- names accepted by [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------------- -- Get dependent modules local nsDetect = require('Module:Namespace detect') local yesno = require('Module:Yesno') ---------------------------------------------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want to be accessible from other modules. -- ---------------------------------------------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory(pageObject, args) -- Don't categorise if the relevant options are set. if yesno(args[cfg.nocat]) or yesno(args[cfg.categories]) == false or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes and args[cfg.category2] ~= cfg.category2Negative ) then return false end -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so we choose the best -- fallback for being over the expensive function limit. The fallback behaviour -- of the old template was to assume the page was not a subpage, so we will do -- the same here. if args[cfg.subpage] == cfg.subpageNo and pageObject and pageObject.isSubpage then return false end if args[cfg.subpage] == cfg.subpageOnly and (not pageObject or (pageObject and not pageObject.isSubpage)) then return false end return true end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck(args) if yesno(args[cfg.nocat]) == false or yesno(args[cfg.categories]) == true or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist(mappings, args) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if args[param] then return true end end end return false end ---------------------------------------------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them to be accessible from #invoke and -- -- from other Lua modules. -- ---------------------------------------------------------------------------------------------------------- local p = {} -- Find if a string matches the blacklist. Returns the match if one is found, or nil otherwise. -- Input should be a page title with a namespace prefix, e.g. "Wikipedia talk:Articles for deletion". function p.matchesBlacklist(page) if type(page) ~= 'string' then return end for i, pattern in ipairs(cfg.blacklist) do local match = mw.ustring.match(page, pattern) if match then return match end end end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. function p._main(args) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = nsDetect.getPageObject(args[cfg.page]) local mappings = nsDetect.getParamMappings() if not needsCategory(pageObject, args) then return end local ret = '' -- Check blacklist if necessary. if not needsBlacklistCheck(args) or not p.matchesBlacklist(pageObject.prefixedText) then if not nsParamsExist(mappings, args) then -- No namespace parameters exist; basic usage. Pass args[1] to -- [[Module:Namespace detect]] using the default namespace -- parameters, and return the result. local ndargs = {} for _, ndarg in ipairs(cfg.defaultNamespaces) do ndargs[ndarg] = args[1] end ndargs.page = args.page local ndresult = nsDetect.main(ndargs) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. if args.all then ret = ret .. args.all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs(mappings) do for _, param in ipairs(params) do ndargs[param] = args[param] or args[cfg.other] or nil end end if args.other then ndargs.other = args.other end if args.page then ndargs.page = args.page end local data = nsDetect.main(ndargs) -- Work out what to return based on the result of the namespace detect call. local datanum = tonumber(data) if type(datanum) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor(datanum) == datanum and args[datanum] then ret = ret .. args[datanum] end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end function p.main(frame) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs(frame.args) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs(origArgs) do if type(v) == 'string' then v = mw.text.trim(v) -- Trim whitespace. end if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = {cfg.nocat, cfg.categories, cfg.category2, cfg.subpage} for _, v in ipairs(lowercase) do local argVal = args[v] if type(argVal) == 'string' then args[v] = mw.ustring.lower(argVal) end end return p._main(args) end return p m5tn92p6gridgj6909mxvvjesdr40n4 97076 97075 2013-09-27T13:05:07Z Mr. Stradivarius 12371 pass the demospace parameter to [[Module:Namespace detect]] 97076 Scribunto text/plain ---------------------------------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, with a few improvements: all -- -- namespaces and all namespace aliases are supported, and namespace names are detected -- -- automatically for the local wiki. This module requires [[Module:Namespace detect]] and -- -- [[Module:Yesno]] to be available on the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set here. -- ---------------------------------------------------------------------------------------------------------- local cfg = {} -- The following config values set the names of parameters that suppress categorisation. They are used -- with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed cfg.nocat = 'nocat' cfg.categories = 'categories' -- The parameter name for the legacy "category2" parameter. This skips the blacklist if set to the -- cfg.category2Yes value, and suppresses categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- cfg.subpage is the parameter name to specify how to behave on subpages. cfg.subpageNo is the value to -- specify to not categorise on subpages; cfg.only is the value to specify to only categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for the namespace that is detected. This -- must be the same as the cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current page; used for testing and -- demonstration. This must be the same as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this list will not be categorised. -- (However, see the explanation of cfg.nocat, cfg.categories and cfg.category2 for some exceptions.) -- If the namespace name has a space in, it must be written with an underscore, e.g. "Wikipedia_talk". -- Other parts of the title can have either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They should be in the format of parameter -- names accepted by [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------------- -- Get dependent modules local nsDetect = require('Module:Namespace detect') local yesno = require('Module:Yesno') ---------------------------------------------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want to be accessible from other modules. -- ---------------------------------------------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory(pageObject, args) -- Don't categorise if the relevant options are set. if yesno(args[cfg.nocat]) or yesno(args[cfg.categories]) == false or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes and args[cfg.category2] ~= cfg.category2Negative ) then return false end -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so we choose the best -- fallback for being over the expensive function limit. The fallback behaviour -- of the old template was to assume the page was not a subpage, so we will do -- the same here. if args[cfg.subpage] == cfg.subpageNo and pageObject and pageObject.isSubpage then return false end if args[cfg.subpage] == cfg.subpageOnly and (not pageObject or (pageObject and not pageObject.isSubpage)) then return false end return true end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck(args) if yesno(args[cfg.nocat]) == false or yesno(args[cfg.categories]) == true or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist(mappings, args) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if args[param] then return true end end end return false end ---------------------------------------------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them to be accessible from #invoke and -- -- from other Lua modules. -- ---------------------------------------------------------------------------------------------------------- local p = {} -- Find if a string matches the blacklist. Returns the match if one is found, or nil otherwise. -- Input should be a page title with a namespace prefix, e.g. "Wikipedia talk:Articles for deletion". function p.matchesBlacklist(page) if type(page) ~= 'string' then return end for i, pattern in ipairs(cfg.blacklist) do local match = mw.ustring.match(page, pattern) if match then return match end end end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. function p._main(args) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = nsDetect.getPageObject(args[cfg.page]) local mappings = nsDetect.getParamMappings() if not needsCategory(pageObject, args) then return end local ret = '' -- Check blacklist if necessary. if not needsBlacklistCheck(args) or not p.matchesBlacklist(pageObject.prefixedText) then if not nsParamsExist(mappings, args) then -- No namespace parameters exist; basic usage. Pass args[1] to -- [[Module:Namespace detect]] using the default namespace -- parameters, and return the result. local ndargs = {} for _, ndarg in ipairs(cfg.defaultNamespaces) do ndargs[ndarg] = args[1] end ndargs.page = args.page ndargs.demospace = args.demospace local ndresult = nsDetect.main(ndargs) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. local all = args.all if type(all) == 'string' then ret = ret .. all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs(mappings) do for _, param in ipairs(params) do ndargs[param] = args[param] or args[cfg.other] or nil end end ndargs.other = args.other ndargs.page = args.page ndargs.demospace = args.demospace local data = nsDetect.main(ndargs) -- Work out what to return based on the result of the namespace detect call. local datanum = tonumber(data) if type(datanum) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor(datanum) == datanum then local dataArg = args[datanum] if type(dataArg) == 'string' then ret = ret .. dataArg end end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end function p.main(frame) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs(frame.args) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs(origArgs) do if type(v) == 'string' then v = mw.text.trim(v) -- Trim whitespace. end if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = {cfg.nocat, cfg.categories, cfg.category2, cfg.subpage} for _, v in ipairs(lowercase) do local argVal = args[v] if type(argVal) == 'string' then args[v] = mw.ustring.lower(argVal) end end return p._main(args) end return p 2gdm43f8ox6j1913xh6dwckxhqnv0lx 97077 97076 2013-10-15T14:10:19Z Mr. Stradivarius 12371 test the sandbox version of [[Module:Namespace detect]] 97077 Scribunto text/plain ---------------------------------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, with a few improvements: all -- -- namespaces and all namespace aliases are supported, and namespace names are detected -- -- automatically for the local wiki. This module requires [[Module:Namespace detect]] and -- -- [[Module:Yesno]] to be available on the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set here. -- ---------------------------------------------------------------------------------------------------------- local cfg = {} -- The following config values set the names of parameters that suppress categorisation. They are used -- with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed cfg.nocat = 'nocat' cfg.categories = 'categories' -- The parameter name for the legacy "category2" parameter. This skips the blacklist if set to the -- cfg.category2Yes value, and suppresses categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- cfg.subpage is the parameter name to specify how to behave on subpages. cfg.subpageNo is the value to -- specify to not categorise on subpages; cfg.only is the value to specify to only categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for the namespace that is detected. This -- must be the same as the cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current page; used for testing and -- demonstration. This must be the same as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this list will not be categorised. -- (However, see the explanation of cfg.nocat, cfg.categories and cfg.category2 for some exceptions.) -- If the namespace name has a space in, it must be written with an underscore, e.g. "Wikipedia_talk". -- Other parts of the title can have either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They should be in the format of parameter -- names accepted by [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------------- -- Get dependent modules local nsDetect = require('Module:Namespace detect/sandbox') -- REMOVE "/sandbox" BEFORE GOING LIVE local yesno = require('Module:Yesno') ---------------------------------------------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want to be accessible from other modules. -- ---------------------------------------------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory(pageObject, args) -- Don't categorise if the relevant options are set. if yesno(args[cfg.nocat]) or yesno(args[cfg.categories]) == false or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes and args[cfg.category2] ~= cfg.category2Negative ) then return false end -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so we choose the best -- fallback for being over the expensive function limit. The fallback behaviour -- of the old template was to assume the page was not a subpage, so we will do -- the same here. if args[cfg.subpage] == cfg.subpageNo and pageObject and pageObject.isSubpage then return false end if args[cfg.subpage] == cfg.subpageOnly and (not pageObject or (pageObject and not pageObject.isSubpage)) then return false end return true end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck(args) if yesno(args[cfg.nocat]) == false or yesno(args[cfg.categories]) == true or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist(mappings, args) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if args[param] then return true end end end return false end ---------------------------------------------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them to be accessible from #invoke and -- -- from other Lua modules. -- ---------------------------------------------------------------------------------------------------------- local p = {} -- Find if a string matches the blacklist. Returns the match if one is found, or nil otherwise. -- Input should be a page title with a namespace prefix, e.g. "Wikipedia talk:Articles for deletion". function p.matchesBlacklist(page) if type(page) ~= 'string' then return end for i, pattern in ipairs(cfg.blacklist) do local match = mw.ustring.match(page, pattern) if match then return match end end end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. function p._main(args) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = nsDetect.getPageObject(args[cfg.page]) local mappings = nsDetect.getParamMappings() if not needsCategory(pageObject, args) then return end local ret = '' -- Check blacklist if necessary. if not needsBlacklistCheck(args) or not p.matchesBlacklist(pageObject.prefixedText) then if not nsParamsExist(mappings, args) then -- No namespace parameters exist; basic usage. Pass args[1] to -- [[Module:Namespace detect]] using the default namespace -- parameters, and return the result. local ndargs = {} for _, ndarg in ipairs(cfg.defaultNamespaces) do ndargs[ndarg] = args[1] end ndargs.page = args.page ndargs.demospace = args.demospace local ndresult = nsDetect.main(ndargs) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. local all = args.all if type(all) == 'string' then ret = ret .. all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs(mappings) do for _, param in ipairs(params) do ndargs[param] = args[param] or args[cfg.other] or nil end end ndargs.other = args.other ndargs.page = args.page ndargs.demospace = args.demospace local data = nsDetect.main(ndargs) -- Work out what to return based on the result of the namespace detect call. local datanum = tonumber(data) if type(datanum) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor(datanum) == datanum then local dataArg = args[datanum] if type(dataArg) == 'string' then ret = ret .. dataArg end end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end function p.main(frame) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs(frame.args) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs(origArgs) do if type(v) == 'string' then v = mw.text.trim(v) -- Trim whitespace. end if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = {cfg.nocat, cfg.categories, cfg.category2, cfg.subpage} for _, v in ipairs(lowercase) do local argVal = args[v] if type(argVal) == 'string' then args[v] = mw.ustring.lower(argVal) end end return p._main(args) end return p b0x29l5atgtha436acbw2tsi6o5m1nh 97078 97077 2013-10-15T14:11:53Z Mr. Stradivarius 12371 use the _main function for nsDetect rather than the main function 97078 Scribunto text/plain ---------------------------------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, with a few improvements: all -- -- namespaces and all namespace aliases are supported, and namespace names are detected -- -- automatically for the local wiki. This module requires [[Module:Namespace detect]] and -- -- [[Module:Yesno]] to be available on the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set here. -- ---------------------------------------------------------------------------------------------------------- local cfg = {} -- The following config values set the names of parameters that suppress categorisation. They are used -- with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed cfg.nocat = 'nocat' cfg.categories = 'categories' -- The parameter name for the legacy "category2" parameter. This skips the blacklist if set to the -- cfg.category2Yes value, and suppresses categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- cfg.subpage is the parameter name to specify how to behave on subpages. cfg.subpageNo is the value to -- specify to not categorise on subpages; cfg.only is the value to specify to only categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for the namespace that is detected. This -- must be the same as the cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current page; used for testing and -- demonstration. This must be the same as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this list will not be categorised. -- (However, see the explanation of cfg.nocat, cfg.categories and cfg.category2 for some exceptions.) -- If the namespace name has a space in, it must be written with an underscore, e.g. "Wikipedia_talk". -- Other parts of the title can have either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They should be in the format of parameter -- names accepted by [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------------- -- Get dependent modules local nsDetect = require('Module:Namespace detect/sandbox') -- REMOVE "/sandbox" BEFORE GOING LIVE local yesno = require('Module:Yesno') ---------------------------------------------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want to be accessible from other modules. -- ---------------------------------------------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory(pageObject, args) -- Don't categorise if the relevant options are set. if yesno(args[cfg.nocat]) or yesno(args[cfg.categories]) == false or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes and args[cfg.category2] ~= cfg.category2Negative ) then return false end -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so we choose the best -- fallback for being over the expensive function limit. The fallback behaviour -- of the old template was to assume the page was not a subpage, so we will do -- the same here. if args[cfg.subpage] == cfg.subpageNo and pageObject and pageObject.isSubpage then return false end if args[cfg.subpage] == cfg.subpageOnly and (not pageObject or (pageObject and not pageObject.isSubpage)) then return false end return true end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck(args) if yesno(args[cfg.nocat]) == false or yesno(args[cfg.categories]) == true or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist(mappings, args) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if args[param] then return true end end end return false end ---------------------------------------------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them to be accessible from #invoke and -- -- from other Lua modules. -- ---------------------------------------------------------------------------------------------------------- local p = {} -- Find if a string matches the blacklist. Returns the match if one is found, or nil otherwise. -- Input should be a page title with a namespace prefix, e.g. "Wikipedia talk:Articles for deletion". function p.matchesBlacklist(page) if type(page) ~= 'string' then return end for i, pattern in ipairs(cfg.blacklist) do local match = mw.ustring.match(page, pattern) if match then return match end end end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. function p._main(args) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = nsDetect.getPageObject(args[cfg.page]) local mappings = nsDetect.getParamMappings() if not needsCategory(pageObject, args) then return end local ret = '' -- Check blacklist if necessary. if not needsBlacklistCheck(args) or not p.matchesBlacklist(pageObject.prefixedText) then if not nsParamsExist(mappings, args) then -- No namespace parameters exist; basic usage. Pass args[1] to -- [[Module:Namespace detect]] using the default namespace -- parameters, and return the result. local ndargs = {} for _, ndarg in ipairs(cfg.defaultNamespaces) do ndargs[ndarg] = args[1] end ndargs.page = args.page ndargs.demospace = args.demospace local ndresult = nsDetect._main(ndargs) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. local all = args.all if type(all) == 'string' then ret = ret .. all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs(mappings) do for _, param in ipairs(params) do ndargs[param] = args[param] or args[cfg.other] or nil end end ndargs.other = args.other ndargs.page = args.page ndargs.demospace = args.demospace local data = nsDetect._main(ndargs) -- Work out what to return based on the result of the namespace detect call. local datanum = tonumber(data) if type(datanum) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor(datanum) == datanum then local dataArg = args[datanum] if type(dataArg) == 'string' then ret = ret .. dataArg end end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end function p.main(frame) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs(frame.args) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs(origArgs) do if type(v) == 'string' then v = mw.text.trim(v) -- Trim whitespace. end if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = {cfg.nocat, cfg.categories, cfg.category2, cfg.subpage} for _, v in ipairs(lowercase) do local argVal = args[v] if type(argVal) == 'string' then args[v] = mw.ustring.lower(argVal) end end return p._main(args) end return p 64pvj2e1a5vel33fx9f2h84ai9g10sa 97079 97078 2013-10-20T10:42:36Z Mr. Stradivarius 12371 use live version of [[Module:Namespace detect]] 97079 Scribunto text/plain ---------------------------------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, with a few improvements: all -- -- namespaces and all namespace aliases are supported, and namespace names are detected -- -- automatically for the local wiki. This module requires [[Module:Namespace detect]] and -- -- [[Module:Yesno]] to be available on the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set here. -- ---------------------------------------------------------------------------------------------------------- local cfg = {} -- The following config values set the names of parameters that suppress categorisation. They are used -- with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed cfg.nocat = 'nocat' cfg.categories = 'categories' -- The parameter name for the legacy "category2" parameter. This skips the blacklist if set to the -- cfg.category2Yes value, and suppresses categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- cfg.subpage is the parameter name to specify how to behave on subpages. cfg.subpageNo is the value to -- specify to not categorise on subpages; cfg.only is the value to specify to only categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for the namespace that is detected. This -- must be the same as the cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current page; used for testing and -- demonstration. This must be the same as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this list will not be categorised. -- (However, see the explanation of cfg.nocat, cfg.categories and cfg.category2 for some exceptions.) -- If the namespace name has a space in, it must be written with an underscore, e.g. "Wikipedia_talk". -- Other parts of the title can have either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They should be in the format of parameter -- names accepted by [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------------- -- Get dependent modules local nsDetect = require('Module:Namespace detect') local yesno = require('Module:Yesno') ---------------------------------------------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want to be accessible from other modules. -- ---------------------------------------------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory(pageObject, args) -- Don't categorise if the relevant options are set. if yesno(args[cfg.nocat]) or yesno(args[cfg.categories]) == false or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes and args[cfg.category2] ~= cfg.category2Negative ) then return false end -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so we choose the best -- fallback for being over the expensive function limit. The fallback behaviour -- of the old template was to assume the page was not a subpage, so we will do -- the same here. if args[cfg.subpage] == cfg.subpageNo and pageObject and pageObject.isSubpage then return false end if args[cfg.subpage] == cfg.subpageOnly and (not pageObject or (pageObject and not pageObject.isSubpage)) then return false end return true end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck(args) if yesno(args[cfg.nocat]) == false or yesno(args[cfg.categories]) == true or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist(mappings, args) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if args[param] then return true end end end return false end ---------------------------------------------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them to be accessible from #invoke and -- -- from other Lua modules. -- ---------------------------------------------------------------------------------------------------------- local p = {} -- Find if a string matches the blacklist. Returns the match if one is found, or nil otherwise. -- Input should be a page title with a namespace prefix, e.g. "Wikipedia talk:Articles for deletion". function p.matchesBlacklist(page) if type(page) ~= 'string' then return end for i, pattern in ipairs(cfg.blacklist) do local match = mw.ustring.match(page, pattern) if match then return match end end end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. function p._main(args) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = nsDetect.getPageObject(args[cfg.page]) local mappings = nsDetect.getParamMappings() if not needsCategory(pageObject, args) then return end local ret = '' -- Check blacklist if necessary. if not needsBlacklistCheck(args) or not p.matchesBlacklist(pageObject.prefixedText) then if not nsParamsExist(mappings, args) then -- No namespace parameters exist; basic usage. Pass args[1] to -- [[Module:Namespace detect]] using the default namespace -- parameters, and return the result. local ndargs = {} for _, ndarg in ipairs(cfg.defaultNamespaces) do ndargs[ndarg] = args[1] end ndargs.page = args.page ndargs.demospace = args.demospace local ndresult = nsDetect._main(ndargs) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. local all = args.all if type(all) == 'string' then ret = ret .. all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs(mappings) do for _, param in ipairs(params) do ndargs[param] = args[param] or args[cfg.other] or nil end end ndargs.other = args.other ndargs.page = args.page ndargs.demospace = args.demospace local data = nsDetect._main(ndargs) -- Work out what to return based on the result of the namespace detect call. local datanum = tonumber(data) if type(datanum) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor(datanum) == datanum then local dataArg = args[datanum] if type(dataArg) == 'string' then ret = ret .. dataArg end end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end function p.main(frame) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs(frame.args) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs(origArgs) do if type(v) == 'string' then v = mw.text.trim(v) -- Trim whitespace. end if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = {cfg.nocat, cfg.categories, cfg.category2, cfg.subpage} for _, v in ipairs(lowercase) do local argVal = args[v] if type(argVal) == 'string' then args[v] = mw.ustring.lower(argVal) end end return p._main(args) end return p i2ez8nejriv7clde6mvnuwl3ypo3qj6 97080 97079 2013-10-20T10:48:14Z Mr. Stradivarius 12371 Protected Module:Category handler: [[Wikipedia:Lua/Modules|High-risk Lua module]] ([Edit=Protected template] (indefinite) [Move=Protected template] (indefinite)) 97079 Scribunto text/plain ---------------------------------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, with a few improvements: all -- -- namespaces and all namespace aliases are supported, and namespace names are detected -- -- automatically for the local wiki. This module requires [[Module:Namespace detect]] and -- -- [[Module:Yesno]] to be available on the local wiki. It can be configured for different wikis -- -- by altering the values in the "cfg" table. -- -- -- ---------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set here. -- ---------------------------------------------------------------------------------------------------------- local cfg = {} -- The following config values set the names of parameters that suppress categorisation. They are used -- with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed cfg.nocat = 'nocat' cfg.categories = 'categories' -- The parameter name for the legacy "category2" parameter. This skips the blacklist if set to the -- cfg.category2Yes value, and suppresses categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- cfg.subpage is the parameter name to specify how to behave on subpages. cfg.subpageNo is the value to -- specify to not categorise on subpages; cfg.only is the value to specify to only categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for the namespace that is detected. This -- must be the same as the cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current page; used for testing and -- demonstration. This must be the same as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this list will not be categorised. -- (However, see the explanation of cfg.nocat, cfg.categories and cfg.category2 for some exceptions.) -- If the namespace name has a space in, it must be written with an underscore, e.g. "Wikipedia_talk". -- Other parts of the title can have either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They should be in the format of parameter -- names accepted by [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------------- -- Get dependent modules local nsDetect = require('Module:Namespace detect') local yesno = require('Module:Yesno') ---------------------------------------------------------------------------------------------------------- -- Local functions -- -- The following are internal functions, which we do not want to be accessible from other modules. -- ---------------------------------------------------------------------------------------------------------- -- Find whether we need to return a category or not. local function needsCategory(pageObject, args) -- Don't categorise if the relevant options are set. if yesno(args[cfg.nocat]) or yesno(args[cfg.categories]) == false or ( args[cfg.category2] and args[cfg.category2] ~= cfg.category2Yes and args[cfg.category2] ~= cfg.category2Negative ) then return false end -- If there is no pageObject available, then that either means that we are over -- the expensive function limit or that the title specified was invalid. Invalid -- titles will probably only be a problem during testing, so we choose the best -- fallback for being over the expensive function limit. The fallback behaviour -- of the old template was to assume the page was not a subpage, so we will do -- the same here. if args[cfg.subpage] == cfg.subpageNo and pageObject and pageObject.isSubpage then return false end if args[cfg.subpage] == cfg.subpageOnly and (not pageObject or (pageObject and not pageObject.isSubpage)) then return false end return true end -- Find whether we need to check the blacklist or not. local function needsBlacklistCheck(args) if yesno(args[cfg.nocat]) == false or yesno(args[cfg.categories]) == true or args[cfg.category2] == cfg.category2Yes then return false else return true end end -- Find whether any namespace parameters have been specified. -- Mappings is the table of parameter mappings taken from -- [[Module:Namespace detect]]. local function nsParamsExist(mappings, args) if args[cfg.all] or args[cfg.other] then return true end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if args[param] then return true end end end return false end ---------------------------------------------------------------------------------------------------------- -- Global functions -- -- The following functions are global, because we want them to be accessible from #invoke and -- -- from other Lua modules. -- ---------------------------------------------------------------------------------------------------------- local p = {} -- Find if a string matches the blacklist. Returns the match if one is found, or nil otherwise. -- Input should be a page title with a namespace prefix, e.g. "Wikipedia talk:Articles for deletion". function p.matchesBlacklist(page) if type(page) ~= 'string' then return end for i, pattern in ipairs(cfg.blacklist) do local match = mw.ustring.match(page, pattern) if match then return match end end end -- The main structure of the module. Checks whether we need to categorise, -- and then passes the relevant arguments to [[Module:Namespace detect]]. function p._main(args) -- Get the page object and argument mappings from -- [[Module:Namespace detect]], to save us from having to rewrite the -- code. local pageObject = nsDetect.getPageObject(args[cfg.page]) local mappings = nsDetect.getParamMappings() if not needsCategory(pageObject, args) then return end local ret = '' -- Check blacklist if necessary. if not needsBlacklistCheck(args) or not p.matchesBlacklist(pageObject.prefixedText) then if not nsParamsExist(mappings, args) then -- No namespace parameters exist; basic usage. Pass args[1] to -- [[Module:Namespace detect]] using the default namespace -- parameters, and return the result. local ndargs = {} for _, ndarg in ipairs(cfg.defaultNamespaces) do ndargs[ndarg] = args[1] end ndargs.page = args.page ndargs.demospace = args.demospace local ndresult = nsDetect._main(ndargs) if ndresult then ret = ret .. ndresult end else -- Namespace parameters exist; advanced usage. -- If the all parameter is specified, return it. local all = args.all if type(all) == 'string' then ret = ret .. all end -- Get the arguments to pass to [[Module:Namespace detect]]. local ndargs = {} for ns, params in pairs(mappings) do for _, param in ipairs(params) do ndargs[param] = args[param] or args[cfg.other] or nil end end ndargs.other = args.other ndargs.page = args.page ndargs.demospace = args.demospace local data = nsDetect._main(ndargs) -- Work out what to return based on the result of the namespace detect call. local datanum = tonumber(data) if type(datanum) == 'number' then -- "data" is a number, so return that positional parameter. -- Remove non-positive integer values, as only positive integers -- from 1-10 were used with the old template. if datanum > 0 and math.floor(datanum) == datanum then local dataArg = args[datanum] if type(dataArg) == 'string' then ret = ret .. dataArg end end else -- "data" is not a number, so return it as it is. if type(data) == 'string' then ret = ret .. data end end end end return ret end function p.main(frame) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs(frame.args) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments for the following args: -- 1, 2, 3 etc., "nocat", "categories", "subpage", and "page". local args = {} for k, v in pairs(origArgs) do if type(v) == 'string' then v = mw.text.trim(v) -- Trim whitespace. end if type(k) == 'number' or k == cfg.nocat or k == cfg.categories or k == cfg.subpage or k == cfg.page then if v ~= '' then args[k] = v end else args[k] = v end end -- Lower-case "nocat", "categories", "category2", and "subpage". These -- parameters are put in lower case whenever they appear in the old -- template, so we can just do it once here and save ourselves some work. local lowercase = {cfg.nocat, cfg.categories, cfg.category2, cfg.subpage} for _, v in ipairs(lowercase) do local argVal = args[v] if type(argVal) == 'string' then args[v] = mw.ustring.lower(argVal) end end return p._main(args) end return p i2ez8nejriv7clde6mvnuwl3ypo3qj6 97081 97080 2014-07-13T09:12:24Z Mr. Stradivarius 12371 Rewrite this using [[Module:Middleclass]]. It is now more efficient: it only parses parameters when necessary, and caches data with mw.loadData where it can. 97081 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local class = require('Module:Middleclass').class local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = class('CategoryHandler') function CategoryHandler:initialize(data, args) self._data = data self._args = args -- Set the title object do local pagename = self:parameter('demopage') local success, titleObj = pcall(mw.title.new, pagename) if success and titleObj then self.title = titleObj else self.title = mw.title.getCurrentTitle() self._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = self:parameter(key) value = trimWhitespace(value, true) self['_' .. key] = yesno(value) end do local subpage = self:parameter('subpage') local category2 = self:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end self._subpage = trimWhitespace(subpage, true) self._category2 = trimWhitespace(category2) -- don't remove blank values end end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler:new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p 0gk28nn4re4b29jsfpgwes1sajtyw6r 97082 97081 2014-07-13T17:57:16Z WOSlinker 3690 apply changes from sandbox as requested by [[User:Jackmcbarn]] which removes middleclass dependency 97082 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj = pcall(mw.title.new, pagename) if success and titleObj then obj.title = titleObj else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p 3gubklzofemfn9qf4shfenu5oqsei9z 97083 97082 2014-07-22T05:08:26Z Mr. Stradivarius 12371 allow invocations specifying the page parameter to use the mw.loadData optimisations, and don't call mw.title.new every time 97083 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p letwavu3yvlayfzew66uuwixmwebq5b 97084 97083 2015-02-19T20:51:18Z Peteforsyth 12372 19 revisions imported from [[:w:Module:Category_handler]]: Attempting, per request from [[User:Titodutta]]. I'm not sure if "w" is the right source wiki (only a few options in drop-down menu) 97084 wikitext text/x-wiki -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p letwavu3yvlayfzew66uuwixmwebq5b 97085 97084 2015-07-29T23:31:30Z Legoktm 2683 Fixing content model 97085 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p letwavu3yvlayfzew66uuwixmwebq5b 97086 97085 2017-11-20T16:18:21Z Defilippoi 13030 97086 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == true or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == true or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return true end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p 8cqli48u4vzz2byphqs54ngzc9vf4gn 97087 97086 2017-11-20T16:59:36Z Stryn 2454 Undo revision 17447604 by [[Special:Contributions/Defilippoi|Defilippoi]] ([[User talk:Defilippoi|talk]]) not sure what this does 97087 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p letwavu3yvlayfzew66uuwixmwebq5b 97088 97087 2019-02-14T01:34:01Z MusikAnimal 12376 Protected "[[Module:Category handler]]": High-risk Lua module ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)) 97087 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p letwavu3yvlayfzew66uuwixmwebq5b 97089 97088 2019-03-22T20:54:40Z Vogone 2479 1 revision imported from [[:w:Module:Category_handler]]: per RFH 97087 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p letwavu3yvlayfzew66uuwixmwebq5b 97090 97089 2021-08-23T18:01:04Z MusikBot II 12440 Changed protection settings for "[[Module:Category handler]]": High-risk template or module ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97087 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p letwavu3yvlayfzew66uuwixmwebq5b 97091 97090 2022-01-16T06:16:23Z TheresNoTime 12448 1 revision imported from [[:w:Module:Category_handler]] 97087 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p letwavu3yvlayfzew66uuwixmwebq5b 97092 97091 2025-04-17T05:49:34Z Veritas Sapientiae 11379 3 revisions imported from [[:commons:Module:Category_handler]] 97087 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p letwavu3yvlayfzew66uuwixmwebq5b 97093 97092 2025-04-27T20:02:12Z Pppery 12444 Protected "[[Module:Category handler]]" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97087 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p letwavu3yvlayfzew66uuwixmwebq5b 97094 97093 2026-06-07T08:43:24Z Tommy Kronkvist 2826 29 versioner importerades från [[:meta:Module:Category_handler]] 97087 Scribunto text/plain -------------------------------------------------------------------------------- -- -- -- CATEGORY HANDLER -- -- -- -- This module implements the {{category handler}} template in Lua, -- -- with a few improvements: all namespaces and all namespace aliases -- -- are supported, and namespace names are detected automatically for -- -- the local wiki. This module requires [[Module:Namespace detect]] -- -- and [[Module:Yesno]] to be available on the local wiki. It can be -- -- configured for different wikis by altering the values in -- -- [[Module:Category handler/config]], and pages can be blacklisted -- -- from categorisation by using [[Module:Category handler/blacklist]]. -- -- -- -------------------------------------------------------------------------------- -- Load required modules local yesno = require('Module:Yesno') -- Lazily load things we don't always need local mShared, mappings local p = {} -------------------------------------------------------------------------------- -- Helper functions -------------------------------------------------------------------------------- local function trimWhitespace(s, removeBlanks) if type(s) ~= 'string' then return s end s = s:match('^%s*(.-)%s*$') if removeBlanks then if s ~= '' then return s else return nil end else return s end end -------------------------------------------------------------------------------- -- CategoryHandler class -------------------------------------------------------------------------------- local CategoryHandler = {} CategoryHandler.__index = CategoryHandler function CategoryHandler.new(data, args) local obj = setmetatable({ _data = data, _args = args }, CategoryHandler) -- Set the title object do local pagename = obj:parameter('demopage') local success, titleObj if pagename then success, titleObj = pcall(mw.title.new, pagename) end if success and titleObj then obj.title = titleObj if titleObj == mw.title.getCurrentTitle() then obj._usesCurrentTitle = true end else obj.title = mw.title.getCurrentTitle() obj._usesCurrentTitle = true end end -- Set suppression parameter values for _, key in ipairs{'nocat', 'categories'} do local value = obj:parameter(key) value = trimWhitespace(value, true) obj['_' .. key] = yesno(value) end do local subpage = obj:parameter('subpage') local category2 = obj:parameter('category2') if type(subpage) == 'string' then subpage = mw.ustring.lower(subpage) end if type(category2) == 'string' then subpage = mw.ustring.lower(category2) end obj._subpage = trimWhitespace(subpage, true) obj._category2 = trimWhitespace(category2) -- don't remove blank values end return obj end function CategoryHandler:parameter(key) local parameterNames = self._data.parameters[key] local pntype = type(parameterNames) if pntype == 'string' or pntype == 'number' then return self._args[parameterNames] elseif pntype == 'table' then for _, name in ipairs(parameterNames) do local value = self._args[name] if value ~= nil then return value end end return nil else error(string.format( 'invalid config key "%s"', tostring(key) ), 2) end end function CategoryHandler:isSuppressedByArguments() return -- See if a category suppression argument has been set. self._nocat == true or self._categories == false or ( self._category2 and self._category2 ~= self._data.category2Yes and self._category2 ~= self._data.category2Negative ) -- Check whether we are on a subpage, and see if categories are -- suppressed based on our subpage status. or self._subpage == self._data.subpageNo and self.title.isSubpage or self._subpage == self._data.subpageOnly and not self.title.isSubpage end function CategoryHandler:shouldSkipBlacklistCheck() -- Check whether the category suppression arguments indicate we -- should skip the blacklist check. return self._nocat == false or self._categories == true or self._category2 == self._data.category2Yes end function CategoryHandler:matchesBlacklist() if self._usesCurrentTitle then return self._data.currentTitleMatchesBlacklist else mShared = mShared or require('Module:Category handler/shared') return mShared.matchesBlacklist( self.title.prefixedText, mw.loadData('Module:Category handler/blacklist') ) end end function CategoryHandler:isSuppressed() -- Find if categories are suppressed by either the arguments or by -- matching the blacklist. return self:isSuppressedByArguments() or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist() end function CategoryHandler:getNamespaceParameters() if self._usesCurrentTitle then return self._data.currentTitleNamespaceParameters else if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end return mShared.getNamespaceParameters( self.title, mappings ) end end function CategoryHandler:namespaceParametersExist() -- Find whether any namespace parameters have been specified. -- We use the order "all" --> namespace params --> "other" as this is what -- the old template did. if self:parameter('all') then return true end if not mappings then mShared = mShared or require('Module:Category handler/shared') mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData end for ns, params in pairs(mappings) do for i, param in ipairs(params) do if self._args[param] then return true end end end if self:parameter('other') then return true end return false end function CategoryHandler:getCategories() local params = self:getNamespaceParameters() local nsCategory for i, param in ipairs(params) do local value = self._args[param] if value ~= nil then nsCategory = value break end end if nsCategory ~= nil or self:namespaceParametersExist() then -- Namespace parameters exist - advanced usage. if nsCategory == nil then nsCategory = self:parameter('other') end local ret = {self:parameter('all')} local numParam = tonumber(nsCategory) if numParam and numParam >= 1 and math.floor(numParam) == numParam then -- nsCategory is an integer ret[#ret + 1] = self._args[numParam] else ret[#ret + 1] = nsCategory end if #ret < 1 then return nil else return table.concat(ret) end elseif self._data.defaultNamespaces[self.title.namespace] then -- Namespace parameters don't exist, simple usage. return self._args[1] end return nil end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- local p = {} function p._exportClasses() -- Used for testing purposes. return { CategoryHandler = CategoryHandler } end function p._main(args, data) data = data or mw.loadData('Module:Category handler/data') local handler = CategoryHandler.new(data, args) if handler:isSuppressed() then return nil end return handler:getCategories() end function p.main(frame, data) data = data or mw.loadData('Module:Category handler/data') local args = require('Module:Arguments').getArgs(frame, { wrappers = data.wrappers, valueFunc = function (k, v) v = trimWhitespace(v) if type(k) == 'number' then if v ~= '' then return v else return nil end else return v end end }) return p._main(args, data) end return p letwavu3yvlayfzew66uuwixmwebq5b Modul:Category handler/data 828 11886 97095 2014-07-07T02:03:36Z Mr. Stradivarius 12371 create data page to be loaded from [[Module:Category handler]] with mw.loadData 97095 Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local matchesBlacklist = require('Module:Category handler/shared').matchesBlacklist data.currentTitleMatchesBlacklist = matchesBlacklist( mw.title.getCurrentTitle().prefixedText, require('Module:Category handler/blacklist') ) or false return data mgw5hcmx0x2br4ot1u0andmbflqlq29 97096 97095 2014-07-07T13:11:45Z Mr. Stradivarius 12371 don't bother with the "or false" 97096 Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local matchesBlacklist = require('Module:Category handler/shared').matchesBlacklist data.currentTitleMatchesBlacklist = matchesBlacklist( mw.title.getCurrentTitle().prefixedText, require('Module:Category handler/blacklist') ) return data dgwtrep38q0knv0l0ngri5pefeghtna 97097 97096 2014-07-07T15:03:12Z Mr. Stradivarius 12371 add a currentTitleNamespaceParameters field 97097 Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local mNamespaceDetect = require('Module:Namespace detect') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mNamespaceDetect.getParamMappings() ) return data 707x4q5usw714zid78iewe87jdeo18r 97098 97097 2014-07-08T00:27:50Z Mr. Stradivarius 12371 use the new shared function for getting parameter mappings 97098 Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mShared.getParamMappings() ) return data k26mwixuaeijisfddb0sxkg82iux8v4 97099 97098 2014-07-13T09:05:55Z Mr. Stradivarius 12371 Protected Module:Category handler/data: [[WP:High-risk templates|High-risk Lua module]] ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)) 97098 Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mShared.getParamMappings() ) return data k26mwixuaeijisfddb0sxkg82iux8v4 97100 97099 2015-02-19T20:51:19Z Peteforsyth 12372 5 revisions imported from [[:w:Module:Category_handler/data]]: Attempting, per request from [[User:Titodutta]]. I'm not sure if "w" is the right source wiki (only a few options in drop-down menu) 97100 wikitext text/x-wiki -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mShared.getParamMappings() ) return data k26mwixuaeijisfddb0sxkg82iux8v4 97101 97100 2015-07-29T23:31:31Z Legoktm 2683 Fixing content model 97101 Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mShared.getParamMappings() ) return data k26mwixuaeijisfddb0sxkg82iux8v4 97102 97101 2019-02-14T01:34:55Z MusikAnimal 12376 Protected "[[Module:Category handler/data]]": High-risk Lua module ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)) 97101 Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mShared.getParamMappings() ) return data k26mwixuaeijisfddb0sxkg82iux8v4 97103 97102 2022-01-16T06:16:24Z TheresNoTime 12448 2 revisions imported from [[:w:Module:Category_handler/data]] 97101 Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mShared.getParamMappings() ) return data k26mwixuaeijisfddb0sxkg82iux8v4 97104 97103 2022-01-16T18:01:31Z MusikBot II 12440 Changed protection settings for "[[Module:Category handler/data]]": High-risk template or module ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97101 Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mShared.getParamMappings() ) return data k26mwixuaeijisfddb0sxkg82iux8v4 97105 97104 2025-04-17T05:49:57Z Veritas Sapientiae 11379 2 revisions imported from [[:commons:Module:Category_handler/data]] 97101 Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mShared.getParamMappings() ) return data k26mwixuaeijisfddb0sxkg82iux8v4 97106 97105 2025-04-27T18:49:28Z Pppery 12444 Protected "[[Module:Category handler/data]]" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97101 Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mShared.getParamMappings() ) return data k26mwixuaeijisfddb0sxkg82iux8v4 97107 97106 2026-06-07T08:43:24Z Tommy Kronkvist 2826 12 versioner importerades från [[:meta:Module:Category_handler/data]] 97101 Scribunto text/plain -- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist. local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle() data.currentTitleMatchesBlacklist = mShared.matchesBlacklist( title.prefixedText, blacklist ) data.currentTitleNamespaceParameters = mShared.getNamespaceParameters( title, mShared.getParamMappings() ) return data k26mwixuaeijisfddb0sxkg82iux8v4 Modul:Category handler/config 828 11887 97108 2014-03-24T05:20:06Z Mr. Stradivarius 12371 copy config data from [[Module:Category handler]] to try and make the separation between config and code clearer 97108 Scribunto text/plain ---------------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set here. -- ---------------------------------------------------------------------------------------------------------- local cfg = {} -- The following config values set the names of parameters that suppress categorisation. They are used -- with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed cfg.nocat = 'nocat' cfg.categories = 'categories' -- The parameter name for the legacy "category2" parameter. This skips the blacklist if set to the -- cfg.category2Yes value, and suppresses categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- cfg.subpage is the parameter name to specify how to behave on subpages. cfg.subpageNo is the value to -- specify to not categorise on subpages; cfg.only is the value to specify to only categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for the namespace that is detected. This -- must be the same as the cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current page; used for testing and -- demonstration. This must be the same as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this list will not be categorised. -- (However, see the explanation of cfg.nocat, cfg.categories and cfg.category2 for some exceptions.) -- If the namespace name has a space in, it must be written with an underscore, e.g. "Wikipedia_talk". -- Other parts of the title can have either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They should be in the format of parameter -- names accepted by [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------------- 7mqk9jkxou904j9i7db26fx3smyx6p8 97109 97108 2014-04-07T16:03:37Z Mr. Stradivarius 12371 return the cfg table 97109 Scribunto text/plain ---------------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names and values can be set here. -- ---------------------------------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. ---------------------------------------------------------------------------------------------------------- -- Start configuration data -- ---------------------------------------------------------------------------------------------------------- -- The following config values set the names of parameters that suppress categorisation. They are used -- with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed cfg.nocat = 'nocat' cfg.categories = 'categories' -- The parameter name for the legacy "category2" parameter. This skips the blacklist if set to the -- cfg.category2Yes value, and suppresses categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- cfg.subpage is the parameter name to specify how to behave on subpages. cfg.subpageNo is the value to -- specify to not categorise on subpages; cfg.only is the value to specify to only categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for the namespace that is detected. This -- must be the same as the cfg.other parameter in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current page; used for testing and -- demonstration. This must be the same as the cfg.page parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this list will not be categorised. -- (However, see the explanation of cfg.nocat, cfg.categories and cfg.category2 for some exceptions.) -- If the namespace name has a space in, it must be written with an underscore, e.g. "Wikipedia_talk". -- Other parts of the title can have either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They should be in the format of parameter -- names accepted by [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } ---------------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------------- return cfg -- Don't edit this line. mc38xwsnmkiiy2hm49j6ikg9wjazgtw 97110 97109 2014-04-07T16:08:24Z Mr. Stradivarius 12371 make this fit within 80 chars 97110 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -- The following config values set the names of parameters that suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and the -- blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and the -- blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed cfg.nocat = 'nocat' cfg.categories = 'categories' -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses categorisation -- if present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative. cfg.category2 = 'category2' cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- cfg.subpage is the parameter name to specify how to behave on subpages. -- cfg.subpageNo is the value to specify to not categorise on subpages; cfg.only -- is the value to specify to only categorise on subpages. cfg.subpage = 'subpage' cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -- The parameter for data to return in all namespaces. cfg.all = 'all' -- The parameter name for data to return if no data is specified for the -- namespace that is detected. This must be the same as the cfg.other parameter -- in [[Module:Namespace detect]]. cfg.other = 'other' -- The parameter name used to specify a page other than the current page; used -- for testing and demonstration. This must be the same as the cfg.page -- parameter in [[Module:Namespace detect]]. cfg.page = 'page' -- The categorisation blacklist. Pages that match Lua patterns in this list will -- not be categorised. (However, see the explanation of cfg.nocat, -- cfg.categories and cfg.category2 for some exceptions.) If the namespace name -- has a space in, it must be written with an underscore, e.g. "Wikipedia_talk". -- Other parts of the title can have either underscores or spaces. cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', '/[aA]rchive' -- Don't categorise archives. } -- This is a table of namespaces to categorise by default. They should be in the -- format of parameter names accepted by [[Module:Namespace detect]]. cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 0lc35bgxjwlf4g8zyrhszfeplr9ndcq 97111 97110 2014-04-07T17:59:47Z Mr. Stradivarius 12371 restructure, make most config optional, and add a few items to the blacklist 97111 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- The nocat and categories parameter suppress ---- categorisation. They are used with Module:Yesno, and work as follows: ---- ---- cfg.nocat: ---- Result of yesno(args[cfg.nocat]) Effect ---- true Categorisation is suppressed ---- false Categorisation is allowed, and the ---- blacklist check is skipped ---- nil Categorisation is allowed ---- ---- cfg.categories: ---- Result of yesno(args[cfg.categories]) Effect ---- true Categorisation is allowed, and the ---- blacklist check is skipped ---- false Categorisation is suppressed ---- nil Categorisation is allowed -- cfg.nocat = 'nocat' -- cfg.categories = 'categories' ---- The parameter name for the legacy "category2" parameter. This skips the ---- blacklist if set to the cfg.category2Yes value, and suppresses ---- categorisation if present but equal to anything other than cfg.category2Yes ---- or cfg.category2Negative. -- cfg.category2 = 'category2' ---- cfg.subpage is the parameter name to specify how to behave on subpages. -- cfg.subpage = 'subpage' ---- The parameter for data to return in all namespaces. -- cfg.all = 'all' ---- The parameter name for data to return if no data is specified for the ---- namespace that is detected. -- cfg.other = 'other' ---- The parameter name used to specify a page other than the current page; used ---- for testing and demonstration. This must be the same as the cfg.page ---- parameter in [[Module:Namespace detect]]. cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -- -- These settings are optional. It is always possible to use the module -- -- defaults instead. -- -------------------------------------------------------------------------------- ---- The following settings are used with the cfg.category2 parameter. Setting ---- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 ---- is present but equal to anything other than cfg.category2Yes or ---- cfg.category2Negative then it supresses cateogrisation. -- cfg.category2Yes = 'yes' -- cfg.category2Negative = '¬' ---- The following settings are used with the cfg.subpage parameter. ---- cfg.subpageNo is the value to specify to not categorise on subpages; ---- cfg.subpageOnly is the value to specify to only categorise on subpages. -- cfg.subpageNo = 'no' -- cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Blacklist -- -- The categorisation blacklist. Pages that match Lua patterns in this list -- -- will not be categorised. (However, see the explanation of cfg.nocat, -- -- cfg.categories and cfg.category2 for some exceptions.) If the namespace -- -- name has a space in, it must be written with an underscore, e.g. -- -- "Wikipedia_talk". Other parts of the title can have either underscores or -- -- spaces. -- -------------------------------------------------------------------------------- cfg.blacklist = { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User_talk:UBX$', '^User_talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', -- Don't categorise User CSD logs or PROD logs. '^User:.*/[cC][sS][dD] ?[lL][oO][gG]', '^User:.*/[pP][rR][oO][dD] ?[lL][oO][gG]', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive", "^Wikipedia:Administrators' noticeboard/3RRArchive", } -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. They should be in -- -- the format of parameter names accepted by [[Module:Namespace detect]]. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. fiij1aiw338zeh83izv29qojxdad6em 97112 97111 2014-04-10T06:44:30Z Mr. Stradivarius 12371 blacklist tweaks 97112 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- The nocat and categories parameter suppress ---- categorisation. They are used with Module:Yesno, and work as follows: ---- ---- cfg.nocat: ---- Result of yesno(args[cfg.nocat]) Effect ---- true Categorisation is suppressed ---- false Categorisation is allowed, and the ---- blacklist check is skipped ---- nil Categorisation is allowed ---- ---- cfg.categories: ---- Result of yesno(args[cfg.categories]) Effect ---- true Categorisation is allowed, and the ---- blacklist check is skipped ---- false Categorisation is suppressed ---- nil Categorisation is allowed -- cfg.nocat = 'nocat' -- cfg.categories = 'categories' ---- The parameter name for the legacy "category2" parameter. This skips the ---- blacklist if set to the cfg.category2Yes value, and suppresses ---- categorisation if present but equal to anything other than cfg.category2Yes ---- or cfg.category2Negative. -- cfg.category2 = 'category2' ---- cfg.subpage is the parameter name to specify how to behave on subpages. -- cfg.subpage = 'subpage' ---- The parameter for data to return in all namespaces. -- cfg.all = 'all' ---- The parameter name for data to return if no data is specified for the ---- namespace that is detected. -- cfg.other = 'other' ---- The parameter name used to specify a page other than the current page; used ---- for testing and demonstration. This must be the same as the cfg.page ---- parameter in [[Module:Namespace detect]]. cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -- -- These settings are optional. It is always possible to use the module -- -- defaults instead. -- -------------------------------------------------------------------------------- ---- The following settings are used with the cfg.category2 parameter. Setting ---- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 ---- is present but equal to anything other than cfg.category2Yes or ---- cfg.category2Negative then it supresses cateogrisation. -- cfg.category2Yes = 'yes' -- cfg.category2Negative = '¬' ---- The following settings are used with the cfg.subpage parameter. ---- cfg.subpageNo is the value to specify to not categorise on subpages; ---- cfg.subpageOnly is the value to specify to only categorise on subpages. -- cfg.subpageNo = 'no' -- cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Blacklist -- -- The categorisation blacklist. Pages that match Lua patterns in this list -- -- will not be categorised. (However, see the explanation of cfg.nocat, -- -- cfg.categories and cfg.category2 for some exceptions.) If the namespace -- -- name has a space in, it must be written with an underscore, e.g. -- -- "Wikipedia_talk". Other parts of the title can have either underscores or -- -- spaces. -- -------------------------------------------------------------------------------- cfg.blacklist = { -- Don't categorise the Main Page. '^Main Page$', -- Don't categorise [[Wikipedia:Cascade-protected items]] or its subpages. -- The pattern '%f[/\0]' matches a blank string where the next character is -- either '/' or the end of the string, and the previous character is not -- one of those characters. '^Wikipedia:Cascade%-protected items%f[/\0]', -- Don't categorise [[User:UBX]], [[User talk:UBX]] or any of their -- subpages. This is the userbox "template" space, and often gets -- categorised with userbox categories by mistake. '^User:UBX%f[/\0]', '^User_talk:UBX%f[/\0]', -- Don't categorise subpages of [[Wikipedia:Template messages]], but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', -- Don't categorise User CSD logs or PROD logs. '^User:.*/[cC][sS][dD] ?[lL][oO][gG]', '^User:.*/[pP][rR][oO][dD] ?[lL][oO][gG]', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive", "^Wikipedia:Administrators' noticeboard/3RRArchive", } -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. They should be in -- -- the format of parameter names accepted by [[Module:Namespace detect]]. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. nua44xaxexftwfrvdd6g7wdny67gj10 97113 97112 2014-07-07T01:55:54Z Mr. Stradivarius 12371 don't bother to use default parameter names - allow each wiki to set parameter names however they want 97113 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- The nocat and categories parameter suppress ---- categorisation. They are used with Module:Yesno, and work as follows: ---- ---- cfg.nocat: ---- Result of yesno(args[cfg.nocat]) Effect ---- true Categorisation is suppressed ---- false Categorisation is allowed, and the ---- blacklist check is skipped ---- nil Categorisation is allowed ---- ---- cfg.categories: ---- Result of yesno(args[cfg.categories]) Effect ---- true Categorisation is allowed, and the ---- blacklist check is skipped ---- false Categorisation is suppressed ---- nil Categorisation is allowed cfg.nocat = 'nocat' cfg.categories = 'categories' ---- The parameter name for the legacy "category2" parameter. This skips the ---- blacklist if set to the cfg.category2Yes value, and suppresses ---- categorisation if present but equal to anything other than cfg.category2Yes ---- or cfg.category2Negative. cfg.category2 = 'category2' ---- cfg.subpage is the parameter name to specify how to behave on subpages. cfg.subpage = 'subpage' ---- The parameter for data to return in all namespaces. cfg.all = 'all' ---- The parameter name for data to return if no data is specified for the ---- namespace that is detected. cfg.other = 'other' ---- The parameter name used to specify a page other than the current page; used ---- for testing and demonstration. This must be the same as the cfg.page ---- parameter in [[Module:Namespace detect]]. cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -- -- These settings are optional. It is always possible to use the module -- -- defaults instead. -- -------------------------------------------------------------------------------- ---- The following settings are used with the cfg.category2 parameter. Setting ---- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 ---- is present but equal to anything other than cfg.category2Yes or ---- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' ---- The following settings are used with the cfg.subpage parameter. ---- cfg.subpageNo is the value to specify to not categorise on subpages; ---- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. They should be in -- -- the format of parameter names accepted by [[Module:Namespace detect]]. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. ezwke82sffy7pvqurrekwsbhwi7rrit 97114 97113 2014-07-07T07:03:44Z Mr. Stradivarius 12371 move parameter names to a cfg.parameters subtable 97114 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. This must be the same as the cfg.page -- parameter in [[Module:Namespace detect]]. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -- -- These settings are optional. It is always possible to use the module -- -- defaults instead. -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. They should be in -- -- the format of parameter names accepted by [[Module:Namespace detect]]. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. c9mvmiiqi8myykd74gwl2zucjc27cbh 97115 97114 2014-07-07T07:04:39Z Mr. Stradivarius 12371 tweak parameter comments 97115 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. This must be the same as the cfg.page -- parameter in [[Module:Namespace detect]]. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -- -- These settings are optional. It is always possible to use the module -- -- defaults instead. -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. They should be in -- -- the format of parameter names accepted by [[Module:Namespace detect]]. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { 'main', 'file', 'help', 'category' } -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. et36nefy33x0xksi81dd200hr6ql3g8 97116 97115 2014-07-07T14:37:14Z Mr. Stradivarius 12371 use namespace numbers for the default namespaces 97116 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. This must be the same as the cfg.page -- parameter in [[Module:Namespace detect]]. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -- -- These settings are optional. It is always possible to use the module -- -- defaults instead. -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. They should be in -- -- the format of parameter names accepted by [[Module:Namespace detect]]. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 4] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 7iau2bek52ytm4va3cke6nauerbfrib 97117 97116 2014-07-07T23:57:08Z Mr. Stradivarius 12371 that must be the other file namespace 97117 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. This must be the same as the cfg.page -- parameter in [[Module:Namespace detect]]. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -- -- These settings are optional. It is always possible to use the module -- -- defaults instead. -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. They should be in -- -- the format of parameter names accepted by [[Module:Namespace detect]]. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. ljr4q10gjdr11z3eb524v7ee56lcb0j 97118 97117 2014-07-08T02:09:08Z Mr. Stradivarius 12371 add wrappers config 97118 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno(args[cfg.nocat]) Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno(args[cfg.categories]) Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. This must be the same as the cfg.page -- parameter in [[Module:Namespace detect]]. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -- -- These settings are optional. It is always possible to use the module -- -- defaults instead. -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. They should be in -- -- the format of parameter names accepted by [[Module:Namespace detect]]. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 5xy6cltbdtyybzojj4mk97qd1eek3ju 97119 97118 2014-07-08T05:27:50Z Mr. Stradivarius 12371 update comments 97119 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 6ga9hbq2pdwalsvx68i53dmbr421rq5 97120 97119 2014-07-13T09:05:36Z Mr. Stradivarius 12371 Protected Module:Category handler/config: [[WP:High-risk templates|High-risk Lua module]] ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)) 97119 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 6ga9hbq2pdwalsvx68i53dmbr421rq5 97121 97120 2015-02-19T20:51:18Z Peteforsyth 12372 13 revisions imported from [[:w:Module:Category_handler/config]]: Attempting, per request from [[User:Titodutta]]. I'm not sure if "w" is the right source wiki (only a few options in drop-down menu) 97121 wikitext text/x-wiki -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 6ga9hbq2pdwalsvx68i53dmbr421rq5 97122 97121 2015-07-29T23:31:30Z Legoktm 2683 Fixing content model 97122 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 6ga9hbq2pdwalsvx68i53dmbr421rq5 97123 97122 2019-02-14T01:34:41Z MusikAnimal 12376 Protected "[[Module:Category handler/config]]": High-risk Lua module ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)) 97122 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 6ga9hbq2pdwalsvx68i53dmbr421rq5 97124 97123 2019-03-13T20:22:24Z Billinghurst 2463 #fit ... [1198] = true, -- translations 97124 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book [1198] = true, -- translations } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. lli53hjfh9fq3gcf2mboybpr7pzhc7v 97125 97124 2019-03-13T20:27:41Z Billinghurst 2463 [866] = true, -- CNBanner 97125 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book [866] = true, -- CNBanner [1198] = true, -- translations } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 6crj8smghdo742lerxwumvuip2neme0 97126 97125 2022-01-16T06:16:24Z TheresNoTime 12448 2 revisions imported from [[:w:Module:Category_handler/config]] 97126 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 6ga9hbq2pdwalsvx68i53dmbr421rq5 97127 97126 2022-01-16T18:01:31Z MusikBot II 12440 Changed protection settings for "[[Module:Category handler/config]]": High-risk template or module ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97126 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 6ga9hbq2pdwalsvx68i53dmbr421rq5 97128 97127 2025-04-17T05:49:57Z Veritas Sapientiae 11379 2 revisions imported from [[:commons:Module:Category_handler/config]] 97126 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 6ga9hbq2pdwalsvx68i53dmbr421rq5 97129 97128 2025-04-27T18:49:38Z Pppery 12444 Protected "[[Module:Category handler/config]]" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97126 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 6ga9hbq2pdwalsvx68i53dmbr421rq5 97130 97129 2026-06-07T08:43:25Z Tommy Kronkvist 2826 22 versioner importerades från [[:meta:Module:Category_handler/config]] 97126 Scribunto text/plain -------------------------------------------------------------------------------- -- [[Module:Category handler]] configuration data -- -- Language-specific parameter names and values can be set here. -- -- For blacklist config, see [[Module:Category handler/blacklist]]. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Start configuration data -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- foo = 'parameter name', -- -- -- -- To add multiple names, you can use this format: -- -- -- -- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}, -- -------------------------------------------------------------------------------- cfg.parameters = { -- The nocat and categories parameter suppress -- categorisation. They are used with Module:Yesno, and work as follows: -- -- cfg.nocat: -- Result of yesno() Effect -- true Categorisation is suppressed -- false Categorisation is allowed, and -- the blacklist check is skipped -- nil Categorisation is allowed -- -- cfg.categories: -- Result of yesno() Effect -- true Categorisation is allowed, and -- the blacklist check is skipped -- false Categorisation is suppressed -- nil Categorisation is allowed nocat = 'nocat', categories = 'categories', -- The parameter name for the legacy "category2" parameter. This skips the -- blacklist if set to the cfg.category2Yes value, and suppresses -- categorisation if present but equal to anything other than -- cfg.category2Yes or cfg.category2Negative. category2 = 'category2', -- cfg.subpage is the parameter name to specify how to behave on subpages. subpage = 'subpage', -- The parameter for data to return in all namespaces. all = 'all', -- The parameter name for data to return if no data is specified for the -- namespace that is detected. other = 'other', -- The parameter name used to specify a page other than the current page; -- used for testing and demonstration. demopage = 'page', } -------------------------------------------------------------------------------- -- Parameter values -- -- These are set values that can be used with certain parameters. Only one -- -- value can be specified, like this: -- -- -- -- cfg.foo = 'value name' -- -- -------------------------------------------------------------------------------- -- The following settings are used with the cfg.category2 parameter. Setting -- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2 -- is present but equal to anything other than cfg.category2Yes or -- cfg.category2Negative then it supresses cateogrisation. cfg.category2Yes = 'yes' cfg.category2Negative = '¬' -- The following settings are used with the cfg.subpage parameter. -- cfg.subpageNo is the value to specify to not categorise on subpages; -- cfg.subpageOnly is the value to specify to only categorise on subpages. cfg.subpageNo = 'no' cfg.subpageOnly = 'only' -------------------------------------------------------------------------------- -- Default namespaces -- -- This is a table of namespaces to categorise by default. The keys are the -- -- namespace numbers. -- -------------------------------------------------------------------------------- cfg.defaultNamespaces = { [ 0] = true, -- main [ 6] = true, -- file [ 12] = true, -- help [ 14] = true, -- category [100] = true, -- portal [108] = true, -- book } -------------------------------------------------------------------------------- -- Wrappers -- -- This is a wrapper template or a list of wrapper templates to be passed to -- -- [[Module:Arguments]]. -- -------------------------------------------------------------------------------- cfg.wrappers = 'Template:Category handler' -------------------------------------------------------------------------------- -- End configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 6ga9hbq2pdwalsvx68i53dmbr421rq5 Modul:Category handler/shared 828 11888 97131 2014-07-06T23:46:51Z Mr. Stradivarius 12371 move blacklist-matching function from [[Module:Category handler]] 97131 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local blacklist = require('Module:Category handler/blacklist') local function matchesBlacklist(page) if type(page) ~= 'string' then return end for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return match end end end return { matchesBlacklist = matchesBlacklist } ts4xme8565qnxi5gbwstq7tmyi8dinx 97132 97131 2014-07-07T01:51:59Z Mr. Stradivarius 12371 allow specifying a custom blacklist 97132 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local function matchesBlacklist(page, blacklist) if type(page) ~= 'string' then return nil end for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return match end end end return { matchesBlacklist = matchesBlacklist } gkfzr3egt584dvad0ov1qmiu0ee8p0g 97133 97132 2014-07-07T13:13:39Z Mr. Stradivarius 12371 make this output either true or false, and switch indentation to tabs 97133 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local function matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end return { matchesBlacklist = matchesBlacklist } 9kbpjimcs9omo9apeyiubqh0miw7p65 97134 97133 2014-07-07T14:55:25Z Mr. Stradivarius 12371 add a getNamespaceParameters function 97134 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey = mw.site.namespaces[titleObj.namespace].name mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p enoq11qxomilr2x76uiqz8pp00nwnup 97135 97134 2014-07-07T15:45:47Z Mr. Stradivarius 12371 return a copy of the params table so that it doesn't contain a metatable 97135 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey = mw.site.namespaces[titleObj.namespace].name mappingsKey = mw.ustring.lower(mappingsKey) local origParams = mappings[mappingsKey] or {} local params = {} for i, v in ipairs(origParams) do params[i] = v end return params end return p 6dsmo3eitd8ff8emep5vrq8i0vsqms5 97136 97135 2014-07-08T00:26:15Z Mr. Stradivarius 12371 return the right key in talk space, and don't copy the table; instead, create a new wrapper function that can load the mappings with either require or mw.loadData 97136 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getParamMappings(useLoadData) local dataPage = 'Module:Namespace detect/data' if useLoadData then return mw.loadData(dataPage).mappings else return require(dataPage).mappings end end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey if titleObj.isTalkPage then mappingsKey = 'talk' else mappingsKey = mw.site.namespaces[titleObj.namespace].name end mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p omlsnhudxz6juptvtxz7ns97jutbzc5 97137 97136 2014-07-13T09:06:15Z Mr. Stradivarius 12371 Protected Module:Category handler/shared: [[WP:High-risk templates|High-risk Lua module]] ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)) 97136 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getParamMappings(useLoadData) local dataPage = 'Module:Namespace detect/data' if useLoadData then return mw.loadData(dataPage).mappings else return require(dataPage).mappings end end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey if titleObj.isTalkPage then mappingsKey = 'talk' else mappingsKey = mw.site.namespaces[titleObj.namespace].name end mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p omlsnhudxz6juptvtxz7ns97jutbzc5 97138 97137 2015-02-19T20:51:19Z Peteforsyth 12372 7 revisions imported from [[:w:Module:Category_handler/shared]]: Attempting, per request from [[User:Titodutta]]. I'm not sure if "w" is the right source wiki (only a few options in drop-down menu) 97138 wikitext text/x-wiki -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getParamMappings(useLoadData) local dataPage = 'Module:Namespace detect/data' if useLoadData then return mw.loadData(dataPage).mappings else return require(dataPage).mappings end end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey if titleObj.isTalkPage then mappingsKey = 'talk' else mappingsKey = mw.site.namespaces[titleObj.namespace].name end mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p omlsnhudxz6juptvtxz7ns97jutbzc5 97139 97138 2015-07-29T23:31:31Z Legoktm 2683 Fixing content model 97139 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getParamMappings(useLoadData) local dataPage = 'Module:Namespace detect/data' if useLoadData then return mw.loadData(dataPage).mappings else return require(dataPage).mappings end end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey if titleObj.isTalkPage then mappingsKey = 'talk' else mappingsKey = mw.site.namespaces[titleObj.namespace].name end mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p omlsnhudxz6juptvtxz7ns97jutbzc5 97140 97139 2019-02-14T01:35:11Z MusikAnimal 12376 Protected "[[Module:Category handler/shared]]": High-risk Lua module ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)) 97139 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getParamMappings(useLoadData) local dataPage = 'Module:Namespace detect/data' if useLoadData then return mw.loadData(dataPage).mappings else return require(dataPage).mappings end end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey if titleObj.isTalkPage then mappingsKey = 'talk' else mappingsKey = mw.site.namespaces[titleObj.namespace].name end mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p omlsnhudxz6juptvtxz7ns97jutbzc5 97141 97140 2022-01-16T06:16:24Z TheresNoTime 12448 2 revisions imported from [[:w:Module:Category_handler/shared]] 97139 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getParamMappings(useLoadData) local dataPage = 'Module:Namespace detect/data' if useLoadData then return mw.loadData(dataPage).mappings else return require(dataPage).mappings end end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey if titleObj.isTalkPage then mappingsKey = 'talk' else mappingsKey = mw.site.namespaces[titleObj.namespace].name end mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p omlsnhudxz6juptvtxz7ns97jutbzc5 97142 97141 2022-01-16T18:01:32Z MusikBot II 12440 Changed protection settings for "[[Module:Category handler/shared]]": High-risk template or module ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97139 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getParamMappings(useLoadData) local dataPage = 'Module:Namespace detect/data' if useLoadData then return mw.loadData(dataPage).mappings else return require(dataPage).mappings end end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey if titleObj.isTalkPage then mappingsKey = 'talk' else mappingsKey = mw.site.namespaces[titleObj.namespace].name end mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p omlsnhudxz6juptvtxz7ns97jutbzc5 97143 97142 2025-04-17T05:49:57Z Veritas Sapientiae 11379 2 revisions imported from [[:commons:Module:Category_handler/shared]] 97139 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getParamMappings(useLoadData) local dataPage = 'Module:Namespace detect/data' if useLoadData then return mw.loadData(dataPage).mappings else return require(dataPage).mappings end end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey if titleObj.isTalkPage then mappingsKey = 'talk' else mappingsKey = mw.site.namespaces[titleObj.namespace].name end mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p omlsnhudxz6juptvtxz7ns97jutbzc5 97144 97143 2025-04-27T18:49:33Z Pppery 12444 Protected "[[Module:Category handler/shared]]" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97139 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getParamMappings(useLoadData) local dataPage = 'Module:Namespace detect/data' if useLoadData then return mw.loadData(dataPage).mappings else return require(dataPage).mappings end end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey if titleObj.isTalkPage then mappingsKey = 'talk' else mappingsKey = mw.site.namespaces[titleObj.namespace].name end mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p omlsnhudxz6juptvtxz7ns97jutbzc5 97145 97144 2026-06-07T08:43:26Z Tommy Kronkvist 2826 14 versioner importerades från [[:meta:Module:Category_handler/shared]] 97139 Scribunto text/plain -- This module contains shared functions used by [[Module:Category handler]] -- and its submodules. local p = {} function p.matchesBlacklist(page, blacklist) for i, pattern in ipairs(blacklist) do local match = mw.ustring.match(page, pattern) if match then return true end end return false end function p.getParamMappings(useLoadData) local dataPage = 'Module:Namespace detect/data' if useLoadData then return mw.loadData(dataPage).mappings else return require(dataPage).mappings end end function p.getNamespaceParameters(titleObj, mappings) -- We don't use title.nsText for the namespace name because it adds -- underscores. local mappingsKey if titleObj.isTalkPage then mappingsKey = 'talk' else mappingsKey = mw.site.namespaces[titleObj.namespace].name end mappingsKey = mw.ustring.lower(mappingsKey) return mappings[mappingsKey] or {} end return p omlsnhudxz6juptvtxz7ns97jutbzc5 Modul:Category handler/blacklist 828 11889 97146 2014-07-06T23:44:59Z Mr. Stradivarius 12371 move blacklist from [[Module:Category handler]] 97146 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. '^Wikipedia:Cascade%-protected items$', '^Wikipedia:Cascade%-protected items/.*$', '^User:UBX$', -- The userbox "template" space. '^User:UBX/.*$', '^User talk:UBX$', '^User talk:UBX/.*$', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.+$', '/[aA]rchive' -- Don't categorise archives. } 90c2dwfuizdmluu4al48fagtm3uogv8 97147 97146 2014-07-08T11:08:50Z Mr. Stradivarius 12371 make the pattern more efficient 97147 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', '/[aA]rchive' -- Don't categorise archives. } ne8sdldor304iu81gnqa05p401j3exc 97148 97147 2014-07-13T09:07:09Z Mr. Stradivarius 12371 Protected Module:Category handler/blacklist: [[WP:High-risk templates|High-risk Lua module]] ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)) 97147 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', '/[aA]rchive' -- Don't categorise archives. } ne8sdldor304iu81gnqa05p401j3exc 97149 97148 2015-02-19T20:51:18Z Peteforsyth 12372 3 revisions imported from [[:w:Module:Category_handler/blacklist]]: Attempting, per request from [[User:Titodutta]]. I'm not sure if "w" is the right source wiki (only a few options in drop-down menu) 97149 wikitext text/x-wiki -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', '/[aA]rchive' -- Don't categorise archives. } ne8sdldor304iu81gnqa05p401j3exc 97150 97149 2015-07-29T23:31:30Z Legoktm 2683 Fixing content model 97150 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', '/[aA]rchive' -- Don't categorise archives. } ne8sdldor304iu81gnqa05p401j3exc 97151 97150 2016-06-03T16:48:40Z MarcoAurelio 2560 Those pages don't exist at Meta and can be removed from this import 97151 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. } ld8om2eltd1tjkv3khg5fe0tb01veh2 97152 97151 2016-12-30T10:58:25Z Mr. Stradivarius 12371 add archives of ANI to the blacklist 97152 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive%d+$", } fbxup60e2b8gllo7lw3iqx5x3hao7zk 97153 97152 2016-12-30T13:43:45Z Mr. Stradivarius 12371 don't categorise sandboxes, and convert this to use tabs 97153 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive%d+$", '/[sS]andbox$', -- Don't categorise sandboxes } fmuyv4f9zw6v3swb7rojsus6uobmp8u 97154 97153 2016-12-30T14:53:53Z Mr. Stradivarius 12371 on second thoughts, blacklisting sandboxes for all templates is probably a bad idea 97154 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive%d+$", } hwue3i1eua4tsdxlsbcs4f5syudywbe 97155 97154 2017-07-17T00:04:38Z Pharos 12374 3 revisions imported from [[:w:Module:Category_handler/blacklist]] 97154 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive%d+$", } hwue3i1eua4tsdxlsbcs4f5syudywbe 97156 97155 2018-08-05T06:59:00Z 187.254.0.222 Blanked the page 97156 Scribunto text/plain phoiac9h4m842xq45sp7s6u21eteeq1 97157 97156 2018-08-05T07:35:13Z Romaine 2443 Undo revision 18273258 by [[Special:Contributions/187.254.0.222|187.254.0.222]] ([[User talk:187.254.0.222|talk]]) 97157 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive%d+$", } hwue3i1eua4tsdxlsbcs4f5syudywbe 97158 97157 2019-02-14T01:34:21Z MusikAnimal 12376 Protected "[[Module:Category handler/blacklist]]": High-risk Lua module ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)) 97157 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template messages/.*$', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive%d+$", } hwue3i1eua4tsdxlsbcs4f5syudywbe 97159 97158 2022-01-16T06:16:24Z TheresNoTime 12448 3 revisions imported from [[:w:Module:Category_handler/blacklist]] 97159 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template index/.*$', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive%d+$", } fsv1drcay6t25e91hzhqxtyp7pckbpx 97160 97159 2022-01-16T18:01:31Z MusikBot II 12440 Changed protection settings for "[[Module:Category handler/blacklist]]": High-risk template or module ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97159 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template index/.*$', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive%d+$", } fsv1drcay6t25e91hzhqxtyp7pckbpx 97161 97160 2025-04-17T05:49:57Z Veritas Sapientiae 11379 2 revisions imported from [[:commons:Module:Category_handler/blacklist]] 97159 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template index/.*$', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive%d+$", } fsv1drcay6t25e91hzhqxtyp7pckbpx 97162 97161 2025-04-27T18:49:24Z Pppery 12444 Protected "[[Module:Category handler/blacklist]]" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97159 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template index/.*$', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive%d+$", } fsv1drcay6t25e91hzhqxtyp7pckbpx 97163 97162 2026-06-07T08:43:27Z Tommy Kronkvist 2826 17 versioner importerades från [[:meta:Module:Category_handler/blacklist]] 97159 Scribunto text/plain -- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested. return { '^Main Page$', -- don't categorise the main page. -- Don't categorise the following pages or their subpages. -- "%f[/\0]" matches if the next character is "/" or the end of the string. '^Wikipedia:Cascade%-protected items%f[/\0]', '^User:UBX%f[/\0]', -- The userbox "template" space. '^User talk:UBX%f[/\0]', -- Don't categorise subpages of these pages, but allow -- categorisation of the base page. '^Wikipedia:Template index/.*$', -- Don't categorise archives. '/[aA]rchive', "^Wikipedia:Administrators' noticeboard/IncidentArchive%d+$", } fsv1drcay6t25e91hzhqxtyp7pckbpx Modul:Namespace detect/data 828 11890 97164 2014-03-20T15:47:15Z Jackmcbarn 4700 [[WP:AES|←]]Created page with '---------------------------------------------------------------------------------------------------- -- Configuration da...' 97164 Scribunto text/plain ---------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names can be set here. -- ---------------------------------------------------------------------------------------------------- local cfg = {} -- This parameter displays content for the main namespace: cfg.main = 'main' -- This parameter displays in talk namespaces: cfg.talk = 'talk' -- This parameter displays content for "other" namespaces (namespaces for which -- parameters have not been specified, or for when cfg.demospace is set to cfg.other): cfg.other = 'other' -- This parameter makes talk pages behave as though they are the corresponding subject namespace. -- Note that this parameter is used with [[Module:Yesno]]. Edit that module to change -- the default values of "yes", "no", etc. cfg.subjectns = 'subjectns' -- This parameter sets a demonstration namespace: cfg.demospace = 'demospace' -- This parameter sets a specific page to compare: cfg.page = 'page' -- The header for the namespace column in the wikitable containing the list of possible subject-space parameters. cfg.wikitableNamespaceHeader = 'Namespace' -- The header for the wikitable containing the list of possible subject-space parameters. cfg.wikitableAliasesHeader = 'Aliases' ---------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------- local function getParamMappings() --[[ Returns a table of how parameter names map to namespace names. The keys are the actual namespace names, in lower case, and the values are the possible parameter names for that namespace, also in lower case. The table entries are structured like this: { [''] = {'main'}, ['wikipedia'] = {'wikipedia', 'project', 'wp'}, ... } ]] local mappings = {} mappings[mw.ustring.lower(mw.site.namespaces[0].name)] = {cfg.main} mappings[cfg.talk] = {cfg.talk} for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { cfg = cfg, paramMappings = getParamMappings() } o8bc17gdfnglc379mgqz6ikurqtcvvx 97165 97164 2014-03-20T15:49:12Z Jackmcbarn 4700 no sense wrapping this 97165 Scribunto text/plain ---------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names can be set here. -- ---------------------------------------------------------------------------------------------------- local cfg = {} -- This parameter displays content for the main namespace: cfg.main = 'main' -- This parameter displays in talk namespaces: cfg.talk = 'talk' -- This parameter displays content for "other" namespaces (namespaces for which -- parameters have not been specified, or for when cfg.demospace is set to cfg.other): cfg.other = 'other' -- This parameter makes talk pages behave as though they are the corresponding subject namespace. -- Note that this parameter is used with [[Module:Yesno]]. Edit that module to change -- the default values of "yes", "no", etc. cfg.subjectns = 'subjectns' -- This parameter sets a demonstration namespace: cfg.demospace = 'demospace' -- This parameter sets a specific page to compare: cfg.page = 'page' -- The header for the namespace column in the wikitable containing the list of possible subject-space parameters. cfg.wikitableNamespaceHeader = 'Namespace' -- The header for the wikitable containing the list of possible subject-space parameters. cfg.wikitableAliasesHeader = 'Aliases' ---------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------- local function getParamMappings() --[[ Returns a table of how parameter names map to namespace names. The keys are the actual namespace names, in lower case, and the values are the possible parameter names for that namespace, also in lower case. The table entries are structured like this: { [''] = {'main'}, ['wikipedia'] = {'wikipedia', 'project', 'wp'}, ... } ]] local mappings = {} mappings[mw.ustring.lower(mw.site.namespaces[0].name)] = {cfg.main} mappings[cfg.talk] = {cfg.talk} for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return cfg, getParamMappings() r6lt1tan1m0l4jsmia0pds7gl8jufn2 97166 97165 2014-03-20T15:52:05Z Jackmcbarn 4700 okay, it needs wrapping after all 97166 Scribunto text/plain ---------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names can be set here. -- ---------------------------------------------------------------------------------------------------- local cfg = {} -- This parameter displays content for the main namespace: cfg.main = 'main' -- This parameter displays in talk namespaces: cfg.talk = 'talk' -- This parameter displays content for "other" namespaces (namespaces for which -- parameters have not been specified, or for when cfg.demospace is set to cfg.other): cfg.other = 'other' -- This parameter makes talk pages behave as though they are the corresponding subject namespace. -- Note that this parameter is used with [[Module:Yesno]]. Edit that module to change -- the default values of "yes", "no", etc. cfg.subjectns = 'subjectns' -- This parameter sets a demonstration namespace: cfg.demospace = 'demospace' -- This parameter sets a specific page to compare: cfg.page = 'page' -- The header for the namespace column in the wikitable containing the list of possible subject-space parameters. cfg.wikitableNamespaceHeader = 'Namespace' -- The header for the wikitable containing the list of possible subject-space parameters. cfg.wikitableAliasesHeader = 'Aliases' ---------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------- local function getParamMappings() --[[ Returns a table of how parameter names map to namespace names. The keys are the actual namespace names, in lower case, and the values are the possible parameter names for that namespace, also in lower case. The table entries are structured like this: { [''] = {'main'}, ['wikipedia'] = {'wikipedia', 'project', 'wp'}, ... } ]] local mappings = {} mappings[mw.ustring.lower(mw.site.namespaces[0].name)] = {cfg.main} mappings[cfg.talk] = {cfg.talk} for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { cfg, getParamMappings() } lxl58hg13tpxjkjwmunfg0tjvyd2f39 97167 97166 2014-03-20T16:02:00Z Jackmcbarn 4700 name return values 97167 Scribunto text/plain ---------------------------------------------------------------------------------------------------- -- Configuration data -- -- Language-specific parameter names can be set here. -- ---------------------------------------------------------------------------------------------------- local cfg = {} -- This parameter displays content for the main namespace: cfg.main = 'main' -- This parameter displays in talk namespaces: cfg.talk = 'talk' -- This parameter displays content for "other" namespaces (namespaces for which -- parameters have not been specified, or for when cfg.demospace is set to cfg.other): cfg.other = 'other' -- This parameter makes talk pages behave as though they are the corresponding subject namespace. -- Note that this parameter is used with [[Module:Yesno]]. Edit that module to change -- the default values of "yes", "no", etc. cfg.subjectns = 'subjectns' -- This parameter sets a demonstration namespace: cfg.demospace = 'demospace' -- This parameter sets a specific page to compare: cfg.page = 'page' -- The header for the namespace column in the wikitable containing the list of possible subject-space parameters. cfg.wikitableNamespaceHeader = 'Namespace' -- The header for the wikitable containing the list of possible subject-space parameters. cfg.wikitableAliasesHeader = 'Aliases' ---------------------------------------------------------------------------------------------------- -- End configuration data -- ---------------------------------------------------------------------------------------------------- local function getParamMappings() --[[ Returns a table of how parameter names map to namespace names. The keys are the actual namespace names, in lower case, and the values are the possible parameter names for that namespace, also in lower case. The table entries are structured like this: { [''] = {'main'}, ['wikipedia'] = {'wikipedia', 'project', 'wp'}, ... } ]] local mappings = {} mappings[mw.ustring.lower(mw.site.namespaces[0].name)] = {cfg.main} mappings[cfg.talk] = {cfg.talk} for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { cfg = cfg, mappings = getParamMappings() } azabagwtr2m3p860msmtewaddrvzmtc 97168 97167 2014-03-21T03:13:45Z Mr. Stradivarius 12371 use a dedicated config page - [[Module:Namespace detect/config]] - for configuration data, and try and reduce unnecessary table lookups in the getParamMappings function 97168 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local ustringLower = mw.ustring.lower local tinsert = table.insert local subjectNamespaces = mw.site.subjectNamespaces local talk = cfg.talk local mappings = {} mappings[ustringLower(subjectNamespaces[0].name)] = {cfg.main} mappings[talk] = {talk} for nsid, ns in pairs(subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = ustringLower(ns.name) local canonicalName = ustringLower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then tinsert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do tinsert(mappings[nsname], ustringLower(alias)) end end end return mappings end return {cfg = cfg, mappings = getParamMappings()} 5dbto78xwi1xr0y9580x1goom6vd4y8 97169 97168 2014-03-21T19:04:15Z Jackmcbarn 4700 IMO, aliasing variables like that makes readability worse 97169 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} mappings[mw.ustring.lower(mw.site.subjectNamespaces[0].name)] = {cfg.main} mappings[cfg.talk] = {cfg.talk} for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return {cfg = cfg, mappings = getParamMappings()} cs4dpxtencc5pvf164b69jx91nbxzo1 97170 97169 2014-03-21T19:06:53Z Jackmcbarn 4700 Undid revision 600634263 by [[Special:Contributions/Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]): Oh, this seems to have been for performance. Still not sure if it's a good idea, but will leave for now 97170 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local ustringLower = mw.ustring.lower local tinsert = table.insert local subjectNamespaces = mw.site.subjectNamespaces local talk = cfg.talk local mappings = {} mappings[ustringLower(subjectNamespaces[0].name)] = {cfg.main} mappings[talk] = {talk} for nsid, ns in pairs(subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = ustringLower(ns.name) local canonicalName = ustringLower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then tinsert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do tinsert(mappings[nsname], ustringLower(alias)) end end end return mappings end return {cfg = cfg, mappings = getParamMappings()} 5dbto78xwi1xr0y9580x1goom6vd4y8 97171 97170 2014-03-22T06:41:09Z Mr. Stradivarius 12371 add a getArgKeys function, so that we can have multiple keys for each argument (helpful for localisation) and so that we only have to create that table once per page 97171 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end local function getArgKeys() -- Returns a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local argKeys = { main = {'main'}, talk = {'talk'}, other = {'other'}, subjectns = {'subjectns'}, demospace = {'demospace'}, page = {'page'} } for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end return argKeys end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local ustringLower = mw.ustring.lower local tinsert = table.insert local subjectNamespaces = mw.site.subjectNamespaces local talk = cfg.talk local mappings = {} mappings[ustringLower(subjectNamespaces[0].name)] = {cfg.main} mappings[talk] = {talk} for nsid, ns in pairs(subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = ustringLower(ns.name) local canonicalName = ustringLower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then tinsert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do tinsert(mappings[nsname], ustringLower(alias)) end end end return mappings end return { argKeys = getArgKeys(), cfg = cfg, mappings = getParamMappings() } 12tzg8kv7dfyr3ciucqvye4688kvws9 97172 97171 2014-03-22T07:03:48Z Mr. Stradivarius 12371 give the argKeys table global scope so that getParamMappings can access it without having to process the cfg table again 97172 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local argKeys = { main = {'main'}, talk = {'talk'}, other = {'other'}, subjectns = {'subjectns'}, demospace = {'demospace'}, page = {'page'} } for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local ustringLower = mw.ustring.lower local tinsert = table.insert local clone = mw.clone local subjectNamespaces = mw.site.subjectNamespaces local mappings = {} mappings[ustringLower(subjectNamespaces[0].name)] = clone(argKeys.main) mappings['talk'] = clone(argKeys.talk) for nsid, ns in pairs(subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = ustringLower(ns.name) local canonicalName = ustringLower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then tinsert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do tinsert(mappings[nsname], ustringLower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } nbmp2ck00vgafnluya60zbnqzblt24o 97173 97172 2014-03-24T11:36:17Z Mr. Stradivarius 12371 avoid using local variables to save table lookups per Jackmcbarn's suggestion, and because this will be cached with mw.loadData so performance of this function is not such a worry 97173 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local argKeys = { main = {'main'}, talk = {'talk'}, other = {'other'}, subjectns = {'subjectns'}, demospace = {'demospace'}, page = {'page'} } for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = ns.name local canonicalName = ns.canonicalName mappings[nsname] = {mw.ustring.lower(nsname)} if canonicalName ~= nsname then table.insert(mappings[nsname], mw.ustring.lower(canonicalName)) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } l7i4r52gjaoabnwgehgxat1xsys7h7g 97174 97173 2014-03-24T11:37:34Z Mr. Stradivarius 12371 Undid revision 601018314 by [[Special:Contributions/Mr. Stradivarius|Mr. Stradivarius]] ([[User talk:Mr. Stradivarius|talk]]) looks like that broke something 97174 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local argKeys = { main = {'main'}, talk = {'talk'}, other = {'other'}, subjectns = {'subjectns'}, demospace = {'demospace'}, page = {'page'} } for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local ustringLower = mw.ustring.lower local tinsert = table.insert local clone = mw.clone local subjectNamespaces = mw.site.subjectNamespaces local mappings = {} mappings[ustringLower(subjectNamespaces[0].name)] = clone(argKeys.main) mappings['talk'] = clone(argKeys.talk) for nsid, ns in pairs(subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = ustringLower(ns.name) local canonicalName = ustringLower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then tinsert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do tinsert(mappings[nsname], ustringLower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } nbmp2ck00vgafnluya60zbnqzblt24o 97175 97174 2014-03-24T11:43:58Z Mr. Stradivarius 12371 found it - mappings[nsname] was getting an upper-case key 97175 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local argKeys = { main = {'main'}, talk = {'talk'}, other = {'other'}, subjectns = {'subjectns'}, demospace = {'demospace'}, page = {'page'} } for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } a02of90c1m5f3f51hk8pohh6uzbla3j 97176 97175 2014-03-24T11:45:45Z Mr. Stradivarius 12371 Protected Module:Namespace detect/data: [[Wikipedia:Lua/Modules|High-risk Lua module]] ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97175 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local argKeys = { main = {'main'}, talk = {'talk'}, other = {'other'}, subjectns = {'subjectns'}, demospace = {'demospace'}, page = {'page'} } for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } a02of90c1m5f3f51hk8pohh6uzbla3j 97177 97176 2014-04-05T05:40:57Z Mr. Stradivarius 12371 use "demopage" instead of "page" as the default page parameter - needed to fix bug on en.wikisource where "Page" is a namespace name 97177 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local argKeys = { main = {'main'}, talk = {'talk'}, other = {'other'}, subjectns = {'subjectns'}, demospace = {'demospace'}, page = {'demopage'} } for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } 7w4pqtjg96k84oemg3mfns6674rnaxo 97178 97177 2014-04-05T17:02:16Z Mr. Stradivarius 12371 bug fix - use the demospace parameter as both key and value in the argKeys table 97178 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local defaultKeys = { 'main', 'talk', 'other', 'subjectns', 'demospace', 'demopage' } local argKeys = {} for i, defaultKey in ipairs(defaultKeys) do argKeys[defaultKey] = {defaultKey} end for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } ojp6d3pc8mql5nufaqdg576c9so3479 97179 97178 2015-02-19T20:51:41Z Peteforsyth 12372 15 revisions imported from [[:w:Module:Namespace_detect/data]]: Attempting, per request from [[User:Titodutta]]. I'm not sure if "w" is the right source wiki (only a few options in drop-down menu) 97179 wikitext text/x-wiki -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local defaultKeys = { 'main', 'talk', 'other', 'subjectns', 'demospace', 'demopage' } local argKeys = {} for i, defaultKey in ipairs(defaultKeys) do argKeys[defaultKey] = {defaultKey} end for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } ojp6d3pc8mql5nufaqdg576c9so3479 97180 97179 2015-07-29T23:31:34Z Legoktm 2683 Fixing content model 97180 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local defaultKeys = { 'main', 'talk', 'other', 'subjectns', 'demospace', 'demopage' } local argKeys = {} for i, defaultKey in ipairs(defaultKeys) do argKeys[defaultKey] = {defaultKey} end for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } ojp6d3pc8mql5nufaqdg576c9so3479 97181 97180 2019-02-14T01:37:00Z MusikAnimal 12376 Protected "[[Module:Namespace detect/data]]": High-risk Lua module ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)) 97180 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local defaultKeys = { 'main', 'talk', 'other', 'subjectns', 'demospace', 'demopage' } local argKeys = {} for i, defaultKey in ipairs(defaultKeys) do argKeys[defaultKey] = {defaultKey} end for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } ojp6d3pc8mql5nufaqdg576c9so3479 97182 97181 2022-01-16T06:16:26Z TheresNoTime 12448 1 revision imported from [[:w:Module:Namespace_detect/data]] 97180 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local defaultKeys = { 'main', 'talk', 'other', 'subjectns', 'demospace', 'demopage' } local argKeys = {} for i, defaultKey in ipairs(defaultKeys) do argKeys[defaultKey] = {defaultKey} end for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } ojp6d3pc8mql5nufaqdg576c9so3479 97183 97182 2022-01-16T18:01:32Z MusikBot II 12440 Changed protection settings for "[[Module:Namespace detect/data]]": High-risk template or module ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97180 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local defaultKeys = { 'main', 'talk', 'other', 'subjectns', 'demospace', 'demopage' } local argKeys = {} for i, defaultKey in ipairs(defaultKeys) do argKeys[defaultKey] = {defaultKey} end for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } ojp6d3pc8mql5nufaqdg576c9so3479 97184 97183 2025-04-17T05:49:57Z Veritas Sapientiae 11379 2 revisions imported from [[:commons:Module:Namespace_detect/data]] 97180 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local defaultKeys = { 'main', 'talk', 'other', 'subjectns', 'demospace', 'demopage' } local argKeys = {} for i, defaultKey in ipairs(defaultKeys) do argKeys[defaultKey] = {defaultKey} end for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } ojp6d3pc8mql5nufaqdg576c9so3479 97185 97184 2025-04-27T18:46:46Z Pppery 12444 Protected "[[Module:Namespace detect/data]]" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97180 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local defaultKeys = { 'main', 'talk', 'other', 'subjectns', 'demospace', 'demopage' } local argKeys = {} for i, defaultKey in ipairs(defaultKeys) do argKeys[defaultKey] = {defaultKey} end for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } ojp6d3pc8mql5nufaqdg576c9so3479 97186 97185 2025-04-27T18:47:39Z Pppery 12444 Protected "[[Module:Namespace detect/data]]" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97180 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local defaultKeys = { 'main', 'talk', 'other', 'subjectns', 'demospace', 'demopage' } local argKeys = {} for i, defaultKey in ipairs(defaultKeys) do argKeys[defaultKey] = {defaultKey} end for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } ojp6d3pc8mql5nufaqdg576c9so3479 97187 97186 2026-06-07T08:43:28Z Tommy Kronkvist 2826 23 versioner importerades från [[:meta:Module:Namespace_detect/data]] 97180 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect data -- -- This module holds data for [[Module:Namespace detect]] to be loaded per -- -- page, rather than per #invoke, for performance reasons. -- -------------------------------------------------------------------------------- local cfg = require('Module:Namespace detect/config') local function addKey(t, key, defaultKey) if key ~= defaultKey then t[#t + 1] = key end end -- Get a table of parameters to query for each default parameter name. -- This allows wikis to customise parameter names in the cfg table while -- ensuring that default parameter names will always work. The cfg table -- values can be added as a string, or as an array of strings. local defaultKeys = { 'main', 'talk', 'other', 'subjectns', 'demospace', 'demopage' } local argKeys = {} for i, defaultKey in ipairs(defaultKeys) do argKeys[defaultKey] = {defaultKey} end for defaultKey, t in pairs(argKeys) do local cfgValue = cfg[defaultKey] local cfgValueType = type(cfgValue) if cfgValueType == 'string' then addKey(t, cfgValue, defaultKey) elseif cfgValueType == 'table' then for i, key in ipairs(cfgValue) do addKey(t, key, defaultKey) end end cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more. end local function getParamMappings() --[[ -- Returns a table of how parameter names map to namespace names. The keys -- are the actual namespace names, in lower case, and the values are the -- possible parameter names for that namespace, also in lower case. The -- table entries are structured like this: -- { -- [''] = {'main'}, -- ['wikipedia'] = {'wikipedia', 'project', 'wp'}, -- ... -- } --]] local mappings = {} local mainNsName = mw.site.subjectNamespaces[0].name mainNsName = mw.ustring.lower(mainNsName) mappings[mainNsName] = mw.clone(argKeys.main) mappings['talk'] = mw.clone(argKeys.talk) for nsid, ns in pairs(mw.site.subjectNamespaces) do if nsid ~= 0 then -- Exclude main namespace. local nsname = mw.ustring.lower(ns.name) local canonicalName = mw.ustring.lower(ns.canonicalName) mappings[nsname] = {nsname} if canonicalName ~= nsname then table.insert(mappings[nsname], canonicalName) end for _, alias in ipairs(ns.aliases) do table.insert(mappings[nsname], mw.ustring.lower(alias)) end end end return mappings end return { argKeys = argKeys, cfg = cfg, mappings = getParamMappings() } ojp6d3pc8mql5nufaqdg576c9so3479 Modul:Namespace detect/config 828 11891 97188 2014-03-20T13:56:40Z Mr. Stradivarius 12371 create separate configuration page for [[Module:Namespace detect]] 97188 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -------------------------------------------------------------------------------- local cfg = {} -- This parameter displays content for the main namespace: cfg.main = 'main' -- This parameter displays in talk namespaces: cfg.talk = 'talk' -- This parameter displays content for "other" namespaces (namespaces for which -- parameters have not been specified, or for when cfg.demospace is set to -- cfg.other): cfg.other = 'other' -- This parameter makes talk pages behave as though they are the corresponding -- subject namespace. Note that this parameter is used with [[Module:Yesno]]. -- Edit that module to change the default values of "yes", "no", etc. cfg.subjectns = 'subjectns' -- This parameter sets a demonstration namespace: cfg.demospace = 'demospace' -- This parameter sets a specific page to compare: cfg.page = 'page' -- The header for the namespace column in the wikitable containing the list of -- possible subject-space parameters. cfg.wikitableNamespaceHeader = 'Namespace' -- The header for the wikitable containing the list of possible subject-space -- parameters. cfg.wikitableAliasesHeader = 'Aliases' return cfg a4y5e4sg2z65xp4c08bnybdzadxk1fd 97189 97188 2014-03-22T13:11:09Z Mr. Stradivarius 12371 make comments more informative, and document the possibility to add parameter as an array 97189 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: -- cfg.page = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. nhqlkljddnzokp06ieg44mu1npyme0d 97190 97189 2014-03-22T13:14:03Z Mr. Stradivarius 12371 test new config system 97190 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: cfg.main = {'foo', 'bar'} ---- This parameter displays in talk namespaces: cfg.talk = 'baz' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: -- cfg.page = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. dwgd32yjk206a9xx1sp5tdt79v9qd61 97191 97190 2014-03-22T13:15:55Z Mr. Stradivarius 12371 Undid revision 600728866 by [[Special:Contributions/Mr. Stradivarius|Mr. Stradivarius]] ([[User talk:Mr. Stradivarius|talk]]) seems to be working 97191 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: -- cfg.page = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. nhqlkljddnzokp06ieg44mu1npyme0d 97192 97191 2014-03-24T11:48:17Z Mr. Stradivarius 12371 Protected Module:Namespace detect/config: [[Wikipedia:Lua/Modules|High-risk Lua module]] ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97191 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: -- cfg.page = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. nhqlkljddnzokp06ieg44mu1npyme0d 97193 97192 2014-04-05T05:39:37Z Mr. Stradivarius 12371 make "page" an optional parameter - needed to fix bug on en.wikisource where "Page" is a namespace name 97193 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: cfg.page = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 6ox7pz4yxkgbbu12wrwgundizc9zzgl 97194 97193 2014-04-05T17:03:49Z Mr. Stradivarius 12371 use cfg.demopage rather than cfg.page now that the default parameter has been changed on the /data page 97194 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 1o6ozz56i8q0xgyl6xa41n2v7kelhli 97195 97194 2015-02-19T20:51:40Z Peteforsyth 12372 7 revisions imported from [[:w:Module:Namespace_detect/config]]: Attempting, per request from [[User:Titodutta]]. I'm not sure if "w" is the right source wiki (only a few options in drop-down menu) 97195 wikitext text/x-wiki -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 1o6ozz56i8q0xgyl6xa41n2v7kelhli 97196 97195 2015-07-29T23:31:33Z Legoktm 2683 Fixing content model 97196 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 1o6ozz56i8q0xgyl6xa41n2v7kelhli 97197 97196 2019-02-14T01:35:50Z MusikAnimal 12376 Protected "[[Module:Namespace detect/config]]": High-risk Lua module ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)) 97196 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 1o6ozz56i8q0xgyl6xa41n2v7kelhli 97198 97197 2022-01-16T06:16:26Z TheresNoTime 12448 1 revision imported from [[:w:Module:Namespace_detect/config]] 97196 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 1o6ozz56i8q0xgyl6xa41n2v7kelhli 97199 97198 2022-01-16T18:01:32Z MusikBot II 12440 Changed protection settings for "[[Module:Namespace detect/config]]": High-risk template or module ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97196 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 1o6ozz56i8q0xgyl6xa41n2v7kelhli 97200 97199 2025-04-17T05:49:57Z Veritas Sapientiae 11379 2 revisions imported from [[:commons:Module:Namespace_detect/config]] 97196 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 1o6ozz56i8q0xgyl6xa41n2v7kelhli 97201 97200 2025-04-27T18:48:03Z Pppery 12444 Protected "[[Module:Namespace detect/config]]" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97196 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 1o6ozz56i8q0xgyl6xa41n2v7kelhli 97202 97201 2026-06-07T08:43:29Z Tommy Kronkvist 2826 14 versioner importerades från [[:meta:Module:Namespace_detect/config]] 97196 Scribunto text/plain -------------------------------------------------------------------------------- -- Namespace detect configuration data -- -- -- -- This module stores configuration data for Module:Namespace detect. Here -- -- you can localise the module to your wiki's language. -- -- -- -- To activate a configuration item, you need to uncomment it. This means -- -- that you need to remove the text "-- " at the start of the line. -- -------------------------------------------------------------------------------- local cfg = {} -- Don't edit this line. -------------------------------------------------------------------------------- -- Parameter names -- -- These configuration items specify custom parameter names. Values added -- -- here will work in addition to the default English parameter names. -- -- To add one extra name, you can use this format: -- -- -- -- cfg.foo = 'parameter name' -- -- -- -- To add multiple names, you can use this format: -- -- -- -- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'} -- -------------------------------------------------------------------------------- ---- This parameter displays content for the main namespace: -- cfg.main = 'main' ---- This parameter displays in talk namespaces: -- cfg.talk = 'talk' ---- This parameter displays content for "other" namespaces (namespaces for which ---- parameters have not been specified): -- cfg.other = 'other' ---- This parameter makes talk pages behave as though they are the corresponding ---- subject namespace. Note that this parameter is used with [[Module:Yesno]]. ---- Edit that module to change the default values of "yes", "no", etc. -- cfg.subjectns = 'subjectns' ---- This parameter sets a demonstration namespace: -- cfg.demospace = 'demospace' ---- This parameter sets a specific page to compare: cfg.demopage = 'page' -------------------------------------------------------------------------------- -- Table configuration -- -- These configuration items allow customisation of the "table" function, -- -- used to generate a table of possible parameters in the module -- -- documentation. -- -------------------------------------------------------------------------------- ---- The header for the namespace column in the wikitable containing the list of ---- possible subject-space parameters. -- cfg.wikitableNamespaceHeader = 'Namespace' ---- The header for the wikitable containing the list of possible subject-space ---- parameters. -- cfg.wikitableAliasesHeader = 'Aliases' -------------------------------------------------------------------------------- -- End of configuration data -- -------------------------------------------------------------------------------- return cfg -- Don't edit this line. 1o6ozz56i8q0xgyl6xa41n2v7kelhli Mall:Fix 10 11892 97203 2011-06-10T20:08:46Z Staeiou 13031 migrating from en.wiki 97203 wikitext text/x-wiki {{#ifeq:{{{substcheck|¬}}}|SUBST |[[Category:Pages with incorrectly substituted templates]] }}{{cat handler |main={{{cat|[[Category:All pages needing cleanup]]}}}{{#if:{{{cat-date|}}} |[[{{{cat-date}}} {{#if:{{{date|}}} |from {{{date}}} }}]]{{#if:{{{date|}}} |{{#ifexist:{{{cat-date}}} from {{{date}}}| |[[Category:Articles with invalid date parameter in template]] }} }} }} |subpage=no }}{{#if:{{{text|}}} |<sup class="{{{class|noprint Inline-Template}}}" title="{{{title|}}}{{#if:{{{date|}}} |<nowiki/> from {{{date}}} }}" style="white-space:nowrap;">&#91;<i>{{#if:{{{pre-text|}}} |{{{pre-text}}}&#32; }}[[{{{link|Wikipedia:Cleanup}}}|{{{text|}}}]]{{#if:{{{post-text|}}} |&#32;{{{post-text}}} }}</i>&#93;</sup>|{{{special|}}} }}<noinclude> {{Documentation}} <!-- Add cats and interwikis to the /doc subpage, not here! --> </noinclude> fr63drait3ia1svaspoj4szbu2efr5q 97204 97203 2011-06-11T08:33:13Z Axpde 3184 +delete 97204 wikitext text/x-wiki {{delete|Copyright violation, copy'n'paste of [[:en:{{FULLPAGENAME}}]] [[User:Axpde|<font color="#0000ff">'''a'''<small>x</small>'''p'''<small><sub>de</sub></small></font>]][[User Talk:Axpde|<font color="#ff0000"><small><sup>Hello!</sup></small></font>]] 08:33, 11 June 2011 (UTC)}} {{#ifeq:{{{substcheck|¬}}}|SUBST |[[Category:Pages with incorrectly substituted templates]] }}{{cat handler |main={{{cat|[[Category:All pages needing cleanup]]}}}{{#if:{{{cat-date|}}} |[[{{{cat-date}}} {{#if:{{{date|}}} |from {{{date}}} }}]]{{#if:{{{date|}}} |{{#ifexist:{{{cat-date}}} from {{{date}}}| |[[Category:Articles with invalid date parameter in template]] }} }} }} |subpage=no }}{{#if:{{{text|}}} |<sup class="{{{class|noprint Inline-Template}}}" title="{{{title|}}}{{#if:{{{date|}}} |<nowiki/> from {{{date}}} }}" style="white-space:nowrap;">&#91;<i>{{#if:{{{pre-text|}}} |{{{pre-text}}}&#32; }}[[{{{link|Wikipedia:Cleanup}}}|{{{text|}}}]]{{#if:{{{post-text|}}} |&#32;{{{post-text}}} }}</i>&#93;</sup>|{{{special|}}} }}<noinclude> {{Documentation}} <!-- Add cats and interwikis to the /doc subpage, not here! --> </noinclude> pge92iwwc6vk7oa8jmfkl1di6l0zbh1 97205 97204 2011-06-11T08:35:15Z WizardOfOz 13032 Undo revision 2653627 by [[Special:Contributions/Axpde|Axpde]] ([[User talk:Axpde|talk]]) is this template protected per copyright on en wiki?!? 97205 wikitext text/x-wiki {{#ifeq:{{{substcheck|¬}}}|SUBST |[[Category:Pages with incorrectly substituted templates]] }}{{cat handler |main={{{cat|[[Category:All pages needing cleanup]]}}}{{#if:{{{cat-date|}}} |[[{{{cat-date}}} {{#if:{{{date|}}} |from {{{date}}} }}]]{{#if:{{{date|}}} |{{#ifexist:{{{cat-date}}} from {{{date}}}| |[[Category:Articles with invalid date parameter in template]] }} }} }} |subpage=no }}{{#if:{{{text|}}} |<sup class="{{{class|noprint Inline-Template}}}" title="{{{title|}}}{{#if:{{{date|}}} |<nowiki/> from {{{date}}} }}" style="white-space:nowrap;">&#91;<i>{{#if:{{{pre-text|}}} |{{{pre-text}}}&#32; }}[[{{{link|Wikipedia:Cleanup}}}|{{{text|}}}]]{{#if:{{{post-text|}}} |&#32;{{{post-text}}} }}</i>&#93;</sup>|{{{special|}}} }}<noinclude> {{Documentation}} <!-- Add cats and interwikis to the /doc subpage, not here! --> </noinclude> fr63drait3ia1svaspoj4szbu2efr5q 97206 97205 2021-06-08T19:47:30Z 1234qwer1234qwer4 8029 no actual documentation, moving cat here 97206 wikitext text/x-wiki {{#ifeq:{{{substcheck|¬}}}|SUBST |[[Category:Pages with incorrectly substituted templates]] }}{{cat handler |main={{{cat|[[Category:All pages needing cleanup]]}}}{{#if:{{{cat-date|}}} |[[{{{cat-date}}} {{#if:{{{date|}}} |from {{{date}}} }}]]{{#if:{{{date|}}} |{{#ifexist:{{{cat-date}}} from {{{date}}}| |[[Category:Articles with invalid date parameter in template]] }} }} }} |subpage=no }}{{#if:{{{text|}}} |<sup class="{{{class|noprint Inline-Template}}}" title="{{{title|}}}{{#if:{{{date|}}} |<nowiki/> from {{{date}}} }}" style="white-space:nowrap;">&#91;<i>{{#if:{{{pre-text|}}} |{{{pre-text}}}&#32; }}[[{{{link|Wikipedia:Cleanup}}}|{{{text|}}}]]{{#if:{{{post-text|}}} |&#32;{{{post-text}}} }}</i>&#93;</sup>|{{{special|}}} }}<noinclude> [[Category:Templates]] </noinclude> 9l47vyzsho6m32gobj0108xrnqfi7ch 97207 97206 2022-06-18T06:35:47Z NguoiDungKhongDinhDanh 10345 ~ 97207 wikitext text/x-wiki {{#ifeq:{{{substcheck|¬}}}|SUBST |[[Category:Pages with incorrectly substituted templates]] }}{{cat handler |main={{{cat|[[Category:All pages needing cleanup]]}}}{{#if:{{{cat-date|}}} |[[{{{cat-date}}} {{#if:{{{date|}}} |from {{{date}}} }}]]{{#if:{{{date|}}} |{{#ifexist:{{{cat-date}}} from {{{date}}}| |[[Category:Pages with invalid date parameter in template]] }} }} }} |subpage=no }}{{#if:{{{text|}}} |<sup class="{{{class|noprint Inline-Template}}}" title="{{{title|}}}{{#if:{{{date|}}} |<nowiki/> from {{{date}}} }}" style="white-space:nowrap;">&#91;<i>{{#if:{{{pre-text|}}} |{{{pre-text}}}&#32; }}[[{{{link|Wikipedia:Cleanup}}}|{{{text|}}}]]{{#if:{{{post-text|}}} |&#32;{{{post-text}}} }}</i>&#93;</sup>|{{{special|}}} }}<noinclude> [[Category:Templates]] </noinclude> 1vntdflzs1jxdcr5ubj1x9dq1znt5e1 97208 97207 2026-06-07T08:43:32Z Tommy Kronkvist 2826 5 versioner importerades från [[:meta:Template:Fix]] 97207 wikitext text/x-wiki {{#ifeq:{{{substcheck|¬}}}|SUBST |[[Category:Pages with incorrectly substituted templates]] }}{{cat handler |main={{{cat|[[Category:All pages needing cleanup]]}}}{{#if:{{{cat-date|}}} |[[{{{cat-date}}} {{#if:{{{date|}}} |from {{{date}}} }}]]{{#if:{{{date|}}} |{{#ifexist:{{{cat-date}}} from {{{date}}}| |[[Category:Pages with invalid date parameter in template]] }} }} }} |subpage=no }}{{#if:{{{text|}}} |<sup class="{{{class|noprint Inline-Template}}}" title="{{{title|}}}{{#if:{{{date|}}} |<nowiki/> from {{{date}}} }}" style="white-space:nowrap;">&#91;<i>{{#if:{{{pre-text|}}} |{{{pre-text}}}&#32; }}[[{{{link|Wikipedia:Cleanup}}}|{{{text|}}}]]{{#if:{{{post-text|}}} |&#32;{{{post-text}}} }}</i>&#93;</sup>|{{{special|}}} }}<noinclude> [[Category:Templates]] </noinclude> 1vntdflzs1jxdcr5ubj1x9dq1znt5e1 Mall:Cat handler 10 11893 97209 2011-06-10T20:09:17Z Staeiou 13031 migrating from en.wiki 97209 wikitext text/x-wiki {{#if: {{#ifeq: {{lc: {{{nocat|}}} }} | true | dontcat <!--"nocat=true", don't categorize--> }}{{#ifeq: {{lc: {{{categories|}}} }} | no | dontcat }}{{#switch: {{lc: {{{category2|¬}}} }} | yes | ¬ = <!--Not defined--> | #default = dontcat <!--"category2 = no/'defined but empty'/'anything'"--> }}{{#switch: {{lc: {{{subpage|}}} }} | no = {{basepage subpage | | dontcat <!--"subpage=no" and on a subpage--> | page = {{{page|}}} <!--For testing--> }} | only = {{basepage subpage | dontcat <!--"subpage=only" and not on a subpage--> | page = {{{page|}}} <!--For testing--> }} }} | <!--Don't categorise (result was "dontcat" or "dontcatdontcat" and so on)--> | <!--Check blacklist--> {{#switch: {{#ifeq: {{lc: {{{nocat|}}} }} | false | <!--"nocat=false", skip blacklist check--> | {{#ifeq: {{lc: {{{categories|}}} }} | yes | <!--Skip blacklist check--> | {{#ifeq: {{lc: {{{category2|}}} }} | yes | <!--Skip blacklist check--> | {{cat handler/blacklist| page = {{{page|}}} }} <!--Check blacklist--> }} }} }} | hide = <!--Blacklist returned "hide", don't categorize--> | #default = <!--Check if any namespace parameter is defined--> {{#ifeq: h0#384!5nea+w9 | {{{all| {{{main| {{{talk| {{{user| {{{wikipedia| {{{file| {{{mediawiki| {{{template| {{{help| {{{category| {{{portal| {{{book| {{{other| h0#384!5nea+w9 }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} | <!--No namespace parameters fed, basic usage--> {{namespace detect | main = {{{1|}}} | file = {{{1|}}} | help = {{{1|}}} | category = {{{1|}}} | portal = {{{1|}}} | book = {{{1|}}} | page = {{{page|}}} <!--For testing and demonstration--> }} | <!--Namespace parameters fed, advanced usage. If "data" is a number, return the corresponding numbered parameter, else return "data". --> {{{all|}}}{{cat handler/numbered | 1 = {{{1|}}} | 2 = {{{2|}}} | 3 = {{{3|}}} | 4 = {{{4|}}} | 5 = {{{5|}}} | 6 = {{{6|}}} | 7 = {{{7|}}} | 8 = {{{8|}}} | 9 = {{{9|}}} | 10 = {{{10|}}} | data = <!--Check what namespace, and return the data for it. Respecting empty parameters on purpose. --> {{namespace detect | main = {{{main| {{{other|}}} }}} | talk = {{{talk| {{{other|}}} }}} | user = {{{user| {{{other|}}} }}} | wikipedia = {{{wikipedia| {{{project| {{{other|}}} }}} }}} | file = {{{file| {{{image| {{{other|}}} }}} }}} | mediawiki = {{{mediawiki| {{{other|}}} }}} | template = {{{template| {{{other|}}} }}} | help = {{{help| {{{other|}}} }}} | category = {{{category| {{{other|}}} }}} | portal = {{{portal| {{{other|}}} }}} | book = {{{book| {{{other|}}} }}} | other = {{{other|}}} <!--Namespace special or a new namespace--> | page = {{{page|}}} <!--For testing and demonstration--> }} }} }} }} }}<noinclude> {{documentation}} <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> 38nf35xxl466pjc3sy6vms5wfjddsgn 97210 97209 2011-06-11T08:33:57Z Axpde 3184 +delete 97210 wikitext text/x-wiki {{delete|Copyright violation, copy'n'paste of [[:en:{{FULLPAGENAME}}]] [[User:Axpde|<font color="#0000ff">'''a'''<small>x</small>'''p'''<small><sub>de</sub></small></font>]][[User Talk:Axpde|<font color="#ff0000"><small><sup>Hello!</sup></small></font>]] 08:33, 11 June 2011 (UTC)}} {{#if: {{#ifeq: {{lc: {{{nocat|}}} }} | true | dontcat <!--"nocat=true", don't categorize--> }}{{#ifeq: {{lc: {{{categories|}}} }} | no | dontcat }}{{#switch: {{lc: {{{category2|¬}}} }} | yes | ¬ = <!--Not defined--> | #default = dontcat <!--"category2 = no/'defined but empty'/'anything'"--> }}{{#switch: {{lc: {{{subpage|}}} }} | no = {{basepage subpage | | dontcat <!--"subpage=no" and on a subpage--> | page = {{{page|}}} <!--For testing--> }} | only = {{basepage subpage | dontcat <!--"subpage=only" and not on a subpage--> | page = {{{page|}}} <!--For testing--> }} }} | <!--Don't categorise (result was "dontcat" or "dontcatdontcat" and so on)--> | <!--Check blacklist--> {{#switch: {{#ifeq: {{lc: {{{nocat|}}} }} | false | <!--"nocat=false", skip blacklist check--> | {{#ifeq: {{lc: {{{categories|}}} }} | yes | <!--Skip blacklist check--> | {{#ifeq: {{lc: {{{category2|}}} }} | yes | <!--Skip blacklist check--> | {{cat handler/blacklist| page = {{{page|}}} }} <!--Check blacklist--> }} }} }} | hide = <!--Blacklist returned "hide", don't categorize--> | #default = <!--Check if any namespace parameter is defined--> {{#ifeq: h0#384!5nea+w9 | {{{all| {{{main| {{{talk| {{{user| {{{wikipedia| {{{file| {{{mediawiki| {{{template| {{{help| {{{category| {{{portal| {{{book| {{{other| h0#384!5nea+w9 }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} | <!--No namespace parameters fed, basic usage--> {{namespace detect | main = {{{1|}}} | file = {{{1|}}} | help = {{{1|}}} | category = {{{1|}}} | portal = {{{1|}}} | book = {{{1|}}} | page = {{{page|}}} <!--For testing and demonstration--> }} | <!--Namespace parameters fed, advanced usage. If "data" is a number, return the corresponding numbered parameter, else return "data". --> {{{all|}}}{{cat handler/numbered | 1 = {{{1|}}} | 2 = {{{2|}}} | 3 = {{{3|}}} | 4 = {{{4|}}} | 5 = {{{5|}}} | 6 = {{{6|}}} | 7 = {{{7|}}} | 8 = {{{8|}}} | 9 = {{{9|}}} | 10 = {{{10|}}} | data = <!--Check what namespace, and return the data for it. Respecting empty parameters on purpose. --> {{namespace detect | main = {{{main| {{{other|}}} }}} | talk = {{{talk| {{{other|}}} }}} | user = {{{user| {{{other|}}} }}} | wikipedia = {{{wikipedia| {{{project| {{{other|}}} }}} }}} | file = {{{file| {{{image| {{{other|}}} }}} }}} | mediawiki = {{{mediawiki| {{{other|}}} }}} | template = {{{template| {{{other|}}} }}} | help = {{{help| {{{other|}}} }}} | category = {{{category| {{{other|}}} }}} | portal = {{{portal| {{{other|}}} }}} | book = {{{book| {{{other|}}} }}} | other = {{{other|}}} <!--Namespace special or a new namespace--> | page = {{{page|}}} <!--For testing and demonstration--> }} }} }} }} }}<noinclude> {{documentation}} <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> 45ktajbfa9vlt66spu36nqt6vw51ckl 97211 97210 2011-06-16T06:07:20Z Nemo bis 4216 attribution: imported from [[w:en:Template:Cat handler]] 97211 wikitext text/x-wiki {{#if: {{#ifeq: {{lc: {{{nocat|}}} }} | true | dontcat <!--"nocat=true", don't categorize--> }}{{#ifeq: {{lc: {{{categories|}}} }} | no | dontcat }}{{#switch: {{lc: {{{category2|¬}}} }} | yes | ¬ = <!--Not defined--> | #default = dontcat <!--"category2 = no/'defined but empty'/'anything'"--> }}{{#switch: {{lc: {{{subpage|}}} }} | no = {{basepage subpage | | dontcat <!--"subpage=no" and on a subpage--> | page = {{{page|}}} <!--For testing--> }} | only = {{basepage subpage | dontcat <!--"subpage=only" and not on a subpage--> | page = {{{page|}}} <!--For testing--> }} }} | <!--Don't categorise (result was "dontcat" or "dontcatdontcat" and so on)--> | <!--Check blacklist--> {{#switch: {{#ifeq: {{lc: {{{nocat|}}} }} | false | <!--"nocat=false", skip blacklist check--> | {{#ifeq: {{lc: {{{categories|}}} }} | yes | <!--Skip blacklist check--> | {{#ifeq: {{lc: {{{category2|}}} }} | yes | <!--Skip blacklist check--> | {{cat handler/blacklist| page = {{{page|}}} }} <!--Check blacklist--> }} }} }} | hide = <!--Blacklist returned "hide", don't categorize--> | #default = <!--Check if any namespace parameter is defined--> {{#ifeq: h0#384!5nea+w9 | {{{all| {{{main| {{{talk| {{{user| {{{wikipedia| {{{file| {{{mediawiki| {{{template| {{{help| {{{category| {{{portal| {{{book| {{{other| h0#384!5nea+w9 }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} | <!--No namespace parameters fed, basic usage--> {{namespace detect | main = {{{1|}}} | file = {{{1|}}} | help = {{{1|}}} | category = {{{1|}}} | portal = {{{1|}}} | book = {{{1|}}} | page = {{{page|}}} <!--For testing and demonstration--> }} | <!--Namespace parameters fed, advanced usage. If "data" is a number, return the corresponding numbered parameter, else return "data". --> {{{all|}}}{{cat handler/numbered | 1 = {{{1|}}} | 2 = {{{2|}}} | 3 = {{{3|}}} | 4 = {{{4|}}} | 5 = {{{5|}}} | 6 = {{{6|}}} | 7 = {{{7|}}} | 8 = {{{8|}}} | 9 = {{{9|}}} | 10 = {{{10|}}} | data = <!--Check what namespace, and return the data for it. Respecting empty parameters on purpose. --> {{namespace detect | main = {{{main| {{{other|}}} }}} | talk = {{{talk| {{{other|}}} }}} | user = {{{user| {{{other|}}} }}} | wikipedia = {{{wikipedia| {{{project| {{{other|}}} }}} }}} | file = {{{file| {{{image| {{{other|}}} }}} }}} | mediawiki = {{{mediawiki| {{{other|}}} }}} | template = {{{template| {{{other|}}} }}} | help = {{{help| {{{other|}}} }}} | category = {{{category| {{{other|}}} }}} | portal = {{{portal| {{{other|}}} }}} | book = {{{book| {{{other|}}} }}} | other = {{{other|}}} <!--Namespace special or a new namespace--> | page = {{{page|}}} <!--For testing and demonstration--> }} }} }} }} }}<noinclude> {{documentation}} <!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> 38nf35xxl466pjc3sy6vms5wfjddsgn 97212 97211 2016-04-17T15:57:59Z MarcoAurelio 2560 Lua 97212 wikitext text/x-wiki {{#invoke:Category handler|main}}<noinclude> {{documentation}} <!-- Add categories to the /doc subpage, and interwikis to Wikidata. --> </noinclude> og6fhyj2ssd4fmzpqzuodk12q3cms0z 97213 97212 2022-04-06T03:09:13Z 65.182.138.217 97213 wikitext text/x-wiki {{#invoke:Category handler|main}}<noinclude> {{documentation}} <!-- Add categoriesjnhhn to the /doc subpage, and interwikis to Wikidata. --> </noinclude> ef1viifoxi3o9vi1a39q29w0mdc4nfe 97214 97213 2022-04-06T03:09:19Z Mtarch11 9049 Reverted changes by [[Special:Contributions/65.182.138.217|65.182.138.217]] ([[User talk:65.182.138.217|talk]]) to last version by MarcoAurelio 97214 wikitext text/x-wiki {{#invoke:Category handler|main}}<noinclude> {{documentation}} <!-- Add categories to the /doc subpage, and interwikis to Wikidata. --> </noinclude> og6fhyj2ssd4fmzpqzuodk12q3cms0z 97215 97214 2024-01-09T18:04:10Z MusikBot II 12440 Protected "[[Template:Cat handler]]": High-risk template or module ([[User:MusikBot II/TemplateProtector|more info]]) ([Edit=Allow only autoconfirmed users] (indefinite)) 97214 wikitext text/x-wiki {{#invoke:Category handler|main}}<noinclude> {{documentation}} <!-- Add categories to the /doc subpage, and interwikis to Wikidata. --> </noinclude> og6fhyj2ssd4fmzpqzuodk12q3cms0z 97216 97215 2025-10-12T15:08:16Z Codename Noreste 11966 Changed protection settings for "[[Template:Cat handler]]": High-risk template: Increasing to match the same protection as the module it uses. ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) 97214 wikitext text/x-wiki {{#invoke:Category handler|main}}<noinclude> {{documentation}} <!-- Add categories to the /doc subpage, and interwikis to Wikidata. --> </noinclude> og6fhyj2ssd4fmzpqzuodk12q3cms0z 97217 97216 2026-06-07T08:43:32Z Tommy Kronkvist 2826 8 versioner importerades från [[:meta:Template:Cat_handler]] 97214 wikitext text/x-wiki {{#invoke:Category handler|main}}<noinclude> {{documentation}} <!-- Add categories to the /doc subpage, and interwikis to Wikidata. --> </noinclude> og6fhyj2ssd4fmzpqzuodk12q3cms0z