Modul:SPARQLMentions
Zur Navigation springen
Zur Suche springen
Die Dokumentation für dieses Modul kann unter Modul:SPARQLMentions/Doku erstellt werden
local p = {}
local function map(func, array)
local new_array = {}
for i,v in ipairs(array) do
new_array[i] = func(v)
end
return new_array
end
local function getAll(text, regexp, seen, items)
if items == nil then items = {} end
if seen == nil then seen = {} end
for item in string.gmatch(text, regexp) do
if seen[item] == nil then
seen[item] = 1
table.insert(items, item)
end
end
return items
end
function p.getFunctions(frame)
if not mw.wikibase then
return "no mw.wikibase"
end
seen = {}
items = {}
func = {'defaultView:BubbleChart', 'defaultView:Graph', 'defaultView:Map', 'defaultView:ImageGrid', 'wikibase:box', "wikibase:cornerWest" }
for _, pr in ipairs(func) do
items = getAll(frame.args[1], pr, seen, items)
end
return table.concat(map(function(it) return getLabel(frame, it) end, items), ", ")
end
function p.getTitle(frame)
if not mw.wikibase then
return "no mw.wikibase"
end
for line in string.gmatch(frame.args[1], "[^%c]+%c?") do
local title = string.match(line, '^#title:%s*([^%c]+)')
if not (title == nil) then
return title
end
end
end
return p