« Module:Episode » : différence entre les versions
Apparence
Contenu supprimé Contenu ajouté
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 20 : | Ligne 20 : | ||
------------------------------------------------------------ |
------------------------------------------------------------ |
||
local function buildEpisodeLink(ep, label) |
local function buildEpisodeLink(ep, label) |
||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
if ep.namespace == "" or ep.namespace == nil then |
if ep.namespace == "" or ep.namespace == nil then |
||
| Ligne 51 : | Ligne 53 : | ||
return "Épisode ou film non référencé" |
return "Épisode ou film non référencé" |
||
end |
end |
||
| ⚫ | |||
local title = frame:preprocess(ep.title_fr) |
|||
| ⚫ | |||
end |
end |
||
| Ligne 62 : | Ligne 67 : | ||
return "Épisode ou film non référencé" |
return "Épisode ou film non référencé" |
||
end |
end |
||
| ⚫ | |||
local title = frame:preprocess(ep.title_fr) |
|||
| ⚫ | |||
end |
end |
||
| Ligne 73 : | Ligne 81 : | ||
return "Épisode ou film non référencé" |
return "Épisode ou film non référencé" |
||
end |
end |
||
| ⚫ | |||
local title = frame:preprocess(ep.title_fr) |
|||
| ⚫ | |||
end |
end |
||
| Ligne 85 : | Ligne 96 : | ||
return "Épisode ou film non référencé" |
return "Épisode ou film non référencé" |
||
end |
end |
||
| ⚫ | |||
local title = frame:preprocess(ep.title_fr) |
|||
| ⚫ | |||
end |
end |
||
| Ligne 125 : | Ligne 139 : | ||
return "Épisode ou film non référencé" |
return "Épisode ou film non référencé" |
||
end |
end |
||
| ⚫ | |||
local title = frame:preprocess(ep.title_fr) |
|||
return frame:preprocess(title) |
|||
end |
end |
||
Version du 28 mai 2026 à 14:39
| 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 = {}
-- Load the centralized Episode Index
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 then
return nil
end
return Index.get(key)
end
------------------------------------------------------------
-- Internal helper: build a link using the episode namespace
-- If namespace is empty (movies), omit it.
------------------------------------------------------------
local function buildEpisodeLink(ep, label)
local title_fr = frame:preprocess(ep.title_fr)
local title = label or title_fr or ep.page_title
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)
------------------------------------------------------------
function p.getEpisode(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
return buildEpisodeLink(ep)
end
------------------------------------------------------------
-- Function 2: Force namespace to "Crédits:"
------------------------------------------------------------
function p.getCreditsLink(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
local title = frame:preprocess(ep.title_fr)
return string.format("[[Crédits:%s|%s]]", ep.page_title, title)
end
------------------------------------------------------------
-- Function 3: Force namespace to "Retranscription:"
------------------------------------------------------------
function p.getTranscriptLink(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
local title = frame:preprocess(ep.title_fr)
return string.format("[[Retranscription:%s|%s]]", ep.page_title, title)
end
------------------------------------------------------------
-- Function 4: Force namespace to "Citations:"
------------------------------------------------------------
function p.getQuotesLink(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
local title = frame:preprocess(ep.title_fr)
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.
------------------------------------------------------------
function p.getImagesLink(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
local title = frame:preprocess(ep.title_fr)
return string.format("[[:Catégorie:Images de %s|%s]]", ep.page_title, title)
end
------------------------------------------------------------
-- Function 6: Retrieve only the page title (no namespace)
------------------------------------------------------------
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"
------------------------------------------------------------
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
------------------------------------------------------------
function p.getEpisodeTitle(frame)
local ep = getEntry(frame)
if not ep then
return "Épisode ou film non référencé"
end
local title = frame:preprocess(ep.title_fr)
return frame:preprocess(title)
end
return p