Jump to content

Module:PreReviewStatus

Unchecked
From Wikinews, the free news source you can write!
[create] Documentation
local p = {}

-- Function to generate the list of articles in the "Review" category
function p.listArticles(frame)
    local category = "Review"
    local limit = tonumber(frame.args[1]) or 100  -- Set a limit to the number of articles to retrieve

    -- Use the MediaWiki API to get category members
    local params = {
        action = "query",
        list = "categorymembers",
        cmtitle = "Category:" .. category,
        cmlimit = limit,
        cmnamespace = 0,  -- Only fetch articles in the main namespace
        format = "json"
    }

    local api = mw.site.api
    local result = api.get(params)
    local pages = result.query.categorymembers

    local output = {}
    for _, page in ipairs(pages) do
        table.insert(output, "* [[" .. page.title .. "]]")
    end

    return table.concat(output, "\n")
end

return p