Module:CareerList: Difference between revisions
Jump to navigation
Jump to search
PeaceDeadC (talk | contribs) No edit summary |
PeaceDeadC (talk | contribs) No edit summary |
||
Line 3: | Line 3: | ||
function p.CareerList(frame) |
function p.CareerList(frame) |
||
local args = frame.args |
local args = frame.args |
||
local site = string.lower(args.site |
local site = string.lower(args.site) |
||
local id = args.id or '' |
local id = args.id or '' |
||
local alias = args.alias or args[1] |
local alias = args.alias or args[1] |
||
local notes = args.notes or 'N/A' |
local notes = args.notes or 'N/A' |
||
Line 20: | Line 20: | ||
-- формируем ссылку |
-- формируем ссылку |
||
local link = string.format('[%s %s]', url, args.site |
local link = string.format('[%s %s]', url, args.site) |
||
-- формируем ячейки таблицы |
-- формируем ячейки таблицы |
||
Line 37: | Line 37: | ||
local args = frame.args |
local args = frame.args |
||
local list = args.list or '' |
local list = args.list or '' |
||
local width = args.width or '100%' |
|||
return string.format([=[ |
return string.format([=[ |
||
<div style="width: |
<div class="mw-parser-output"><table class="wikitable career-list" style="width:100%%;"> |
||
<table style="width: 100%%; table-layout: fixed"> |
|||
<caption>%s</caption> |
<caption>%s</caption> |
||
<thead> |
<thead> |
||
<tr> |
<tr> |
||
<th |
<th>Категория</th> |
||
<th |
<th>Ссылка</th> |
||
<th |
<th>Псевдоним</th> |
||
<th |
<th>Заметки</th> |
||
</tr> |
</tr> |
||
</thead> |
</thead> |
||
⚫ | |||
<tbody> |
|||
%s |
|||
</tbody> |
|||
</table> |
|||
⚫ | |||
end |
end |
||
Revision as of 21:59, 12 March 2023
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