Module:Wd: Difference between revisions
Content deleted Content added
Johnrdorazio (talk | contribs) m 1 revision imported |
Partial revert to undo introduction of linking obscurity |
||
Line 653: | Line 653: | ||
function Config:getLabel(id, raw, link, short) |
function Config:getLabel(id, raw, link, short) |
||
local label = nil |
local label = nil |
||
local |
local prefix, title= "", nil |
||
local prefix= "" |
|||
if not id then |
if not id then |
||
Line 670: | Line 669: | ||
if mw.wikibase.isValidEntityId(id) and mw.wikibase.entityExists(id) then |
if mw.wikibase.isValidEntityId(id) and mw.wikibase.entityExists(id) then |
||
label = id |
label = id |
||
if id:sub(1,1) == "P" then |
|||
prefix = "Property:" |
|||
end |
|||
end |
end |
||
prefix = "d:" |
prefix, title = "d:Special:EntityPage/", label -- may be nil |
||
title = label -- may be nil |
|||
else |
else |
||
-- try short name first if requested |
-- try short name first if requested |
||
Line 691: | Line 684: | ||
-- get label |
-- get label |
||
if not label then |
if not label then |
||
label = mw.wikibase.getLabelByLang(id, self.langCode) |
label = mw.wikibase.getLabelByLang(id, self.langCode) -- XXX: should use fallback labels? |
||
end |
end |
||
end |
end |
||
Line 704: | Line 697: | ||
elseif id:sub(1,1) == "P" then |
elseif id:sub(1,1) == "P" then |
||
-- properties have no sitelink, link to Wikidata instead |
-- properties have no sitelink, link to Wikidata instead |
||
title = id |
prefix, title = "d:Special:EntityPage/", id |
||
prefix = "d:Property:" |
|||
end |
end |
||
end |
end |
||
label = mw.text.nowiki(label) -- escape raw label text so it cannot be wikitext markup |
|||
if title then |
if title then |
||
label = buildWikilink(prefix .. title, label) |
label = buildWikilink(prefix .. title, label) |