Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Television episode redirect handler
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
require("strict") local p = {} local addManualCategory = false local currentFrame local categoryList = { ["SEASON_EPISODE_CATEGORY"] = "Category:%s (%s %s) episodes" } local TEMP_TRACKING_CATEGORY = "[[Category:Television episode redirect handler parameter usage tracking|%s]]" --[[ Helper function which creates a season category, checks if it exists and returns it if it does or an empty string if it doesn't. --]] local function getSeasonCategory(seriesName, seasonType, seasonNumber) local seasonCategory = string.format(categoryList["SEASON_EPISODE_CATEGORY"], seriesName, seasonType, seasonNumber) if (mw.title.new(seasonCategory).exists) then return "[[" .. seasonCategory .. "]]" else return "" end end --[[ Local function which sets adds the primary episode redirect to a season category, if it exists. --]] local function getSeasonCategory(args) local seasonNumber local seasonType if (args.season_num) then seasonNumber = args.season_num seasonType = "season" elseif (args.season_num_uk) then seasonNumber = args.season_num_uk seasonType = "series" end local seasonCategory = "" if (args.series_name and seasonNumber) then seasonCategory = getSeasonCategory(args.series_name, seasonType, seasonNumber) if (seasonCategory == "") then local seriesNameNoDab = mw.ustring.gsub(args.series_name, "%s+%b()$", "") seasonCategory = getSeasonCategory(seriesNameNoDab, seasonType, seasonNumber) end end return seasonCategory end --[[ Local function which "Module:Sort title" to retrieve a sortkey and set it as the default sortkey. --]] local function getDefaultSortKey() local sortkeyModule = require("Module:Sort title") local sortkey = sortkeyModule._getSortKey() return currentFrame:preprocess{text = "{{DEFAULTSORT:" .. sortkey .. "}}"} end --[[ Local function which calls "Module:Television episode short description" to add a short description. --]] local function getShortDescription(args) local shortDescription = require("Module:Television episode short description")._getShortDescription return shortDescription(currentFrame, args) end --[[ Public function which is used to create a Redirect category shell with relevant redirects, and a short description for a television episode. A sort key is also added to the article. Parameters: See module documentation for details. --]] function p.main(frame) currentFrame = frame local getArgs = require("Module:Arguments").getArgs local args = getArgs(currentFrame) local redirectTemplateHandler = require("Module:Redirect template handler") local validArgs = {"season_num", "season_num_uk", "episode_num", "limited", "not_dab", "parent_series", "special"} local redirectCategoryShell, mainRedirect, unknownParametersErrors = redirectTemplateHandler.setEpisodeRedirect(args, validArgs) -- Used for testcases testing. if (args.test) then -- This is not the shell, but just the redirect template names that were used. return redirectCategoryShell end -- Only add a short description to the main redirect, -- and not to a crossover episode, as the short description isn't set up to handle it. local shortDescription = "" if (mainRedirect and not args.series_name2) then shortDescription = getShortDescription(args) end local defaultSortKey = getDefaultSortKey() local seasonCategory = getSeasonCategory(args) if (unknownParametersErrors) then return redirectCategoryShell .. "\n" .. shortDescription .. "\n" .. defaultSortKey .. "\n" .. seasonCategory .. unknownParametersErrors else return redirectCategoryShell .. "\n" .. shortDescription .. "\n" .. defaultSortKey .. "\n" .. seasonCategory end end return p
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Auto short description
(
edit
)
Template:Fiction-related redirects templates
(
edit
)
Template:High-use
(
edit
)
Template:Lua
(
edit
)
Template:Mlx
(
edit
)
Template:Module link expanded
(
edit
)
Template:Template link
(
edit
)
Template:Tl
(
edit
)
Template:Transcluded section
(
edit
)
Template:Trim
(
edit
)
Module:Arguments
(
edit
)
Module:Lua banner
(
edit
)
Module:Separated entries
(
edit
)
Module:TableTools
(
edit
)
Module:Television episode redirect handler/doc
(
edit
)