local getArgs = require('Module:Arguments').getArgs
local profiles =
local types =
local get_wikidata_value = function(entity, property) if entity and property then local value = entity:getBestStatements(property)[1] if value then return value["mainsnak"]["datavalue"]["value"] end end return nilend
local get_type = function(value, entity) if value and (value
"team" or value
local get_name = function(frame, name) return name or frame:expandTemplateend
local get_external_link = function(frame, text, category, entity, property) local args = getArgs(frame) local id = args[1] or args["id"] if not id and entity then id = get_wikidata_value(entity, property) if id then text = text .. frame:expandTemplate end end if not id then return mw.title.getCurrentTitle.namespace
local p =
function p.cagematch(frame) local args = getArgs(frame) local entity = mw.wikibase.getEntity local _type = get_type(args["type"], entity) return get_external_link(frame, "[" .. profiles["cagematch"]["url"] .. profiles["cagematch"][_type]["url"] .. " %s]'s profile at " .. profiles["cagematch"]["name"], nil, entity, profiles["cagematch"][_type]["wikidata"] )end
function p.wrestlingtitlespersonalities(frame) return get_external_link(frame, "%s's profile at Wrestling-Titles.com", "", nil, nil )end
function p.rohroster(frame) return get_external_link(frame, "%s's Ring of Honor profile", nil, nil, nil )end
function p.njpw(frame) local args = getArgs(frame) return get_external_link(frame, "[" .. (args["newlink"] and "http://www.njpw1972.com/profile/%s" or "http://www.njpw.co.jp/english/data/detail_profile.php?f=%s") .. " %s]'s New Japan Pro-Wrestling profile", nil, nil, nil )end
function p.gfw(frame) return get_external_link(frame, "%s's Global Force Wrestling profile", nil, nil, nil )end
function p.dragongateusa(frame) return get_external_link(frame, "%s's Dragon Gate USA profile", nil, nil, nil )end
function p.chikara(frame) return get_external_link(frame, "%s's Chikara profile", nil, nil, nil )end
function p.profiles(frame) local args = getArgs(frame) local entity = mw.wikibase.getEntity local _type = get_type(args["type"], entity) local text = ""
for site, data in pairs(profiles) do local value = args[site] or get_wikidata_value(entity, data[_type]["wikidata"]) if value and data[_type]["url"] then text = string.format("[" .. data["url"] .. data[_type]["url"] .. " " .. data["name"] .. "]", value) .. (args[site] and "" or frame:expandTemplate) .. ", " .. text end end
if text
0 and "" or nil end
return get_name(frame, args["name"]) .. "'s profile at " .. string.sub(text, 1, -3)end
return p