Module:Sandbox: Difference between revisions

From Minecraft JE Data
Jump to navigation Jump to search
No edit summary
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 14: Line 14:
link = "Property:"..id
link = "Property:"..id
else
else
link = "Special:EntityData:"..id
link = "Special:EntityData/"..id
end
end
Line 20: Line 20:
end
end


function p.test_snak(frame)
function p.test_snapshot(frame)
local id = frame.args.id;
local id = frame.args.id;
local entity = mw.wikibase.getEntity(id)
local snak = entity['claims']['P4'][1]
local snapshot = mw.wikibase.getEntity(id);
mw.wikibase.renderSnak( snak )
local snapshot_name = snapshot:getLabel();
local release = snapshot:formatPropertyValues('P9')['value'];
return snapshot_name .. " (" .. release .. " snapshot)"
end
end


return p;
return p;

Latest revision as of 00:52, 9 July 2022

Documentation for this module may be created at Module:Sandbox/doc

local p = {};

function p.test(frame)
	local id = frame.args.id;
	local label = mw.wikibase.getLabel(id);
	
	local entity_type = mw.ustring.sub(id, 1, 1)
	
	local link
	
	if entity_type == "Q" then
		link = "Item:"..id
	elseif entity_type == "P" then
		link = "Property:"..id
	else
		link = "Special:EntityData/"..id
	end
	
	return "[["..link.."|"..label.." ".."("..id..")".."]]"
end

function p.test_snapshot(frame)
	local id = frame.args.id;
	
	local snapshot = mw.wikibase.getEntity(id);
	local snapshot_name = snapshot:getLabel();
	local release = snapshot:formatPropertyValues('P9')['value'];
	return snapshot_name .. " (" .. release .. " snapshot)"
end

return p;