Module:HeroData/nav: Difference between revisions

Jump to navigation Jump to search
Jannepg (talk | contribs)
mNo edit summary
added gallery function
Line 149: Line 149:


     local ret = table.concat(parts, ' • ')
     local ret = table.concat(parts, ' • ')
    if debug_mode then
        return ret
    else
        return frame:preprocess(ret)
    end
end
-- for image galleries
local utilities = require('Module:Utilities')
p.get_hero_gallery = function(frame)
    local file_name = frame.args['1']
    local description = frame.args['2']
    local in_herolabs = frame.args['in_herolabs'] or 'false'
    local debug_mode = frame.args['debug_mode'] == 'true'
    local no_redlinks = frame.args['no_redlinks'] == 'true'  -- default: false
    local heroes = get_heroes(in_herolabs)
    local parts = {}
    local start_gallery = '<gallery>'
    local end_gallery = '</gallery>'
    for _, hero in ipairs(heroes) do
        local page_title = hero.name
        if subpage then
            page_title = hero.name .. '/' .. subpage
        end
        -- Skip redlinks entirely when enabled
        if not (no_redlinks and not utilities.page_exists(page_title)) then
            local item
                item = 'File:' .. hero.name .. file_name .. '|'.. hero.name .. description ..
            table.insert(parts, item)
        end
    end
    local ret = table.concat(start_gallery, parts, end_gallery)


     if debug_mode then
     if debug_mode then