Content deleted Content added
Disable removal of wikilinks per discussion |
minor clean + fix "Lua error in Module:Episode_list at line 324: attempt to compare nil with number" at Go! Go! Itsutsugo Land due to episode 26 |
||
Line 1:
local p = {}
Line 6 ⟶ 5:
local htmlColor = mw.loadData('Module:Color contrast/colors')
local delinkModule = require('Module:Delink')
local langModule = require("Module:Lang")
local mathModule = require('Module:Math')
local tableEmptyCellModule = require('Module:Table empty cell')
Line 19 ⟶ 18:
-- Variable that will keep track if a TBA value was entered.
local cellValueTBA = false
-- Variable that handles the assigned tracking categories.
local trackingCategories = ""
Line 28 ⟶ 27:
["alt_air_dates"] = "[[Category:Episode lists with incorrectly formatted alternate air dates]]",
["faulty_line_colors"] = "[[Category:Episode lists with faulty line colors]]",
["
["default_line_colors"] = "[[Category:Episode list using the default LineColor]]",
["row_deviations"] = "[[Category:Episode lists with row deviations]]",
Line 52 ⟶ 51:
-- List of cells that have parameter groups
local parameterGroupCells = {}
local firstParameterGroupCell
-- List of title parameter names in this order.
Line 69 ⟶ 68:
local function idTrim(val, search)
local valFind = string.find(val, search)
if (valFind == nil) then
return val
Line 108 ⟶ 107:
-- fix for lists in the Short Summary
local shortSummaryText = args.ShortSummary
if (shortSummaryText:match('^[*:;#]') or shortSummaryText:match('^{|')) then
shortSummaryText = '<span></span>\n' .. shortSummaryText
Line 140 ⟶ 139:
local linkContrastRatio = colorContrastModule._ratio{args.TopColor, '#0B0080', ['error'] = 0}
local visitedLinkContrastRatio = colorContrastModule._ratio{args.TopColor, '#0645AD', ['error'] = 0}
if (textContrastRatio < 7 or linkContrastRatio < 7 or visitedLinkContrastRatio < 7) then
addTrackingCategory(trackingCategoryList["invalid_top_colors"])
Line 152 ⟶ 151:
local blackContrastRatio = colorContrastModule._ratio{args.LineColor, 'black', ['error'] = 0}
local whiteContrastRatio = colorContrastModule._ratio{'white', args.LineColor, ['error'] = 0}
if (colorContrastModule._lum(args.LineColor) == '') then
addTrackingCategory(trackingCategoryList["faulty_line_colors"])
elseif (blackContrastRatio < 7 and whiteContrastRatio < 7) then
addTrackingCategory(trackingCategoryList["
end
else
Line 174 ⟶ 173:
local function setTBDStatus(args)
local month, day, year = args.OriginalAirDate:gsub(" ", " "):match("(%a+) (%d+), (%d+)")
if (month == nil) then
day, month, year = args.OriginalAirDate:gsub(" ", " "):match("(%d+) (%a+) (%d+)")
end
if (day == nil) then
return tableEmptyCellModule._main({alt_text = "TBD"})
Line 199 ⟶ 198:
local seconds = os.time() - os.time({year = year, month = monthList[month], day = day, hour = 0, min = 0, sec = 0})
if (seconds >= 60 * 60 * 24 * 7 * 4) then
return tableEmptyCellModule._main({alt_text = "N/A"})
Line 226 ⟶ 225:
and string.match(args[v], '2C2C2C') == nil
and string.find(args[v], 'dtstart') == nil
and onInitialPage
and title.namespace == 0)
then
addTrackingCategory(trackingCategoryList["air_dates"])
end
-- Alternate air dates that do use {{Start date}}
if (v == 'AltDate' and args[v] ~= '' and string.find(args[v], 'dtstart') ~= nil and onInitialPage and title.namespace == 0) then
Line 251 ⟶ 250:
-- ProductionCode parameter not used; Do nothing.
end
nonNilParams = nonNilParams + 1
end
Line 279 ⟶ 278:
end
end
return args
end
Line 303 ⟶ 302:
createEmptyCell(args, v, false)
end
-- If serial titles need to be centered and not left, then this should be removed.
local textAlign = "center"
Line 309 ⟶ 308:
textAlign = "left"
end
-- Remove wikilinks from links in serial rowspans rows after the first.
-- if (currentRow > 1) then
-- args[v] = removeWikilinks(args, v)
-- end
local thisRowspan
if (firstParameterGroupCell and k < firstParameterGroupCell) then
Line 321 ⟶ 320:
thisRowspan = 1
end
if (currentRow == 1 or (currentRow > 1 and k >= (firstParameterGroupCell or 0))) then
createTableData(args[v], thisRowspan, textAlign)
end
Line 328 ⟶ 327:
checkUsageOfDateTemplates(args, v, onInitialPage, title)
end
if (args[v] == "TBA") then
cellValueTBA = true
Line 342 ⟶ 341:
Line 2: <AltTitle><RAltTitle> (with no space between) OR
Line 2: Transcription: <TranslitTitle> (<Language>: <NativeTitle>)<RAltTitle> (with space between first two parameters)
If <Title> or <RTitle> are empty,
then the values of line 2 will be placed on line 1 instead.
Line 376 ⟶ 375:
-- Surround the AltTitle/TranslitTitle with quotes; No quotes if empty.
if (args.AltTitle or args.TranslitTitle) then
isCellPresent = true
if (useSecondLine) then
titleString = titleString .. "<br />"
lineBreakUsed = true
end
if (hasValue(args.AltTitle)) then
titleString = titleString .. '"' .. args.AltTitle .. '"'
Line 419 ⟶ 418:
else
isCellPresent = true
if (useSecondLine and lineBreakUsed == false) then
titleString = titleString .. "<br />"
end
titleString = titleString .. args.RAltTitle
end
Line 442 ⟶ 441:
local function extractDataFromNumberedTitleArgs(args, i)
local nextGroupValid = false
for _, v in ipairs(titleList) do
local parameter = v
local numberedParameter = v .. "_" .. i
args[parameter] = args[numberedParameter]
if (nextGroupValid == false and hasValue(args[numberedParameter])) then
nextGroupValid = true
end
end
return args, nextGroupValid
end
Line 462 ⟶ 461:
local isCellPresent = false
local isFirstTitleGroup = true -- Making sure that the title cell is created at least once and isn't created again if other #N titles are empty.
for i = 1, numberOfParameterGroups do
local args, nextGroupValid = extractDataFromNumberedTitleArgs(args, i)
Line 483 ⟶ 482:
end
end
return titleText
end
Line 491 ⟶ 490:
local titleText
local isCellPresent
if (multiTitleListEnabled) then
titleText, isCellPresent = processMultiTitleList(args, numberOfParameterGroups)
Line 509 ⟶ 508:
textAlign = "left"
end
-- If title is the first cell, create it with a !scope="row"
if (nonNilParams == 0) then
Line 544 ⟶ 543:
end
-- Local function which is used to create a table row header for either the
-- EpisodeNumber or EpisodeNumber2 column cells.
local function
row:tag('th')
:attr('scope', 'row')
Line 574 ⟶ 573:
return tableEmptyCellModule._main({})
else
local episodeNumber1
local episodeNumber2
-- Used for double episodes that need a visual "–"" or "<hr />"" added.
local divider
Line 586 ⟶ 585:
episodeNumber1, episodeNumber2 = episodeNumber:match('^(%w+)%s*<hr */%s*>%s*(%w+)$')
divider = "<hr />"
elseif (episodeNumber:match('^(%w+)%s*<hr */%s*>.-<hr */%s*>%s*(%w+)$')) then
episodeNumber1, episodeNumber2 = episodeNumber:match('^(%w+)%s*<hr */%s*>.-<hr */%s*>%s*(%w+)$')
divider = "<hr />"
Line 593 ⟶ 592:
divider = "–"
else
episodeNumber1, episodeNumber2 = mw.ustring.match(episodeNumber, '^(%w+)%s*[%s%-–,/&].-[%s%-–,/&]%s*(%w+)$')
divider = "–"
end
Line 611 ⟶ 610:
if (args.EpisodeNumber2) then
local episodeText = getEpisodeText(args.EpisodeNumber2)
if (nonNilParams == 0) then
createTableRowEpisodeNumberHeader(args.EpisodeNumber2, numberOfParameterGroups, episodeText)
Line 620 ⟶ 619:
nonNilParams = nonNilParams + 1
end
end
Line 629 ⟶ 628:
createTableRowEpisodeNumberHeader(args.EpisodeNumber, numberOfParameterGroups, episodeText)
nonNilParams = nonNilParams + 1
end
end
Line 648 ⟶ 647:
createEpisodeNumberCell2(args, numberOfParameterGroups)
createTitleCell(args, numberOfParameterGroups, false, true)
for i = 1, numberOfParameterGroups do
args = extractDataFromNumberedSerialArgs(args, i, numberOfParameterGroups, title)
createCells(args, true, i, onInitialPage, title, numberOfParameterGroups)
if (i ~= numberOfParameterGroups) then
row = row:done()
:tag('tr')
:css('background', topColor)
Line 671 ⟶ 670:
end
end
if (hasValue(args.NumParts)) then
return args.NumParts, true
Line 704 ⟶ 703:
rowColorEnabled = true
end
return rowColorEnabled
end
Line 712 ⟶ 711:
-- Default color to light blue
local lineColor = args.LineColor or 'CCCCFF'
-- Add # to color if necessary, and set to default color if invalid
if (htmlColor[lineColor] == nil) then
Line 720 ⟶ 719:
end
end
return lineColor
end
Line 731 ⟶ 730:
-- with one of them not requiring an article name, so for backward compatability, the whole sequence is kept.
local onInitialPage
-- Only sublist had anything about hiding, so only it needs to even check
if (sublist) then
Line 746 ⟶ 745:
end
end
return onInitialPage
end
Line 755 ⟶ 754:
local pageTitle = title.text
local initiallistTitle = args['1'] or ''
-- Is this list on the same page as the page directly calling the template?
local onInitialPage = isOnInitialPage(args, sublist, pageTitle, initiallistTitle)
Line 775 ⟶ 774:
local numberOfParameterGroups, multiTitleListEnabled = getnumberOfParameterGroups(args)
if (multiTitleListEnabled and not args.Title_2) then
createMultiRowCells(args, numberOfParameterGroups, onInitialPage, title, topColor)
else
createSingleRowCells(args, numberOfParameterGroups, multiTitleListEnabled, onInitialPage, title)
end
Line 787 ⟶ 786:
addTopColorTrackingCategories(args)
end
if (cellValueTBA == true and title.namespace == 0) then
addTrackingCategory(trackingCategoryList["tba_values"])
Line 804 ⟶ 803:
-- Local function which handles both module entry points.
local function main(frame, sublist)
local getArgs = require('Module:Arguments').getArgs
local args
Line 852 ⟶ 851:
-- |Aux4= — optional; General purpose parameter. The meaning is specified by the column header.
-- |ShortSummary= — optional; A short 100–200 word plot summary of the episode.
-- |LineColor= — optional; Colors the separator line between episode entries. If not defined the color defaults to "#CCCCFF"
and the article is placed in Category:Episode list using the default LineColor.
Use of "#", or anything but a valid hex code will result in an invalid syntax.
-- |TopColor= — discouraged; Colors the main row of information (that is, not the ShortSummary row).
Articles using this parameter are placed in Category:Episode lists with row deviations.
-- |RowColor= — optional; Switch parameter that must only be defined when the EpisodeNumber= entry is not a regular number
(e.g. "12–13" for two episodes described in one table entry).
If the first episode number is even, define pass "on". If the first episode number is odd, pass "off".
--]]
|