Compare commits
2 commits
ed199defcb
...
d2e75d6e21
| Author | SHA1 | Date | |
|---|---|---|---|
| d2e75d6e21 | |||
| 3ed3baa833 |
1 changed files with 37 additions and 12 deletions
|
|
@ -129,6 +129,7 @@ local function makelink(v, out, maxpos, wdl, namestyle)
|
|||
if v.mainsnak.snaktype == "value" then
|
||||
if v.mainsnak.datatype == "wikibase-item" then
|
||||
local qnumber = v.mainsnak.datavalue.value.id
|
||||
local human_instance = false
|
||||
local sitelink = mw.wikibase.getSitelink(qnumber)
|
||||
if qnumber == "Q2818964" then sitelink = nil end -- suppress link to "Various authors"
|
||||
|
||||
|
|
@ -172,7 +173,18 @@ local function makelink(v, out, maxpos, wdl, namestyle)
|
|||
if item_lookup and position <= max_authors_displayed then
|
||||
last_name = last_name or getValue({"P734", qid=qnumber, maxvals=1, ps=2})
|
||||
first_names = first_names or getValue({"P735", qid=qnumber, maxvals=0, ps=2})
|
||||
|
||||
-- check if P31 "instance of" Q5 "human"
|
||||
local instance_of = mw.wikibase.getBestStatements(qnumber, 'P31')
|
||||
if instance_of and instance_of[1] then
|
||||
for k, vi in pairs(instance_of) do
|
||||
if vi.mainsnak.snaktype == "value" and vi.mainsnak.datatype == "wikibase-item" and vi.mainsnak.datavalue.value.id == 'Q5' then
|
||||
human_instance = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if first_names then
|
||||
first_names = getStyledNames(first_names, namestyle)
|
||||
end
|
||||
|
|
@ -192,6 +204,7 @@ local function makelink(v, out, maxpos, wdl, namestyle)
|
|||
first = first_names or nil,
|
||||
link = sitelink or nil,
|
||||
qid = qnumber,
|
||||
human = human_instance,
|
||||
}
|
||||
end
|
||||
elseif v.mainsnak.datatype == "string" then
|
||||
|
|
@ -342,6 +355,7 @@ local function get_name_list (nl_type, args, qid, wdl)
|
|||
label = label:gsub(''', '\''); -- prevent cs1|2 multiple names categorization; replace html entity with the actual character
|
||||
names[i].label = label
|
||||
names[i].qid = out[k].qid or nil
|
||||
names[i].human = out[k].human or nil
|
||||
mw.log(i .. " " .. k .. " " .. label)
|
||||
if args[nl_type .. i] then -- name gets overwritten
|
||||
-- pull corresponding -link only if overwritten name is same as WD name
|
||||
|
|
@ -770,19 +784,28 @@ local function _cite_q (citeq_args)
|
|||
and not is_set (citeq_args.surname) and not is_set (citeq_args.surname1)
|
||||
and not is_set (citeq_args['author-last']) and not is_set (citeq_args['author-last1']) and not is_set (citeq_args['author1-last'])
|
||||
and not is_set (citeq_args['author-surname']) and not is_set (citeq_args['author-surname1']) and not is_set (citeq_args['author1-surname1']) then -- if neither are set, try to get authors from Wikidata
|
||||
names.authors = get_name_list ('author', citeq_args, qid, wdl) -- modify citeq_args table with authors from Wikidata
|
||||
names.authors = get_name_list ('author', citeq_args, qid, wdl) or {} -- modify citeq_args table with authors from Wikidata
|
||||
else
|
||||
names.authors = {}
|
||||
names.authors_overridden = true
|
||||
end
|
||||
|
||||
if not is_set (citeq_args.editor) and not is_set (citeq_args.editor1)
|
||||
and not is_set (citeq_args['editor-last']) and not is_set (citeq_args['editor-last1']) and not is_set (citeq_args['editor1-last'])
|
||||
and not is_set (citeq_args['editor-surname']) and not is_set (citeq_args['editor-surname1']) and not is_set (citeq_args['editor1-surname']) then -- if neither are set, try to get editors from Wikidata
|
||||
names.editors = get_name_list ('editor', citeq_args, qid, wdl) -- modify citeq_args table with editors from Wikidata
|
||||
names.editors = get_name_list ('editor', citeq_args, qid, wdl) or {} -- modify citeq_args table with editors from Wikidata
|
||||
else
|
||||
names.editors = {}
|
||||
names.editors_overridden = true
|
||||
end
|
||||
|
||||
if not is_set (citeq_args.translator) and not is_set (citeq_args.translator1)
|
||||
and not is_set (citeq_args['translator-last']) and not is_set (citeq_args['translator-last1']) and not is_set (citeq_args['translator1-last'])
|
||||
and not is_set (citeq_args['translator-surname']) and not is_set (citeq_args['translator-surname1']) and not is_set (citeq_args['translator1-surname']) then -- if neither are set, try to get translators from Wikidata
|
||||
names.translators = get_name_list ('translator', citeq_args, qid, wdl) -- modify citeq_args table with translators from Wikidata
|
||||
names.translators = get_name_list ('translator', citeq_args, qid, wdl) or {} -- modify citeq_args table with translators from Wikidata
|
||||
else
|
||||
names.translators = {}
|
||||
names.translators_overridden = true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -826,10 +849,10 @@ local function _cite_q (citeq_args)
|
|||
local missing_names = {}
|
||||
for i, author in pairs(names.authors or {}) do
|
||||
-- mw.logObject(author)
|
||||
if not author.last and i <= (tonumber (citeq_args['display-authors']) or tonumber (author_count)) then
|
||||
if not author.last and i <= (tonumber(citeq_args['display-authors']) or author_count) then
|
||||
if author.qid then
|
||||
-- ignore anonymous
|
||||
if author.qid ~= 'Q4233718' then
|
||||
-- ignore anonymous or non-humans
|
||||
if author.human then
|
||||
table.insert(missing_names, author.label .. " <span title='edit author in Wikidata'>[[File:Edit icon on Wikisite.svg|14px|alt=|link=[[:d:" .. author.qid .. "]] ]]</span>")
|
||||
end
|
||||
else
|
||||
|
|
@ -838,10 +861,10 @@ local function _cite_q (citeq_args)
|
|||
end
|
||||
end
|
||||
for i, editor in pairs(names.editors or {}) do
|
||||
if not editor.last and i <= (tonumber (citeq_args['display-editors']) or tonumber (editor_count)) then
|
||||
if not editor.last and i <= (tonumber(citeq_args['display-editors']) or editor_count) then
|
||||
if editor.qid then
|
||||
-- ignore anonymous
|
||||
if editor.qid ~= 'Q4233718' then
|
||||
-- ignore anonymous or non-humans
|
||||
if editor.human then
|
||||
table.insert(missing_names, editor.label .. " <span title='edit editor in Wikidata'>[[File:Edit icon on Wikisite.svg|14px|alt=|link=[[:d:" .. editor.qid .. "]] ]]</span>")
|
||||
end
|
||||
else
|
||||
|
|
@ -852,8 +875,8 @@ local function _cite_q (citeq_args)
|
|||
for i, translator in pairs(names.translators or {}) do
|
||||
if not translator.last then
|
||||
if translator.qid then
|
||||
-- ignore anonymous
|
||||
if translator.qid ~= 'Q4233718' then
|
||||
-- ignore anonymous or non-humans
|
||||
if translator.human then
|
||||
table.insert(missing_names, translator.label .. " <span title='edit translator in Wikidata'>[[File:Edit icon on Wikisite.svg|14px|alt=|link=[[:d:" .. translator.qid .. "]] ]]</span>")
|
||||
end
|
||||
else
|
||||
|
|
@ -875,7 +898,9 @@ local function _cite_q (citeq_args)
|
|||
|
||||
-- handle supplied {{para|ref}} for readable ID, avoid CS1 duplicate default error
|
||||
local pubyear = yearFromDate(citeq_args['publication-date'])
|
||||
if citeq_args.ref and 'none' ~= citeq_args.ref then
|
||||
if names.authors_overridden or (#names.authors == 0 and names.editors_overridden) then
|
||||
-- if names are supplied manually, then don't mess with supplied ref parameter
|
||||
elseif citeq_args.ref and 'none' ~= citeq_args.ref then
|
||||
local citeref = make_citeref(names.authors or names.editors, pubyear)
|
||||
if citeq_args.ref == citeref then
|
||||
citeq_args.ref = nil -- avoid CS1 maint: ref duplicates default
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue