Module:SiteList: Difference between revisions

From Porn Base Central
Jump to navigation Jump to search
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
Line 35: Line 35:
else
else
typeText = siteType
typeText = siteType
end

-- Проверяем пространство имен и добавляем категорию
local title = mw.title.getCurrentTitle()
local category = ''
if title.namespace == 0 and siteInfo and siteInfo.id then
category = '[[Category:Website' .. siteInfo.id .. ' models]]'
end
end


Line 51: Line 44:
| 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>
| style="text-align:center;vertical-align:middle;" | <small>%s</small>
]], backgroundColor, typeText, websiteText, alias ~= '' and alias or mw.title.getCurrentTitle().text, notes)
%s
]], backgroundColor, typeText, websiteText, alias ~= '' and alias or mw.title.getCurrentTitle().text, notes, category)


return result
return result

Revision as of 16:35, 21 July 2023

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