Module:Professional wrestling profiles/sandbox
Appearance
![]() | This is the module sandbox page for Module:Professional wrestling profiles (diff). See also the companion subpage for test cases (run). |
Implements {{Professional wrestling profiles}}, and a family of related templates, including Template:Chikara profile, Template:Dragongateusa profile, Template:Gfw profile, Template:NJPW profile, and Template:Roh roster.
Tracking category
local data = {
{"cagematch", "http://www.cagematch.net/?id=2&nr=$1", "Cagematch.net", "P2728"},
{"wrestlingdata", "http://wrestlingdata.com/index.php?befehl=bios&wrestler=$1", "Wrestlingdata.com", "P2764"},
{"iwd", "http://www.profightdb.com/wrestlers/$1.html", "Internet Wrestling Database", "P2829"}
}
local p = {}
local categories = {}
local ent = mw.wikibase.getEntityObject()
local yesno = require('Module:Yesno')
local getArgs = require('Module:Arguments').getArgs
function getValue(param,wd)
local para,wd = param,wd
if para then
value = para
elseif entity then
if entity.claims[wd] then
local mainsnak = entity.claims[wd][1].mainsnak
if mainsnak.snaktype == 'value' then
wdvalue = mainsnak.datavalue.value
if not value then value = wdvalue elseif wdvalue ~= value then
table.insert(categories, messages.wdDiff)
end
end
else
table.insert(categories, messages.notWD)
end
end
return value
end
function p._profiles(args)
local title = mw.title.getCurrentTitle()
local name = args.name or string.gsub(title.text, " %b()", "")
local prefix = ''
local text
local letter = string.sub(name,-1)
local out = {}
for _,v in ipairs(data) do
local param, link, title, wdid = unpack(v)
--local param = args[v[1]]
--local link = v[2]
--local wdid = v[3]
param = args[param]
if param then
out[#out+1] = "[" .. string.gsub(link, "$1", getValue(param,wdid)) .. ' ' .. title .. "]"
end
end
if letter=='s' then
text = name .. "'"
else
text = name .. "'s"
end
if out[1] then
prefix = text .. ' profile at '
end
return prefix .. mw.text.listToText(out, ', ', ', ' )
end
function p.profiles(frame)
local args = getArgs(frame)
return p._profiles(args)
end
return p