Module:Episode: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 23: | Line 23: | ||
-- Function 2: Force namespace to "Credits:" |
-- Function 2: Force namespace to "Credits:" |
||
function p.getCreditsLink(frame) |
function p.getCreditsLink(frame) |
||
local |
local key = string.lower(frame.args[1] or "") |
||
local |
local entry = data[key] |
||
if not |
if not entry then |
||
return " |
return "Episode not found" |
||
end |
end |
||
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 35: | Line 36: | ||
-- Function 3: Force namespace to "Transcript:" |
-- Function 3: Force namespace to "Transcript:" |
||
function p.getTranscriptLink(frame) |
function p.getTranscriptLink(frame) |
||
local |
local key = string.lower(frame.args[1] or "") |
||
local |
local entry = data[key] |
||
if not |
if not entry then |
||
return " |
return "Episode not found" |
||
end |
end |
||
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 |
||
| ⚫ | |||
| ⚫ | |||
function p.getQuotesLink(frame) |
function p.getQuotesLink(frame) |
||
local |
local key = string.lower(frame.args[1] or "") |
||
local |
local entry = data[key] |
||
if not |
if not entry then |
||
return " |
return "Episode not found" |
||
end |
end |
||
local _, link, title = unpack(entry) -- We ignore original namespace |
|||
return string.format("[[Quotes:%s|%s]]", link, title) |
return string.format("[[Quotes:%s|%s]]", link, title) |
||
end |
end |
||
-- Function |
-- Function 5: Force namespace to "Category:Images from" |
||
function p.getImagesLink(frame) |
function p.getImagesLink(frame) |
||
local |
local key = string.lower(frame.args[1] or "") |
||
local |
local entry = data[key] |
||
if not |
if not entry then |
||
return " |
return "Episode not found" |
||
end |
end |
||
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 |
|||
-- 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 |
end |
||
Latest revision as of 20:28, 21 July 2025
| You might want to create a documentation page for this Scribunto module. Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this module. |
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 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