Module:SiteList

From Porn Base Central
Revision as of 18:07, 21 July 2023 by PeaceDeadC (talk | contribs)
Jump to navigation Jump to search

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

local p = {}

local function buildRow(siteType, site, id, sceneid, alias, notes)
    local siteInfo = mw.loadData('Module:SiteDictionary')[site:lower()]
    local link = 'N/A'
    local siteLabel = 'N/A'
    if siteInfo then
        if sceneid and sceneid ~= '' then
            link = string.format(siteInfo.sceneFormat, sceneid)
        elseif id and id ~= '' then
            link = string.format(siteInfo.idFormat, id)
        else
            link = siteInfo.defaultLink
        end
        siteLabel = string.format("[%s %s]", link, siteInfo.name)
    end

    return string.format('|-\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n', siteType, siteLabel, alias or 'N/A', notes or 'N/A')
end

function p.siteList(frame)
    local args = frame:getParent().args
    local siteType = args[1]
    local site = args.site or ''
    local id = args.id or ''
    local sceneid = args.sceneid or ''
    local alias = args.alias or ''
    local notes = args.notes or ''

    return buildRow(siteType, site, id, sceneid, alias, notes)
end

return p