Module:Πρώτοςσυμμετοχές
Τεκμηρίωση module[δημιουργία]
Μπορείτε να συμβάλλετε στη δημιουργία σελίδας τεκμηρίωσης για αυτό το Scribunto module. Οι συντάκτες μπορούν να πειραματίζονται στο πρόχειρο (δημιουργία | αντίγραφο) και στις δοκιμαστικές σελίδες (δημιουργία) του module. Παρακαλούμε να προσθέτετε τις κατηγορίες στην υποσελίδα τεκμηρίωσης. Υποσελίδες αυτού του module. |
local p = {}
function p.main(frame)
local entity = mw.wikibase.getEntity()
if not entity or not entity.claims or not entity.claims.P3279 then
mw.log("no claims")
return
end
-- select P3279 with P1129 and P1013=Q179304
local data = {}
for i, v in ipairs(entity.claims.P3279) do
if v.type == "statement" and v.rank ~= "deprecated" and v.qualifiers and v.qualifiers.P1013 and v.qualifiers.P1129-- not deprecated statement with qualifier P393
and v.mainsnak.snaktype == "value" then
local id = v.mainsnak.datavalue.value.id
local caps
for _, e in ipairs(v.qualifiers.P1013) do
if e.snaktype == "value" and e.datavalue.value.id == "Q179304" then
for _, f in ipairs(v.qualifiers.P1129) do
if f.snaktype == "value" then
caps = tonumber(f.datavalue.value.amount)
end
end
if caps then break end
end
end
if caps then
table.insert(data, { id, caps })
end
end
end
if #data == 0 then
mw.log("there is no data with caps")
return
end
local function makeResult(id)
local sitelink = mw.wikibase.sitelink(id)
local label = mw.wikibase.label(id)
if sitelink and label and (sitelink ~= label) then
return "[["..sitelink.."|"..label.."]]"
elseif sitelink then
return "[["..sitelink.."]]"
elseif label then
return "[[d:" .. id .. "|" .. label .. "]]"
else
return "[[d:" .. id .. "|" .. id .. "]]"
end
end
local result = {}
for _, v in ipairs(data) do
table.insert(result, makeResult(v[1]) .. ' (' .. v[2] .. ')')
end
mw.log(table.concat(result, ", "))
return table.concat(result, ", ")
end
return p