Modul:Icon: Unterschied zwischen den Versionen

K
11 Versionen von wpen:Module:Icon importiert
(add default empty alt text for icons. There is probably an elegant way to provide real alt text if it is desirable to do so.)
K (11 Versionen von wpen:Module:Icon importiert)
 
(3 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
-- This module implements [[Template:Icon]].
-- This module implements [[Template:Icon]].


require("Module:No globals")
require("strict")
local yesNo = require("Module:Yesno")
local yesNo = require("Module:Yesno")
local getArgs = require("Module:Arguments").getArgs
local getArgs = require("Module:Arguments").getArgs
Zeile 7: Zeile 7:


local p = {}
local p = {}
-- Determine whether we're being called from a sandbox
local sandbox = mw.getCurrentFrame():getTitle():find('sandbox', 1, true) and '/sandbox' or ''


-- Implements [[Template:Icon]]
-- Implements [[Template:Icon]]
-- Returns the icon image corresponding to a string (like 'B')
-- Returns the icon image corresponding to a string (like 'B')
function p._main(args, data)
function p._main(args, data)
local inSandbox = yesNo(args.sandbox)
local data_module = 'Module:Icon/data'..sandbox
local data_module = 'Module:Icon/data'..(inSandbox and '/sandbox' or '')
data = data or mw.loadData(data_module)
data = data or mw.loadData(data_module)
local code = args.class or args[1]
local code = args.class or args[1]
Zeile 24: Zeile 26:
end
end
return string.format(
return string.format(
'[[File:%s%s%s|%s|class=noviewer|alt=]]',
'[[File:%s%s%s|%s|class=noviewer|alt=%s]]',
iconData.image,
iconData.image,
iconData.tooltip and '|' .. iconData.tooltip or '',
iconData.tooltip and '|' .. iconData.tooltip or '',
iconData.link == false and '|link=' or '',
iconData.link == false and '|link=' or '',
args.size or '16x16px'
args.size or '16x16px',
iconData.alt or ''
)
)
end
end