Module:Protection banner: Difference between revisions

    (change category table scheme)
    (add a (very) preliminary sketch of what the main function might look like)
    Line 154: Line 154:
    }
    }
    }
    }
    --------------------------------------------------------------------------------
    -- Main functions
    --------------------------------------------------------------------------------
    local getArgs = require('Module:Arguments').getArgs
    local yesno = require('Module:Yesno')
    local p = {}
    function p.main(frame)
    -- Get data
    local args = getArgs(frame)
    local title = p.getTitle(args.page)
    local protType, protLevel = p.getProtectionStatus(title)
    local namespace = p.getNamespace(title)
    local expiry = p.getExpiry(args.expiry)
    local reason = p.getReason(args.reason)
    -- Sort categories and build a category link with the best match
    categories = p.sortCategories(categories, protType, protLevel, namespace, expiry, reason)
    local category = categories[1].name
    category = string.format('[[Category:%s]]', category)
    -- Find whether we are small or not and output a padlock or a banner as appropriate
    local isSmall = yesno(args.small, true)
    if isSmall then
    return p.exportPadlock()
    else
    return p.exportBanner()
    end
    end
    return p