Content deleted Content added
Prepare for "series ordinal" by introducing a "position" local variable. |
Hack support for author name string. |
||
Line 28:
local function get_name_list (nl_type, args, qid, wdl)
local propertyID = "P50"
local fallbackID = "P2093" -- author name string
if 'author' == nl_type then
propertyID = 'P50'; -- for authors
fallbackID = 'P2093';
elseif 'editor' == nl_type then
propertyID = 'P98'; -- for editors
fallbackID = nil;
else
return; -- not specified so return
Line 52 ⟶ 55:
end
local entity, props▼
local entity = mw.wikibase.getEntity(qid)
if entity and entity.claims then
props = entity.claims[propertyID]
if fallbackID then
end
end
-- Make sure it actually has one of the
if not (props
return nil
end
Line 71 ⟶ 75:
local out = {}
local link = {}
local maxpos = 0
if props and props[1] then
-- Linked authors / editors
▲ local maxpos = 0
for k, v in pairs(props) do
local qnumber = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
Line 119 ⟶ 123:
end
end
end
if fallback and fallback[1] then
-- Name-only authors / editors
for k, v in pairs(fallback) do
local label = v.mainsnak.datavalue["value"]
local position = maxpos + 1 -- Default to 'next' author.
-- todo: use P1545 (series ordinal) instead of default position.
maxpos = math.max(maxpos, position)
if not out[position] then
out[position] = label
end
end
end
-- if there's anything to return, then insert the additions in the template arguments table
-- in the form |author1=firstname secondname |author2= ...
|