Changes

Jump to navigation Jump to search
665 bytes added ,  06:17, 24 June 2018
Detect if on module page
Line 1: Line 1:  
-- This module implements the {{lua}} template.
 
-- This module implements the {{lua}} template.
   
local yesno = require('Module:Yesno')
 
local yesno = require('Module:Yesno')
 
local mList = require('Module:List')
 
local mList = require('Module:List')
Line 37: Line 36:  
end
 
end
 
local moduleList = mList.makeList('bulleted', moduleLinks)
 
local moduleList = mList.makeList('bulleted', moduleLinks)
boxArgs.text = 'Uses [[Wikipedia:Lua|Lua]]:\n' .. moduleList
+
boxArgs.text = 'This ' ..
 +
(mw.title.getCurrentTitle():inNamespaces(828,829) and 'module' or 'template') ..
 +
' uses [[Wikipedia:Lua|Lua]]:\n' .. moduleList
 
end
 
end
 
boxArgs.type = 'notice'
 
boxArgs.type = 'notice'
 
boxArgs.small = true
 
boxArgs.small = true
boxArgs.image = '[[File:Lua-logo-nolabel.svg|30px|alt=Lua logo|link=Wikipedia:Lua]]'
+
boxArgs.image = '[[File:Lua-logo-nolabel.svg|30px|alt=|link=]]'
 
return mMessageBox.main('mbox', boxArgs)
 
return mMessageBox.main('mbox', boxArgs)
 
end
 
end
Line 81: Line 82:  
end
 
end
 
cats[#cats + 1] = category
 
cats[#cats + 1] = category
 +
local protLevels = {
 +
autoconfirmed = 1,
 +
extendedconfirmed = 2,
 +
templateeditor = 3,
 +
sysop = 4
 +
}
 +
local currentProt = titleObj.protectionLevels["edit"][1]
 +
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
 +
for i, module in ipairs(modules) do
 +
local moduleProt = mw.title.new(module).protectionLevels["edit"][1]
 +
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
 +
if moduleProt < currentProt then
 +
cats[#cats + 1] = "Templates using under-protected Lua modules"
 +
break
 +
end
 +
end
 
end
 
end
 
 
Anonymous user

Navigation menu