« Module:Episode » : différence entre les versions
Apparence
Contenu supprimé Contenu ajouté
Page créée avec « local data = require("Module:Episode/data") local p = {} -- Function 1: Get full episode link from key function p.getEpisode(frame) local key = string.lower(frame.args[1] or "") local entry = data[key] if not entry then return "Épisode non référencé" end local ns, link, _, title = unpack(entry) -- If namespace is empty or nil, omit it if ns == "" or ns == nil then return string.format("%s", link, title)... » |
Aucun résumé des modifications |
||
| Ligne 1 : | Ligne 1 : | ||
local data = require("Module:Episode/data") |
|||
local p = {} |
local p = {} |
||
-- Load the centralized Episode Index |
|||
-- Function 1: Get full episode link from key |
|||
local Index = require("Module:Episode/Index") |
|||
function p.getEpisode(frame) |
|||
local key = string.lower(frame.args[1] or "") |
|||
local entry = data[key] |
|||
------------------------------------------------------------ |
|||
if not entry then |
|||
-- Internal helper: retrieve episode entry from key |
|||
return "Épisode non référencé" |
|||
------------------------------------------------------------ |
|||
local function getEntry(frame) |
|||
local key = frame.args[1] |
|||
if not key then |
|||
return nil |
|||
end |
end |
||
return Index.get(key) |
|||
end |
|||
------------------------------------------------------------ |
|||
local ns, link, _, title = unpack(entry) |
|||
-- Internal helper: build a link using the episode namespace |
|||
-- If namespace is empty (movies), omit it. |
|||
------------------------------------------------------------ |
|||
local function buildEpisodeLink(ep, label) |
|||
local title = label or ep.title_fr or ep.page_title |
|||
if ep.namespace == "" or ep.namespace == nil then |
|||
-- Movies and telefilms: no namespace |
|||
return string.format("[[%s|%s]]", |
return string.format("[[%s|%s]]", ep.page_title, title) |
||
else |
else |
||
-- Regular episodes: use namespace |
|||
return string.format("[[%s:%s|%s]]", ns, link, title) |
|||
return string.format("[[%s:%s|%s]]", ep.namespace, ep.page_title, title) |
|||
end |
end |
||
end |
end |
||
------------------------------------------------------------ |
|||
-- Function 2: Force namespace to "Credits:" |
|||
-- Function 1: Get full episode link (default namespace) |
|||
function p.getCreditsLink(frame) |
|||
------------------------------------------------------------ |
|||
local key = string.lower(frame.args[1] or "") |
|||
function p.getEpisode(frame) |
|||
local entry = data[key] |
|||
local ep = getEntry(frame) |
|||
if not ep then |
|||
return "Épisode ou film non référencé" |
|||
end |
|||
return buildEpisodeLink(ep) |
|||
end |
|||
------------------------------------------------------------ |
|||
if not entry then |
|||
-- Function 2: Force namespace to "Crédits:" |
|||
return "Épisode non référencé" |
|||
------------------------------------------------------------ |
|||
function p.getCreditsLink(frame) |
|||
local ep = getEntry(frame) |
|||
if not ep then |
|||
return "Épisode ou film non référencé" |
|||
end |
end |
||
return string.format("[[Crédits:%s|%s]]", ep.page_title, ep.title_fr) |
|||
local _, link, _,title = unpack(entry) -- We ignore original namespace |
|||
return string.format("[[Crédits:%s|%s]]", link, title) |
|||
end |
end |
||
------------------------------------------------------------ |
|||
-- Function 3: Force namespace to "Transcript:" |
|||
-- Function 3: Force namespace to "Retranscription:" |
|||
------------------------------------------------------------ |
|||
function p.getTranscriptLink(frame) |
function p.getTranscriptLink(frame) |
||
local |
local ep = getEntry(frame) |
||
if not ep then |
|||
return "Épisode ou film non référencé" |
|||
if not entry then |
|||
return "Épisode non référencé" |
|||
end |
end |
||
return string.format("[[Retranscription:%s|%s]]", ep.page_title, ep.title_fr) |
|||
end |
|||
------------------------------------------------------------ |
|||
local _, link, _, title = unpack(entry) -- We ignore original namespace |
|||
-- Function 4: Force namespace to "Citations:" |
|||
return string.format("[[Retranscription:%s|%s]]", link, title) |
|||
------------------------------------------------------------ |
|||
end |
|||
-- Function 4: Force namespace to "Quotes:" |
|||
function p.getQuotesLink(frame) |
function p.getQuotesLink(frame) |
||
local |
local ep = getEntry(frame) |
||
if not ep then |
|||
return "Épisode ou film non référencé" |
|||
if not entry then |
|||
return "Épisode non référencé" |
|||
end |
end |
||
return string.format("[[Citations:%s|%s]]", ep.page_title, ep.title_fr) |
|||
local _, link, title = unpack(entry) -- We ignore original namespace |
|||
return string.format("[[Citations:%s|%s]]", link, title) |
|||
end |
end |
||
------------------------------------------------------------ |
|||
-- Function 5: Force namespace to "Category:Images from" |
|||
-- Function 5: Force namespace to "Catégorie:Images de ..." |
|||
-- Leading colon prevents categorization when used in articles. |
|||
------------------------------------------------------------ |
|||
function p.getImagesLink(frame) |
function p.getImagesLink(frame) |
||
local |
local ep = getEntry(frame) |
||
if not ep then |
|||
return "Épisode ou film non référencé" |
|||
if not entry then |
|||
return "Épisode non référencé" |
|||
end |
end |
||
return string.format("[[:Catégorie:Images de %s|%s]]", ep.page_title, ep.title_fr) |
|||
local _, link, _, title = unpack(entry) -- We ignore original namespace |
|||
return string.format("[[:Catégorie:Images de %s|%s]]", link, title) |
|||
end |
end |
||
------------------------------------------------------------ |
|||
-- Function 6: Retrieve from link |
|||
-- Function 6: Retrieve only the page title (no namespace) |
|||
------------------------------------------------------------ |
|||
function p.getEpisodeLink(frame) |
function p.getEpisodeLink(frame) |
||
local |
local ep = getEntry(frame) |
||
if not ep then |
|||
return "Épisode ou film non référencé" |
|||
if not entry then |
|||
return "Épisode non référencé" |
|||
end |
end |
||
return ep.page_title |
|||
local _, link, _, _ = unpack(entry) -- We ignore original namespace |
|||
return string.format("%s", link) |
|||
end |
end |
||
------------------------------------------------------------ |
|||
-- Function 7: Get full episode link only from key |
|||
-- Function 7: Retrieve full link target (namespace + title) |
|||
-- Example: "Épisode:Enfants des dieux" |
|||
-- Movies return only "Enfants des dieux" |
|||
------------------------------------------------------------ |
|||
function p.getEpisodeFullLink(frame) |
function p.getEpisodeFullLink(frame) |
||
local |
local ep = getEntry(frame) |
||
if not ep then |
|||
return "Épisode ou film non référencé" |
|||
if not entry then |
|||
return "Épisode non référencé" |
|||
end |
end |
||
if ep.namespace == "" or ep.namespace == nil then |
|||
local ns, link, _, _ = unpack(entry) |
|||
return ep.page_title |
|||
-- If namespace is empty or nil, omit it |
|||
if ns == "" or ns == nil then |
|||
return string.format("%s", link) |
|||
else |
else |
||
return string.format("%s:%s", |
return string.format("%s:%s", ep.namespace, ep.page_title) |
||
end |
end |
||
end |
end |
||
------------------------------------------------------------ |
|||
-- Function 8: Get episode title only from key |
|||
-- Function 8: Retrieve only the French title |
|||
------------------------------------------------------------ |
|||
function p.getEpisodeTitle(frame) |
function p.getEpisodeTitle(frame) |
||
local |
local ep = getEntry(frame) |
||
if not ep then |
|||
return "Épisode ou film non référencé" |
|||
if not entry then |
|||
return "Episode not found" |
|||
end |
end |
||
return ep.title_fr |
|||
local _, _, _, title = unpack(entry) |
|||
return string.format("%s", title) |
|||
end |
end |
||
Version du 28 mai 2026 à 14:08
| 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 = label or ep.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
return string.format("[[Crédits:%s|%s]]", ep.page_title, ep.title_fr)
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
return string.format("[[Retranscription:%s|%s]]", ep.page_title, ep.title_fr)
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
return string.format("[[Citations:%s|%s]]", ep.page_title, ep.title_fr)
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
return string.format("[[:Catégorie:Images de %s|%s]]", ep.page_title, ep.title_fr)
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
return ep.title_fr
end
return p