Jump to content

Module:Build bracket/Config

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Pbrks (talk | contribs) at 02:01, 13 August 2025 (Created page with 'local Config = {} -- ======================== -- Color configuration -- ======================== Config.COLORS = { -- Cell backgrounds cell_bg_light = 'var(--background-color-neutral-subtle,#f8f9fa)', cell_bg_dark = 'var(--background-color-neutral,#eaecf0)', text_color = 'var(--color-base,#202122)', path_line_color = 'gray', cell_border = 'var(--border-color-base,#a2a9b1)', } -- ======================== -- Init /...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
local Config = {}

-- ========================
-- Color configuration
-- ========================
Config.COLORS = {
    -- Cell backgrounds
    cell_bg_light    = 'var(--background-color-neutral-subtle,#f8f9fa)',
    cell_bg_dark     = 'var(--background-color-neutral,#eaecf0)',
    text_color       = 'var(--color-base,#202122)',
    path_line_color  = 'gray',
    cell_border      = 'var(--border-color-base,#a2a9b1)',
}

-- ========================
-- Init / parseArgs
-- ========================
function Config.init(frame, state, config, Helpers)
    -- Store args in config so Helpers.bargs can see them
    local fargs = frame.args or {}
    local pargs = (frame.getParent and frame:getParent().args) or {}
    config._fargs = fargs
    config._pargs = pargs

    -- Inject argument fetcher into Helpers
    Helpers.bargs = function(key)
        return pargs[key] or fargs[key]
    end

    -- Short-hands
    local bargs     = Helpers.bargs
    local notempty  = Helpers.notempty
    local yes       = Helpers.yes
    local no        = Helpers.no
    local tonumber  = tonumber

    -- ========== Core config parsing ==========
    config.r        = tonumber(fargs.rows) or ''
    config.c        = tonumber(fargs.rounds) or 1
    local maxc      = tonumber(pargs.maxrounds) or tonumber(pargs.maxround) or ''
    config.minc     = tonumber(pargs.minround) or 1
    if notempty(maxc) then config.c = maxc end

    config.autocol    = yes(fargs.autocol)
    config.colspacing = tonumber(fargs['col-spacing']) or 5
    config.height     = bargs('height') or 0

    local bw = (bargs('boldwinner') or ''):lower()
    config.boldwinner        = bw
    config.boldwinner_mode   = 'off'
    config.boldwinner_aggonly = false

    local function yesish(s)
        return s=='y' or s=='yes' or s=='true' or s=='1'
    end

    if bw == 'low' then
        config.boldwinner_mode = 'low'
    elseif bw == 'high' or yesish(bw) then
        config.boldwinner_mode = 'high'
    elseif bw == 'aggregate' or bw == 'agg' or bw == 'aggregate-high' or bw == 'agg-high' then
        config.boldwinner_mode = 'high'
        config.boldwinner_aggonly = true
    elseif bw == 'aggregate-low' or bw == 'agg-low' then
        config.boldwinner_mode = 'low'
        config.boldwinner_aggonly = true
    end

    if yes(bargs('boldwinner-aggregate-only')) then
        config.boldwinner_aggonly = true
    end

    config.forceseeds = yes(bargs('seeds'))
    config.seeds      = not no(bargs('seeds'))

    do
        local aval = (bargs('aggregate') or ''):lower()
        if aval == 'sets' or aval == 'legs' then
            config.aggregate_mode = 'sets'
        elseif aval == 'score' then
            config.aggregate_mode = 'score'
        elseif aval == 'y' or aval == 'yes' or aval == 'true' or aval == '1' then
            config.aggregate_mode = 'manual'
        else
            config.aggregate_mode = 'off'
        end
        config.aggregate = (config.aggregate_mode ~= 'off')
    end

    config.autolegs   = yes(bargs('autolegs'))
    config.paramstyle = (bargs('paramstyle') == 'numbered') and 'numbered' or 'indexed'
    config.nowrap     = not no(pargs.nowrap)
end

return Config