Documentation for this module may be created at Module:CareerList/doc
-- загрузка конфигурационного файла
local config = require('Module:CareerList/config')
-- функция определения ссылки на сайт
local function getSiteLink(site, id)
-- проверка наличия значения в конфигурационном файле
if not config.sites[site] then
error(string.format('Сайт %s не найден в конфигурационном файле', site))
end
-- замена переменной $1 на значение id
local url = config.sites[site].url:gsub('%$1', id)
-- возврат ссылки
return string.format('[[%s|%s]]', url, site)
end
-- функция создания ячейки таблицы
local function makeCell(site, id, alias, notes)
-- определение цвета фона ячейки 1
local bg
if site == 'Studio' then
bg = '#DADADA'
elseif site == 'Website' then
bg = '#E7E7E7'
else
error(string.format('Значение site (%s) должно быть "Studio" или "Website"', site))
end
-- определение значения alias
if alias == '' then
alias = config.sites[site].name
end
-- определение значения notes
if notes == '' then
notes = 'N/A'
end
-- создание ячейки
local cell = string.format('|-\n| style="background-color: %s;" | %s\n| %s\n| %s\n| %s', bg, site, getSiteLink(site, id), alias, notes)
return cell
end
-- экспорт функций
return {
getSiteLink = getSiteLink,
makeCell = makeCell
}