Module:CareerList

From Porn Base Central
Revision as of 01:08, 13 March 2023 by 64.43.50.12 (talk)
Jump to navigation Jump to search

Documentation for this module may be created at Module:CareerList/doc

local p = {}

local function getConfig(site)
    local config = mw.loadData("Module:CareerList/config")
    return config[site]
end

function p.CareerListTop(frame)
    local args = frame.args
    local list = args.list or ""
    local bgcolor = args.bgcolor or "#F2F2F2"
    return string.format([[
        <table class="wikitable" style="background-color:%s;width:100%%;">
            <tr>
                <th>Site</th>
                <th>ID</th>
                <th>Alias</th>
                <th>Notes</th>
            </tr>
            %s
        </table>
    ]], bgcolor, list)
end

function p.CareerList(frame)
    local args = frame.args
    local site = args.site or ""
    local id = args.id or ""
    local alias = args.alias or mw.title.getCurrentTitle().text
    local notes = args.notes or "N/A"
    local config = getConfig(site)
    if not config then
        return ""
    end
    local url = config.url:gsub("%$1", id)
    local bgcolor = config.type == "Studio" and "#DADADA" or "#FFFFFF"
    local color = config.type == "Studio" and "#000000" or "#000000"
    return string.format([[
        <tr style="background-color:%s;color:%s;">
            <td><a href="%s">%s</a></td>
            <td>%s</td>
            <td>%s</td>
            <td>%s</td>
        </tr>
    ]], bgcolor, color, url, config.name, id, alias, notes)
end

return p