Documentation for this module may be created at Module:CareerList/doc
local p = {} local cfg = mw.loadData('Module:CareerList/config') local function getSiteLink(site) site = mw.ustring.lower(site) local url = cfg[site].url or '' local id = cfg[site].id or '' return url:gsub('$1', id) end local function makeCell(args, bgcolor) local site = args.site or '' local id = args.id or '' local alias = args.alias or mw.title.getCurrentTitle().text local notes = args.notes or 'N/A' local link = string.format("[%s %s]", site, alias or pagename or "N/A") local bg = (site == 'Website') and '#E7E7E7' or '#DADADA' local rowbg = (bgcolor == '#FFFFFF') and '#F3F3F3' or '#FFFFFF' return string.format([[ <tr style="background-color: %s;"> <td style="background-color: %s;">%s</td> <td style="background-color: %s;"><a href="%s">%s</a></td> <td>%s</td> <td>%s</td> </tr> ]], bgcolor, bg, site, rowbg, link, alias, alias, notes) end function p.main(frame) local args = frame.args local list = args.list or '' local title = args.title or '' local bgcolor = '#F2F2F2' local rows = '' for row in mw.ustring.gmatch(list, '{{CareerListCell(.-)}}') do rows = rows .. makeCell(mw.text.split(row, '|'), bgcolor) bgcolor = (bgcolor == '#FFFFFF') and '#F3F3F3' or '#FFFFFF' end return string.format([[ <table class="wikitable" style="width: 100%; margin: 1em 0; background-color: %s;"> <caption>%s</caption> <tr> <th style="width: 15%;">Type</th> <th style="width: 35%;">Name</th> <th style="width: 35%;">Alias</th> <th style="width: 15%;">Notes</th> </tr> %s </table> ]], bgcolor, title, rows) end return p