Module:Library/Pipeline
From Comprehensible Input Wiki
Documentation for this module may be created at Module:Library/Pipeline/doc
local p = {}
function createTable(lang)
if lang[1] then
local g = mw.ext.externaldata.getWebData {
url = 'https://comprehensibleinputwiki.com/sqltest.php?language=' .. lang[1],
data = {title, channel, id, service, index, difficulty, difficulty_ordered},
format = 'JSON'
}
local h = mw.ext.externaldata.getWebData {
url = tostring(mw.uri.fullUrl( 'Data:Mandarin Chinese/Videos' )) .. '?action=raw',
format = 'CSV with header'
}
tableOut = '<table id="library2"><tr id="lib-header"><th>Video</th><th>Title</th><th>Difficulty</th><th>Channel</th></tr>'
for key, value in ipairs(g) do
tableOut = tableOut .. '<tr data-index="' .. value['index'] .. '"><td data-sort="' .. value['index'] .. '"> ' .. value['id'] .. '</td><td>' .. value['title'] .. '</td><td data-order="' .. value['difficulty_ordered'] .. '">' .. value['difficulty'] .. '</td><td>' .. value['channel'] .. '</td></tr>'
end
tableOut = tableOut .. '</table>'
return tableOut
else
return 'No language selected.'
end
end
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '\n['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
p.showLibrary = function(frame)
return createTable(frame:getParent().args)
end
return p