Module:SiteListModule

From Porn Base Central
Revision as of 23:14, 21 July 2023 by PeaceDeadC (talk | contribs) (Created page with "local p = {} local websites = { website1 = { url = "https://website1.com", modelPath = "/models/", updatePath = "/updates/", defaultPath = "", category = "Network1" }, website2 = { url = "https://website2.com", modelPath = "/people/", updatePath = "/scene/", defaultPath = "", category = "Network2" }, website3 = { url =...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

local p = {}

local websites = {
    website1 = {
        url = "https://website1.com",
        modelPath = "/models/",
        updatePath = "/updates/",
        defaultPath = "",
        category = "[[:Category:Network1|Network1]]"
    },
    website2 = {
        url = "https://website2.com",
        modelPath = "/people/",
        updatePath = "/scene/",
        defaultPath = "",
        category = "[[:Category:Network2|Network2]]"
    },
    website3 = {
        url = "https://website3.com",
        modelPath = "/performers/",
        updatePath = "/videos/",
        defaultPath = "",
        category = "[[:Category:Network3|Network3]]"
    }
}

function p.site(frame)
    local siteKey = frame.args.site
    local id = frame.args.id or ""
    local sceneid = frame.args.sceneid or ""
    local alias = frame.args.alias or ""
    local notes = frame.args.notes or "N/A"

    if websites[siteKey] then
        local site = websites[siteKey]
        local siteURL = ""

        if id and sceneid then
            siteURL = site.url .. site.updatePath .. sceneid .. ".html"
        elseif id then
            siteURL = site.url .. site.modelPath .. id .. ".html"
        else
            siteURL = site.url
        end

        return string.format('[%s %s] <small>(%s)</small>', siteURL, siteKey, site.category)
    else
        return "None"
    end
end

function p.addCategory(frame)
    local namespace = mw.title.getCurrentTitle().namespace
    local category = ""
    if namespace == 0 then -- mainspace
        category = "[[Category:Articles in the mainspace using Template:SiteList]]"
    elseif namespace == 2 then -- userspace
        category = "[[Category:Articles in the userspace using Template:SiteList]]"
    elseif namespace == 118 then -- draft
        category = "[[Category:Drafts using Template:SiteList]]"
    end

    return category
end

return p