Module:DynamicYSWSList
Documentation for this module may be created at Module:DynamicYSWSList/doc
local p = {}
function p.fetchlist(frame)
local data, errors = mw.ext.externalData.getExternalData{
url = 'https://hackclub.com/api/v1/events',
format = 'json with jsonpath',
data = 'name=$.data[*].name,description=$.data[*].description,'
.. 'link=$.data[*].url,date=$.data[*].startDate'
}
if not data or #data == 0 then
local msg = '<span class="error">Error fetch failed</span>'
if errors and #errors > 0 then
msg = msg .. '<br>(' .. table.concat(errors, '; ') .. ')'
end
return msg
end
local rows = { '=== All Hack Club Events ===' }
for _, row in ipairs(data) do
table.insert(rows, string.format('* [%s %s] %s (%s)',
row.link or '#', row.name or 'Untitled', row.description or '', row.date or ''))
end
return frame:preprocess(table.concat(rows, '\n'))
end
return p