Module:Wd: Difference between revisions

m
1 revision imported
No edit summary
m (1 revision imported)
 
(4 intermediate revisions by 3 users not shown)
Line 68: Line 68:


local aliasesP = {
local aliasesP = {
coord                  = "P5283",
coord                  = "P625",
-----------------------
-----------------------
image                  = "P725",
image                  = "P18",
author                  = "P3990",
author                  = "P50",
publisher              = "P213",
publisher              = "P123",
importedFrom            = "P413",
importedFrom            = "P143",
statedIn                = "P1408",
statedIn                = "P248",
pages                  = "P1956",
pages                  = "P304",
language                = "P3001",
language                = "P407",
hasPart                = "P4273",
hasPart                = "P527",
publicationDate        = "P4788",
publicationDate        = "P577",
startTime              = "P4821",
startTime              = "P580",
endTime                = "P4841",
endTime                = "P582",
chapter                = "P7048",
chapter                = "P792",
retrieved              = "P7275",
retrieved              = "P813",
referenceURL            = "P7714",
referenceURL            = "P854",
sectionVerseOrParagraph = "P7839",
sectionVerseOrParagraph = "P958",
archiveURL              = "P66",
archiveURL              = "P1065",
title                  = "P458",
title                  = "P1476",
formatterURL            = "P574",
formatterURL            = "P1630",
quote                  = "P622",
quote                  = "P1683",
shortName              = "P739",
shortName              = "P1813",
definingFormula        = "P1463",
definingFormula        = "P2534",
archiveDate            = "P1873",
archiveDate            = "P2960",
inferredFrom            = "P2352",
inferredFrom            = "P3452",
typeOfReference        = "P2788",
typeOfReference        = "P3865",
column                  = "P2826"
column                  = "P3903"
}
}


local aliasesQ = {
local aliasesQ = {
percentage              = "Q1906",
percentage              = "Q11229",
prolepticJulianCalendar = "Q13230",
prolepticJulianCalendar = "Q1985786",
citeWeb                = "Q13234",
citeWeb                = "Q5637226",
citeQ                  = "Q13236"
citeQ                  = "Q22321052"
}
}


Line 194: Line 194:
cfg.langObj = mw.language.new(cfg.langCode)
cfg.langObj = mw.language.new(cfg.langCode)


cfg.siteID = mw.wikibase.getSiteGlobalId()
cfg.siteID = mw.wikibase.getGlobalSiteId()


cfg.states = {}
cfg.states = {}
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 title = nil
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
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)
Line 740: Line 733:
end
end


value = "[[File:OOjs UI icon edit-ltr-progressive.svg|frameless|text-top|10px|alt=" .. i18n['info']['edit-on-wikidata'] .. "|link=https://en.seminaverbi.bibleget.io/wiki/" .. prefix .. self.entityID .. "?uselang=" .. self.langCode
value = "[[File:OOjs UI icon edit-ltr-progressive.svg|frameless|text-top|10px|alt=" .. i18n['info']['edit-on-wikidata'] .. "|link=https://www.wikidata.org/wiki/" .. prefix .. self.entityID .. "?uselang=" .. self.langCode


if self.propertyID then
if self.propertyID then
Line 2,541: Line 2,534:
-- main function that is supposed to be used by wrapper templates
-- main function that is supposed to be used by wrapper templates
function p.main(frame)
function p.main(frame)
if not mw.wikibase then return nil end
local f, args
local f, args