Module:SiteList: Difference between revisions

1,481 bytes added ,  23 July 2023
no edit summary
No edit summary
No edit summary
Tag: Reverted
end
 
return result{
style = style,
siteType = siteType and siteType:gsub("^%l", string.upper) or 'Website',
linkOrLabel = linkOrLabel,
categoryLink = categoryLink,
alias = alias,
notes = notes,
additionalInfo = result -- ваш код для добавления информации категории
}
else
return string.format('|-\n| colspan="4" style="text-align:center;vertical-align:middle;color:red;font-weight:bold;" | Error: invalid site parameter: %s. See [[PBC:SiteList|PBC:SiteList for documentation]] \n| style="width: 0px; padding: 0px; border: none;" |\n', args.site)
end
end
 
function p.siteList(frame)
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:SiteListTop'})
local sites = {}
for i, site in ipairs(args.list) do
local siteData = p.site({args = {site = site}})
if siteData then
table.insert(sites, siteData)
end
end
-- Сортируем массив сайтов по linkOrLabel
table.sort(sites, function(a, b) return a.linkOrLabel < b.linkOrLabel end)
-- Создаем итоговую строку
local result = ''
for _, site in ipairs(sites) do
result = result .. string.format(
'|-\n| style="%s" | %s\n| style="text-align:center;vertical-align:middle;" | %s%s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="width: 0px; padding: 0px; border: none;" |\n',
site.style,
site.siteType,
site.linkOrLabel,
site.categoryLink,
site.alias,
site.notes
) .. site.additionalInfo
end
return result
end