Module:Sandbox/Gonnym/episodewikidata explained

local getArgs = require('Module:Arguments').getArgslocal getWikiDataValue = require('Module:WikidataIB/sandbox')._getValue

p =

local function getPreviousEpisodeFromWikiData return getWikiDataValueend

local function getNextEpisodeFromWikiData return getWikiDataValueend

function p.getPreviousEpisodeFromWikiData return getWikiDataValueend

function p.getNextEpisodeFromWikiData return getWikiDataValueend

local function getFormattedPreviousEpisodeLink(args) local previousEpisodeRaw = args.rprev or args.RPrev local previousEpisode = args.prev or getPreviousEpisodeFromWikiData

local previousEpisodeLink local hasLink = true if (previousEpisodeRaw) then previousEpisodeLink = previousEpisodeRaw elseif (previousEpisode) then previousEpisodeLink = '"' .. previousEpisode .. '"' else previousEpisodeLink = " - " hasLink = false end return previousEpisodeLink, hasLinkend

local function getFormattedNextEpisodeLink(args) local nextEpisodeRaw = args.rnext or args.RNext local nextEpisode = args.next or getNextEpisodeFromWikiData

local nextEpisodeLink local hasLink = true if (nextEpisodeRaw) then nextEpisodeLink = nextEpisodeRaw elseif (nextEpisode) then nextEpisodeLink = '"' .. nextEpisode .. '"' else nextEpisodeLink = " - " hasLink = false end

return nextEpisodeLink, hasLinkend

function p.getEpisodeChronology(frame) local args = getArgs(frame) local previousEpisodeLink, hasPreviousLink = getFormattedPreviousEpisodeLink(args) local nextEpisodeLink, hasNextLink = getFormattedNextEpisodeLink(args) if (hasPreviousLink or hasNextLink) then-- return frame:expandTemplate local chronologyString = '

' .. '

← \'\'\'Previous\'\'\'
' .. previousEpisodeLink .. '

' .. '

\'\'\'Next\'\'\' →
' .. nextEpisodeLink .. '

' .. '

' return chronologyString else return nil endend

function p.getHeaderTitle(frame) local args = getArgs(frame) local previousEpisode = args.prev or args.rprev or args.RPrev or getPreviousEpisodeFromWikiData local nextEpisode = args.next or args.rnext or args.RNext or getNextEpisodeFromWikiData if (previousEpisode or nextEpisode) then return "Episode chronology" endend

return p