Modul:Infobox television season name: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
k Cleanup
Update dan cleanup.
Baris 1:
local match = require("Module:String")._match
local pipedLink = ""
 
local p = {}
Baris 8 ⟶ 6:
Local function which is used to create an pipped article link.
--]]
local function createArticleTitleWithPipedLink(article, pipedLink)
if (pipedLink == nil or pipedLink == "") then
return "[[" .. article .. "]]"
else
return "[[" .. article .. "|" .. pipedLink .. "]]"
end
end
 
--[[
Local helper function which is used to get the current season number and modified show name
from the show name.
--]]
local function getModifiedShowNameAndCurrentSeasonNumberFromShowName(showName)
local _, _, showNameModified, seasonNumber = string.find(showName, "(.*)%s+(%d+)")
return showNameModified, seasonNumber
end
 
--[[
Local helper function which is used to get the current season number from the disambiguation.
--]]
local function getCurrentSeasonNumberFromDisambiguation(shortDisambiguation)
return match(shortDisambiguation , "%d+", 1, -1, false, "")
end
 
Baris 19 ⟶ 33:
Local helper function which is used to get the type of word used for "season"
in the disambiguation.
 
Returns one of three options: "season", "series" or "story arc".
--]]
local function getSeasonType(shortDisambiguation)
local seasonType = if (string.find(shortDisambiguation , "seristory arc")) then
return "arc cerita"
if (seasonType) then
end
seasonType = "seri"
 
else
if (string.find(shortDisambiguation , "series")) then
seasonType = "musim"
return "seri"
end
end
return seasonType
 
return "musim"
end
 
Baris 42 ⟶ 60:
--]]
local function getDisambiguation(title)
returnlocal disambiguation = match(title, "%s%((.-)%)", 1, -1, false, "")
if (disambiguation == "") then
return nil
else
return disambiguation
end
end
 
--[[
Local helper function which is used to get the show name from the title.
--]]
local function getShowName(title)
return mw.ustring.gsub(title, "%s+%b()$", "")
end
 
Baris 76 ⟶ 106:
 
--[[
Local function which isreturns useda toseason createarticle atitle TVand seasona piped link.
 
The following are the supported season naming styles:
Baris 88 ⟶ 118:
-- <showName> (<year> TV series, <seasonType> <seasonNumber>)
Example: Teenage Mutant Ninja Turtles (1987 TV series, season 2)
-- <showName> (<country> TV series, <seasonType> <seasonNumber>)
Example: Love Island (British TV series, series 2)
--]]
local function getArticleTitle(title, prevOrNextSeasonNumber)
local showName = mw.ustring.gsubgetShowName(title, "%s+%b()$", "")
local disambiguation = getDisambiguation(title)
local year = match(disambiguation, "(%d+ seri TV, )", 1, -1, false, "")
local shortDisambiguation = getShortDisambiguation(disambiguation)
local seasonType
local country = match(shortDisambiguation, "(([%s%w]+)%s+)[season series]", 1, -1, false, "")
local seasonNumber = ""
local seasonType = getSeasonType(shortDisambiguation)
local pipedLink = ""
if (disambiguation) then
shortDisambiguation = getShortDisambiguation(disambiguation)
seasonType = getSeasonType(shortDisambiguation)
seasonNumber = getCurrentSeasonNumberFromDisambiguation(shortDisambiguation)
pipedLink = seasonType:gsub("^%l", string.upper) .. " "
end
 
local realitySeriesStyle = false
local showNameModified
local seasonNumber = match(shortDisambiguation , "%d+", 1, -1, false, "")
if (seasonNumber == "") then
if (string.match(showName , "%s+(%d+)")) then
_, _, showNameModified, seasonNumber = string.findgetModifiedShowNameAndCurrentSeasonNumberFromShowName(showName, "(.*)%s+(%d+)")
realitySeriesStyle = true
else
return "" -- Not a valid next/prev season link
Baris 113 ⟶ 149:
else
seasonNumber = seasonNumber + prevOrNextSeasonNumber
pipedLink = seasonType:gsub("^%l", string.upper) .. " "pipedLink .. seasonNumber
-- Titles such as "Big Brother 1 (American season)""
if (realitySeriesStyleshowNameModified and disambiguation) then
return showNameModified .. " " .. seasonNumber .. " (" .. countrydisambiguation .. seasonType .. ")", pipedLink
 
-- Titles such as "Big Brother Brasil 1"
elseif (showNameModified) then
return showNameModified .. " " .. seasonNumber, nil
-- Standard titles such as "Lost (season 1)"
else
returndisambiguation showName= string.. " gsub(" .. year .. country .. seasonType ..disambiguation, " %d+$" .., seasonNumber .. ")"
return showName .. " (" .. disambiguation .. ")", pipedLink
end
return
end
end
Baris 161 ⟶ 202:
--]]
local function getSeasonArticleLink(frame, number)
local articleTitle, pipedLink = createArticleTitleHelper(frame, number)
return createArticleTitleWithPipedLink(articleTitle, pipedLink)
end
 
Baris 216 ⟶ 257:
local title = getTitle(frame)
local disambiguation = getDisambiguation(title)
if (disambiguation) then
local shortDisambiguation = getShortDisambiguation(disambiguation)
return getSeasonType(shortDisambiguation)
else
return ""
end
end
 
--[[
Public function which is used to return the relevant text for the sub-header field.
The text is returned in the format of <code>Season #</code> or <code>Series #</code>,
depending on either what the article disambiguation uses, or on manually entered parameters of the infobox.
--]]
function p.getInfoboxSubHeader(frame)
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame)
 
local seasonType
local seasonNumber
if (args.season_number) then
seasonType = "Musim"
seasonNumber = args.season_number
elseif (args.series_number) then
seasonType = "Seri"
seasonNumber = args.series_number
end
 
local title = getTitle(frame)
local showName = getShowName(title)
local disambiguation = getDisambiguation(title)
if (not seasonNumber and disambiguation) then
local shortDisambiguation = getShortDisambiguation(disambiguation)
 
seasonType = getSeasonType(shortDisambiguation)
seasonType = seasonType:sub(1, 1):upper() .. seasonType:sub(2)
seasonNumber = getCurrentSeasonNumberFromDisambiguation(shortDisambiguation)
end
 
if (seasonNumber and seasonNumber ~= "") then
return seasonType .. " " .. seasonNumber
end
return nil
end