Module:DynamicYSWSList: Difference between revisions

does this work
 
gorkie's hope for a fix
Line 2: Line 2:


function p.fetchlist(frame)
function p.fetchlist(frame)
     -- local args = frame:getParent().args
     local data, errors = mw.ext.externalData.getExternalData{
    local sourceUrl = "https://hackclub.com/api/v1/events/rss"
        url = 'https://hackclub.com/api/v1/events',
    local dataMap = "name=name, description=description, link=link, date=pubDate, page=[[name]]"
        format = 'json with jsonpath',
 
        data = 'name=$.data[*].name,description=$.data[*].description,'
    local data = mw.ext.externalData.getExternalData{
            .. 'link=$.data[*].url,date=$.data[*].startDate'
        url = sourceUrl,
        format = 'xml',
        data = dataMap
     }
     }


     if not data or #data == 0 then
     if not data or #data == 0 then
         return '<span class="error">Error fetch failed</span>'
         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
     end


     local output = {}
     local rows = { '=== All Hack Club Events ===' }
    table.insert(output, "=== 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


     for i, row in ipairs(data) do
     return frame:preprocess(table.concat(rows, '\n'))
        local name = row.name or "Missingname"
        local description = row.description or "Missing desc"
        local link = row.link or "Missing link"
        local date = row.date or "Missing date"
    end
   
end
end


return p
return p