Documentation for this module may be created at Module:CareerList/doc
local p = {}
function p.CareerList(frame)
local args = frame.args
local site = string.lower(args.site or '')
local id = args.id or ''
local alias = args.alias or args[1] or ''
local notes = args.notes or 'N/A'
-- получаем конфигурацию сайтов
local sites = mw.loadData('Module:CareerList/config')
local siteData = sites[site]
if not siteData then
return ''
end
-- заменяем переменную $1 в URL на значение id
local url = siteData.url:gsub('%$1', id)
-- формируем ссылку
local link = string.format('[%s %s]', url, args.site or '')
-- формируем ячейки таблицы
local cells = {
siteData.label,
link,
alias,
notes
}
-- возвращаем сформированную строку таблицы
return string.format('|-\n| %s || %s || %s || %s', unpack(cells))
end
function p.CareerListTop(frame)
local args = frame.args
local list = args.list or ''
local width = args.width or '100%'
return string.format([=[
<div style="width: %s">
<table style="width: 100%%; table-layout: fixed">
<caption>%s</caption>
<thead>
<tr>
<th scope="col">Категория</th>
<th scope="col">Ссылка</th>
<th scope="col">Псевдоним</th>
<th scope="col">Заметки</th>
</tr>
</thead>
<tbody>
%s
</tbody>
</table>
</div>]=], width, args.title or '', list)
end
return p