Aller au contenu

« Module:Episode » : différence entre les versions

De Stargate Wiki Sémantique
Contenu supprimé Contenu ajouté
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 13 : Ligne 13 :
local ns, link, _, title = unpack(entry)
local ns, link, _, title = unpack(entry)


-- If namespace is empty or nil, omit it
if ns == "" or ns == nil then
if ns == "" or ns == nil then
return string.format("[[%s|%s]]", link, title)
return string.format("[[%s|%s]]", link, title)
Ligne 30 : Ligne 29 :
end
end


local _, link, _,title = unpack(entry) -- We ignore original namespace
local _, link, _, title = unpack(entry)
return string.format("[[Crédits:%s|%s]]", link, title)
return string.format("[[Crédits:%s|%s]]", link, title)
end
end
Ligne 43 : Ligne 42 :
end
end


local _, link, _, title = unpack(entry) -- We ignore original namespace
local _, link, _, title = unpack(entry)
return string.format("[[Retranscription:%s|%s]]", link, title)
return string.format("[[Retranscription:%s|%s]]", link, title)
end
end

-- Function 4: Force namespace to "Quotes:"
-- Function 4: Force namespace to "Quotes:"
function p.getQuotesLink(frame)
function p.getQuotesLink(frame)
Ligne 55 : Ligne 55 :
end
end


-- FIX : 4 valeurs → il faut 4 variables
local _, link, title = unpack(entry) -- We ignore original namespace
local _, link, _, title = unpack(entry)
return string.format("[[Citations:%s|%s]]", link, title)
return string.format("[[Citations:%s|%s]]", link, title)
end
end
Ligne 68 : Ligne 69 :
end
end


local _, link, _, title = unpack(entry) -- We ignore original namespace
local _, link, _, title = unpack(entry)
return string.format("[[:Catégorie:Images de %s|%s]]", link, title)
return string.format("[[:Catégorie:Images de %s|%s]]", link, title)
end
end
Ligne 81 : Ligne 82 :
end
end


local _, link, _, _ = unpack(entry) -- We ignore original namespace
local _, link = unpack(entry)
return string.format("%s", link)
return link
end
end


Ligne 94 : Ligne 95 :
end
end


local ns, link, _, _ = unpack(entry)
local ns, link = unpack(entry)


-- If namespace is empty or nil, omit it
if ns == "" or ns == nil then
if ns == "" or ns == nil then
return string.format("%s", link)
return link
else
else
return string.format("%s:%s", ns, link)
return ns .. ":" .. link
end
end
end
end
Ligne 114 : Ligne 114 :


local _, _, _, title = unpack(entry)
local _, _, _, title = unpack(entry)
return string.format("%s", title)
return title
end
end



Version du 4 juin 2026 à 20:50

Documentation icon Documentation module[créer]
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 ns == "" or ns == nil then
        return string.format("[[%s|%s]]", link, title)
    else
        return string.format("[[%s:%s|%s]]", ns, link, title)
    end
end

-- Function 2: Force namespace to "Credits:"
function p.getCreditsLink(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 _, link, _, title = unpack(entry)
    return string.format("[[Crédits:%s|%s]]", link, title)
end

-- Function 3: Force namespace to "Transcript:"
function p.getTranscriptLink(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 _, link, _, title = unpack(entry)
    return string.format("[[Retranscription:%s|%s]]", link, title)
end

-- Function 4: Force namespace to "Quotes:"
function p.getQuotesLink(frame)
    local key = string.lower(frame.args[1] or "")
    local entry = data[key]

    if not entry then
        return "Épisode non référencé"
    end

    -- FIX : 4 valeurs → il faut 4 variables
    local _, link, _, title = unpack(entry)
    return string.format("[[Citations:%s|%s]]", link, title)
end

-- Function 5: Force namespace to "Category:Images from"
function p.getImagesLink(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 _, link, _, title = unpack(entry)
    return string.format("[[:Catégorie:Images de %s|%s]]", link, title)
end

-- Function 6: Retrieve from link
function p.getEpisodeLink(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 _, link = unpack(entry)
    return link
end

-- Function 7: Get full episode link only from key
function p.getEpisodeFullLink(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 = unpack(entry)

    if ns == "" or ns == nil then
        return link
    else
        return ns .. ":" .. link
    end
end

-- Function 8: Get episode title only from key
function p.getEpisodeTitle(frame)
    local key = string.lower(frame.args[1] or "")
    local entry = data[key]

    if not entry then
        return "Episode not found"
    end

    local _, _, _, title = unpack(entry)
    return title
end

return p