Compare commits

...

5 commits

Author SHA1 Message Date
Trappist the monk
ed199defcb should not use fixed font size 2026-10-19 13:34:43 +13:00
Trappist the monk
3ff8162b8e editor count, compare numbers to numbers 2026-10-19 13:32:53 +13:00
Trappist the monk
c259ed2704 ref=none is legitimate 2026-10-19 13:32:53 +13:00
Trappist the monk
746e3a3947 author count, compare numbers to numbers 2026-10-19 13:32:29 +13:00
0f2ae4f34d fix citeref trim bug 2026-10-19 13:22:24 +13:00

View file

@ -109,7 +109,8 @@ end
local function make_citeref(names, year) local function make_citeref(names, year)
local refs = {} local refs = {}
for i, v in ipairs(names) do for i, v in ipairs(names) do
refs[i] = mw.text.trim(v.last) or mw.text.trim(v.label) or '' local name = v.last or v.label or ''
refs[i] = mw.text.trim(name)
if i == 4 then break end if i == 4 then break end
end end
table.insert(refs, year) table.insert(refs, year)
@ -825,7 +826,7 @@ local function _cite_q (citeq_args)
local missing_names = {} local missing_names = {}
for i, author in pairs(names.authors or {}) do for i, author in pairs(names.authors or {}) do
-- mw.logObject(author) -- mw.logObject(author)
if not author.last and i <= (citeq_args['display-authors'] or author_count) then if not author.last and i <= (tonumber (citeq_args['display-authors']) or tonumber (author_count)) then
if author.qid then if author.qid then
-- ignore anonymous -- ignore anonymous
if author.qid ~= 'Q4233718' then if author.qid ~= 'Q4233718' then
@ -837,7 +838,7 @@ local function _cite_q (citeq_args)
end end
end end
for i, editor in pairs(names.editors or {}) do for i, editor in pairs(names.editors or {}) do
if not editor.last and i <= (citeq_args['display-editors'] or editor_count) then if not editor.last and i <= (tonumber (citeq_args['display-editors']) or tonumber (editor_count)) then
if editor.qid then if editor.qid then
-- ignore anonymous -- ignore anonymous
if editor.qid ~= 'Q4233718' then if editor.qid ~= 'Q4233718' then
@ -866,7 +867,7 @@ local function _cite_q (citeq_args)
if #missing_names > 0 and not string.find(opt_cat, name_cat, 1, true) then if #missing_names > 0 and not string.find(opt_cat, name_cat, 1, true) then
opt_cat = opt_cat .. name_cat opt_cat = opt_cat .. name_cat
-- TODO: format and i18n this string -- TODO: format and i18n this string
opt_cat = opt_cat .. ' <span class="error" style="font-size:1em"><code class="cs1-code">{{[[Template:Cite Q|Cite Q]]}}</code>: Missing first/last names in Wikidata for ' .. table.concat(missing_names, ', ') .. ' ([[Template:Cite Q#Error messages|help]])</span> ' opt_cat = opt_cat .. ' <span class="error" style="font-size:inherit"><code class="cs1-code">{{[[Template:Cite Q|Cite Q]]}}</code>: Missing first/last names in Wikidata for ' .. table.concat(missing_names, ', ') .. ' ([[Template:Cite Q#Error messages|help]])</span> '
end end
-- change edition to ordinal if it's set and numeric -- change edition to ordinal if it's set and numeric
@ -874,14 +875,14 @@ local function _cite_q (citeq_args)
-- handle supplied {{para|ref}} for readable ID, avoid CS1 duplicate default error -- handle supplied {{para|ref}} for readable ID, avoid CS1 duplicate default error
local pubyear = yearFromDate(citeq_args['publication-date']) local pubyear = yearFromDate(citeq_args['publication-date'])
if citeq_args.ref then if citeq_args.ref and 'none' ~= citeq_args.ref then
local citeref = make_citeref(names.authors or names.editors, pubyear) local citeref = make_citeref(names.authors or names.editors, pubyear)
if citeq_args.ref == citeref then if citeq_args.ref == citeref then
citeq_args.ref = nil -- avoid CS1 maint: ref duplicates default citeq_args.ref = nil -- avoid CS1 maint: ref duplicates default
else else
local tpara = frame:expandTemplate{ title = 'para', args = {'ref', citeq_args.ref} } local tpara = frame:expandTemplate{ title = 'para', args = {'ref', citeq_args.ref} }
-- TODO: format and i18n this string -- TODO: format and i18n this string
opt_cat = opt_cat .. ' <span class="error" style="font-size:1em"><code class="cs1-code">{{[[Template:Cite Q|Cite Q]]}}</code>: supplied ' .. tpara .. ' does not match value generated from Wikidata: <code class="cs1-code">' .. citeref .. '</code> ([[Template:Cite Q#Error messages|help]])</span> ' opt_cat = opt_cat .. ' <span class="error" style="font-size:inherit"><code class="cs1-code">{{[[Template:Cite Q|Cite Q]]}}</code>: supplied ' .. tpara .. ' does not match value generated from Wikidata: <code class="cs1-code">' .. citeref .. '</code> ([[Template:Cite Q#Error messages|help]])</span> '
end end
end end