Content deleted Content added
debug |
add check that page is valid |
||
(11 intermediate revisions by 4 users not shown) | |||
Line 1:
local p = {}
function p.
local function checkId(id)
local z=mw.wikibase.getEntity(frame.args[1])▼
end▼
return mw.wikibase.getEntityIdForTitle(sitelink) or mw.wikibase.getEntity(id).id
if type(id) == 'string' then▼
id = mw.ustring.upper(mw.ustring.sub(id,1,1))..mw.ustring.sub(id,2)▼
-- id is in the proper format for a Wikidata entity▼
return id▼
end
else
▲ id = mw.wikibase.getEntityIdForTitle(id)
end
▲ if id then
▲ end
-- id is a title that matches a Wikidata entity▼
▲ local instanceOf = mw.wikibase.getBestStatements(id, 'P31')[1]
if instanceOf and instanceOf.mainsnak.datavalue.value.id ~= 'Q4167410' then▼
▲
-- not disambiguation▼
if mw.wikibase.isValidEntityId(idOrTitle) then
return id▼
return checkId(idOrTitle)
local eid = mw.wikibase.getEntityIdForTitle(idOrTitle)
if eid then
local instanceOf = mw.wikibase.getBestStatements(eid, 'P31')[1] --instance of
▲ -- instance-of value is missing or is not "disambiguation"
else
-- idOrTitle is a title, but no wikidata item exists for that title
local page = mw.title.new(idOrTitle)
if page then -- valid title
local rtarget = page.redirectTarget
if rtarget then -- title is a Wikipedia redirect
return p._id(rtarget.fullText, alt)
end
end
end
end
end
return
end
function p.
▲ else
▲ return p.entityid(frame, frame.args[1])
▲ end
end
|