Module:Professional wrestling profiles

local getArgs = require('Module:Arguments').getArgs
local p = {}

local profiles = {
	{
		key = "wwe",
		name = "WWE",
		person = { url = "https://www.wwe.com/superstars/%s", wikidata = "P2857" },
		team = { url = "https://www.wwe.com/superstars/%s", wikidata = "P2857" },
		stable = { url = "https://www.wwe.com/superstars/%s", wikidata = "P2857" }
	},
	{
		key = "roh",
		name = "Ring of Honor",
		person = { url = "https://www.ringofhonor.com/active-roster/%s", wikidata = nil },
		team = { url = nil, wikidata = nil },
		stable = { url = nil, wikidata = nil }
	},
	{
		key = "njpw",
		name = "New Japan Pro-Wrestling",
		person = { url = "https://www.njpw1972.com/profile/%s", wikidata = nil },
		team = { url = nil, wikidata = nil },
		stable = { url = nil, wikidata = nil }
	},
	{
		key = "cagematch",
		name = "Cagematch",
		person = { url = "https://www.cagematch.net/?id=2&nr=%s", wikidata = "P2728" },
		team = { url = "https://www.cagematch.net/?id=28&nr=%s", wikidata = "P2939" },
		stable = { url = "https://www.cagematch.net/?id=29&nr=%s", wikidata = "P3042" }
	},
	{
		key = "wrestlingdata",
		name = "Wrestlingdata",
		person = { url = "https://www.wrestlingdata.com/index.php?befehl=bios&wrestler=%s", wikidata = "P2764" },
		team = { url = "https://www.wrestlingdata.com/index.php?befehl=stables&stable=%s", wikidata = nil },
		stable = { url = "https://www.wrestlingdata.com/index.php?befehl=stables&stable=%s", wikidata = nil }
	},
	{
		key = "iwd",
		name = "Internet Wrestling Database",
		person = { url = "http://www.profightdb.com/wrestlers/%s.html", wikidata = "P2829" },
		team = { url = nil, wikidata = nil },
		stable = { url = nil, wikidata = nil }
	},
	{
		key = "wrestlingtitles",
		name = "Wrestling-Titles",
		person = { url = "https://www.wrestling-titles.com/personalities/%s/", wikidata = nil },
		team = { url = nil, wikidata = nil },
		stable = { url = nil, wikidata = nil }
	}
}

local function fetch_wikidata(entity, property)
	if entity and property then
		local value = entity:getBestStatements(property)[1]
		if value then
			return value["mainsnak"]["datavalue"]["value"]
		end
	end
	return nil
end

function p.profiles(frame)
	local args = getArgs(frame)
	local entity = mw.wikibase.getEntity()
	local _type = "person"
	local text = ""

	-- Determine type
	if args["type"] and (args["type"] == "person" or args["type"] == "team" or args["type"] == "stable") then
		_type = args["type"]
	else
		local instance = fetch_wikidata(entity, "P31")	-- "instance of" on Wikidata
		local types = {
			["Q5"] = "person",							-- "human"
			["Q1066670"] = "team",						-- "tag team"
			["Q25178247"] = "stable"					-- "professional wrestling stable"
		}
		if instance and types[instance.id] then
			_type = types[instance.id]
		end
	end

	-- Parse profiles
	for index, data in ipairs(profiles) do
		local value = args[data["key"]] or fetch_wikidata(entity, data[_type]["wikidata"])
		if value and data[_type]["url"] then
			text = text
			.. string.format("[" .. data[_type]["url"] .. " " .. data["name"] .. "]", value)
			.. (args[data["key"]] and "" or frame:expandTemplate{title = 'EditAtWikidata', args = { pid = data[_type]["wikidata"] }})
			.. ", "
		end
	end
	if text == "" then
		return mw.title.getCurrentTitle().namespace == 0 and "[[Category:Professional wrestling profiles template without any identifiers]]" or nil
	end

	return (args["name"] or frame:expandTemplate{title = 'PAGENAMEBASE'}) .. "'s profile at " .. string.sub(text, 1, -3)
end

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.