Module:Episode: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
local p = {} |
local p = {} |
||
-- Function 1: Get full episode link from key |
|||
function p.getEpisode(frame) |
function p.getEpisode(frame) |
||
local key = string.lower(frame.args[1] or "") |
local key = string.lower(frame.args[1] or "") |
||
| Line 18: | Line 19: | ||
return string.format("[[%s:%s|%s]]", ns, link, title) |
return string.format("[[%s:%s|%s]]", ns, link, title) |
||
end |
end |
||
end |
|||
-- Function 2: Force namespace to "Credits:" |
|||
function p.getCreditsLink(frame) |
|||
local link = frame.args[1] |
|||
local title = frame.args[2] |
|||
if not link or not title then |
|||
return "Missing link or title" |
|||
end |
|||
return string.format("[[Credits:%s|%s]]", link, title) |
|||
end |
|||
-- Function 3: Force namespace to "Transcript:" |
|||
function p.getTranscriptLink(frame) |
|||
local link = frame.args[1] |
|||
local title = frame.args[2] |
|||
if not link or not title then |
|||
return "Missing link or title" |
|||
end |
|||
return string.format("[[Transcript:%s|%s]]", link, title) |
|||
end |
|||
-- Function 3: Force namespace to "Quotes:" |
|||
function p.getQuotesLink(frame) |
|||
local link = frame.args[1] |
|||
local title = frame.args[2] |
|||
if not link or not title then |
|||
return "Missing link or title" |
|||
end |
|||
return string.format("[[Quotes:%s|%s]]", link, title) |
|||
end |
|||
-- Function 3: Force namespace to "Category:Images from" |
|||
function p.getImagesLink(frame) |
|||
local link = frame.args[1] |
|||
local title = frame.args[2] |
|||
if not link or not title then |
|||
return "Missing link or title" |
|||
end |
|||
return string.format("[[Category:Images from %s|%s]]", link, title) |
|||
end |
end |
||
Revision as of 17:49, 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 link = frame.args[1]
local title = frame.args[2]
if not link or not title then
return "Missing link or title"
end
return string.format("[[Credits:%s|%s]]", link, title)
end
-- Function 3: Force namespace to "Transcript:"
function p.getTranscriptLink(frame)
local link = frame.args[1]
local title = frame.args[2]
if not link or not title then
return "Missing link or title"
end
return string.format("[[Transcript:%s|%s]]", link, title)
end
-- Function 3: Force namespace to "Quotes:"
function p.getQuotesLink(frame)
local link = frame.args[1]
local title = frame.args[2]
if not link or not title then
return "Missing link or title"
end
return string.format("[[Quotes:%s|%s]]", link, title)
end
-- Function 3: Force namespace to "Category:Images from"
function p.getImagesLink(frame)
local link = frame.args[1]
local title = frame.args[2]
if not link or not title then
return "Missing link or title"
end
return string.format("[[Category:Images from %s|%s]]", link, title)
end
return p