Module:SiteList

From Porn Base Central
Revision as of 16:35, 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 = {}

function p.list(frame)
    local args = frame:getParent().args
    local siteType = args[1] or ''
    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 'N/A'

    -- Создаем словарь соответствий для сайтов
    local siteData = mw.loadData('Module:SiteDictionary') 
    local siteInfo = siteData[site]

    local websiteText = "None"
    if siteInfo then
        websiteText = string.format(
            siteInfo.template,
            sceneid ~= '' and sceneid or id ~= '' and id or '',
            siteInfo.name
        )
    end

    -- Выбираем тип и форматируем данные
    local typeText = ''
    local backgroundColor = ''

    if string.lower(siteType) == 'website' then
        typeText = 'Website'
        backgroundColor = '#E7E7E7'
    elseif string.lower(siteType) == 'studio' then
        typeText = 'Studio'
        backgroundColor = '#DADADA'
    else
        typeText = siteType
    end

    -- Строим результат
    local result = string.format([[
        |-
        | style="text-align:center;vertical-align:middle; background-color:%s;text-align:center;color:black" | '''%s'''
        | style="text-align:center;vertical-align:middle;" | %s
        | style="text-align:center;vertical-align:middle;" | %s
        | style="text-align:center;vertical-align:middle;" | <small>%s</small>
    ]], backgroundColor, typeText, websiteText, alias ~= '' and alias or mw.title.getCurrentTitle().text, notes)

    return result
end

return p