Module:SiteList: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
PeaceDeadC (talk | contribs) Created page with "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[si..." |
PeaceDeadC (talk | contribs) No edit summary Tag: Reverted |
||
| Line 35: | Line 35: | ||
else |
else |
||
typeText = siteType |
typeText = siteType |
||
end |
|||
-- Проверяем пространство имен и добавляем категорию |
|||
local title = mw.title.getCurrentTitle() |
|||
local category = '' |
|||
if title.namespace == 0 then |
|||
category = '[[Category:Website' .. siteInfo.id .. ' models]]' |
|||
end |
end |
||
| Line 44: | Line 51: | ||
| 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> |
||
%s |
|||
]], backgroundColor, typeText, websiteText, alias ~= '' and alias or mw.title.getCurrentTitle().text, notes) |
]], backgroundColor, typeText, websiteText, alias ~= '' and alias or mw.title.getCurrentTitle().text, notes, category) |
||
return result |
return result |
||
Revision as of 13:22, 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