Module:SiteList: 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 createURL(site, id, sceneid)
local function buildRow(site, id, sceneid, alias, notes)
local siteInfo = mw.loadData('Module:SiteDictionary')[site:lower()]
site = string.lower(site) -- приводим имя сайта к нижнему регистру
local site_data = mw.loadData('Module:SiteDictionary')[site]
local link = 'N/A'
if site_data then
if siteInfo then
local url = site_data.base_url

if sceneid then
if sceneid then
url = url .. string.format(site_data.scene_url, sceneid)
link = string.format(siteInfo.sceneFormat, sceneid)
elseif id then
elseif id then
url = url .. string.format(site_data.id_url, id)
link = string.format(siteInfo.idFormat, id)
else
link = siteInfo.defaultLink
end
end

return url
else
return ''
end
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|-', site, link, alias or 'N/A', notes or 'N/A')
end
end


function p.siteList(frame)
function p.siteList(frame)
local args = frame:getParent().args
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:SiteList'})
local site = args.site or ""
local site = args[1]
local id = args.id or ""
local id = args.id
local sceneid = args.sceneid or ""
local sceneid = args.sceneid
local alias = args.alias or mw.title.getCurrentTitle().text
local alias = args.alias
local notes = args.notes or "N/A"
local notes = args.notes
return buildRow(site, id, sceneid, alias, notes)

local url = createURL(site, id, sceneid)

local output = '<tr><td>' .. site .. '</td><td><a href="' .. url .. '">' .. site .. '</a></td><td>' .. alias .. '</td><td>' .. notes .. '</td></tr>'

return output
end
end



Revision as of 17:44, 21 July 2023

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

local p = {}

local function buildRow(site, id, sceneid, alias, notes)
    local siteInfo = mw.loadData('Module:SiteDictionary')[site:lower()]
    local link = 'N/A'
    if siteInfo then
        if sceneid then
            link = string.format(siteInfo.sceneFormat, sceneid)
        elseif id then
            link = string.format(siteInfo.idFormat, id)
        else
            link = siteInfo.defaultLink
        end
    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|-', site, link, alias or 'N/A', notes or 'N/A')
end

function p.siteList(frame)
    local args = frame:getParent().args
    local site = args[1]
    local id = args.id
    local sceneid = args.sceneid
    local alias = args.alias
    local notes = args.notes
    return buildRow(site, id, sceneid, alias, notes)
end

return p