Module:Episode list: Difference between revisions

Content deleted Content added
disable call to new function addRowDividerTrackingCategory to see if this resolves problems at Template talk:Episode list#References in ShortSummary get transcluded even when the text isn't displayed due to all args being evaluated
Comment out per talk page
 
(36 intermediate revisions by 10 users not shown)
Line 4:
local colorContrastModule = require('Module:Color contrast')
local htmlColor = mw.loadData('Module:Color contrast/colors')
local delinkModule = require('Module:Delink')
local langModule = require("Module:Lang")
local mathModule = require('Module:Math')
Line 34 ⟶ 33:
["nonmatching_numbered_parameters"] = "[[Category:Episode lists with a non-matching set of numbered parameters]]",
["raw_unformatted_storyteleplay"] = "[[Category:Episode lists with unformatted story or teleplay credits]]",
["dividers"] = "[[Category:Episode lists with row dividers]]"
}
 
Line 129 ⟶ 127:
shortSummaryText = shortSummaryText .. '\n<span></span>'
end
local shortSummaryDiv = mw.html.create('div')
:addClass('shortSummaryText')
:css('max-width', '90vw')
:css('position', 'sticky')
:css('left', '0.2em')
:newline()
:wikitext(shortSummaryText)
 
local shortSummaryCell = mw.html.create('td')
Line 135 ⟶ 141:
:attr('colspan', nonNilParams)
:newline()
:wikitextnode(shortSummaryTextshortSummaryDiv)
 
return mw.html.create('tr')
Line 142 ⟶ 148:
end
 
-- Local function which is used to check if visual row dividers are used.
-- Adds a tracking category if row dividers are found.
local function addRowDividerTrackingCategory(args)
local divider_list = {
"<hr />",
"<hr/>",
}
for _, v in pairs(args) do
for _, pattern in pairs(divider_list) do
if string.find(v, pattern) then
return addTrackingCategory(trackingCategoryList["dividers"])
end
end
end
end
 
-- Local function which is used to add tracking categories for Top Color issues.
Line 190 ⟶ 181:
addTrackingCategory(trackingCategoryList["default_line_colors"])
end
end
 
-- Local function which is used to remove wiki-links from repated information in rowspans.
-- Used for Doctor Who serials, where the director and writer are the same for each part of serial.
local function removeWikilinks(args, v)
return delinkModule._delink{args[v]}
end
 
Line 203 ⟶ 188:
local function setTBDStatus(args, awaitingText, expiredText, weeks)
if args.OriginalAirDate == nil or args.OriginalAirDate == '' then
return tableEmptyCellModule._main({alt_text = awaitingText, title_text = awaitingText})
end
 
-- If it hasn't aired, change to "N/A".
if string.match(args.OriginalAirDate, '^Unaired') then
return tableEmptyCellModule._main({alt_text = "N/A"})
end
 
local month, day, year = args.OriginalAirDate:gsub("&nbsp;", " "):match("(%a+) (%d+), (%d+)")
 
Line 238 ⟶ 228:
 
if (seconds >= 60 * 60 * 24 * 7 * weeks) then
return tableEmptyCellModule._main({alt_text = expiredText, title_text = expiredText})
else
return tableEmptyCellModule._main({alt_text = awaitingText, title_text = awaitingText})
end
end
Line 260 ⟶ 250:
-- Air dates that don't use {{Start date}}
local function checkUsageOfDateTemplates(args, v, onInitialPage, title)
if (v == 'OriginalAirDate'
and args[v] ~= ''
and string.match(args[v], '%d%d%d%d') ~=-- nilEnsure it contains a four-digit number (likely a year)
and string.match(args[v], '2C2C2C') == nil -- Avoids this specific pattern
and not string.findmatch(args[v], 'dtstart^Unaired') ==-- Exclude anything starting with nil"Unaired"
and string.find(args[v], 'itvstart') == nil -- Avoids a {{Start date}} unique class
and onInitialPage
and title.namespace == 0)
then
addTrackingCategory(trackingCategoryList["air_dates"])
Line 307 ⟶ 298:
use the non-numbered parameter names (Title, Aux).
 
The function returns the args as non-numbered prameterparameter names.
]]--
local function extractDataFromNumberedSerialArgs(args, i, numberOfParameterGroups, title)
Line 339 ⟶ 330:
Line 1: <Title><RTitle> (with no space between)
Line 2: <AltTitle><RAltTitle> (with no space between) OR
Line 2: TranscriptionTransliteration: <TranslitTitle> (<Language>: <NativeTitle>)<RAltTitle> (with space between first two parameters)
 
If <Title> or <RTitle> are empty,
Line 386 ⟶ 377:
elseif (hasValue(args.TranslitTitle)) then
if (hasValue(args.NativeTitleLangCode)) then
titleString = titleString .. 'TranscriptionTransliteration: "' .. langModule._transl_xlit({args.NativeTitleLangCode, args.TranslitTitle, italic = 'no'}) .. '"'
else
titleString = titleString .. 'TranscriptionTransliteration: "' .. args.TranslitTitle .. '"'
end
end
Line 405 ⟶ 396:
if (hasValue(args.NativeTitleLangCode)) then
local languageCode = "Lang-" .. args.NativeTitleLangCode
titleString = titleString .. " (" .. langModule._lang_xx_inherit_langx({code = args.NativeTitleLangCode, text=args.NativeTitle}) .. ")"
else
titleString = titleString .. " (" .. args.NativeTitle .. ")"
Line 432 ⟶ 423:
Local function which is used to extract data
from the numbered title parameters (Title1, RTitle2, etc.), and then convert them to
use the non-numbered prameterparameter names (Title, RTitle).
 
The function returns two results:
Line 534 ⟶ 525:
createTitleCell(args, numberOfParameterGroups, currentRow, isSerial)
end
elseif excludeList[v] and args[excludeList[v]] then
-- Ignore this parameter set as multiple conflicting parameters were used
elseif (args[v] and (v ~= 'EpisodeNumber' and v ~= 'EpisodeNumber2')) then
-- Set empty cells to TBA/TBD
Line 547 ⟶ 540:
-- If serial titles need to be centered and not left, then this should be removed.
local textAlign = "center"
-- if (v == 'Aux1' and isSerial) then
-- textAlign = "left"
-- end
 
local thisRowspan
Line 564 ⟶ 557:
checkUsageOfDateTemplates(args, v, onInitialPage, title)
end
 
-- Usages of TBA via [[Template:TableTBA]] can be found with the "tv-tba" class.
if (args[v] == "TBA") then
if args[v] and (args[v] == "TBA" or string.find(args[v], "tv%-tba")) then
cellValueTBA = true
end
Line 689 ⟶ 683:
createCells(args, true, i, onInitialPage, title, numberOfParameterGroups)
if (i ~= numberOfParameterGroups) then
local textColor = '#333'
if (args[v]topColor == "TBA")'inherit' then
textColor = 'inherit'
end
row = row:done() -- Use done() to close the 'tr' tag in rowspaned rows.
:tag('tr')
:addClass('vevent')
:addClass('module-episode-list-row')
:css('text-align', 'center')
:css('background', topColor)
:css('color', textColor)
end
end
Line 725 ⟶ 728:
return '#' .. args.TopColor
end
elseif (rowColorEnabled and onInitialPage and mathModule._mod(episodeNumber, 2) == 0) then
return '#E9E9E9'
elseif (onInitialPage and args.ShortSummary) then
return '#F2F2F2'
else
return 'inherit'
Line 768 ⟶ 767:
-- with one of them not requiring an article name, so for backward compatability, the whole sequence is kept.
local onInitialPage
local onInitialPageCheck = (mw.uri.anchorEncode(pageTitle) == mw.uri.anchorEncode(initiallistTitle))
 
-- Only sublist had anything about hiding, so only it needs to even check
if (sublist) then
onInitialPage = mw.uri.anchorEncode(pageTitle) == mw.uri.anchorEncode(initiallistTitle)onInitialPageCheck
-- avoid processing ghost references
if (not onInitialPage) then
Line 780:
onInitialPage = true
else
onInitialPage = mw.uri.anchorEncode(pageTitle) == mw.uri.anchorEncode(initiallistTitle)onInitialPageCheck
end
end
Line 806:
 
local root = mw.html.create() -- Create the root mw.html object to return
local textColor = '#333'
if topColor == 'inherit' then
textColor = 'inherit'
end
 
row = root:tag('tr') -- Create the table row and store it globally
:addClass('vevent')
:addClass('module-episode-list-row')
:css('text-align', 'center')
:css('background', topColor)
:css('color', textColor)
 
local numberOfParameterGroups, multiTitleListEnabled = getnumberOfParameterGroups(args)
Line 828 ⟶ 835:
addTrackingCategory(trackingCategoryList["tba_values"])
end
 
-- addRowDividerTrackingCategory(args) -- see [[Template talk:Episode list#References in ShortSummary get transcluded even when the text isn't displayed]]
 
-- Do not show the summary if this is being transcluded on the initial list page