« Module:ZoteroItem » : différence entre les versions
Annulation des modifications 17552 de Marc (discussion) Balise : Annulation |
Aucun résumé des modifications |
||
| Ligne 157 : | Ligne 157 : | ||
function p.relations(frame) | function p.relations(frame) | ||
local itemKey = frame.args[1] | local itemKey = frame.args[1] | ||
local groupName = "alcolois" | local groupName = "alcolois" | ||
local groupId = "4893620" | local groupId = "4893620" | ||
| Ligne 164 : | Ligne 164 : | ||
local rel = data.data.relations | local rel = data.data.relations | ||
local | local urls = {} | ||
for k, v in pairs(rel) do | for k, v in pairs(rel) do | ||
if k == "dc:relation" | if k == "dc:relation" then | ||
if type(v) == "string" then | |||
local id = | local id = v:match("/items/(%w+)$") | ||
if id then | if id then | ||
table.insert(urls, string.format( | |||
"https://www.zotero.org/groups/%s/%s/items/%s", | "https://www.zotero.org/groups/%s/%s/items/%s", | ||
groupId, | groupId, groupName, id | ||
)) | |||
end | |||
) | elseif type(v) == "table" then | ||
for _, url in ipairs(v) do | |||
local id = tostring(url):match("/items/(%w+)$") | |||
if id then | |||
table.insert(urls, string.format( | |||
"https://www.zotero.org/groups/%s/%s/items/%s", | |||
groupId, groupName, id | |||
)) | |||
end | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
if # | if #urls == 0 then | ||
return " | return "" | ||
end | end | ||
return "" | return table.concat(urls, ", ") | ||
end | end | ||
return p | return p | ||