Content deleted Content added
No edit summary |
No edit summary |
||
(9 intermediate revisions by the same user not shown) | |||
Line 1:
require('strict')
local match = require("Module:String")._match
Line 52 ⟶ 53:
return "season"
end
--- Returns the season number from the title.
--- @param title string The article's title.
--- @return string | nil
local function
end▼
return match(title , "%d+", 1, -1, false, "")▼
--- Returns the disambiguation from the title.
--- @param title string The article's title.
--- @return string | nil
local function getDisambiguation(title)▼
if disambiguation and disambiguation == "" then
return nil
end
return
end
Line 73 ⟶ 76:
--- @return string | nil
local function getTitleWithoutDisambiguation(title)
local disambiguation =
if disambiguation
return string.gsub(title, "%(" .. disambiguation .. "%)", "")
end
return title
▲end
▲local function getDisambiguation(title)
end
Line 131 ⟶ 129:
--- @return string
local function getShowName(title)
local name, _ = mw.ustring.gsub(title, "season %
name, _ = mw.ustring.gsub(name, "series %d*$", "")
name, _ = mw.ustring.gsub(name, "specials", "")
name, _ = mw.ustring.gsub(name, "story arc %d*$", "")
name = string.match(name, "^%s*(.-)%s*$") -- Trim spaces.
return name
end
Line 187 ⟶ 189:
--- -- Style: <showName> (<year> TV series) <seasonType> <seasonNumber>
--- Example: Love Island (2015 TV series) series 2
--- -- Style: <showName> (<country> <seasonType>)
--- Example: Big Brother 2 (American season).
Line 195 ⟶ 197:
local function getArticleTitleAndPipedLink(title, seasonNumberDiff)
local seasonType = getSeasonType(title)
local seasonNumber =
if tonumber(seasonNumber) == nil then
return "", nil
Line 201 ⟶ 203:
seasonNumber = seasonNumber + seasonNumberDiff
local modifiedTitle = string.gsub(title, "%d+$", seasonNumber)
local pipedLink = seasonType:gsub("^%l", string.upper) .. " " .. seasonNumber
local disambiguation = getDisambiguation(title)
-- Titles such as "Big Brother
if disambiguation
local titleWithoutDisambiguation = string.gsub(title, disambiguation, "_DAB_")
modifiedTitle = string.gsub(titleWithoutDisambiguation, "%d+", seasonNumber)
modifiedTitle = string.gsub(modifiedTitle, "_DAB_", disambiguation)
return modifiedTitle, pipedLink
-- Titles such as "Big Brother Brasil
elseif not string.find(title, seasonType) then
return modifiedTitle, nil
-- Invalid usages of TV series articles with the television season infobox.
elseif disambiguation and string.find(disambiguation, "TV series") and not (string.find(disambiguation, ", season") or string.find(disambiguation, ", series")) then
return "", nil
Line 228 ⟶ 233:
local getArgs = require("Module:Arguments").getArgs
local args = getArgs(frame)
if args.italic_title then
return "no"
end
local title = args.title
if not title then
title = mw.title.getCurrentTitle().text
Line 301 ⟶ 309:
title = getTitleWithoutDisambiguation(title)
local seasonType = getSeasonType(title)
end
--- Returns an {{Italic title}} instance if title qualifies or a blank string.
--- @param frame table
--- @return string
function p.getItalicTitle(frame)
local getArgs = require("Module:Arguments").getArgs
local args = getArgs(frame)
-- If italic_title is set then "no" is the only valid value.
-- Don't set an italic title.
if args.italic_title then
return ""
end
local title = getTitle(frame)
return seasonType▼
title = getShowName(getTitleWithoutDisambiguation(title))
-- If the infobox is used on List of articles don't set an italic title.
-- TODO: this can be fixed in the future but current usages use a manual display title.
if string.find(title, "List of") then
return ""
end
return frame:expandTemplate{title = "Italic title", args = {string = title}}
end
--- Returns the text used for the |above= field of the infobox.
---
--- @param frame table
--- @return string
function p.getAboveTitle(frame)
local getArgs = require("Module:Arguments").getArgs
local args = getArgs(frame)
local title = getTitle(frame)
title = getShowName(getTitleWithoutDisambiguation(title))
end
--- Returns the
---
--- The text is returned in the format of "Season #" or "Series #",
Line 314 ⟶ 356:
--- @param frame table The frame invoking the module.
--- @return string | nil
function p.
local getArgs = require("Module:Arguments").getArgs
local args = getArgs(frame)
Line 330 ⟶ 372:
if not seasonNumber then
local title = getTitle(frame)
seasonNumber =
seasonType = getSeasonType(
-- For pages like "Doctor Who specials (2008–2010)".
if seasonType == "specials" then
local disambiguation = getDisambiguation(title) or ""
return disambiguation .. " " .. seasonType
end
seasonType = seasonType:sub(1, 1):upper() .. seasonType:sub(2)
Line 371 ⟶ 414:
local title = getTitle(frame)
local showName = getShowName(getTitleWithoutDisambiguation(title))
if showName then
local disambiguation = getDisambiguation(title)
if disambiguation then
disambiguation = " (" .. disambiguation .. ")"
local listOfEpisodesArticle = string.format("List of %s%s episodes", showName, TVProgramDisambiguation)▼
end
▲ local listOfEpisodesArticle = string.format("List of %s%s episodes", showName,
return getListOfEpisodesLink(listOfEpisodesArticle)
end
|