Content deleted Content added
Hack support for author name string. |
Support series ordinal qualifier |
||
Line 45:
if wdl and (#wdl > 0) then
wdl = wdl:lower()
end▼
else
-- wdl is empty, so
Line 65 ⟶ 61:
end
-- Make sure it actually has at least one of the properties requested
if not (props and props[1]) and not (fallback and fallback[1]) then
return nil
Line 77 ⟶ 73:
local maxpos = 0
if props and props[1] then
for k, v in pairs(props) do
local qnumber = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
Line 88 ⟶ 83:
end
local position = maxpos + 1 -- Default to 'next' author.
--
if v["qualifiers"] and v.qualifiers["P1545"] and v.qualifiers["P1545"][1] then
position = tonumber(v.qualifiers["P1545"][1].datavalue.value)
▲ end
maxpos = math.max(maxpos, position)
if sitelink then
Line 125 ⟶ 123:
end
if fallback and fallback[1] then
--
for k, v in pairs(fallback) do
local label = v.mainsnak.datavalue["value"]
local position = maxpos + 1 -- Default to 'next' author.
--
if v["qualifiers"] and v.qualifiers["P1545"] and v.qualifiers["P1545"][1] then
position = tonumber(v.qualifiers["P1545"][1].datavalue.value)
end▼
maxpos = math.max(maxpos, position)
if not out[position] then -- prefer the linked author above
out[position] = label
end
Line 139 ⟶ 140:
-- if there's anything to return, then insert the additions in the template arguments table
-- in the form |author1=firstname secondname |author2= ...
-- Renumber, in case we have inconsistent numbering
if #out > 0 then▼
local keys = {}
for k,v in pairs(out) do
keys[#keys+1] = k
▲ end
end
for k,v in pairs(link) do -- author-linkn or editor-linkn▼
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
end
end
|