Changes
Fixed a few of the ambox bugs. Still have to add category support.
end
end
return page or end local function presentButBlank(s) if type(s) ~= 'string' then return end if s and not mw.titleustring.getCurrentTitlefind(s, '%S')then return true else return false end
end
local title = mw.title.getCurrentTitle()
local nsid = title.namespace
-- Get a language object for formatDate.
local lang = mw.language.getContentLanguage()
-- Commenting this out for now - this will require tinkering with Namespace detect to differentiate between
-- Process data for collapsible text fields
local textname, issue, talk, fix, date, info
if data.useCollapsibleTextFields then
name = args.name local nameTitle = getTitleObject(name) local isTemplatePage = nameTitle and title.prefixedText == ('Template:' .. nameTitle.text ) and true or false local sect = args.sect if presentButBlank(sect) then sect = 'This article ' elseif type(sect) == 'string' then sect = 'This ' .. sect .. ' ' end issue = (sect or '') .. (args.issueor '') .. ' ' .. (args.text or '')
talk = args.talk
if presentButBlank(talk) and isTemplatePage then
talk = '#'
end
fix = args.fix
date = args.date
if presentButBlank(date) and isTemplatePage then
date = lang:formatDate('F Y')
end
info = args.info
end -- Process the talk link, if present. if talk then -- See if the talk link exists and is for a talk or a content namespace. local talkTitle = type(talk) == 'string' and getTitleObject(talk) if not talkTitle or not talkTitle.isTalkPage then -- If we couldn't process the talk page link, get the talk page of the current page. local success success, talkTitle = pcall(title.talkPageTitle, title) if not success then talkTitle = nil end end if talkTitle and talkTitle.exists then local talkText = ' Relevant discussion may be found on' if talkTitle.isTalkPage then talkText = mw.ustring.format('%s [[%s|%s]].', talkText, talk, talkTitle.prefixedText) else text talkText = argsmw.ustring.format('%s the [[%s#%s|talk page]].', talkText, talkTitle.textprefixedText, talk) end talk = talkText end
end
-- Find whether we are using a small message box and process our data accordingly.
local isSmall = data.allowSmall and (args.small == 'yes' or args.small == true) and true or false
local smallClass, image, imageRight, text, imageSize
if isSmall then
smallClass = data.smallClass or 'mbox-small'
image = args.smallimage or args.image
imageRight = args.smallimageright or args.imageright
if data.useCollapsibleTextFields then text = args.smalltext or issue else text = args.smalltext or args.text end
imageSize = data.imageSmallSize or '30x30px'
else
imageRight = args.imageright
imageSize = '40x40px'
text = args.text
end
------------------------ Build the box ----------------------------
local root = htmlBuilder.create()
-- Do the subst check.
if data.substCheck and args.subst == 'SUBST' then
if type(args.name) == 'string' then
end
root.wikitext('[[Category:Pages with incorrectly substituted templates]]') -- This puts the category at the *end* of the output, rather than after the subst error message.
end
-- Build the box.
local box = root.tag('table')
box
.attr('id', args.id)
-- Add the left-hand image.
local row = box.tag('tr')
local imageLeftCell = row.tag('td').addClass('mbox-image')
local imageCheckBlank = data.imageCheckBlank
if image ~= 'none' and not imageCheckBlank or image ~= 'none' and imageCheckBlank and image ~= 'blank' then
-- Add the text.
local textCell = row.tag('td').addClass('mbox-text')
if data.useCollapsibleTextFields then
textCell
textCellSpan
.addClass('mbox-text-span')
.wikitext(textissue)
if not isSmall then
textCellSpan
.addClass('hide-when-compact')
.wikitext(talk)
.wikitext(' ')
.wikitext(fix)
.done()
-- Add the right-hand image.
local imageRightCell = row.tag('td').addClass('mbox-imageright')
if imageRight and not (data.imageRightNone and imageRight == 'none') then
if not isSmall and data.imageCellDiv then