Module:SiteList: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
PeaceDeadC (talk | contribs) No edit summary Tag: Reverted |
PeaceDeadC (talk | contribs) No edit summary Tags: Manual revert Reverted |
||
| Line 5: | Line 5: | ||
local siteType = args[1] or '' |
local siteType = args[1] or '' |
||
local site = args['site'] or '' |
local site = args['site'] or '' |
||
local id = args['id |
local id = args['id'] or '' |
||
local sceneid = |
local sceneid = args['sceneid'] or '' |
||
local alias = args['alias'] or '' |
local alias = args['alias'] or '' |
||
local notes = args['notes'] or 'N/A' |
local notes = args['notes'] or 'N/A' |
||
| Line 40: | Line 40: | ||
local title = mw.title.getCurrentTitle() |
local title = mw.title.getCurrentTitle() |
||
local category = '' |
local category = '' |
||
if title.namespace == 0 |
if title.namespace == 0 then |
||
category = '[[Category:Website' .. siteInfo.id .. ' models]]' |
category = '[[Category:Website' .. siteInfo.id .. ' models]]' |
||
end |
end |
||
Revision as of 13:29, 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 title = mw.title.getCurrentTitle()
local category = ''
if title.namespace == 0 then
category = '[[Category:Website' .. siteInfo.id .. ' models]]'
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>
%s
]], backgroundColor, typeText, websiteText, alias ~= '' and alias or mw.title.getCurrentTitle().text, notes, category)
return result
end
return p