Module:wikibase-test
From Rhizome Artbase
Documentation for this module may be created at Module:wikibase-test/doc
local p = {}
-- simple test to check for arbitrary element access
function p.singleinfo(frame)
local entity = mw.wikibase.getEntity( "Q1208" )
return entity:getDescription( "en" )
end
function p.id(frame)
if not mw.wikibase then
return "no mw.wikibase"
end
entity = mw.wikibase:getEntityObject()
if entity == nil then
return "no entity"
end
return entity.id
end
function p.label(frame)
return mw.wikibase.label( frame.args[1] )
end
function p.list(frame)
rows = ""
for item_number=1000,2000 do
local item_id = "Q" .. item_number
local item = mw.wikibase.getEntity( item_id )
if item then
local instance_of = item:formatPropertyValues( "P3" )
local label = item:getLabel( "en" )
if label == nil then
label = ""
end
row = "<tr><td>" .. item_id .. "</td><td>" .. label .. "</td><td>" .. instance_of["value"] .. "</td></tr>\n"
rows = rows .. row
end
end
return "<table class=\"wikitable sortable\">\n<tr><th>id</th><th>label</th><th>instance of</th></tr>\n" .. rows .. "</table>"
end
function p.getItem(frame)
local item = mw.wikibase.getEntity( "Q1996" )
local instance_of = item.formatPropertyValues( "P3" )
return instance_of.value
end
-- function p.page(frame)
-- if frame.args[1] == nil then
-- local entity = mw.wikibase.getEntityObject()
-- if not entity then return nil end
-- local id = entity.id
-- else
-- id = frame.args[1]
-- end
-- return mw.wikibase.sitelink( id )
-- end
return p