Changes
initial code for ambox
local function generateBoxStructure()
local root = htmlBuilder.create() -- Includes error messages and categories added after the box.
local substCheck = root.tag('b').addClass('error')
local box = root.tag('table')
local row = box.tag('tr')
local imageLeftCell = row.tag('td') return root, substCheck, box, row, imageLeftCell
end
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 args.text
imageSize = data.imageSmallSize or '30x30px'
else
image = args.image
-- Get the box structure.
local root, substCheck, box, row , imageLeftCell = generateBoxStructure() -- Do the subst check. if data.substCheck and args.subst == 'SUBST' then if type(args.name) == 'string' then substCheck .wikitext(mw.ustring.format( 'Template <code>%s%s%s</code> has been incorrectly substituted.', mw.text.nowiki('{{'), args.name, mw.text.nowiki('}}') )) 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.
end
box
.addClass(isSmall and 'mbox-small'smallClass)
.addClass(data.classPlainlinksYesno and yesno(args.plainlinks or true) and 'plainlinks')
.addClass(typeData.class)
-- Add the left-hand image.
local imageCheckBlank = data.imageCheckBlank if image ~= 'none' and not imageCheckBlank or image ~= 'none' and imageCheckBlank and image ~= 'blank' then row.tag('td')imageLeftCell
.addClass('mbox-image')
if not isSmall and data.imageCellDiv then
imageLeftCell = imageLeftCell.tag('div').css('width', '52px') -- If we are using a div, redefine imageLeftCell so that the image is inside it.
end
imageLeftCell
.wikitext(image or mw.ustring.format('[[File:%s|%s|link=|alt=]]', typeData.image, imageSize))
elseif data.imageEmptyCell then
end
return tostring(root)
end
function p._ambox(args)
local data = {}
data.types = {
speedy = {
class = 'ambox-speedy',
image = 'Ambox speedy deletion.png'
},
delete = {
class = 'ambox-delete',
image = 'Ambox deletion.png'
},
content = {
class = 'ambox-content',
image = 'Ambox content.png'
},
style = {
class = 'ambox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'ambox-move',
image = 'Ambox move.png'
},
protection = {
class = 'ambox-protection',
image = 'Ambox protection.png'
},
notice = {
class = 'ambox-notice',
image = 'Ambox notice.png'
}
}
data.default = 'notice'
data.allowSmall = true
data.substCheck = true
data.classes = {'metadata', 'plainlinks', 'ambox'}
data.smallClass = 'mbox-small-left'
data.imageEmptyCell = true
data.imageCheckBlank = true
data.imageSmallSize = '20x20px'
data.imageCellDiv = true
data.talkLink = true
return p.build(data, args)
end
end
p.ambox = makeWrapper(p._ambox)
p.fmbox = makeWrapper(p._fmbox)
p.imbox = makeWrapper(p._imbox)