Modul:Protection banner: Unterschied zwischen den Versionen

export classes for testing purposes and a few other tweaks
(add no globals now, to catch any problems sooner rather than later)
(export classes for testing purposes and a few other tweaks)
Zeile 88: Zeile 88:


function Config:getConfigTable(key)
function Config:getConfigTable(key)
local whitelisted = {
local blacklist = {
images = true,
banners = true,
categories = true,
defaultBanners = true
categoryNamespaces = true,
pagetypeNamespaces = true,
errorCategories = true
}
}
if whitelisted[key] then
if not blacklist[key] then
return self._cfg[key]
return self._cfg[key]
else
else
Zeile 187: Zeile 184:
local ProtectionBanner = {}
local ProtectionBanner = {}


function ProtectionBanner._newBannerTemplate(args)
function ProtectionBanner.exportToWiki(frame, title)
-- Makes a new banner template object. This will be a new instance of
-- the most suitable subclass of BannerTemplate, e.g. Banner or Padlock.
if yesno(args.small) then
return Padlock:new(args)
else
return Banner:new(args)
end
end
 
function ProtectionBanner.exportToWiki(frame, titleObj)
local args = mArguments.getArgs(frame)
local args = mArguments.getArgs(frame)
return ProtectionBanner.exportToLua(args, titleObj)
return ProtectionBanner.exportToLua(args, title)
end
end


function ProtectionBanner.exportToLua(args, title)
function ProtectionBanner.exportToLua(args, title)
title = title or mw.title.getCurrentTitle()
title = title or mw.title.getCurrentTitle()
local pstatus = ProtectionStatus.new(args, title)
local cfg = Config:new()
-- Get the banner template object
local banner
do
local bannerClass
if yesno(args.small) then
bannerClass = Padlock
else
bannerClass = Banner
end
banner = bannerClass:new()
end
end
function ProtectionBanner._exportClasses()
return {
ProtectionStatus = ProtectionStatus,
Config = Config,
Image = Image,
Blurb = Blurb,
BannerTemplate = BannerTemplate,
Banner = Banner,
Padlock = Padlock,
Category = Category,
ProtectionCategory = ProtectionCategory,
ErrorCategory = ErrorCategory,
ExpiryCategory = ExpiryCategory
}
end
end


return ProtectionBanner
return ProtectionBanner
Anonymer Benutzer