Module:SiteList: Difference between revisions

From Porn Base Central
Jump to navigation Jump to search
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 2: Line 2:


local function buildRow(siteType, site, id, sceneid, alias, notes)
local function buildRow(siteType, site, id, sceneid, alias, notes)
local siteInfo = mw.loadData('Module:SiteDictionary')[site:lower()]
local siteInfo = SiteDictionary[site]
local link = 'N/A'
local link
local siteLabel = 'N/A'


if siteInfo then
if sceneid ~= '' then
-- проверка наличия sceneid
link = string.format(siteInfo.sceneFormat, sceneid)
if sceneid ~= "" then
elseif id ~= '' then
link = string.format(siteInfo.sceneFormat, sceneid)
link = string.format(siteInfo.idFormat, id)
-- если sceneid нет, проверка наличия id
elseif id ~= "" then
link = string.format(siteInfo.idFormat, id)
-- если нет и sceneid, и id, использование defaultLink
else
link = siteInfo.defaultLink
end
-- форматирование ссылки для вывода
siteLabel = string.format("[%s %s]", link, siteInfo.name)
else
else
siteLabel = siteType
link = siteInfo.defaultLink
end
end


return string.format('|-\n| %s || [ %s %s] || %s || %s || %s\n',
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')
siteType, link, siteInfo.name, alias, sceneid, notes)
end
end


Line 30: Line 21:
local siteType = args[1] or 'N/A'
local siteType = args[1] or 'N/A'
local site = args.site or 'N/A'
local site = args.site or 'N/A'
-- обработка id и sceneid как отдельных ключей и значений
local id = args.id or ''
local id = args.id or ''
local sceneid = args.sceneid or ''
local sceneid = args.sceneid or ''

Revision as of 19:24, 21 July 2023

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

local p = {}

local function buildRow(siteType, site, id, sceneid, alias, notes)
    local siteInfo = SiteDictionary[site]
    local link

    if sceneid ~= '' then
        link = string.format(siteInfo.sceneFormat, sceneid)
    elseif id ~= '' then
        link = string.format(siteInfo.idFormat, id)
    else
        link = siteInfo.defaultLink
    end

    return string.format('|-\n| %s || [ %s %s] || %s || %s || %s\n', 
        siteType, link, siteInfo.name, alias, sceneid, notes)
end

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

return p