Use Erratum template, qidonly config lookups, 5 September 2026
This commit is contained in:
parent
fbc531998a
commit
d0298adb5d
2 changed files with 50 additions and 21 deletions
|
|
@ -4,7 +4,7 @@ local wdib = require('Module:WikidataIB')
|
|||
local getValue = wdib._getValue
|
||||
local _getPropOfProp = wdib._getPropOfProp
|
||||
local followQid = wdib._followQid
|
||||
local getPropertyIDs = wdib._getPropertyIDs
|
||||
--local getPropertyIDs = wdib._getPropertyIDs
|
||||
local cite_cfg = mw.loadData ('Module:Cite/config')
|
||||
local cfg = mw.loadData ('Module:Cite_Q/config')
|
||||
local cs1_module = 'Module:Citation/CS1' -- don't load the module yet, may not be needed
|
||||
|
|
@ -157,8 +157,8 @@ returns nothing; modifies the args table
|
|||
]=]
|
||||
|
||||
local function get_name_list (nl_type, args, qid, wdl)
|
||||
local propertyID = "P50"
|
||||
local fallbackID = "P2093" -- author name string
|
||||
local propertyID
|
||||
local fallbackID
|
||||
|
||||
if nl_type =="author" then
|
||||
propertyID = 'P50' -- for authors
|
||||
|
|
@ -357,7 +357,15 @@ local function _cite_q (citeq_args)
|
|||
|
||||
-- loop through list of simple properties and get their values in citeq_args
|
||||
for name, data in pairs(cfg.simple_properties_t) do
|
||||
if data.qidonly then
|
||||
citeq_args[name] = followQid({qid = qid, props = data.id})
|
||||
if citeq_args[name] == qid then
|
||||
citeq_args[name] = nil
|
||||
end
|
||||
end
|
||||
if not citeq_args[name] then
|
||||
citeq_args[name] = getValue( {data.id, fwd = "ALL", osd = "no", noicon = "true", qid = qid, maxvals = data.maxvals, linked = data.linked, rank = data.rank or "best", citeq_args[name] } )
|
||||
end
|
||||
if data.populate_from_journal then
|
||||
local publishedin = getValue( {"P1433", ps = 1, qid = qid, maxvals = 0, citeq_args[name], qual = data.id, qualsonly = 'yes'} )
|
||||
citeq_args[name] = publishedin or _getPropOfProp({qid = qid, prop1 = "P1433", prop2 = data.id, maxvals = data.maxvals, ps = 1})
|
||||
|
|
@ -619,19 +627,18 @@ local function _cite_q (citeq_args)
|
|||
local retract = ''
|
||||
if citeq_args.retracted_by then
|
||||
opt_cat = cfg.i18n_t.trackingcats.retracted
|
||||
local retract_qid = followQid({qid = qid, props = "P5824"})
|
||||
local retract_id = string.gsub(retract_qid, 'Q', '')
|
||||
local retract_id = string.gsub(citeq_args.retracted_by, 'Q', '')
|
||||
local retr_params = {
|
||||
citeq = 'yes',
|
||||
id = frame:expandTemplate{
|
||||
title = 'QID', args = {qid = retract_id}
|
||||
}
|
||||
}
|
||||
retr_params.doi = getValue({"P356", ps = 1, qid = retract_qid}) or nil
|
||||
retr_params.doi = getValue({"P356", ps = 1, qid = citeq_args.retracted_by}) or nil
|
||||
retr_params.doi = retr_params.doi and retr_params.doi:lower() or nil
|
||||
retr_params.bibcode = getValue({"P819", ps = 1, qid = retract_qid}) or nil
|
||||
retr_params.pmc = getValue({"P932", ps = 1, qid = retract_qid}) or nil
|
||||
retr_params.pmid = getValue({"P698", ps = 1, qid = retract_qid}) or nil
|
||||
retr_params.bibcode = getValue({"P819", ps = 1, qid = citeq_args.retracted_by}) or nil
|
||||
retr_params.pmc = getValue({"P932", ps = 1, qid = citeq_args.retracted_by}) or nil
|
||||
retr_params.pmid = getValue({"P698", ps = 1, qid = citeq_args.retracted_by}) or nil
|
||||
if 'yes' == citeq_args['retracted-intentional'] then
|
||||
retr_params.intentional = 'yes'
|
||||
end
|
||||
|
|
@ -668,20 +675,40 @@ local function _cite_q (citeq_args)
|
|||
return frame:preprocess (table.concat ({'<syntaxhighlight lang="wikitext" inline="1">', table.concat (expand_args, ' |') .. '}}', '</syntaxhighlight>'}));
|
||||
end
|
||||
|
||||
local erratumid = getPropertyIDs( { "P2507", qid = qid, fwd = "ALL", osd = "no", rank = "best", maxvals = 1 } )
|
||||
if erratumid then
|
||||
erratumid = " [[d:" .. erratumid .. "|" .. cfg.i18n_t.erratum .. "]]" .. cfg.i18n_t.trackingcats.erratum
|
||||
else
|
||||
erratumid = ""
|
||||
-- Indicator if item has corrigendum/erratum
|
||||
local erratumid = ""
|
||||
if citeq_args.erratum then
|
||||
opt_cat = opt_cat .. cfg.i18n_t.trackingcats.erratum
|
||||
local erratum_params = {
|
||||
citeq = 'yes',
|
||||
id = frame:expandTemplate{
|
||||
title = 'QID', args = {qid = string.gsub(citeq_args.erratum, 'Q', '')}
|
||||
}
|
||||
}
|
||||
erratum_params.doi = getValue({"P356", ps = 1, qid = citeq_args.erratum}) or nil
|
||||
erratum_params.doi = erratum_params.doi and erratum_params.doi:lower() or nil
|
||||
erratum_params.bibcode = getValue({"P819", ps = 1, qid = citeq_args.erratum}) or nil
|
||||
erratum_params.pmc = getValue({"P932", ps = 1, qid = citeq_args.erratum}) or nil
|
||||
erratum_params.pmid = getValue({"P698", ps = 1, qid = citeq_args.erratum}) or nil
|
||||
if 'yes' == citeq_args['erratum-checked'] then
|
||||
erratum_params.checked = 'yes'
|
||||
end
|
||||
erratumid = ' ' .. frame:expandTemplate{ title = "Erratum", args = erratum_params }
|
||||
end
|
||||
citeq_args.erratum = nil
|
||||
citeq_args['erratum-checked'] = nil
|
||||
|
||||
if getValue( {"P1366", ps = 1, qid = qid} ) then
|
||||
if citeq_args.replaced_by then
|
||||
opt_cat = opt_cat .. cfg.i18n_t.trackingcats.replaced
|
||||
citeq_args.replaced_by = nil
|
||||
end
|
||||
if not citeq_args.title then -- emit category link if missing title
|
||||
opt_cat = opt_cat .. cfg.i18n_t.trackingcats['no-label-or-title'];
|
||||
end
|
||||
|
||||
-- Disable CiteSeerX IDs for now
|
||||
citeq_args.citeseerx = nil
|
||||
|
||||
-- render the template
|
||||
local lc_template = template and template:lower() or "citation"
|
||||
local output
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ settings definitions for i18n
|
|||
local i18n_t = {
|
||||
["cite_q"] = "{{cite Q|",
|
||||
["erratum"] = "(erratum)",
|
||||
-- ["unknown-author"] = mw.wikibase.getLabel("Q4233718"):gsub("^%l", mw.ustring.upper),
|
||||
["wdq"] = "[[WDQ (identifier)|Wikidata]]", -- go through "WDQ (identifier)" redirect to reduce clutter in "What links here" and improve reverse lookup. Keep in sync with {{QID}}.
|
||||
["wikisource"] = "enwikisource",
|
||||
["errors"] = {
|
||||
|
|
@ -44,6 +43,7 @@ id = PXXX
|
|||
|
||||
maxvals = maximum number of multiple values (0 for all)
|
||||
linked = "no" suppresses linking
|
||||
qidonly = true - fetch the QID rather than the label string
|
||||
populate_from_journal = true/false determines whether to look in a journal where the source is published
|
||||
rank = "best", "preferred", normal, etc. determines how Wikidata ranks are treated
|
||||
others = true - the value for the property goes to "others" section
|
||||
|
|
@ -71,10 +71,12 @@ local simple_properties_t = {
|
|||
hdl = {id = "P1184", maxvals = 1}, -- take care of |hdl-access=?
|
||||
ismn = {id = "P1208", maxvals = 1},
|
||||
journal = {id = "P1433", maxvals = 1},
|
||||
thesis_degree = {id = "P13338", maxvals = 1},
|
||||
thesis_submitted_to = {id = "P4101", maxvals = 1},
|
||||
retracted_by = {id = "P5824", maxvals = 1}, -- transient, non-CS1
|
||||
citeseerx = {id = "P3784", maxvals = 1},
|
||||
thesis_degree = {id = "P13338", maxvals = 1}, -- transient, non-CS1
|
||||
thesis_submitted_to = {id = "P4101", maxvals = 1}, -- transient, non-CS1
|
||||
retracted_by = {id = "P5824", qidonly=true, maxvals = 1}, -- transient, non-CS1
|
||||
replaced_by = {id = "P1366", qidonly=true, maxvals = 1}, -- transient, non-CS1
|
||||
erratum = {id = "P2507", qidonly=true, maxvals = 1}, -- transient, non-CS1
|
||||
-- citeseerx = {id = "P3784", maxvals = 1},
|
||||
osti = {id = "P3894", maxvals = 1}, -- take care of |osti-access=?
|
||||
biorxiv = {id = "P3951", maxvals = 1},
|
||||
asin = {id = "P5749", maxvals = 1}, -- What about |asin-tld=? (WD examples resolve to .com at present, but may change)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue