Module:Infobox television episode: Difference between revisions

Created page with "--- @module local p = {} local maintenance_categories = { incorrectly_formatted = "%s", unlinked_values = "%s", image_values_without_an_image = "Category:Pages using infobox television episode with image-related values without an image", unnecessary_title_parameter = "[[Category:Pages using infobox televis..."
 
No edit summary
 
Line 212: Line 212:


--- Returns a maintenance category if the date is not formatted correctly with a {{Start date}} template.
--- Returns a maintenance category if the date is not formatted correctly with a {{Start date}} template.
--- Allow "Unaired" as a valid value for unaired television episodes.
---
---
--- Infobox parameters checked:
--- Infobox parameters checked:
Line 221: Line 222:
--- @return string
--- @return string
local function are_dates_formatted_correctly(start_date)
local function are_dates_formatted_correctly(start_date)
if start_date and not string.find(start_date, "dtstart") then
if start_date and (string.find(start_date, "film%-date") or not string.find(start_date, "itvstart") and start_date ~= "Unaired") then
return maintenance_categories.dates_incorrectly_formatted
return maintenance_categories.dates_incorrectly_formatted
end
end
Line 341: Line 342:
--- - |music=
--- - |music=
--- - |guests=
--- - |guests=
--- - |module=
---
---
--- The function currently checks if the following values are present:
--- The function currently checks if the following values are present:
--- - '' - italics or bold.
--- - '' - italics or bold.
---
--- Note:
--- If the series is American Horror Story then the season_article value is allowed to be formatted.
--- If in the future more series need this exception then the hardcoded value in the function should be taken out into a list.
---
---
--- @param args table
--- @param args table
Line 363: Line 369:
music = true,
music = true,
guests = true,
guests = true,
module = true,
}
}


for key, value in pairs(args) do
for key, value in pairs(args) do
if not ignore_parameters[key] and string.find(value, "''", 1, true) then
if not ignore_parameters[key] and string.find(value, "''", 1, true) then
return string.format(maintenance_categories.incorrectly_formatted, key)
if key == "season_article" and args.series == "[[American Horror Story]]" then --TODO: This is hardcoded for now.
-- Do nothing.
else
return string.format(maintenance_categories.incorrectly_formatted, key)
end
end
end
end
end
Line 741: Line 752:
--- @param frame table
--- @param frame table
--- @return string
--- @return string
function p.above_title(frame)
local function _above_title(frame, args)
local getArgs = require("Module:Arguments").getArgs
local args = getArgs(frame)
 
if args.rtitle then
if args.rtitle then
return create_title_with_rtitle_value(args.rtitle)
return create_title_with_rtitle_value(args.rtitle)
Line 779: Line 787:
local series_name_escaped, _ = get_series_name(args.series)
local series_name_escaped, _ = get_series_name(args.series)


if args.italic_title and not args.rtitle then
-- args.no_bold is used from IMDb episode so it requires this correction here also.
if (args.italic_title and not args.rtitle) or args.no_bold then
local title_modification = get_display_title_text(page_text, article_title)
local title_modification = get_display_title_text(page_text, article_title)


Line 795: Line 804:
end
end


if not title_parts.disambiguation or (series_name_escaped ~= "" and (title_parts.disambiguation == series_name_escaped or string.find(title_parts.disambiguation, series_name_escaped))) then
if not title_parts.disambiguation or (series_name_escaped ~= "" and (title_parts.disambiguation == series_name_escaped or string.find(title_parts.disambiguation, series_name_escaped))) or args.no_bold then
return string.format(title_format, get_page_name_with_apostrophe_quotation_fixes(frame, title_parts.title))
return string.format(title_format, get_page_name_with_apostrophe_quotation_fixes(frame, title_parts.title))
end
end


return string.format(title_format, get_page_name_with_apostrophe_quotation_fixes(frame, article_title))
return string.format(title_format, get_page_name_with_apostrophe_quotation_fixes(frame, article_title))
end
--- Returns the episode title from the article title, with textual fixes if needed.
---
--- Used by {{Infobox television episode}} and {{IMDb episode}} to automatically style the title without needing manual input.
---
--- @param frame table
--- @return string
function p.above_title(frame)
local getArgs = require("Module:Arguments").getArgs
local args = getArgs(frame)
local title = _above_title(frame, args)
-- The title used by {{IMDb episode}} should not be in bold.
if args.no_bold then
title = string.gsub(title, "'''", "")
end
return title
end
end