Modul:Navbox: Unterschied zwischen den Versionen
apparently none of the test cases test tracking categories. fix a bunch of script errors
(don't use globals) |
(apparently none of the test cases test tracking categories. fix a bunch of script errors) |
||
Zeile 256: | Zeile 256: | ||
-- Tracking categories | -- Tracking categories | ||
-- | -- | ||
local function needsHorizontalLists() | local function needsHorizontalLists() | ||
Zeile 295: | Zeile 274: | ||
end | end | ||
local function getTrackingCategories() | |||
local cats = {} | |||
if needsHorizontalLists() then table.insert(cats, 'Navigational boxes without horizontal lists') end | |||
if hasBackgroundColors() then table.insert(cats, 'Navboxes using background colours') end | |||
return cats | |||
end | |||
local function renderTrackingCategories(builder) | |||
local frame = mw.getCurrentFrame() | |||
if not frame then return end | |||
local s = frame:preprocess('{{#ifeq:{{NAMESPACE}}|{{ns:10}}|1|0}}{{SUBPAGENAME}}') | |||
if mw.ustring.sub(s, 1, 1) == '0' then return end -- not in template space | |||
local subpage = mw.ustring.lower(mw.ustring.sub(s, 2)) | |||
if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end | |||
for i, cat in ipairs(getTrackingCategories()) do | |||
builder.wikitext('[[Category:' .. cat .. ']]') | |||
end | |||
end | |||
-- | -- |