More actions
Content deleted Content added
use mw.ustring.lower to convert the reason to lower case, for the benefit of other-language wikis |
produce wikitext errors rather than script errors for errors caused by invalid user input |
||
Line 15: | Line 15: | ||
-- Helper functions |
-- Helper functions |
||
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
||
local function makeWikitextError(msg) |
|||
-- @TODO: localise this. |
|||
local boilerplate = 'Error: $1 ([[Module:Protection banner#Errors|help]])' |
|||
local errorText = mw.message.newRawMessage(boilerplate):params(msg):plain() |
|||
return string.format( |
|||
'<strong class="error">%s</strong>', |
|||
errorText |
|||
) |
|||
end |
|||
local function makeCategoryLink(cat) |
local function makeCategoryLink(cat) |
||
Line 42: | Line 52: | ||
dateType, |
dateType, |
||
tostring(dateString) |
tostring(dateString) |
||
)) |
), 0) |
||
end |
end |
||
Line 84: | Line 94: | ||
self.action = args.action |
self.action = args.action |
||
else |
else |
||
error(string.format( |
|||
error('Unsupported action ' .. args.action, 2) |
|||
'invalid action ("%s")', |
|||
tostring(args.action) |
|||
), 0) |
|||
end |
end |
||
Line 800: | Line 813: | ||
end |
end |
||
-- Initialise protection and |
-- Initialise the protection object and check for errors |
||
local protectionObj = |
local protectionObjCreated, protectionObj = pcall( |
||
Protection.new, Protection, -- equivalent to Protection:new() |
|||
args, |
|||
cfg, |
|||
title |
|||
) |
|||
if not protectionObjCreated then |
|||
-- protectionObj is the error message. |
|||
return makeWikitextError(protectionObj) |
|||
end |
|||
-- Initialise the blurb object |
|||
local blurbObj = Blurb:new(protectionObj, args, cfg) |
local blurbObj = Blurb:new(protectionObj, args, cfg) |
||