Module:Wikimedia Resource Center badge
Module documentation
[create]
local p = {}
is_rtl = require('Module:Is rtl')
ModuleMsg = require( 'Module:ModuleMsg' )
lang = mw.getCurrentFrame():preprocess('{{int:lang}}')
pagelang = mw.getCurrentFrame():preprocess('{{PAGELANGUAGE}}')
function get_icon(dir)
return '<span style="display:inline-block; padding:0.3em; background:#2a4b8d;">[[File:Telescope mark white.svg|25px|link=Wikimedia Resource Center]]</span>'
end
function p.render(frame)
for key, value in pairs(frame:getParent().args) do
if key == 'forceflip' then
ff = value
elseif key == 'additional' then
additional = value
end
end
if ff == 'true' or ff == 'yes' or ff == '1' then
ff = true
end
if ff == true then
msg = ModuleMsg:get_msgs('Template:I18n/Wikimedia Resource Center', lang)
if is_rtl[lang] == true then
mode = 'rtl'
else
mode = 'ltr'
end
else
msg = ModuleMsg:get_msgs('Template:I18n/Wikimedia Resource Center', pagelang)
if is_rtl[pagelang] == true then
mode = 'rtl'
else
mode = 'ltr'
end
end
-- Creating initial box
content = '<div style="margin-top:0.75em; margin-bottom:0.75em;' -- UNCLOSED TAG
if mode == 'rtl' then
content = content .. ' float:right;'
end
content = content .. '">'
-- Make image show up on the left side of the box
-- (Note that CSSJanus may intervene and move it to the right)
if ff == nil then
if mode == 'ltr' then
content = content .. get_icon('right')
else
content = content .. get_icon('left')
end
elseif mode == 'ltr' then
content = content .. get_icon('right')
end
content = content .. '<span style="padding:0.5em;">'
content = content .. '<span style="font-size:1.125em;">' .. msg['badge'] .. '</span>'
if additional ~= nil then
content = content .. '<span style="padding-left:0.75em; margin-left:0.75em; border-left:2px solid #2a4b8d; font-size:1.125em;">' .. additional .. '</span>'
end
content = content .. '</span>'
-- Make image show up on the left side of the box
if mode == 'rtl' and ff == true then
content = content .. get_icon('left')
end
content = content .. '</div><div style="clear:both;"></div>'
return content
end
return p