Content deleted Content added
+debug rendering; |
Matthiaspaul (talk | contribs) Route through special identifier redirect to reduce clutter in "What links here" and improve reverse-lookup. Add support for "(())" empty accept-as-is markup to unset pulled parameter values for compatibility with CS1/CS2. CE. See Template_talk:Citation#Et_al |
||
Line 6:
local simple_properties = { -- PXXX, is multiple?, linked?
publisher = {id = "P123", maxvals = 1},
oclc = {id = "P243", maxvals = 1},
place = {id = "P291", maxvals = 0, linked = 'no'},
doi = {id = "P356", maxvals = 1},
issue = {id = "P433", maxvals = 1, populate_from_journal = true},
pmid = {id = "P698", maxvals = 1},
arxiv = {id = "P818", maxvals = 1},
bibcode = {id = "P819", maxvals = 1},
jstor = {id = "P888", maxvals = 1},
mr = {id = "P889", maxvals = 1},
ssrn = {id = "P893", maxvals = 1},
pmc = {id = "P932", maxvals = 1},
lccn = {id = "P1144", maxvals = 1},
hdl = {id = "P1184", maxvals = 1},
ismn = {id = "P1208", maxvals = 1},
journal = {id = "P1433", maxvals = 1},
citeseerx = {id = "P3784", maxvals = 1},
osti = {id = "P3894", maxvals = 1},
biorxiv = {id = "P3951", maxvals = 1},
isbn = {id = "P212", maxvals = 1, populate_from_journal = true}, -- ISBN 13
issn = {id = "P236", maxvals = 1, populate_from_journal = true},
chapter = {id = "P792", maxvals = 1},
["date"] = {id = "P577", maxvals = 1, populate_from_journal = true},
series = {id = "P179", maxvals = 1, populate_from_journal = true},
volume = {id = "P478", maxvals = 1, populate_from_journal = true},
title = {id = "P1476", maxvals = 1},
url = {id = "P953", maxvals = 1}, -- full work available at
pages = {id = "P304", maxvals = 1, populate_from_journal = true},
translator = {id = "P655", maxvals = 0}, -- does **not** go to "others" section!
illustrator = {id = "P110", maxvals = 0, others = true}, -- goes to "others" section
composer = {id = "P86", maxvals = 0, others = true}, -- goes to "others" section
animator = {id = "P6942", maxvals = 0, others = true}, -- goes to "others" section
director = {id = "P57", maxvals = 0, others = true}, -- goes to "others" section
screenwriter = {id = "P58", maxvals = 0, others = true}, -- goes to "others" section
}
Line 181:
-- Renumber, in case we have inconsistent numbering
local keys = {}
for k, v in pairs(out) do
keys[#keys + 1] = k
end
table.sort(keys) -- as they might be out of order
for i, k in ipairs(keys) do
mw.log(i .. " " .. k .. " " .. out[k])
args[nl_type .. i] = out[k] -- author-n or editor-n
if link[k] then
Line 209:
function citeq.cite_q (frame)
local citeq_args = {};
local _debug = false; -- when set to anything, causes cite q to render <code><nowiki>{{citation|...}}</nowiki></code>
for k, v in pairs(frame:getParent().args) do
Line 259:
end
if data.others then
oth[#oth + 1] = citeq_args[name] and (name:gsub("^%l", string.upper) .. ": " .. citeq_args[name])
citeq_args[name] = nil
end
Line 267:
citeq_args.journal = citeq_args.journal and citeq_args.journal:gsub("^''", ""):gsub("''$", ""):gsub("|''", "|"):gsub("'']]", "]]")
citeq_args.ol = (getValue( {"P648", ps = 1, qid = qid, maxvals = 1, citeq_args.ol } ) or ''):gsub("^OL(.+)$", "%1")
citeq_args.biorxiv = citeq_args.biorxiv and ("10.1101/" .. citeq_args.biorxiv)
citeq_args.isbn = getValue( {"P957", ps = 1, qid = qid, maxvals = 0, citeq_args.isbn } ) -- try ISBN 10
citeq_args.url = getValue( {"P856", ps = 1, qid = qid, maxvals = 0, citeq_args.url } ) -- try official website
citeq_args.url = getValue( {"P2699", ps = 1, qid = qid, maxvals = 0, citeq_args.url } ) -- try url
local slink = mw.wikibase.getSitelink(qid)
Line 309:
for k, v in pairs(citeq_args) do
if v == '(())' or v == 'unset' or type(k) ~= 'string' then -- empty accept-as-is-written (()) markup to indicate an empty/unused parameter value, other ((...)) markups are passed down to module:citation to support the usual special cases there
citeq_args[k] = nil
end
Line 347:
local debug_args = {'{{citation'}; -- init with citation template
for p, v in pairs (citeq_args) do -- spin through citeq_args and
table.insert (debug_args, p .. '=' .. v); -- add parameter name = value
end
-- make the nowiki'd string and done
Line 357:
returntext = returntext .. ','
end
returntext = returntext .. ' [[WDQ (identifier)|Wikidata]] [[:d:' .. qid .. '|' .. qid .. ']]' -- go through special "WDQ (identifier)" redirect to reduce clutter in "What links here" and improve reverse lookup. (A better name might be "QID (identifier)", but needs to be kept in sync with what's used by Template:QID.)
return returntext
end
|