Module:Profile picture
Jump to navigation
Jump to search
The Lua source code for the display of profile pictures through {{Profile picture}}.
local p = {}
local data = {
default = mw.loadData('Module:Profile picture/default'),
maintheme = mw.loadData('Module:Profile picture/maintheme'),
permamode = mw.loadData('Module:Profile picture/permamode'),
restore = mw.loadData('Module:Profile picture/restore'),
event = mw.loadData('Module:Profile picture/event'),
special = mw.loadData('Module:Profile picture/special'),
}
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
function p.main(frame)
local args = getArgs(frame, {
wrappers = 'Template:Profile picture'
})
return p._main(args)
end
function p._main(args)
local key = args[1]
if not key then error('Profile picture name missing') end
local prop
for k, v in pairs(data) do
prop = v[key]
if prop then
break
end
end
if not prop then return ' <i>Profile picture not found</i> ' end
local name = prop.name
local attrs = {
['data-name'] = name,
['data-desc'] = prop.desc,
['data-obtain'] = prop.obtain,
}
local pagename = 'Profile pictures#'..name
local container = mw.html.create('')
local gridview = yesno(args.gridview)
if gridview then
local wrapper = container:tag('div')
:cssText("display:inline-block; position:relative; margin:5px 10px;")
local ppclass = wrapper:tag('div')
:addClass('profile-picture')
local inner = ppclass:tag('div')
:addClass('inner profile-picture-bg')
local a = inner:tag('div')
:addClass('a')
local dtooltip = a:tag('div')
:addClass('profile-picture-tooltip')
:attr(attrs)
:wikitext('[[File:'..name..'_profile.png|40x40px|link='..pagename..']]')
else
local stooltip = container:tag('span')
:addClass('profile-picture-tooltip')
:attr(attrs)
:wikitext('[[File:'..name..'_profile.png|20x20px|link=]] [['..pagename..'|"'..name..'"]]')
end
return container
end
return p