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

нема опису редагування
Немає опису редагування
Немає опису редагування
 
Рядок 1: Рядок 1:
local p = {}
local p = {}
local page_cache = {}
local page_cache = {}


Рядок 45: Рядок 44:
     end
     end
     return count
     return count
end
-- Секції, які треба ігнорувати в меню
local function should_skip_section(section_name)
    local skip_patterns = {
        "Записи ігор",
        "Ігри гравця"
    }
   
    for _, pattern in ipairs(skip_patterns) do
        if mw.ustring.match(section_name, pattern) then
            return true
        end
    end
   
    return false
end
end


Рядок 69: Рядок 84:
                 local processed = frame:preprocess(section_name)
                 local processed = frame:preprocess(section_name)
                 processed = mw.text.trim(processed)
                 processed = mw.text.trim(processed)
                local anchor = mw.ustring.gsub(processed, " ", "_")
                local display = processed
                  
                  
                 local section_pos = mw.ustring.find(content, line, 1, true)
                 -- Пропускаємо секції з ігор
               
                if not should_skip_section(processed) then
                if section_pos then
                    local anchor = mw.ustring.gsub(processed, " ", "_")
                     local section_content = get_section_content(content, section_pos)
                    local display = processed
                   
                     local section_pos = mw.ustring.find(content, line, 1, true)
                      
                      
                     if mw.ustring.match(processed, "Цікаві факти") then
                     if section_pos then
                        local facts_count = count_facts(section_content)
                        local section_content = get_section_content(content, section_pos)
                        if facts_count > 0 then
                       
                            display = processed .. " (" .. facts_count .. ")"
                        if mw.ustring.match(processed, "Цікаві факти") then
                        end
                            local facts_count = count_facts(section_content)
                    elseif mw.ustring.match(processed, "Нагороди") then
                            if facts_count > 0 then
                        local awards_count = count_awards(section_content)
                                display = processed .. " (" .. facts_count .. ")"
                        if awards_count > 0 then
                            end
                            display = processed .. " (" .. awards_count .. ")"
                        elseif mw.ustring.match(processed, "Нагороди") then
                            local awards_count = count_awards(section_content)
                            if awards_count > 0 then
                                display = processed .. " (" .. awards_count .. ")"
                            end
                         end
                         end
                     end
                     end
                end
                   
               
                    if processed ~= "" then
                if processed ~= "" then
                        table.insert(sections, {
                    table.insert(sections, {
                            display = display,
                        display = display,
                            anchor = anchor
                        anchor = anchor
                        })
                    })
                    end
                 end
                 end
             end
             end