Module:Protection banner: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(make the protection object responsible for accessing the title object and the config inside the Blurb class) |
(get rid of a few more unnecessary local variables) |
||
Line 393: | Line 393: | ||
-- A link to the page history or the move log, depending on the kind of |
-- A link to the page history or the move log, depending on the kind of |
||
-- protection. |
-- protection. |
||
local action = self._protectionObj.action |
|||
local pagename = self._protectionObj.title.prefixedText |
local pagename = self._protectionObj.title.prefixedText |
||
if action == 'move' then |
if self._protectionObj.action == 'move' then |
||
-- We need the move log link. |
-- We need the move log link. |
||
return self.makeFullUrl( |
return self.makeFullUrl( |
||
Line 413: | Line 412: | ||
function Blurb:_makeDeletionDiscussionLinkParameter() |
function Blurb:_makeDeletionDiscussionLinkParameter() |
||
if self._deletionDiscussionPage then |
|||
if deletionDiscussionPage then |
|||
local display = self:_getExpandedMessage('deletion-discussion-link-display') |
local display = self:_getExpandedMessage('deletion-discussion-link-display') |
||
return string.format('[[%s|%s]]', |
return string.format('[[%s|%s]]', self._deletionDiscussionPage, display) |
||
end |
end |
||
end |
end |
||
function Blurb:_makeDisputeBlurbParameter() |
function Blurb:_makeDisputeBlurbParameter() |
||
if type(self._protectionObj.expiry) == 'number' then |
|||
if type(expiry) == 'number' then |
|||
return self:_getExpandedMessage('dispute-blurb-expiry') |
return self:_getExpandedMessage('dispute-blurb-expiry') |
||
else |
else |
||
Line 431: | Line 428: | ||
function Blurb:_makeDisputeSectionParameter() |
function Blurb:_makeDisputeSectionParameter() |
||
-- "disputes", with or without a section link |
-- "disputes", with or without a section link |
||
local section = self._section |
|||
local disputes = self:_getExpandedMessage('dispute-section-link-display') |
local disputes = self:_getExpandedMessage('dispute-section-link-display') |
||
if |
if self._section then |
||
return string.format( |
return string.format( |
||
'[[%s:%s#%s|%s]]', |
'[[%s:%s#%s|%s]]', |
||
mw.site.namespaces[self._protectionObj.title.namespace].talk.name, |
mw.site.namespaces[self._protectionObj.title.namespace].talk.name, |
||
self._protectionObj.title.text, |
self._protectionObj.title.text, |
||
self._section, |
|||
disputes |
disputes |
||
) |
) |
||
Line 533: | Line 529: | ||
function Blurb:_makeIntroBlurbParameter() |
function Blurb:_makeIntroBlurbParameter() |
||
if type(self._protectionObj.expiry) == 'number' then |
|||
if type(expiry) == 'number' then |
|||
return self:_getExpandedMessage('intro-blurb-expiry') |
return self:_getExpandedMessage('intro-blurb-expiry') |
||
else |
else |
||
Line 542: | Line 537: | ||
function Blurb:_makeOfficeBlurbParameter() |
function Blurb:_makeOfficeBlurbParameter() |
||
if self._protectionObj.protectionDate then |
|||
if protectionDate then |
|||
return self:_getExpandedMessage('office-blurb-protectiondate') |
return self:_getExpandedMessage('office-blurb-protectiondate') |
||
else |
else |
||
Line 552: | Line 546: | ||
function Blurb:_makePagetypeParameter() |
function Blurb:_makePagetypeParameter() |
||
local pagetypes = self._cfg.pagetypes |
local pagetypes = self._cfg.pagetypes |
||
return pagetypes[self._protectionObj.title.namespace] |
|||
or pagetypes.default |
|||
or error('no default pagetype defined') |
|||
end |
end |
||
Line 600: | Line 595: | ||
function Blurb:_makeProtectionLogParameter() |
function Blurb:_makeProtectionLogParameter() |
||
local action = self._protectionObj.action |
|||
local pagename = self._protectionObj.title.prefixedText |
local pagename = self._protectionObj.title.prefixedText |
||
if action == 'autoreview' then |
if self._protectionObj.action == 'autoreview' then |
||
-- We need the pending changes log. |
-- We need the pending changes log. |
||
return self.makeFullUrl( |
return self.makeFullUrl( |
||
Line 620: | Line 614: | ||
function Blurb:_makeResetBlurbParameter() |
function Blurb:_makeResetBlurbParameter() |
||
if self._protectionObj.protectionDate then |
|||
if protectionDate then |
|||
return self:_getExpandedMessage('reset-blurb-protectiondate') |
return self:_getExpandedMessage('reset-blurb-protectiondate') |
||
else |
else |
||
Line 629: | Line 622: | ||
function Blurb:_makeTalkPageParameter() |
function Blurb:_makeTalkPageParameter() |
||
local section = self._section |
|||
⚫ | |||
return string.format( |
return string.format( |
||
'[[%s:%s#%s|%s]]', |
'[[%s:%s#%s|%s]]', |
||
mw.site.namespaces[self._protectionObj.title.namespace].talk.name, |
mw.site.namespaces[self._protectionObj.title.namespace].talk.name, |
||
self._protectionObj.title.text, |
self._protectionObj.title.text, |
||
self._section or 'top', |
|||
⚫ | |||
display |
|||
) |
) |
||
end |
end |
||
function Blurb:_makeTooltipBlurbParameter() |
function Blurb:_makeTooltipBlurbParameter() |
||
if type(self._protectionObj.expiry) == 'number' then |
|||
if type(expiry) == 'number' then |
|||
return self:_getExpandedMessage('tooltip-blurb-expiry') |
return self:_getExpandedMessage('tooltip-blurb-expiry') |
||
else |
else |
||
Line 650: | Line 640: | ||
function Blurb:_makeVandalTemplateParameter() |
function Blurb:_makeVandalTemplateParameter() |
||
return require('Module:Vandal-m')._main{ |
|||
⚫ | |||
local username = self._username |
|||
} |
|||
⚫ | |||
return mVandalM._main{username} |
|||
end |
end |
||