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 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)
return "arc cerita"
end
if (string.find(shortDisambiguation , "series")) then
return "seri"
end
return "musim"
end
Baris 42 ⟶ 60:
--]]
local function getDisambiguation(title)
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
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 =
local disambiguation = getDisambiguation(title)
local shortDisambiguation
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 showNameModified
if (seasonNumber == "") then
if (string.match(showName , "%s+(%d+)")) then
else
return "" -- Not a valid next/prev season link
Baris 113 ⟶ 149:
else
seasonNumber = seasonNumber + prevOrNextSeasonNumber
pipedLink =
-- Titles such as "Big Brother 1 (American season)""
if (
return showNameModified .. " " .. seasonNumber .. " (" ..
-- Titles such as "Big Brother Brasil 1"
elseif (showNameModified) then
return showNameModified .. " " .. seasonNumber, nil
-- Standard titles such as "Lost (season 1)"
else
return showName .. " (" .. disambiguation .. ")", pipedLink
end
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) 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
|