Module:CareerList
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)
local id = args.id or ''
local alias = args.alias or args[1]
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)
-- формируем ячейки таблицы
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 ''
return string.format([=[
<div class="mw-parser-output"><table class="wikitable career-list" style="width:100%%;">
<caption>%s</caption>
<thead>
<tr>
<th>Категория</th>
<th>Ссылка</th>
<th>Псевдоним</th>
<th>Заметки</th>
</tr>
</thead>
<tbody>%s</tbody></table></div>]=], args.title or '', list)
end
return p