Модуль:Players: відмінності між версіями

317 байтів вилучено ,  22 квітня 2024
нема опису редагування
(Створена сторінка: local p = {} function p.fetchCategoryData(frame) local categoryName = "Учасники_спільноти_MCC" -- The category to fetch from local continue = nil local pages = {} repeat local query = mw.smw.ask('Category:' .. categoryName .. '|limit=500' .. (continue and '|continue=' .. continue or '')) for _, page in pairs(query) do table.insert(pages, page.fullText) end continue = query["...)
 
Немає опису редагування
Рядок 3: Рядок 3:
function p.fetchCategoryData(frame)
function p.fetchCategoryData(frame)
     local categoryName = "Учасники_спільноти_MCC"  -- The category to fetch from
     local categoryName = "Учасники_спільноти_MCC"  -- The category to fetch from
    local continue = nil
     local pages = mw.title.makeTitle(14, categoryName):getCategoryMembers()
     local pages = {}
    repeat
        local query = mw.smw.ask('[[Category:' .. categoryName .. ']]|limit=500' .. (continue and '|continue=' .. continue or ''))
        for _, page in pairs(query) do
            table.insert(pages, page.fullText)
        end
        continue = query["query-continue-offset"]  -- If more than 500 results, need to continue querying
    until not continue
 
     -- Start the wikitable
     -- Start the wikitable
     local output = '{| class="wikitable sortable" style="text-align:center;"\n! Учасник\n! Page Link\n'
     local output = '{| class="wikitable sortable" style="text-align:center;"\n! Учасник\n! Page Link\n'
 
   
     -- Add rows to the wikitable
     -- Add rows to the wikitable
     for _, pageTitle in ipairs(pages) do
     for _, page in ipairs(pages) do
         output = output .. '|-\n| ' .. pageTitle .. '\n| [[' .. pageTitle .. ']]\n'
        local title = page.text
         output = output .. '|-\n| ' .. title .. '\n| [[' .. title .. ']]\n'
     end
     end