Anonymous user
Fixed a few of the ambox bugs. Still have to add category support.
(more ambox stuff - still a little broken) |
(Fixed a few of the ambox bugs. Still have to add category support.) |
||
Line 17:
end
end
return page
end
local function presentButBlank(s)
if type(s) ~= 'string' then return end
if s and not mw.ustring.find(s, '%S') then
return true
else
return false
end
end
Line 24 ⟶ 33:
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
Line 48 ⟶ 60:
-- Process data for collapsible text fields
local
if data.useCollapsibleTextFields then
local nameTitle = getTitleObject(name)
local isTemplatePage = nameTitle and title.prefixedText == ('Template:' .. nameTitle.text) and true or false
if presentButBlank(sect) then
sect = 'This article '
elseif type(sect) == 'string' then
sect = 'This ' .. sect .. ' '
end
issue = (sect or '') .. (args.issue or '') .. ' ' .. (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
▲ text = args.text
-- 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
talkText = mw.ustring.format('%s the [[%s#%s|talk page]].', talkText, talkTitle.prefixedText, 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
text = args.smalltext or issue
else
text = args.smalltext or args.text
end
imageSize = data.imageSmallSize or '30x30px'
else
Line 72 ⟶ 124:
imageRight = args.imageright
imageSize = '40x40px'
text = args.text
end
local substCheck = root.tag('b').addClass('error')▼
local box = root.tag('table')▼
local row = box.tag('tr')▼
local imageLeftCell = row.tag('td').addClass('mbox-image')▼
local textCell = row.tag('td').addClass('mbox-text')▼
------------------------ 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
.
.wikitext(mw.
mw.text.nowiki('
mw.text.nowiki('}}')
))
end
root.wikitext('[[Category:Pages with incorrectly substituted templates]]')
end
-- Build the box.
▲ local box = root.tag('table')
box
.attr('id', args.id)
Line 116 ⟶ 164:
-- 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
Line 130 ⟶ 180:
-- Add the text.
if data.useCollapsibleTextFields then
textCell
Line 136 ⟶ 187:
textCellSpan
.addClass('mbox-text-span')
.wikitext(
if not isSmall then
textCellSpan
Line 142 ⟶ 193:
.addClass('hide-when-compact')
.wikitext(talk)
.wikitext(' ')
.wikitext(fix)
.done()
Line 160 ⟶ 212:
-- Add the right-hand image.
if imageRight and not (data.imageRightNone and imageRight == 'none') then
if not isSmall and data.imageCellDiv then
|