Module:Message box: Difference between revisions

These can just go, the first for being very Wikipedia-specific, and the second for being almost impossible to import properly
m (1 revision imported: updating our documentation module pages with WMF updates)
(These can just go, the first for being very Wikipedia-specific, and the second for being almost impossible to import properly)
Line 6:
local getArgs
local yesno = require('Module:Yesno')
local templatestyles = 'Module:Message box/styles.css'
 
-- Get a language object for formatDate and ucfirst.
Line 12 ⟶ 13:
-- Define constants
local CONFIG_MODULE = 'Module:Message box/configuration'
local DEMOSPACES = {user = 'tmbox', talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'}
 
--------------------------------------------------------------------------------
Line 162 ⟶ 163:
self.typeClass = typeData.class
self.typeImage = typeData.image
 
-- Find if the box has been wrongly substituted.
self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'
 
-- Find whether we are using a small message box.
Line 268 ⟶ 266:
end
if talkTitle and talkTitle.exists then
local talkText = 'Relevant discussion may be found on'
local talkText
if talkArgIsTalkPage then
if self.isSmall then
:wikitext( talkText = string.format(
local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk)
'%s [[%s|%s]].',
talkText = string.format('([[%s|talk]])', talkLink)
talkText,
else
talk,
talkText = 'Relevant discussion may be found on'
talkTitle.prefixedText
if talkArgIsTalkPage then
) )
talkText = string.format(
else
'%s [[%s|%s]].',
talkText = string.format(
talkText,
'%s the [[%s#%s|talk page]].',
talk,
talkText,
talkTitle.prefixedText
talkTitle.prefixedText,
)
talk
else
)
talkText = string.format(
end
'%s the [[%s#%s|talk page]].',
talkText,
talkTitle.prefixedText,
talk
)
end
end
self.talk = talkText
end
Line 303 ⟶ 295:
end
if date then
self.date = string.format(" <spansmall class='date-container'>''(<span class='date'>%s</span>)''</spansmall>", date)
end
self.info = args.info
if yesno(args.removalnotice) then
self.removalNotice = cfg.removalNotice
end
end
 
Line 326 ⟶ 315:
self.imageEmptyCell = cfg.imageEmptyCell
if cfg.imageEmptyCellStyle then
self.imageEmptyCellStyle = 'border:none;padding:00px;width:1px'
end
 
Line 438 ⟶ 427:
local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText
self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort)
end
if self.isSubstituted then
self:addCat('all', 'Pages with incorrectly substituted templates')
end
end
Line 473 ⟶ 459:
function MessageBox:export()
local root = mw.html.create()
 
-- Add the subst check error.
if self.isSubstituted and self.name then
root:tag('b')
:addClass('error')
:wikitext(string.format(
'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.',
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
))
end
 
-- Create the box table.
Line 530 ⟶ 506:
:addClass('mbox-text-span')
:wikitext(self.issue or nil)
if (self.talk or self.fix) and not self.isSmall then
textCellDiv:tag('span')
:addClass('hide-when-compact')
Line 542 ⟶ 518:
:addClass('hide-when-compact')
:wikitext(self.info and (' ' .. self.info) or nil)
end
if self.removalNotice then
textCellDiv:tag('span')
:addClass('hide-when-compact')
:tag('i')
:wikitext(string.format(" (%s)", self.removalNotice))
end
else
Line 612 ⟶ 582:
box:setCategories()
return box:export()
end
local function templatestyles(frame, src)
return mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = templatestyles} }
.. 'CONFIG_MODULE'
end
 
Anonymous user