Module:Link box
Jump to navigation
Jump to search
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.main(frame)
local args = getArgs(frame, {
removeBlanks = false
})
local image = args.image or args[1] or '[[File:Wiki.png|60px|link=]]'
local imageRight = args.imageright or args["image-right"] or ''
local text = args.text or args[2] or 'This default text shows when someone doesn\'t bother to use the <code>text</code> parameter'
local position = args.position or args.float or 'default'
local templatestyles = args.templatestyles or ''
local stylesheets = {}
table.insert(stylesheets, frame:extensionTag{
name = 'templatestyles',
args = { src = 'Link box/styles.css' }
})
if templatestyles ~= '' then
table.insert(stylesheets, frame:extensionTag{
name = 'templatestyles',
args = { src = templatestyles }
})
end
local customClass = args.class or args.bodyclass or ''
local style = args.style or ''
local box = mw.html.create('div')
:addClass('noprint link-box link-box-' .. position .. ' ' .. customClass)
if style ~= '' then
box:attr('style',style)
end
box:tag('div')
:addClass('link-box-image')
:wikitext(image)
box:tag('div')
:addClass('link-box-text')
:wikitext(text)
if imageRight ~= '' then
box:tag('div')
:addClass('link-box-imageright')
:wikitext(imageRight)
end
return table.concat(stylesheets) .. tostring(box)
end
return p