Editing Module:Protection banner

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. Read the Privacy Policy to learn what information we collect about you and how we use it.

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 46: Line 46:
dateType,
dateType,
tostring(dateString)
tostring(dateString)
), 4)
), 0)
end
end


Line 115: Line 115:
'invalid action: %s',
'invalid action: %s',
tostring(args.action)
tostring(args.action)
), 3)
), 0)
end
end


Line 138: Line 138:
obj.reason = mw.ustring.lower(args[1])
obj.reason = mw.ustring.lower(args[1])
if obj.reason:find('|') then
if obj.reason:find('|') then
error('reasons cannot contain the pipe character ("|")', 3)
error('reasons cannot contain the pipe character ("|")', 0)
end
end
end
end
Line 520: Line 520:
level,
level,
talkKey
talkKey
), 8)
))
end
end
return self:_substituteParameters(msg)
return self:_substituteParameters(msg)
Line 560: Line 560:
return pagetypes[self._protectionObj.title.namespace]
return pagetypes[self._protectionObj.title.namespace]
or pagetypes.default
or pagetypes.default
or error('no default pagetype defined', 8)
or error('no default pagetype defined')
end
end


Line 575: Line 575:
msg = protectionBlurbs.edit.default
msg = protectionBlurbs.edit.default
else
else
error('no protection blurb defined for protectionBlurbs.edit.default', 8)
error('no protection blurb defined for protectionBlurbs.edit.default')
end
end
return self:_substituteParameters(msg)
return self:_substituteParameters(msg)
Line 601: Line 601:
msg = protectionLevels.edit.default
msg = protectionLevels.edit.default
else
else
error('no protection level defined for protectionLevels.edit.default', 8)
error('no protection level defined for protectionLevels.edit.default')
end
end
return self:_substituteParameters(msg)
return self:_substituteParameters(msg)
Line 681: Line 681:
tostring(key),
tostring(key),
type(msg)
type(msg)
), 4)
))
end
end
return self:_substituteParameters(msg)
return self:_substituteParameters(msg)
Line 771: Line 771:
-- Renders the banner.
-- Renders the banner.
makeMessageBox = makeMessageBox or require('Module:Message box').main
makeMessageBox = makeMessageBox or require('Module:Message box').main
local reasonText = self._reasonText or error('no reason text set', 2)
local reasonText = self._reasonText or error('no reason text set')
local explanationText = self._explanationText
local explanationText = self._explanationText
local mbargs = {
local mbargs = {
Line 836: Line 836:
cfg = cfg or require(CONFIG_MODULE)
cfg = cfg or require(CONFIG_MODULE)


local protectionObj = Protection.new(args, cfg, title)
-- Initialise the protection object and check for errors
local protectionObjCreated, protectionObj = pcall(
Protection.new,
args,
cfg,
title
)
if not protectionObjCreated then
local errorBlurb = cfg.msg['error-message-blurb'] or 'Error: $1.'
local errorText = mw.message.newRawMessage(errorBlurb)
:params(protectionObj) -- protectionObj is the error message
:plain()
return string.format(
'<strong class="error">%s</strong>%s',
errorText,
makeCategoryLink(
cfg.msg['tracking-category-incorrect'],
title and title.text or mw.title.getCurrentTitle().text
)
)
end


local ret = {}
local ret = {}
Line 875: Line 895:
-- Find default args, if any.
-- Find default args, if any.
local parent = frame.getParent and frame:getParent()
local parent = frame.getParent and frame:getParent()
local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')]
local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')] or {}


-- Find user args, and use the parent frame if we are being called from a
-- Find user args, and use the parent frame if we are being called from a
Line 887: Line 907:
-- Build the args table. User-specified args overwrite default args.
-- Build the args table. User-specified args overwrite default args.
local args = {}
local args = {}
for k, v in pairs(defaultArgs or {}) do
for k, v in pairs(defaultArgs) do
args[k] = v
args[k] = v
end
end
Please note that all contributions to Nonbinary Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see Nonbinary 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: