Module:Episode: Difference between revisions
Appearance
Content deleted Content added
Created page with "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 "Episode not found" 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) else ret..." |
mNo edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 11: | Line 11: | ||
end |
end |
||
local ns, link, title = unpack(entry) |
local ns, link, _, title = unpack(entry) |
||
-- If namespace is empty or nil, omit it |
-- If namespace is empty or nil, omit it |
||
| Line 18: | Line 18: | ||
else |
else |
||
return string.format("[[%s:%s|%s]]", ns, link, title) |
return string.format("[[%s:%s|%s]]", ns, link, title) |
||
end |
|||
end |
|||
-- Function 1b: Get full episode link from key with chapter |
|||
function p.getEpisodeChapter(frame) |
|||
local key = string.lower(frame.args[1] or "") |
|||
local entry = data[key] |
|||
if not entry then |
|||
return "Episode not found" |
|||
end |
|||
local ns, link, chapter, title = unpack(entry) |
|||
-- If namespace is empty or nil, omit it |
|||
if ns == "" or ns == nil then |
|||
return string.format("[[%s|%s: %s]]", link, chapter, title) |
|||
else |
|||
return string.format("[[%s:%s|%s: %s]]", ns, link, chapter, title) |
|||
end |
end |
||
end |
end |
||
| Line 30: | Line 49: | ||
end |
end |
||
local _, link, title = unpack(entry) -- We ignore original namespace |
local _, link, _,title = unpack(entry) -- We ignore original namespace |
||
return string.format("[[Credits:%s|%s]]", link, title) |
return string.format("[[Credits:%s|%s]]", link, title) |
||
end |
end |
||
| Line 43: | Line 62: | ||
end |
end |
||
local _, link, title = unpack(entry) -- We ignore original namespace |
local _, link, _, title = unpack(entry) -- We ignore original namespace |
||
return string.format("[[Transcript:%s|%s]]", link, title) |
return string.format("[[Transcript:%s|%s]]", link, title) |
||
end |
end |
||
| Line 68: | Line 87: | ||
end |
end |
||
local _, link, title = unpack(entry) -- We ignore original namespace |
local _, link, _, title = unpack(entry) -- We ignore original namespace |
||
return string.format("[[:Category:Images from %s|%s]]", link, title) |
return string.format("[[:Category:Images from %s|%s]]", link, title) |
||
end |
end |
||
| Line 81: | Line 100: | ||
end |
end |
||
local _, link, _ = unpack(entry) -- We ignore original namespace |
local _, link, _, _ = unpack(entry) -- We ignore original namespace |
||
return string.format("%s", link) |
return string.format("%s", link) |
||
end |
end |
||
| Line 94: | Line 113: | ||
end |
end |
||
local ns, link, _ = unpack(entry) |
local ns, link, _, _ = unpack(entry) |
||
-- If namespace is empty or nil, omit it |
-- If namespace is empty or nil, omit it |
||
Latest revision as of 13:19, 2 August 2025
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 "Episode not found"
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|%s]]", link, title)
else
return string.format("[[%s:%s|%s]]", ns, link, title)
end
end
-- Function 1b: Get full episode link from key with chapter
function p.getEpisodeChapter(frame)
local key = string.lower(frame.args[1] or "")
local entry = data[key]
if not entry then
return "Episode not found"
end
local ns, link, chapter, title = unpack(entry)
-- If namespace is empty or nil, omit it
if ns == "" or ns == nil then
return string.format("[[%s|%s: %s]]", link, chapter, title)
else
return string.format("[[%s:%s|%s: %s]]", ns, link, chapter, 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 "Episode not found"
end
local _, link, _,title = unpack(entry) -- We ignore original namespace
return string.format("[[Credits:%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 "Episode not found"
end
local _, link, _, title = unpack(entry) -- We ignore original namespace
return string.format("[[Transcript:%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 "Episode not found"
end
local _, link, title = unpack(entry) -- We ignore original namespace
return string.format("[[Quotes:%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 "Episode not found"
end
local _, link, _, title = unpack(entry) -- We ignore original namespace
return string.format("[[:Category:Images from %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 "Episode not found"
end
local _, link, _, _ = unpack(entry) -- We ignore original namespace
return string.format("%s", 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 "Episode not found"
end
local ns, link, _, _ = unpack(entry)
-- If namespace is empty or nil, omit it
if ns == "" or ns == nil then
return string.format("%s", link)
else
return string.format("%s:%s", ns, link)
end
end
return p