« Module:Episode » : différence entre les versions
Apparence
Contenu supprimé Contenu ajouté
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| (6 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
local p = {} |
local p = {} |
||
-- |
-- Centralized Episode Index (multi-series, episodes + movies) |
||
local Index = require("Module:Episode/index") |
local Index = require("Module:Episode/index") |
||
| Ligne 9 : | Ligne 9 : | ||
local function getEntry(frame) |
local function getEntry(frame) |
||
local key = frame.args[1] |
local key = frame.args[1] |
||
if not key then |
if not key or key == "" then |
||
return nil |
return nil |
||
end |
end |
||
return Index.get(key) |
return Index.get(key) |
||
end |
|||
------------------------------------------------------------ |
|||
-- Internal helper: preprocess a title using the parser |
|||
-- Falls back gracefully if title is missing. |
|||
------------------------------------------------------------ |
|||
local function preprocessTitle(frame, ep) |
|||
local raw = ep.title_fr or ep.page_title or ep.property or ep.id or "" |
|||
| ⚫ | |||
end |
end |
||
| Ligne 18 : | Ligne 27 : | ||
-- Internal helper: build a link using the episode namespace |
-- Internal helper: build a link using the episode namespace |
||
-- If namespace is empty (movies), omit it. |
-- If namespace is empty (movies), omit it. |
||
-- Title is always preprocessed here. |
|||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
local function buildEpisodeLink(ep, |
local function buildEpisodeLink(frame, ep, labelOverride) |
||
local title = |
local title = labelOverride or preprocessTitle(frame, ep) |
||
if ep.namespace == "" or ep.namespace == nil then |
if ep.namespace == "" or ep.namespace == nil then |
||
| Ligne 33 : | Ligne 43 : | ||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
-- Function 1: Get full episode link (default namespace) |
-- Function 1: Get full episode link (default namespace) |
||
-- Uses preprocessed French title as label. |
|||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
function p.getEpisode(frame) |
function p.getEpisode(frame) |
||
| Ligne 39 : | Ligne 50 : | ||
return "Épisode ou film non référencé" |
return "Épisode ou film non référencé" |
||
end |
end |
||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
end |
end |
||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
-- Function 2: Force namespace to "Crédits:" |
-- Function 2: Force namespace to "Crédits:" |
||
-- Uses preprocessed French title as label. |
|||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
function p.getCreditsLink(frame) |
function p.getCreditsLink(frame) |
||
| Ligne 52 : | Ligne 62 : | ||
return "Épisode ou film non référencé" |
return "Épisode ou film non référencé" |
||
end |
end |
||
| ⚫ | |||
local title = preprocessTitle(frame, ep) |
|||
| ⚫ | |||
end |
end |
||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
-- Function 3: Force namespace to "Retranscription:" |
-- Function 3: Force namespace to "Retranscription:" |
||
-- Uses preprocessed French title as label. |
|||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
function p.getTranscriptLink(frame) |
function p.getTranscriptLink(frame) |
||
| Ligne 63 : | Ligne 76 : | ||
return "Épisode ou film non référencé" |
return "Épisode ou film non référencé" |
||
end |
end |
||
| ⚫ | |||
local title = preprocessTitle(frame, ep) |
|||
| ⚫ | |||
end |
end |
||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
-- Function 4: Force namespace to "Citations:" |
-- Function 4: Force namespace to "Citations:" |
||
-- Uses preprocessed French title as label. |
|||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
function p.getQuotesLink(frame) |
function p.getQuotesLink(frame) |
||
| Ligne 74 : | Ligne 90 : | ||
return "Épisode ou film non référencé" |
return "Épisode ou film non référencé" |
||
end |
end |
||
| ⚫ | |||
local title = preprocessTitle(frame, ep) |
|||
| ⚫ | |||
end |
end |
||
| Ligne 80 : | Ligne 98 : | ||
-- Function 5: Force namespace to "Catégorie:Images de ..." |
-- Function 5: Force namespace to "Catégorie:Images de ..." |
||
-- Leading colon prevents categorization when used in articles. |
-- Leading colon prevents categorization when used in articles. |
||
-- Uses preprocessed French title as label. |
|||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
function p.getImagesLink(frame) |
function p.getImagesLink(frame) |
||
| Ligne 86 : | Ligne 105 : | ||
return "Épisode ou film non référencé" |
return "Épisode ou film non référencé" |
||
end |
end |
||
| ⚫ | |||
local title = preprocessTitle(frame, ep) |
|||
| ⚫ | |||
end |
end |
||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
-- Function 6: Retrieve only the page title (no namespace) |
-- Function 6: Retrieve only the page title (no namespace) |
||
-- No preprocess needed here. |
|||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
function p.getEpisodeLink(frame) |
function p.getEpisodeLink(frame) |
||
| Ligne 103 : | Ligne 125 : | ||
-- Function 7: Retrieve full link target (namespace + title) |
-- Function 7: Retrieve full link target (namespace + title) |
||
-- Example: "Épisode:Enfants des dieux" |
-- Example: "Épisode:Enfants des dieux" |
||
-- Movies return only "Enfants des dieux" |
-- Movies return only "Enfants des dieux". |
||
-- No preprocess needed here. |
|||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
function p.getEpisodeFullLink(frame) |
function p.getEpisodeFullLink(frame) |
||
| Ligne 119 : | Ligne 142 : | ||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
-- Function 8: Retrieve only the French title |
-- Function 8: Retrieve only the French title (preprocessed) |
||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
function p.getEpisodeTitle(frame) |
function p.getEpisodeTitle(frame) |
||
| Ligne 126 : | Ligne 149 : | ||
return "Épisode ou film non référencé" |
return "Épisode ou film non référencé" |
||
end |
end |
||
return ep |
return preprocessTitle(frame, ep) |
||
end |
|||
------------------------------------------------------------ |
|||
-- Function 9: Get the episode number as a two‑digit string |
|||
-- Returns "" for movies (no episode number) |
|||
------------------------------------------------------------ |
|||
function p.getEpisodeNumber(frame) |
|||
local ep = getEntry(frame) |
|||
if not ep then |
|||
return "Épisode ou film non référencé" |
|||
end |
|||
-- Movies and telefilms have no episode number |
|||
if not ep.episode or ep.episode == "" then |
|||
return "" |
|||
end |
|||
-- Format as two digits (01, 02, ..., 22) |
|||
return string.format("%02d", tonumber(ep.episode)) |
|||
end |
|||
------------------------------------------------------------ |
|||
-- Function 10: Get the season number as a numeric string |
|||
-- Returns "" for movies (no season number) |
|||
------------------------------------------------------------ |
|||
function p.getSeasonNumber(frame) |
|||
local ep = getEntry(frame) |
|||
if not ep then |
|||
return "Épisode ou film non référencé" |
|||
end |
|||
-- Movies and telefilms have no season number |
|||
if not ep.season or ep.season == "" then |
|||
return "" |
|||
end |
|||
-- Return numeric season (no formatting) |
|||
return tostring(ep.season) |
|||
end |
end |
||
Dernière version du 29 mai 2026 à 20:58
| Il sera peut-être nécessaire de créer une page documentation pour ce module Scribunto programmé dans la page créer Les éditeurs peuvent faire des tests sur les pages bac à sable (créer | miroir) et études de cas (créer) du module. Veuillez ajouter les catégories dans la sous-page /documentation. Sous-pages de ce module. |
local p = {}
-- Centralized Episode Index (multi-series, episodes + movies)
local Index = require("Module:Episode/index")
------------------------------------------------------------
-- Internal helper: retrieve episode entry from key
------------------------------------------------------------
local function getEntry(frame)
local key = frame.args[1]
if not key or key == "" then
return nil
end
return Index.get(key)
end
------------------------------------------------------------
-- Internal helper: preprocess a title using the parser
-- Falls back gracefully if title is missing.
------------------------------------------------------------
local function preprocessTitle(frame, ep)
local raw = ep.title_fr or ep.page_title or ep.property or ep.id or ""
return frame:preprocess(raw)
end
------------------------------------------------------------
-- Internal helper: build a link using the episode namespace
-- If namespace is empty (movies), omit it.
-- Title is always preprocessed here.
------------------------------------------------------------
local function buildEpisodeLink(frame, ep, labelOverride)
local title = labelOverride or preprocessTitle(frame, ep)
if ep.namespace == "" or ep.namespace == nil then
-- Movies and telefilms: no namespace
return string.format("[[%s|%s]]", ep.page_title, title)
else
-- Regular episodes: use namespace
return string.format("[[%s:%s|%s]]", ep.namespace, ep.page_title, title)
end
end
------------------------------------------------------------
-- Function 1: Get full episode link (default namespace)
-- Uses preprocessed French title as label.
------------------------------------------------------------
function p.getEpisode(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
return buildEpisodeLink(frame, ep)
end
------------------------------------------------------------
-- Function 2: Force namespace to "Crédits:"
-- Uses preprocessed French title as label.
------------------------------------------------------------
function p.getCreditsLink(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
local title = preprocessTitle(frame, ep)
return string.format("[[Crédits:%s|%s]]", ep.page_title, title)
end
------------------------------------------------------------
-- Function 3: Force namespace to "Retranscription:"
-- Uses preprocessed French title as label.
------------------------------------------------------------
function p.getTranscriptLink(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
local title = preprocessTitle(frame, ep)
return string.format("[[Retranscription:%s|%s]]", ep.page_title, title)
end
------------------------------------------------------------
-- Function 4: Force namespace to "Citations:"
-- Uses preprocessed French title as label.
------------------------------------------------------------
function p.getQuotesLink(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
local title = preprocessTitle(frame, ep)
return string.format("[[Citations:%s|%s]]", ep.page_title, title)
end
------------------------------------------------------------
-- Function 5: Force namespace to "Catégorie:Images de ..."
-- Leading colon prevents categorization when used in articles.
-- Uses preprocessed French title as label.
------------------------------------------------------------
function p.getImagesLink(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
local title = preprocessTitle(frame, ep)
return string.format("[[:Catégorie:Images de %s|%s]]", ep.page_title, title)
end
------------------------------------------------------------
-- Function 6: Retrieve only the page title (no namespace)
-- No preprocess needed here.
------------------------------------------------------------
function p.getEpisodeLink(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
return ep.page_title
end
------------------------------------------------------------
-- Function 7: Retrieve full link target (namespace + title)
-- Example: "Épisode:Enfants des dieux"
-- Movies return only "Enfants des dieux".
-- No preprocess needed here.
------------------------------------------------------------
function p.getEpisodeFullLink(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
if ep.namespace == "" or ep.namespace == nil then
return ep.page_title
else
return string.format("%s:%s", ep.namespace, ep.page_title)
end
end
------------------------------------------------------------
-- Function 8: Retrieve only the French title (preprocessed)
------------------------------------------------------------
function p.getEpisodeTitle(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
return preprocessTitle(frame, ep)
end
------------------------------------------------------------
-- Function 9: Get the episode number as a two‑digit string
-- Returns "" for movies (no episode number)
------------------------------------------------------------
function p.getEpisodeNumber(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
-- Movies and telefilms have no episode number
if not ep.episode or ep.episode == "" then
return ""
end
-- Format as two digits (01, 02, ..., 22)
return string.format("%02d", tonumber(ep.episode))
end
------------------------------------------------------------
-- Function 10: Get the season number as a numeric string
-- Returns "" for movies (no season number)
------------------------------------------------------------
function p.getSeasonNumber(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
-- Movies and telefilms have no season number
if not ep.season or ep.season == "" then
return ""
end
-- Return numeric season (no formatting)
return tostring(ep.season)
end
return p