Module:Sandbox/Theki/profile
Module documentation
[create]
local p = {}
function p.picture(frame)
local a = {}
for el in string.gmatch(frame.args[1], "[^,]+") do
table.insert(a, el)
end
if #a == 1 then
return "[[File:" .. a[1] .. "|256px]]"
else
return frame:preprocess(mw.getCurrentFrame():extensionTag({
name = "gallery",
args = { mode = "slideshow", style = "margin:0!important;" },
content = table.concat(a, "\n")
}))
end
end
local sites = {
metawikimedia = { n = "Meta", i = "Wikimedia Community Logo.svg" },
wikifunctions = { n = "Wikifunctions", i = "Wikifunctions-logo.svg" },
wikipedia = { n = "Wikipedia", i = "Wikipedia-logo-v2-square.svg" },
wikisource = { n = "Wikisource", i = "Wikisource-logo.svg" }
}
function p.sites(frame)
local o = '<div class="prof-sitelist" style="width:100%;">'
local i = 0
local title = mw.title.getCurrentTitle()
local pagename = title.nsText .. ":" .. title.rootText -- could just assume that this is in User:
for site,timeJoined,description in string.gmatch(frame.args[1], "(%l+)%s+(%d+)%s*([^;]*);?$?") do
local j = (os.time() - timeJoined) / 60 / 60 / 24
local unit = "days"
if j >= 365 then
j = j / 365;
unit = "years"
end
j = math.floor(j * 10) / 10
o = o
.. '<div class="prof-site" style="border:1px solid #acb0be;' .. (i ~= 0 and "border-top:0;" or "") .. 'display:flex;align-items:stretch;min-height:50px;"><div class="prof-site-icon" style="background-color:#e6e9ef;display:flex;flex-direction:column;align-items:center;padding:0.5em;flex-basis:108px;min-width:108px;box-sizing:border-box;justify-content:center;">'
.. "[[File:" .. sites[site].i .. "|32px]]" .. "[[" .. site .. ":" .. pagename .. "|" .. sites[site].n .. "]]"
.. '</div><div class="prof-site-desc" style="display:flex;align-items:center;padding:0.5em;flex-grow:1;"><div><div>'
.. description
.. '</div><span style="font-size:7pt;color:#000a;">Joined <strong>' .. j .. " " .. unit .. " ago" .. '</strong></span></div></div></div>'
i = i + 1
end
return o .. "</div>"
end
return p