Modul:Infobox television season name: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
RaFaDa20631 (bicara | kontrib)
Tidak ada ringkasan suntingan
RaFaDa20631 (bicara | kontrib)
Tidak ada ringkasan suntingan
Baris 1:
require('strict')
local match = require("Module:String")._match
 
Baris 40 ⟶ 39:
end
 
--- Returns the type of word used for "seasonMusim" in the titledisambiguation.
---
--- The returned value can be one of three options: "seasonMusim", "seriesSeri", "story arc" or "specialsspesials".
--- @param titledisambiguation string The article's titledisambiguation.
--- @return string
local function getSeasonType(titledisambiguation)
for _, seasonType in pairs({"musim", "seri", "story arc", "spesialspesials"}) do
if string.find(titledisambiguation, seasonType) then
return seasonType
end
end
return "musimseason"
end
 
--- Returns the seasondisambiguation number fromwithout the title"(year) TV series," part.
--- @param titledisambiguation string The article's titledisambiguation.
--- @return string | nil
local function getSeasonNumbergetShortDisambiguation(titledisambiguation)
returnlocal match(titleshortDisambiguation, _ = string.gsub(disambiguation, "%d+", 1,TV -1series, false", "")
return shortDisambiguation
end
 
Baris 66:
local function getDisambiguation(title)
local disambiguation = match(title, "%s%((.-)%)", 1, -1, false, "")
if disambiguation and disambiguation == "" then
return nil
end
return disambiguation
end
 
--- Returns the title without its disambiguation.
--- @param title string The article's title.
--- @return string | nil
local function getTitleWithoutDisambiguation(title)
local disambiguation = getDisambiguation(title)
if disambiguation then
return string.gsub(title, "%(" .. disambiguation .. "%)", "")
end
return title
end
 
Baris 129 ⟶ 118:
--- @return string
local function getShowName(title)
local name, _ = mw.ustring.gsub(title, "musim %d*s+%b()$", "")
name, _ = mw.ustring.gsub(name, "seri %d*$", "")
name, _ = mw.ustring.gsub(name, "spesial", "")
name, _ = mw.ustring.gsub(name, "story arc %d*$", "")
name = string.match(name, "^%s*(.-)%s*$") -- Trim spaces.
return name
end
Baris 179 ⟶ 164:
---
--- The following are the supported season naming styles:
--- -- Style: <showName> (<seasonType> <seasonNumber>)
--- Example: Lost (season 2).
--- Example: Doctor Who (series 2).
--- -- Style: <showName> (<country> TV series) <seasonType> <seasonNumber>)
--- Example: The Office (American TV series) season 2).
--- Example: TeenageX Mutant Ninja TurtlesFactor (1987 TVBritish series) season 2).
--- Example: X Factor (British TV series) series 2.
--- Example: Love Island (British TV series) series 2
--- -- 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).
--- -- Style: <showName> (<year> TV series, <seasonType> <seasonNumber>)
 
--- Example: Teenage Mutant Ninja Turtles (1987 TV series, season 2)
--- -- Style: <showName> (<country> TV series, <seasonType> <seasonNumber>)
--- Example: Love Island (British TV series, series 2)
--- @param title string The article's title.
--- @param seasonNumberDiff number The number difference between the current season and the other season.
--- @return string, string
local function getArticleTitleAndPipedLink(title, seasonNumberDiff)
local seasonTypedisambiguation = getSeasonTypegetDisambiguation(title)
local shortDisambiguation
local seasonNumber = getSeasonNumber(title)
local seasonType
local seasonNumber
local pipedLink = ""
 
if disambiguation then
shortDisambiguation = getShortDisambiguation(disambiguation)
seasonType = getSeasonType(shortDisambiguation)
seasonNumber = getCurrentSeasonNumberFromDisambiguation(shortDisambiguation)
pipedLink = seasonType:gsub("^%l", string.upper) .. " "
end
 
local showName = getShowName(title)
local showNameModified
if not seasonNumber or seasonNumber == "" then
-- Not a valid next/prev season link.
if not string.match(showName, "%s+(%d+)$") then
return "", nil
end
showNameModified, seasonNumber = getShowNameAndSeasonNumberFromShowName(showName)
end
 
if tonumber(seasonNumber) == nil then
return "", nil
end
 
seasonNumber = seasonNumber + seasonNumberDiff
local modifiedTitlepipedLink = string.gsub(title,pipedLink "%d+$",.. seasonNumber)
local pipedLink = seasonType:gsub("^%l", string.upper) .. " " .. seasonNumber
 
-- Titles such as "Big Brother 1 (American season)".
local disambiguation = getDisambiguation(title)
if showNameModified and disambiguation then
-- Titles such as "Big Brother 2 (American season) and Teenage Mutant Ninja Turtles (1987 TV series) season 2".
return showNameModified .. " " .. seasonNumber .. " (" .. disambiguation .. ")", pipedLink
if disambiguation then
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 21".
elseif not string.find(title, seasonType)showNameModified then
return modifiedTitleshowNameModified .. " " .. seasonNumber, 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
-- Standard titles such as "Lost (season 1)".
 
-- Standard titles such as "Lost season 1".
else
local newDisambiguation, _ = string.gsub(disambiguation, "%d+$", seasonNumber)
return modifiedTitle, pipedLink
return showName .. " (" .. newDisambiguation .. ")", pipedLink
end
end
Baris 233 ⟶ 234:
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
Baris 302 ⟶ 300:
end
 
--- Returns the type of season word used - "season" or "seriesSeri".
--- @param frame table The frame invoking the module.
--- @return string
function p.getSeasonWord(frame)
local title = getTitle(frame)
local disambiguation = getDisambiguation(title)
title = getTitleWithoutDisambiguation(title)
if not disambiguation then
local seasonType = getSeasonType(title)
return seasonType
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 shortDisambiguation = getShortDisambiguation(disambiguation)
local title = getTitle(frame)
local seasonType = getSeasonType(shortDisambiguation)
title = getShowName(getTitleWithoutDisambiguation(title))
if seasonType == "spesials" then
 
seasonType = "season"
-- 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 seasonType
return frame:expandTemplate{title = "Italic title", args = {string = title}}
end
 
--- Returns the relevant text used for the |above=sub-header field of the infobox.
---
--- The text is returned in the format of "Season #" or "Seri #",
--- @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))
return title
end
 
--- Returns the text used for the |subheader= field of the infobox.
---
--- The text is returned in the format of "Season #" or "Series #",
--- depending on either what the article disambiguation uses, or on the manually entered parameters of the infobox.
--- @param frame table The frame invoking the module.
--- @return string | nil
function p.getSubHeadergetInfoboxSubHeader(frame)
local getArgs = require("Module:Arguments").getArgs
local args = getArgs(frame)
Baris 366 ⟶ 335:
seasonNumber = args.season_number
elseif args.series_number then
seasonType = "SeriSeries"
seasonNumber = args.series_number
end
 
local title = getTitle(frame)
if not seasonNumber then
local titledisambiguation = getTitlegetDisambiguation(frametitle)
if not seasonNumber and disambiguation then
local titleWithoutDisambiguation = getTitleWithoutDisambiguation(title)
local shortDisambiguation = getShortDisambiguation(disambiguation)
seasonNumber = getSeasonNumber(titleWithoutDisambiguation)
 
seasonType = getSeasonType(titleWithoutDisambiguation)
seasonType = getSeasonType(shortDisambiguation)
if seasonType == "spesials" then
-- For pages like "Doctor Who specials (2008–2010)".
return shortDisambiguation
if seasonType == "specials" then
local disambiguation = getDisambiguation(title) or ""
return disambiguation .. " " .. seasonType
end
seasonType = seasonType:sub(1, 1):upper() .. seasonType:sub(2)
seasonNumber = getCurrentSeasonNumberFromDisambiguation(shortDisambiguation)
end
 
Baris 414 ⟶ 382:
 
local title = getTitle(frame)
local showName = getShowName(getTitleWithoutDisambiguation(title))
 
if showName then
local disambiguation = getDisambiguation(title)
local TVProgramDisambiguation = getTVProgramDisambiguation(disambiguation)
if disambiguation then
local listOfEpisodesArticle = string.format("List of %s%s episodes", showName, TVProgramDisambiguation)
disambiguation = " (" .. disambiguation .. ")"
end
local listOfEpisodesArticle = string.format("List of %s%s episodes", showName, disambiguation or "")
return getListOfEpisodesLink(listOfEpisodesArticle)
end