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 getValue = wdib._getValue
|
||||||
local _getPropOfProp = wdib._getPropOfProp
|
local _getPropOfProp = wdib._getPropOfProp
|
||||||
local followQid = wdib._followQid
|
local followQid = wdib._followQid
|
||||||
local getPropertyIDs = wdib._getPropertyIDs
|
--local getPropertyIDs = wdib._getPropertyIDs
|
||||||
local cite_cfg = mw.loadData ('Module:Cite/config')
|
local cite_cfg = mw.loadData ('Module:Cite/config')
|
||||||
local cfg = mw.loadData ('Module:Cite_Q/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
|
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 function get_name_list (nl_type, args, qid, wdl)
|
||||||
local propertyID = "P50"
|
local propertyID
|
||||||
local fallbackID = "P2093" -- author name string
|
local fallbackID
|
||||||
|
|
||||||
if nl_type =="author" then
|
if nl_type =="author" then
|
||||||
propertyID = 'P50' -- for authors
|
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
|
-- loop through list of simple properties and get their values in citeq_args
|
||||||
for name, data in pairs(cfg.simple_properties_t) do
|
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] } )
|
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
|
if data.populate_from_journal then
|
||||||
local publishedin = getValue( {"P1433", ps = 1, qid = qid, maxvals = 0, citeq_args[name], qual = data.id, qualsonly = 'yes'} )
|
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})
|
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 = ''
|
local retract = ''
|
||||||
if citeq_args.retracted_by then
|
if citeq_args.retracted_by then
|
||||||
opt_cat = cfg.i18n_t.trackingcats.retracted
|
opt_cat = cfg.i18n_t.trackingcats.retracted
|
||||||
local retract_qid = followQid({qid = qid, props = "P5824"})
|
local retract_id = string.gsub(citeq_args.retracted_by, 'Q', '')
|
||||||
local retract_id = string.gsub(retract_qid, 'Q', '')
|
|
||||||
local retr_params = {
|
local retr_params = {
|
||||||
citeq = 'yes',
|
citeq = 'yes',
|
||||||
id = frame:expandTemplate{
|
id = frame:expandTemplate{
|
||||||
title = 'QID', args = {qid = retract_id}
|
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.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.bibcode = getValue({"P819", ps = 1, qid = citeq_args.retracted_by}) or nil
|
||||||
retr_params.pmc = getValue({"P932", ps = 1, qid = retract_qid}) or nil
|
retr_params.pmc = getValue({"P932", ps = 1, qid = citeq_args.retracted_by}) or nil
|
||||||
retr_params.pmid = getValue({"P698", ps = 1, qid = retract_qid}) or nil
|
retr_params.pmid = getValue({"P698", ps = 1, qid = citeq_args.retracted_by}) or nil
|
||||||
if 'yes' == citeq_args['retracted-intentional'] then
|
if 'yes' == citeq_args['retracted-intentional'] then
|
||||||
retr_params.intentional = 'yes'
|
retr_params.intentional = 'yes'
|
||||||
end
|
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>'}));
|
return frame:preprocess (table.concat ({'<syntaxhighlight lang="wikitext" inline="1">', table.concat (expand_args, ' |') .. '}}', '</syntaxhighlight>'}));
|
||||||
end
|
end
|
||||||
|
|
||||||
local erratumid = getPropertyIDs( { "P2507", qid = qid, fwd = "ALL", osd = "no", rank = "best", maxvals = 1 } )
|
-- Indicator if item has corrigendum/erratum
|
||||||
if erratumid then
|
local erratumid = ""
|
||||||
erratumid = " [[d:" .. erratumid .. "|" .. cfg.i18n_t.erratum .. "]]" .. cfg.i18n_t.trackingcats.erratum
|
if citeq_args.erratum then
|
||||||
else
|
opt_cat = opt_cat .. cfg.i18n_t.trackingcats.erratum
|
||||||
erratumid = ""
|
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
|
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
|
opt_cat = opt_cat .. cfg.i18n_t.trackingcats.replaced
|
||||||
|
citeq_args.replaced_by = nil
|
||||||
end
|
end
|
||||||
if not citeq_args.title then -- emit category link if missing title
|
if not citeq_args.title then -- emit category link if missing title
|
||||||
opt_cat = opt_cat .. cfg.i18n_t.trackingcats['no-label-or-title'];
|
opt_cat = opt_cat .. cfg.i18n_t.trackingcats['no-label-or-title'];
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Disable CiteSeerX IDs for now
|
||||||
|
citeq_args.citeseerx = nil
|
||||||
|
|
||||||
-- render the template
|
-- render the template
|
||||||
local lc_template = template and template:lower() or "citation"
|
local lc_template = template and template:lower() or "citation"
|
||||||
local output
|
local output
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ settings definitions for i18n
|
||||||
local i18n_t = {
|
local i18n_t = {
|
||||||
["cite_q"] = "{{cite Q|",
|
["cite_q"] = "{{cite Q|",
|
||||||
["erratum"] = "(erratum)",
|
["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}}.
|
["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",
|
["wikisource"] = "enwikisource",
|
||||||
["errors"] = {
|
["errors"] = {
|
||||||
|
|
@ -44,6 +43,7 @@ id = PXXX
|
||||||
|
|
||||||
maxvals = maximum number of multiple values (0 for all)
|
maxvals = maximum number of multiple values (0 for all)
|
||||||
linked = "no" suppresses linking
|
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
|
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
|
rank = "best", "preferred", normal, etc. determines how Wikidata ranks are treated
|
||||||
others = true - the value for the property goes to "others" section
|
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=?
|
hdl = {id = "P1184", maxvals = 1}, -- take care of |hdl-access=?
|
||||||
ismn = {id = "P1208", maxvals = 1},
|
ismn = {id = "P1208", maxvals = 1},
|
||||||
journal = {id = "P1433", maxvals = 1},
|
journal = {id = "P1433", maxvals = 1},
|
||||||
thesis_degree = {id = "P13338", maxvals = 1},
|
thesis_degree = {id = "P13338", maxvals = 1}, -- transient, non-CS1
|
||||||
thesis_submitted_to = {id = "P4101", maxvals = 1},
|
thesis_submitted_to = {id = "P4101", maxvals = 1}, -- transient, non-CS1
|
||||||
retracted_by = {id = "P5824", maxvals = 1}, -- transient, non-CS1
|
retracted_by = {id = "P5824", qidonly=true, maxvals = 1}, -- transient, non-CS1
|
||||||
citeseerx = {id = "P3784", maxvals = 1},
|
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=?
|
osti = {id = "P3894", maxvals = 1}, -- take care of |osti-access=?
|
||||||
biorxiv = {id = "P3951", maxvals = 1},
|
biorxiv = {id = "P3951", maxvals = 1},
|
||||||
asin = {id = "P5749", maxvals = 1}, -- What about |asin-tld=? (WD examples resolve to .com at present, but may change)
|
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