Module:CareerList: Difference between revisions

From Porn Base Central
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
local p = {}
local p = {}


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

function p.CareerListTop(frame)
local args = frame.args
local args = frame.args
local list = args.list or ""
local list = args.list or ""
local bgcolor = args.bgcolor or "#F2F2F2"
local bgColor = args.bgColor or "#F2F2F2"
local html = mw.html.create()
return string.format([[

<table class="wikitable" style="background-color:%s;width:100%%;">
<tr>
html:tag("div")
:css("background-color", bgColor)
<th>Site</th>
:wikitext("{| class=\"wikitable career-list\"")
<th>ID</th>
<th>Alias</th>
:wikitext("\n|-" .. "\n!")
<th>Notes</th>
:wikitext(list)
</tr>
:wikitext("\n|}")

%s
return tostring(html)
</table>
]], bgcolor, list)
end
end


function p.CareerList(frame)
function p.createCareerList(frame)
local args = frame.args
local args = frame.args
local site = args.site or ""
local site = args.site or ""
Line 29: Line 23:
local alias = args.alias or mw.title.getCurrentTitle().text
local alias = args.alias or mw.title.getCurrentTitle().text
local notes = args.notes or "N/A"
local notes = args.notes or "N/A"
local config = getConfig(site)
local html = mw.html.create()

if not config then
local config = mw.loadData("Module:CareerList/Config")
return ""

local url = config[site].url or ""
url = url:gsub("%$1", id)

local bgColor = "#FFFFFF"
if config[site].type == "Studio" then
bgColor = "#DADADA"
elseif config[site].type == "Website" then
bgColor = "#E7E7E7"
end
end

local url = config.url:gsub("%$1", id)
html:tag("tr")
local bgcolor = config.type == "Studio" and "#DADADA" or "#FFFFFF"
:css("background-color", bgColor)
local color = config.type == "Studio" and "#000000" or "#000000"
:tag("td")
return string.format([[
:wikitext(config[site].name or "")
<tr style="background-color:%s;color:%s;">
<td><a href="%s">%s</a></td>
:wikitext(": ")
<td>%s</td>
:tag("a")
<td>%s</td>
:attr("href", url)
<td>%s</td>
:wikitext(alias)
</tr>
:done()
:tag("td")
]], bgcolor, color, url, config.name, id, alias, notes)
:wikitext(notes)
:done()

return tostring(html)
end
end



Revision as of 01:28, 13 March 2023

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

local p = {}

function p.createCareerListTop(frame)
    local args = frame.args
    local list = args.list or ""
    local bgColor = args.bgColor or "#F2F2F2"
    local html = mw.html.create()

    html:tag("div")
        :css("background-color", bgColor)
        :wikitext("{| class=\"wikitable career-list\"")
        :wikitext("\n|-" .. "\n!")
        :wikitext(list)
        :wikitext("\n|}")

    return tostring(html)
end

function p.createCareerList(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 html = mw.html.create()

    local config = mw.loadData("Module:CareerList/Config")

    local url = config[site].url or ""
    url = url:gsub("%$1", id)

    local bgColor = "#FFFFFF"
    if config[site].type == "Studio" then
        bgColor = "#DADADA"
    elseif config[site].type == "Website" then
        bgColor = "#E7E7E7"
    end

    html:tag("tr")
        :css("background-color", bgColor)
        :tag("td")
            :wikitext(config[site].name or "")
            :wikitext(": ")
            :tag("a")
                :attr("href", url)
                :wikitext(alias)
        :done()
        :tag("td")
            :wikitext(notes)
        :done()

    return tostring(html)
end

return p