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 siteDB = require('Module:SiteDatabase')


-- Создаем таблицу сайтов
function p.siteList(frame)
local sites = {
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:SiteList'})
website1 = {
url = 'https://website1.com/',
updatesUrl = 'https://website1.com/updates/',
modelsUrl = 'https://website1.com/models/',
category = 'Network1',
},
website2 = {
url = 'https://website2.com/',
updatesUrl = 'https://website2.com/scene/',
modelsUrl = 'https://website2.com/people/',
category = 'Network2',
},
website3 = {
url = 'https://website3.com/',
updatesUrl = 'https://website3.com/videos/',
modelsUrl = 'https://website3.com/performers/',
category = 'Network3',
},
-- Добавьте больше сайтов здесь по необходимости
}


-- Функция для обработки каждого сайта
local site = args.site
function p.site(frame)
local id = args.id or ''
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:SiteList'})
local sceneid = args.sceneid or ''
local alias = args.alias or mw.title.getCurrentTitle().text
local site = args.site and sites[args.site:lower()]
local notes = args.notes or 'N/A'


local siteData = siteDB.sites[site]
if site then
local url = site.url
if args.id then
url = site.modelsUrl .. args.id .. '.html'
elseif args.sceneid then
url = site.updatesUrl .. args.sceneid .. '.html'
end


local alias = args.alias or mw.title.getCurrentTitle().text
if siteData then
local url = siteData.default_url
local notes = args.notes or 'N/A'
if id ~= '' then
url = siteData.model_url:gsub('MODEL_ID', id)
elseif sceneid ~= '' then
url = siteData.scene_url:gsub('SCENE_ID', sceneid)
end
local link = '[' .. url .. ' ' .. site .. '] <small>(' .. siteData.category .. ')</small>'


local result = string.format(
if mw.title.getCurrentTitle().namespace == 0 then
'|-\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',
link = link .. siteData.model_category
args[1] == 'Studio' and 'Studio' or 'Website',
end
string.format('[%s %s] <small>([[:Category:%s|%s]])</small>', url, args.site, site.category, site.category),
alias,
notes
)


-- Добавление в категории в зависимости от пространства имен
return link
local ns = mw.title.getCurrentTitle().namespace
else
if ns == 0 then
return 'None'
table.insert(result, '[[Category:Articles in the mainspace using Template:SiteList]]')
end
elseif ns == 2 then
table.insert(result, '[[Category:Articles in the userspace using Template:SiteList]]')
elseif ns == 118 then
table.insert(result, '[[Category:Drafts using Template:SiteList]]')
end

return result
else
return mw.text.nowiki('{{SiteList}}') .. ' Error: invalid site parameter'
end
end
end



Revision as of 23:18, 21 July 2023

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

local p = {}

-- Создаем таблицу сайтов
local sites = {
    website1 = {
        url = 'https://website1.com/',
        updatesUrl = 'https://website1.com/updates/',
        modelsUrl = 'https://website1.com/models/',
        category = 'Network1',
    },
    website2 = {
        url = 'https://website2.com/',
        updatesUrl = 'https://website2.com/scene/',
        modelsUrl = 'https://website2.com/people/',
        category = 'Network2',
    },
    website3 = {
        url = 'https://website3.com/',
        updatesUrl = 'https://website3.com/videos/',
        modelsUrl = 'https://website3.com/performers/',
        category = 'Network3',
    },
    -- Добавьте больше сайтов здесь по необходимости
}

-- Функция для обработки каждого сайта
function p.site(frame)
    local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:SiteList'})
    local site = args.site and sites[args.site:lower()]

    if site then
        local url = site.url
        if args.id then
            url = site.modelsUrl .. args.id .. '.html'
        elseif args.sceneid then
            url = site.updatesUrl .. args.sceneid .. '.html'
        end

        local alias = args.alias or mw.title.getCurrentTitle().text
        local notes = args.notes or 'N/A'

        local result = 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',
            args[1] == 'Studio' and 'Studio' or 'Website',
            string.format('[%s %s] <small>([[:Category:%s|%s]])</small>', url, args.site, site.category, site.category),
            alias,
            notes
        )

        -- Добавление в категории в зависимости от пространства имен
        local ns = mw.title.getCurrentTitle().namespace
        if ns == 0 then
            table.insert(result, '[[Category:Articles in the mainspace using Template:SiteList]]')
        elseif ns == 2 then
            table.insert(result, '[[Category:Articles in the userspace using Template:SiteList]]')
        elseif ns == 118 then
            table.insert(result, '[[Category:Drafts using Template:SiteList]]')
        end

        return result
    else
        return mw.text.nowiki('{{SiteList}}') .. ' Error: invalid site parameter'
    end
end

return p