Module:Protection banner: Difference between revisions
Content deleted Content added
config isn't an object anymore |
make the Protection class be in charge of the title, and some other tweaks |
||
Line 10:
-- Lazily initialise modules and objects we don't always need.
local
--------------------------------------------------------------------------------
Line 67:
}
function Protection:initialize(args, cfg
self._cfg = cfg
if args.title then
self.title = mw.title.new(args.title)
if not self.title then
error('Invalid title "' .. args.title .. '"', 2)
end
else
end
-- Set action
Line 84 ⟶ 91:
-- Set level
do
self.level = effectiveProtectionLevel(self.action,
if self.level == 'accountcreator' then
-- Lump titleblacklisted pages in with template-protected pages,
Line 147 ⟶ 154:
function Protection:makeProtectionCategory()
local cfg = self._cfg
local
-- Exit if the page is not protected.
Line 165 ⟶ 172:
local nskey
do
local namespace =
local categoryNamespaces = cfg.categoryNamespaceKeys
nskey = categoryNamespaces[namespace]
Line 326 ⟶ 333:
function Protection:makeTemplateCategory()
local cfg = self._cfg
local
local cat
Line 332 ⟶ 339:
and (
(self.action ~= 'edit' and self.action ~= 'move')
or (
)
then
Line 346 ⟶ 353:
local Blurb = class('Blurb')
function Blurb:initialize(cfg, protectionObj
self._cfg = cfg
self._protectionObj = protectionObj
self._bannerConfig = protectionObj.bannerConfig
self.
end
Line 428 ⟶ 435:
-- protection.
local action = self._protectionObj.action
local pagename = self.
if action == 'move' then
-- We need the move log link.
Line 470 ⟶ 477:
return string.format(
'[[%s:%s#%s|%s]]',
mw.site.namespaces[self.
self.
section,
disputes
Line 523 ⟶ 530:
local action = self._protectionObj.action
local level = self._protectionObj.level
local namespace = self.
local isTalk = self.
-- @TODO: add semi-protection and pending changes blurbs
Line 587 ⟶ 594:
function Blurb:_makePagetypeParameter()
local pagetypes = self._cfg.pagetypes
local namespace = self.
return pagetypes[namespace] or pagetypes.default or error('no default pagetype defined')
end
Line 636 ⟶ 643:
function Blurb:_makeProtectionLogParameter()
local action = self._protectionObj.action
local pagename = self.
if action == 'autoreview' then
-- We need the pending changes log.
Line 668 ⟶ 675:
return string.format(
'[[%s:%s#%s|%s]]',
mw.site.namespaces[self.
self.
section or 'top',
display
Line 687 ⟶ 694:
local mVandalM = require('Module:Vandal-m')
local username = self._username
username = username or self.
return mVandalM._main{username}
end
Line 742 ⟶ 749:
end
function BannerTemplate:setImageFilename(filename, protectionObj
if filename then
self._imageFilename = filename
Line 751 ⟶ 758:
local level = protectionObj.level
local expiry = protectionObj.expiry
local namespace =
-- Deal with special cases first.
Line 827 ⟶ 834:
function Banner:__tostring()
-- Renders the banner.
local reasonText = self._reasonText or error('no reason text set')
local explanationText = self._explanationText
Line 840 ⟶ 847:
)
}
return
end
Line 877 ⟶ 884:
--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------
local
function p._exportClasses()
mArguments = mArguments or require('Module:Arguments')▼
return {▼
Protection = Protection,▼
Blurb = Blurb,▼
BannerTemplate = BannerTemplate,▼
Banner = Banner,▼
Padlock = Padlock,▼
}▼
end
function
if not cfg then
▲ titleObj = titleObj or mw.title.getCurrentTitle()
end
-- Initialise protection and blurb objects
local protectionObj = Protection:new(args, cfg
local blurbObj = Blurb:new(cfg, protectionObj
blurbObj:setDeletionDiscussionPage(args.xfd)
blurbObj:setUsername(args.user)
Line 914 ⟶ 927:
-- Set the image fields
local bannerConfig = protectionObj.bannerConfig
bannerObj:setImageFilename(bannerConfig.image, protectionObj
if isPadlock then
bannerObj:setImageTooltip(blurbObj:makeTooltipText())
Line 928 ⟶ 941:
bannerObj:setReasonText(blurbObj:makeReasonText())
bannerObj:setExplanationText(blurbObj:makeExplanationText())
bannerObj:setPage(
end
Line 945 ⟶ 958:
end
function
if not getArgs then
▲ -- This is used to export the classes for testing purposes.
▲ return {
end
▲ Protection = Protection,
return p._main(getArgs(frame))
▲ Blurb = Blurb,
▲ BannerTemplate = BannerTemplate,
▲ Banner = Banner,
▲ Padlock = Padlock,
▲ }
end
return
|