Module:Protection banner: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(add some more blurbs) |
(more data table restructuring, plus some fiddling around with the category name function; this is a progress save, so the code is horribly broken at the moment) |
||
Line 9: | Line 9: | ||
cfg.reasons = { |
cfg.reasons = { |
||
blp = { |
|||
categoryOrder = 'reason', |
|||
banner = 'blp' |
|||
}, |
|||
dispute = { |
|||
categoryOrder = 'reason', |
|||
banner = 'dispute' |
|||
}, |
|||
office = { |
|||
categoryOrder = 'reason', |
|||
banner = 'office' |
|||
}, |
|||
sock = { |
|||
categoryOrder = 'reason', |
|||
banner = 'sock' |
|||
}, |
|||
usertalk = { |
|||
banner = 'usertalk' |
|||
}, |
|||
vandalism = { |
|||
categoryOrder = 'namespace', |
|||
⚫ | |||
⚫ | |||
} |
|||
cfg.banners = { |
|||
-- $1 = "until" or "or until" depending on the expiry |
-- $1 = "until" or "or until" depending on the expiry |
||
-- $2 = "disputes", with or without a section link |
-- $2 = "disputes", with or without a section link |
||
blp = { |
blp = { |
||
behavior = 'reasonFirst' |
|||
}, |
}, |
||
dispute = { |
dispute = { |
||
text = '$1 editing $2 have been resolved', |
|||
behavior = 'reasonFirst', |
|||
tooltip = 'due to editing disputes', |
|||
iconReason = 'due to editing disputes', |
|||
dispute = true |
dispute = true |
||
}, |
}, |
||
office = { |
office = { |
||
behavior = 'reasonFirst' |
|||
}, |
}, |
||
sock = { |
sock = { |
||
}, |
|||
behavior = 'reasonFirst' |
|||
usertalk = { |
|||
text = '', |
|||
explanation = 'If you cannot edit this user talk page and you need to' |
|||
.. ' make a change or leave a message, you can' |
|||
.. ' [[Wikipedia:Requests for page protection#' |
|||
.. 'Current requests for edits to a protected page|request an edit]],' |
|||
.. ' [[Wikipedia:Requests for page protection#' |
|||
.. 'Current requests for reduction in protection level|request unprotection]],' |
|||
.. ' [[Special:Userlogin|log in]],' |
|||
.. ' or [[Special:UserLogin/signup|create an account]].' |
|||
}, |
}, |
||
vandalism = { |
vandalism = { |
||
text = 'due to [[Wikipedia:Vandalism|vandalism]]', |
|||
behavior = 'namespaceFirst', |
|||
tooltip = 'due to vandalism' |
|||
⚫ | |||
}, |
}, |
||
⚫ | |||
cfg.protectionLevels = { |
|||
foo |
|||
} |
} |
||
Line 158: | Line 186: | ||
end |
end |
||
function p.getCategoryName(cats, |
function p.getCategoryName(cats, action, level, namespace, reason, expiry) |
||
--[[ |
--[[ |
||
-- Gets a category name from the category table, given a combination of |
-- Gets a category name from the category table, given a combination of |
||
Line 172: | Line 200: | ||
--]] |
--]] |
||
local properties = { |
local properties = { |
||
{pos = 5, val = expiry}, |
expiry = {pos = 5, val = expiry}, |
||
{pos = 3, val = p.matchNamespace(namespace)}, |
namespace = {'namespace', pos = 3, val = p.matchNamespace(namespace)}, |
||
{pos = 4, val = reason}, |
reason = {pos = 4, val = reason}, |
||
{pos = 2, val = |
level = {pos = 2, val = level}, |
||
{pos = 1, val = |
action = {pos = 1, val = action} |
||
} |
} |
||
Line 186: | Line 214: | ||
-- vandalism categories if they were available. |
-- vandalism categories if they were available. |
||
--]] |
--]] |
||
local |
local categoryOrder |
||
if not reason then |
if not reason then |
||
categoryOrder = 'reason' |
|||
else |
else |
||
categoryOrder = cfg.reasons[reason].categoryOrder |
|||
end |
end |
||
if |
if categoryOrder == 'namespace' then |
||
toTableEnd(properties, 2) -- move namespace to end |
toTableEnd(properties, 2) -- move namespace to end |
||
elseif |
elseif categoryOrder == 'reason' then |
||
toTableEnd(properties, 3) -- move reason to end |
toTableEnd(properties, 3) -- move reason to end |
||
else |
else |