Changes

m
1 revision imported
Line 169: Line 169:  
end
 
end
 
return setmetatable(obj, Protection)
 
return setmetatable(obj, Protection)
 +
end
 +
 +
function Protection:isUserScript()
 +
-- Whether the page is a user JavaScript or CSS page.
 +
local title = self.title
 +
return title.namespace == 2 and (
 +
title.contentModel == 'javascript' or title.contentModel == 'css'
 +
)
 
end
 
end
   Line 174: Line 182:  
return self.level ~= '*'
 
return self.level ~= '*'
 
end
 
end
 +
 +
function Protection:shouldShowLock()
 +
-- Whether we should output a banner/padlock
 +
return self:isProtected() and not self:isUserScript()
 +
end
 +
 +
-- Whether this page needs a protection category.
 +
Protection.shouldHaveProtectionCategory = Protection.shouldShowLock
    
function Protection:isTemporary()
 
function Protection:isTemporary()
Line 180: Line 196:     
function Protection:makeProtectionCategory()
 
function Protection:makeProtectionCategory()
 +
if not self:shouldHaveProtectionCategory() then
 +
return ''
 +
end
 +
 
local cfg = self._cfg
 
local cfg = self._cfg
 
local title = self.title
 
local title = self.title
  −
-- Exit if the page is not protected.
  −
if not self:isProtected() then
  −
return ''
  −
end
   
 
 
-- Get the expiry key fragment.
 
-- Get the expiry key fragment.
Line 201: Line 216:  
namespaceFragment = 'talk'
 
namespaceFragment = 'talk'
 
end
 
end
+
 
 
-- Define the order that key fragments are tested in. This is done with an
 
-- Define the order that key fragments are tested in. This is done with an
 
-- array of tables containing the value to be tested, along with its
 
-- array of tables containing the value to be tested, along with its
Line 309: Line 324:  
function Protection:isIncorrect()
 
function Protection:isIncorrect()
 
local expiry = self.expiry
 
local expiry = self.expiry
return not self:isProtected()
+
return not self:shouldHaveProtectionCategory()
 
or type(expiry) == 'number' and expiry < os.time()
 
or type(expiry) == 'number' and expiry < os.time()
 
end
 
end
Line 324: Line 339:  
function Protection:makeCategoryLinks()
 
function Protection:makeCategoryLinks()
 
local msg = self._cfg.msg
 
local msg = self._cfg.msg
local ret = { self:makeProtectionCategory() }
+
local ret = {self:makeProtectionCategory()}
 
if self:isIncorrect() then
 
if self:isIncorrect() then
 
ret[#ret + 1] = makeCategoryLink(
 
ret[#ret + 1] = makeCategoryLink(
Line 440: Line 455:  
)
 
)
 
end
 
end
 +
end
 +
 +
function Blurb:_makeEditRequestParameter()
 +
local mEditRequest = require('Module:Submit an edit request')
 +
local action = self._protectionObj.action
 +
local level = self._protectionObj.level
 +
 +
-- Get the edit request type.
 +
local requestType
 +
if action == 'edit' then
 +
if level == 'autoconfirmed' then
 +
requestType = 'semi'
 +
elseif level == 'extendedconfirmed' then
 +
requestType = 'extended'
 +
elseif level == 'templateeditor' then
 +
requestType = 'template'
 +
end
 +
end
 +
requestType = requestType or 'full'
 +
 +
-- Get the display value.
 +
local display = self:_getExpandedMessage('edit-request-display')
 +
 +
return mEditRequest._link{type = requestType, display = display}
 
end
 
end
   Line 613: Line 652:     
function Blurb:_makeVandalTemplateParameter()
 
function Blurb:_makeVandalTemplateParameter()
return require('Module:Vandal-m')._main{
+
return mw.getCurrentFrame():expandTemplate{
self._args.user or self._protectionObj.title.baseText
+
title="vandal-m",
 +
args={self._args.user or self._protectionObj.title.baseText}
 
}
 
}
 
end
 
end
Line 814: Line 854:  
 
 
-- Render the banner
 
-- Render the banner
if protectionObj:isProtected() then
+
if protectionObj:shouldShowLock() then
 
ret[#ret + 1] = tostring(
 
ret[#ret + 1] = tostring(
 
(yesno(args.small) and Padlock or Banner)
 
(yesno(args.small) and Padlock or Banner)
4,000

edits