Module:CareerList: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
PeaceDeadC (talk | contribs) No edit summary Tag: Manual revert |
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 or '') |
||
local id = args.id or '' |
local id = args.id or '' |
||
local alias = args.alias or args[1] |
local alias = args.alias or args[1] or '' |
||
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 or '') |
||
-- формируем ячейки таблицы |
-- формируем ячейки таблицы |
||
| 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: %s"> |
|||
{| class="wikitable" |
|||
<table style="width: 100%%; table-layout: fixed"> |
|||
|+ %s |
|||
<caption>%s</caption> |
|||
| ⚫ | |||
<thead> |
|||
! Ссылка |
|||
<tr> |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
<th scope="col">Ссылка</th> |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
%s |
|||
</tbody> |
|||
</table> |
|||
| ⚫ | |||
end |
end |
||
Revision as of 18:52, 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 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