Jump to content

Editing Module:Lua banner

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
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 36: Line 35:
moduleLinks[i] = string.format('[[:%s]]', module)
moduleLinks[i] = string.format('[[:%s]]', module)
local maybeSandbox = mw.title.new(module .. '/sandbox')
local maybeSandbox = mw.title.new(module .. '/sandbox')
if maybeSandbox and maybeSandbox.exists then
if maybeSandbox.exists then
moduleLinks[i] = moduleLinks[i] .. string.format(' ([[:%s|sandbox]])', maybeSandbox.fullText)
moduleLinks[i] = moduleLinks[i] .. string.format(' ([[:%s|sandbox]])', maybeSandbox.fullText)
end
end
Line 53: Line 52:
boxArgs.type = 'notice'
boxArgs.type = 'notice'
boxArgs.small = true
boxArgs.small = true
boxArgs.image = '[[File:Lua-Logo.svg|30px|alt=|link=]]'
boxArgs.image = '[[File:Lua-logo-nolabel.svg|30px|alt=|link=]]'
return mMessageBox.main('mbox', boxArgs)
return mMessageBox.main('mbox', boxArgs)
end
end
Line 77: Line 76:
testcases = true
testcases = true
}
}
if not subpageBlacklist[titleObj.subpageText] then
if not subpageBlacklist[titleObj.subpageText] then
local protCatName
local protCatName
Line 84: Line 82:
if not category then
if not category then
local categories = {
local categories = {
['Module:String'] = 'Templates based on the String Lua module',
['Module:String'] = 'Lua String-based templates',
['Module:Math'] = 'Templates based on the Math Lua module',
['Module:Math'] = 'Templates based on the Math Lua module',
['Module:BaseConvert'] = 'Templates based on the BaseConvert Lua module',
['Module:BaseConvert'] = 'Templates based on the BaseConvert Lua module',
['Module:Citation/CS1'] = 'Templates based on the Citation/CS1 Lua module'
['Module:Citation'] = 'Lua-based citation templates'
}
}
categories['Module:Citation/CS1'] = categories['Module:Citation']
category = modules[1] and categories[modules[1]]
category = modules[1] and categories[modules[1]]
category = category or 'Lua-based templates'
category = category or 'Lua-based templates'
Line 97: Line 96:
protCatName = "Modules depending on under-protected modules"
protCatName = "Modules depending on under-protected modules"
end
end
if not args.noprotcat and protCatName then
if not args.noprotcat and protCatName then
local protLevels = {
local protLevels = {
Line 107: Line 105:
local currentProt
local currentProt
if titleObj.id ~= 0 then
if titleObj.id ~= 0 then
-- check protection level only if page exists
-- id is 0 (page does not exist) if am previewing before creating a template.
if titleObj.protectionLevels and titleObj.protectionLevels["edit"] then
currentProt = titleObj.protectionLevels["edit"][1]
currentProt = titleObj.protectionLevels["edit"][1]
end
end
end
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
for i, module in ipairs(modules) do
for i, module in ipairs(modules) do
if module ~= "WP:libraryUtil" then
if module ~= "WP:libraryUtil" then
local moduleTitle = mw.title.new(module)
local moduleProt = mw.title.new(module).protectionLevels["edit"][1]
local moduleProt
if moduleTitle and moduleTitle.protectionLevels and moduleTitle.protectionLevels["edit"] then
moduleProt = moduleTitle.protectionLevels["edit"][1]
end
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
if moduleProt < currentProt then
if moduleProt < currentProt then
Line 130: Line 121:
end
end
end
end
for i, cat in ipairs(cats) do
for i, cat in ipairs(cats) do
cats[i] = string.format('[[Category:%s]]', cat)
cats[i] = string.format('[[Category:%s]]', cat)
Please note that all contributions to American Election Wiki are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) (see American Election Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Template used on this page:

Cookies help us deliver our services. By using our services, you agree to our use of cookies.