Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Module:HAND links

Permanently protected module
From Wikipedia, the free encyclopedia

local p = {}

function p.links(frame)
	local entity = mw.wikibase.getEntity()
	if not entity then
		return ""
	end

	local property = frame.args[1] or "P14750"
	local claims = entity.claims and entity.claims[property]
	if not claims then
		return ""
	end

	local links = {}

	for _, claim in ipairs(claims) do
		local mainsnak = claim.mainsnak
		local value = mainsnak
			and mainsnak.snaktype == "value"
			and mainsnak.datavalue
			and mainsnak.datavalue.value

		if type(value) == "string" or type(value) == "number" then
			local code = tostring(value)
			local encodedCode = mw.uri.encode(code, "PATH")
			local countryCode = mw.uri.encode(
				mw.ustring.lower(mw.ustring.sub(code, 1, 2)),
				"PATH"
			)

			table.insert(
				links,
				"* [https://doi.org/10.23/"
					.. encodedCode
					.. " HAND ID] – Their entry in the HAND (Human and Digital) Talent ID registry of real people and fictional characters"
			)
		end
	end

	return table.concat(links, "\n")
end

return p