Content deleted Content added
neither of these fixed it Tags: Manual revert Reverted |
keep trying i guess with this revert? Tag: Reverted |
||
Line 1:
--
-- This module implements {{Navbox}}
--
local p = {}
local navbar = require('Module:Navbar')._navbar
local getArgs -- lazily initialized
local cfg = mw.loadData('Module:Navbox/configuration')
local args
local
local listnums
local ODD_EVEN_MARKER = '\127_ODDEVEN_\127'
local RESTART_MARKER = '\127_ODDEVEN0_\127'
local REGEX_MARKER = '\127_ODDEVEN(%d?)_\127'
local function striped(wikitext
-- Return wikitext with markers replaced for odd/even striping.
-- Child (subgroup) navboxes are flagged with a category that is removed
-- by parent navboxes. The result is that the category shows all pages
-- where a child navbox is not contained in a parent navbox.
if border == cfg.keyword.border_subgroup and args[cfg.arg.orphan] ~= cfg.keyword.orphan_yes then
-- No change; striping occurs in outermost navbox.
return wikitext .. cfg.category.orphan
end
local first, second =
if args[cfg.arg.evenodd] then
if args[cfg.arg.evenodd] == cfg.keyword.evenodd_swap then
Line 30 ⟶ 39:
else
local index = 0
changer = function (code) -- where is code set???
if code == '0' then
-- Current occurrence is for a group before a nested table.
Line 44 ⟶ 53:
end
local regex = cfg.category.orphan:gsub('([%[%]])', '%%%1')
return (wikitext:gsub(regex, ''):gsub(REGEX_MARKER, changer)) -- () omits gsub count
end
Line 59 ⟶ 67:
local prefix, content = line:match('^([*:;#]+)%s*(.*)')
if prefix and not content:match(cfg.pattern.nowrap) then
line = mw.ustring.format(cfg.nowrap_item, prefix, content)
end
table.insert(lines, line)
Line 72 ⟶ 80:
local function renderNavBar(titleCell)
if args[cfg.arg.navbar] ~= cfg.keyword.navbar_off and
(args[cfg.arg.name] and not mw.getCurrentFrame():getParent():getTitle():gsub(cfg.pattern.sandbox, '') == cfg.pattern.navbox) then
titleCell:wikitext(navbar{
args[cfg.arg.name],
[cfg.navbar.mini] = 1,
[cfg.navbar.fontstyle] = (args[cfg.arg.basestyle] or '') .. ';' ..
(args[cfg.arg.titlestyle] or '') ..
';background:none transparent;border:none;box-shadow:none;padding:0;'
})
end
Line 88 ⟶ 95:
end
--
-- Title row
--
local function renderTitleRow(tbl)
if not args[cfg.arg.title] then return end
Line 135 ⟶ 145:
:wikitext(processItem(args[cfg.arg.title]))
end
--
-- Above/Below rows
--
local function getAboveBelowColspan()
Line 155 ⟶ 169:
:tag('div')
-- id for aria-labelledby attribute, if no title
:attr('id', args[cfg.arg.title] and nil or mw.uri.anchorEncode(args[cfg.arg.above]))
:wikitext(processItem(args[cfg.arg.above], args[cfg.arg.nowrapitems]))
end
Line 176 ⟶ 187:
end
--
-- List rows
--
local function renderListRow(tbl, index, listnum)
local row = tbl:tag('tr')
Line 183 ⟶ 197:
:tag('td')
:addClass(cfg.class.noviewer)
:addClass(cfg.class.
:addClass(args[cfg.arg.imageclass])
:css('width', '1px') -- Minimize width
:css('padding', '0 2px 0 0')
:cssText(args[cfg.arg.imageleftstyle])
:attr('rowspan',
:tag('div')
:wikitext(processItem(args[cfg.arg.imageleft]))
end
local groupCell = row:tag('th')
-- id for aria-labelledby attribute, if lone group with no title or above
if listnum == 1 and not (args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group2]) then
groupCell
:attr('id', mw.uri.anchorEncode(args[cfg.arg.group1]))
Line 210 ⟶ 221:
:addClass(args[cfg.arg.groupclass])
:cssText(args[cfg.arg.basestyle])
:css('width', args[cfg.arg.groupwidth] or '1%') -- If groupwidth not specified, minimize width
groupCell
:cssText(args[cfg.arg.groupstyle])
:cssText(args[
:wikitext(args[
end
local listCell = row:tag('td')
if args[
listCell
:css('text-align', 'left')
Line 241 ⟶ 251:
end
local
local oddEven = ODD_EVEN_MARKER
if listText:sub(1, 12) == '</div><table' then
-- Assume list text is for a subgroup navbox so no
oddEven = listText:find(cfg.pattern.navbox_title) and RESTART_MARKER or cfg.class.navbox_odd_part
end
listCell
Line 255 ⟶ 261:
:cssText(args[cfg.arg.liststyle])
:cssText(rowstyle)
:cssText(args[
:addClass(cfg.class.navbox_list)
:addClass(
:addClass(args[cfg.arg.listclass])
:addClass(args[
:tag('div')
:css('padding', (index == 1 and args[cfg.arg.list1padding]) or args[cfg.arg.listpadding] or '0 0.25em')
:wikitext(processItem(listText, args[cfg.arg.nowrapitems]))
Line 274 ⟶ 276:
:addClass(cfg.class.navbox_image)
:addClass(args[cfg.arg.imageclass])
:css('width', '1px') -- Minimize width
:css('padding', '0 0 0 2px')
:cssText(args[cfg.arg.imagestyle])
:attr('rowspan',
:tag('div')
:wikitext(processItem(args[cfg.arg.image]))
Line 283 ⟶ 285:
end
--
-- Tracking categories
--
local function needsHorizontalLists()
if border == cfg.keyword.border_subgroup or args[cfg.arg.tracking] == cfg.keyword.tracking_no then
return false
end
-- FIXME: These should be finding the classes in list_classes, not looking for equality.
end
local function hasBackgroundColors()
for _, key in ipairs(
cfg.arg.basestyle, cfg.arg.abovestyle, cfg.arg.belowstyle}) do
if tostring(args[key]):find('background', 1, true) then
return true
Line 301 ⟶ 308:
local function hasBorders()
for _, key in ipairs(
cfg.arg.abovestyle, cfg.arg.belowstyle}) do
if tostring(args[key]):find('border', 1, true) then
return true
Line 321 ⟶ 329:
end
local function getTrackingCategories(
local cats = {}
if needsHorizontalLists(
if isIllegible() then table.insert(cats, cfg.category.illegible) end
if hasBorders() then table.insert(cats, cfg.category.borders) end
Line 334 ⟶ 338:
end
local function renderTrackingCategories(builder
local title = mw.title.getCurrentTitle()
if title.namespace ~= 10 then return end -- not in template space
local subpage = title.subpageText
if subpage == cfg.keyword.subpage_doc or subpage == cfg.keyword.subpage_sandbox
or subpage == cfg.keyword.
for _, cat in ipairs(getTrackingCategories(
builder:wikitext('[[Category:' .. cat .. ']]')
end
end
--
-- Main navbox tables
--
local function renderMainTable()
local tbl = mw.html.create('table')
:addClass(cfg.class.nowraplinks)
:addClass(args[cfg.arg.bodyclass])
if args[cfg.arg.title] and (args[cfg.arg.state] ~= cfg.keyword.state_plain and
tbl
:addClass(cfg.class.collapsible)
Line 366 ⟶ 367:
tbl:css('border-spacing', 0)
if border == cfg.keyword.border_subgroup or border == cfg.keyword.border_none then
tbl
:addClass(cfg.class.navbox_subgroup)
:cssText(args[cfg.arg.bodystyle])
:cssText(args[cfg.arg.style])
else -- regular navbox - bodystyle and style will
tbl
:addClass(cfg.class.navbox_inner)
Line 382:
renderTitleRow(tbl)
renderAboveRow(tbl)
for i, listnum in ipairs(listnums) do
renderListRow(tbl, i, listnum
end
renderBelowRow(tbl)
Line 393 ⟶ 392:
function p._navbox(navboxArgs)
args = navboxArgs
for k, _ in pairs(args) do
Line 403 ⟶ 402:
table.sort(listnums)
if border == cfg.keyword.border_child then
border = cfg.keyword.border_subgroup
Line 409 ⟶ 408:
-- render the main body of the navbox
local tbl = renderMainTable(
-- render the appropriate wrapper around the navbox, depending on the border param
local res = mw.html.create()
if border == cfg.keyword.border_none then
Line 418 ⟶ 417:
:node(tbl)
-- aria-labelledby title, otherwise above, otherwise lone group
if args[cfg.arg.title] or args[cfg.arg.above] or (args[cfg.arg.group1] and not args[cfg.arg.group2]) then
else
nav:attr('aria-label', cfg.aria_label)
end
elseif border == cfg.keyword.border_subgroup then
-- We assume that this navbox is being rendered in a list cell of a parent navbox, and is
--
--
res
:wikitext('</div>')
Line 449 ⟶ 440:
:node(tbl)
-- aria-labelledby title, otherwise above, otherwise lone group
if args[cfg.arg.title] or args[cfg.arg.above] or (args[cfg.arg.group1] and not args[cfg.arg.group2]) then
else
nav:attr('aria-label', cfg.aria_label)
Line 463 ⟶ 447:
end
if (args[cfg.arg.nocat] or cfg.keyword.nocat_false):lower() == cfg.keyword.nocat_false then
renderTrackingCategories(res)
end
return striped(tostring(res
end
Line 474 ⟶ 457:
getArgs = require('Module:Arguments').getArgs
end
args = getArgs(frame
-- Read the arguments in the order they'll be output in, to make references number in the right order.
local _
_ = args[cfg.arg.title]
_ = args[cfg.arg.above]
for i = 1, 20 do
_ = args[
_ = args[
end
_ = args[cfg.arg.below]
|