Latest revision as of 13:32, 5 July 2024 view sourceTrappist the monk (talk | contribs)Administrators479,909 editsNo edit summary |
Latest revision as of 12:08, 19 September 2024 edit So9q (talk | contribs)Extended confirmed users549 edits only include |id= parameter if template is not arxiv, add guessing of arxiv template based on arxiv identifier |
Line 647: |
Line 647: |
|
elseif citeq_args.website then |
|
elseif citeq_args.website then |
|
template = template or "web" |
|
template = template or "web" |
|
|
elseif citeq_args.arxiv then |
|
|
template = template or "arxiv" |
|
end |
|
end |
|
|
|
|
|
|
-- support arXiv classification |
|
-- template is CS1 designator: journal, web, news, etc. |
|
|
if template then |
|
if citeq_args.arxiv then |
|
|
local arxiv_class |
|
-- citeq_args.mode = citeq_args.mode or "cs1" -- a cs1 template already knows that it is cs1 so this line is superfluous |
|
|
|
arxiv_class = getValue( {"P818", qual = "P820", qid = qid, maxvals = 1, rank="best", qualsonly=true} ) |
|
template = "Cite " .. template |
|
|
|
if arxiv_class then |
|
else |
|
|
|
-- See https://en.wikipedia.org/Template:Cite_arXiv |
|
-- citeq_args.mode = citeq_args.mode or "cs2" -- a cs2 template already knows that it is cs2 so this line is superfluous |
|
|
|
-- "class: arXiv classification, e.g. hep-th. Optional. |
|
template = "Citation" |
|
|
|
-- To be used only with new-style (2007 and later) eprint identifiers |
|
|
-- that do not include the classification." |
|
|
citeq_args.class = arxiv_class |
|
|
end |
|
end |
|
end |
|
|
|
|
|
|
-- ************* |id= parameter ********************** |
|
-- |id= could hold more than one identifier pulled from Wikidata not supported by {{citation}}, right now only add our qid to the list |
|
|
|
-- Only include |id= if template is not arxiv |
|
local list_sep = '. ' |
|
|
if citeq_args.mode ~= 'cs1' then |
|
if template ~= "arxiv" then |
|
|
-- |id= could hold more than one identifier pulled from Wikidata not supported by {{citation}}, right now only add our qid to the list |
|
list_sep = ', ' |
|
|
|
local list_sep = '. ' |
|
end |
|
|
|
if citeq_args.mode ~= 'cs1' then |
|
local id = '] ]' -- go through "WDQ (identifier)" redirect to reduce clutter in "What links here" and improve reverse lookup. Keep in sync with {{QID}}. |
|
|
|
list_sep = ', ' |
|
local old_id = citeq_args.id |
|
|
if wdl then -- show WD logo |
|
|
id = id .. ']' -- possibly replace by WD edit icon? |
|
|
end |
|
|
if is_set (old_id) then |
|
|
citeq_args.id = old_id .. list_sep .. id -- append to user-specified contents |
|
|
else |
|
|
citeq_args.id = id |
|
|
end |
|
|
|
|
|
-- clean up any blank parameters |
|
|
for k, v in pairs(citeq_args) do |
|
|
if v == "" then citeq_args = nil end |
|
|
end |
|
|
|
|
|
-- if |expand=<anything>, write a nowiki'd version to see what the {{citation}} template call looks like |
|
|
if expand then |
|
|
local expand_args = { "{{" .. template } -- init with citation template |
|
|
if expand == "self" then |
|
|
citeq_args.id = old_id -- restore original |id= parameter |
|
|
expand_args = { "{{cite Q|" .. qid } -- expand to itself |
|
|
end |
|
end |
|
|
local id = '] ]' -- go through "WDQ (identifier)" redirect to reduce clutter in "What links here" and improve reverse lookup. Keep in sync with {{QID}}. |
|
-- make a sortable table and sort it by param name |
|
|
local sorttable = {} |
|
local old_id = citeq_args.id |
|
|
if wdl then -- show WD logo |
|
for param, val in pairs (citeq_args) do |
|
|
|
id = id .. ']' -- possibly replace by WD edit icon? |
|
table.insert(sorttable, {param, val}) |
|
|
end |
|
end |
|
|
if is_set (old_id) then |
|
table.sort(sorttable, comp_key) |
|
|
|
citeq_args.id = old_id .. list_sep .. id -- append to user-specified contents |
|
-- add contents to expand_args |
|
|
|
else |
|
for idx, val in ipairs(sorttable) do |
|
|
|
citeq_args.id = id |
|
table.insert(expand_args, val .. '=' .. val) |
|
|
|
end |
|
|
|
|
|
-- clean up any blank parameters |
|
|
for k, v in pairs(citeq_args) do |
|
|
if v == "" then citeq_args = nil end |
|
|
end |
|
|
|
|
|
-- if |expand=<anything>, write a nowiki'd version to see what the {{citation}} template call looks like |
|
|
if expand then |
|
|
local expand_args = { "{{" .. template } -- init with citation template |
|
|
if expand == "self" then |
|
|
citeq_args.id = old_id -- restore original |id= parameter |
|
|
expand_args = { "{{cite Q|" .. qid } -- expand to itself |
|
|
end |
|
|
-- make a sortable table and sort it by param name |
|
|
local sorttable = {} |
|
|
for param, val in pairs (citeq_args) do |
|
|
table.insert(sorttable, {param, val}) |
|
|
end |
|
|
table.sort(sorttable, comp_key) |
|
|
-- add contents to expand_args |
|
|
for idx, val in ipairs(sorttable) do |
|
|
table.insert(expand_args, val .. '=' .. val) |
|
|
end |
|
|
-- make the nowiki'd string and done |
|
|
return frame:preprocess (table.concat ({'<syntaxhighlight lang="wikitext" inline="1">', table.concat (expand_args, ' |') .. '}}', '</syntaxhighlight>'})); |
|
end |
|
end |
|
-- make the nowiki'd string and done |
|
|
return frame:preprocess (table.concat ({'<syntaxhighlight lang="wikitext" inline="1">', table.concat (expand_args, ' |') .. '}}', '</syntaxhighlight>'})); |
|
|
end |
|
end |
|
|
|
|
|
-- ************* Assign template ********************** |
|
|
-- template is CS1 designator: journal, web, news, etc. |
|
|
if template then |
|
|
-- citeq_args.mode = citeq_args.mode or "cs1" -- a cs1 template already knows that it is cs1 so this line is superfluous |
|
|
template = "Cite " .. template |
|
|
else |
|
|
-- citeq_args.mode = citeq_args.mode or "cs2" -- a cs2 template already knows that it is cs2 so this line is superfluous |
|
|
template = "Citation" |
|
|
end |
|
|
|
|
|
local erratumid = getPropertyIDs( { "P2507", qid = qid, fwd = "ALL", osd = "no", rank = "best", maxvals = 1 } ) |
|
local erratumid = getPropertyIDs( { "P2507", qid = qid, fwd = "ALL", osd = "no", rank = "best", maxvals = 1 } ) |
Line 769: |
Line 789: |
|
end |
|
end |
|
end |
|
end |
|
|
|
|
|
|
|
return p |
|
return p |