Module:Wd: Difference between revisions

Update from sandbox, see talk
m (1 revision imported)
WordPress>Janhrach
(Update from sandbox, see talk)
Line 1,815: Line 1,815:
     local numAuthorNameStringParameters = 0
     local numAuthorNameStringParameters = 0
     local tempLink
     local tempLink
     local additionalRefProperties = {}  -- will hold properties of the reference which are not in statement.snaks, namely backup title from "subject named as" and URL from an external ID
     local additionalRefProperties = {}  -- will hold properties of the reference which are not in statement.snaks, namely backup title from "subject named as" and link from an external ID
     local wikidataPropertiesOfSource  -- will contain "Wikidata property" properties of the item in stated in, if any
     local wikidataPropertiesOfSource  -- will contain "Wikidata property" properties of the item in stated in, if any


local version = 5 -- increment this each time the below logic is changed to avoid conflict errors
local version = 6 -- increment this each time the below logic is changed to avoid conflict errors


if statement.snaks then
if statement.snaks then
Line 1,859: Line 1,859:
         -- "stated in" was given but "reference URL" was not.
         -- "stated in" was given but "reference URL" was not.
         -- get "Wikidata property" properties from the item in "stated in"
         -- get "Wikidata property" properties from the item in "stated in"
         -- if any of the returned properties of the external-id datatype is in statement.snaks, generate a URL from it and use the URL in the reference
         -- if any of the returned properties of the external-id datatype is in statement.snaks, generate a link from it and use the link in the reference
        
        
         -- find the "Wikidata property" properties in the item from "stated in"
         -- find the "Wikidata property" properties in the item from "stated in"
Line 1,867: Line 1,867:
         tempLink = self.conf:getValue(statement.snaks[wikidataPropertyOfSource][1], false, true)  -- not raw, linked
         tempLink = self.conf:getValue(statement.snaks[wikidataPropertyOfSource][1], false, true)  -- not raw, linked
         if mw.ustring.match(tempLink, "^%[%Z- %Z+%]$") then  -- getValue returned a URL.
         if mw.ustring.match(tempLink, "^%[%Z- %Z+%]$") then  -- getValue returned a URL.
             additionalRefProperties[aliasesP.referenceURL] = mw.ustring.gsub(tempLink, "^%[(%Z-) %Z+%]$", "%1")  -- the URL is in wiki markup, so strip the square brackets and the display text
             additionalRefProperties[aliasesP.referenceURL] = mw.ustring.gsub(tempLink, "^%[(%Z-) %Z+%]$", "%1")  -- the link is in wiki markup, so strip the square brackets and the display text
             statement.snaks[wikidataPropertyOfSource] = nil
             statement.snaks[wikidataPropertyOfSource] = nil
             break
             break
Line 1,890: Line 1,890:
if i == aliasesP.author or i == aliasesP.authorNameString then
if i == aliasesP.author or i == aliasesP.authorNameString then
params[i] = self:getReferenceDetails(statement.snaks, i, false, self.linked, true)  -- link = true/false, anyLang = true
params[i] = self:getReferenceDetails(statement.snaks, i, false, self.linked, true)  -- link = true/false, anyLang = true
elseif i == aliasesP.statedIn then
-- Get "stated in" raw, as it is wanted (for Cite Q) even if it doesn't have a local language label.
params[aliasesP.statedIn] = {self:getReferenceDetail(statement.snaks, aliasesP.statedIn, true)}  -- raw = true
else
else
params[i] = {self:getReferenceDetail(statement.snaks, i, false, (self.linked or (i == aliasesP.statedIn)) and (statement.snaks[i][1].datatype ~= 'url'), true)}  -- link = true/false, anyLang = true
params[i] = {self:getReferenceDetail(statement.snaks, i, false, self.linked and (statement.snaks[i][1].datatype ~= 'url'), true)}  -- link = true/false, anyLang = true
end
end
 
if #params[i] == 0 then
if #params[i] == 0 then
params[i] = nil
params[i] = nil
Line 1,979: Line 1,982:
-- (1) use the general template for citing web references if there is a match and if at least both "reference URL" and "title" are present
-- (1) use the general template for citing web references if there is a match and if at least both "reference URL" and "title" are present
if citeWeb and not citeMismatch['web'] and citeParams['web'][i18n['cite']['web'][aliasesP.referenceURL]] and citeParams['web'][i18n['cite']['web'][aliasesP.title]] then
if citeWeb and not citeMismatch['web'] and citeParams['web'][i18n['cite']['web'][aliasesP.referenceURL]] and citeParams['web'][i18n['cite']['web'][aliasesP.title]] then
-- we need a processed "stated in" for this template
citeParams['web'][i18n['cite']['web'][aliasesP.statedIn]] = self:getReferenceDetail(statement.snaks, aliasesP.statedIn, false, self.linked, true)
useCite = citeWeb
useCite = citeWeb
useParams = citeParams['web']
useParams = citeParams['web']
Line 1,984: Line 1,989:
-- (2) use the template that expands stated-in references into citations if there is a match and if at least "stated in" is present
-- (2) use the template that expands stated-in references into citations if there is a match and if at least "stated in" is present
elseif citeQ and not citeMismatch['q'] and citeParams['q'][i18n['cite']['q'][aliasesP.statedIn]] then
elseif citeQ and not citeMismatch['q'] and citeParams['q'][i18n['cite']['q'][aliasesP.statedIn]] then
-- we need the raw "stated in" Q-identifier for the this template
citeParams['q'][i18n['cite']['q'][aliasesP.statedIn]] = self:getReferenceDetail(statement.snaks, aliasesP.statedIn, true)  -- raw = true
useCite = citeQ
useCite = citeQ
useParams = citeParams['q']
useParams = citeParams['q']
Anonymous user