Module:Sandbox/Gonnym/episodewikidata
Appearance
local getWikiDataValue = require('Module:WikidataIB').getValue
p = {}
local function getFormattedPreviousEpisodeLink(args)
local previousEpisodeRaw = args.rprev or args.RPrev
local previousEpisode = args.prev or getWikiDataValue({fetchwikidata = "ALL", onlysourced = "n", "P155"})
local previousEpisodeLink
if (previousEpisodeRaw) then
previousEpisodeLink = previousEpisodeRaw
elseif (previousEpisode) then
previousEpisodeLink = '"' .. previousEpisode .. '"'
else
previousEpisodeLink = "—"
end
end
local function getFormattedNextEpisodeLink(args)
local nextEpisodeRaw = args.rnext or args.RNext
local nextEpisode = args.next or getWikiDataValue({fetchwikidata = "ALL", onlysourced = "n", "P156"})
local nextEpisodeLink
if (nextEpisodeRaw) then
nextEpisodeLink = nextEpisodeRaw
elseif (nextEpisode) then
nextEpisodeLink = '"' .. nextEpisode .. '"'
else
nextEpisodeLink = "—"
end
end
function p.getEpisodeChronology(frame)
local previousEpisodeLink = getFormattedPreviousEpisodeLink(args)
local nextEpisodeLink = getFormattedNextEpisodeLink(args)
--{{succession links|left=previousEpisodeLink|right=nextEpisodeLink}}
return '! style="width:100%;" ! style="width: 50%; padding: 0.2em 0.1em 0.2em 0; text-align: center;" ! ← \'\'\'Previous\'\'\'<br />' .. previousEpisodeLink .. '! style="width: 50%; padding: 0.2em 0 0.2em 0.1em; text-align: center;" ! \'\'\'Next\'\'\' →<br />' .. nextEpisodeLink
end
local function getHeaderTitle()
local previousEpisode = args.prev or args.rprev or args.RPrev or getWikiDataValue({fetchwikidata = "ALL", onlysourced = "n", "P155"})
local nextEpisode = args.next or args.rnext or args.RNext or getWikiDataValue({fetchwikidata = "ALL", onlysourced = "n", "P156"})
if (previousEpisode or nextEpisode) then
return "Episode chronology"
end
end
return p