Module:Chronology

From SPCodex, The Smashing Pumpkins wiki

Documentation for this module may be created at Module:Chronology/doc

local p = {};
local data = {
	['The Smashing Pumpkins'] = {
		['albums'] = {
			{ title = 'Nothing Ever Changes', year = 1988 },
			{ title = 'The Smashing Pumpkins', year = 1989, link = 'The Smashing Pumpkins (album)' },
			{ title = 'Moon Demo', year = 1989 },
			{ title = 'Gish', year = 1991 },
			{ title = 'Lull', year = 1991 },
			{ title = 'Peel Sessions', year = 1992 },
			{ title = 'Siamese Dream', year = 1993 },
			{ title = 'Siamese Singles', year = 1994 },
			{ title = 'Pisces Iscariot', year = 1994 },
			{ title = 'Mellon Collie and the Infinite Sadness', year = 1995 },
			{ title = 'The Aeroplane Flies High', year = 1996 },
			{ title = 'Adore', year = 1998 },
			{ title = 'Machina/The Machines of God', year = 2000},
			{ title = 'Machina II/The Friends & Enemies of Modern Music', year = 2000 },
			{ title = 'Live at Cabaret Metro 10-5-88', year = 2000 },
			{ title = 'Rotten Apples', year = 2001 },
			{ title = 'Judas O', year = 2001 },
			{ title = 'Rarities and B-Sides', year = 2005 },
			{ title = 'Zeitgeist', year = 2007 },
			{ title = 'American Gothic', year = 2007 },
			{ title = 'Teargarden by Kaleidyscope', year = 2009 },
			{ title = 'Oceania', year = 2011 },
			{ title = 'Monuments to an Elegy', year = 2014 },
			{ title = 'Shiny and Oh So Bright, Vol. 1 / LP: No Past. No Future. No Sun.', year = 2018 }
		}
	},
	['Billy Corgan'] = {
		['albums'] = {
			{ title = 'TheFutureEmbrace', year = 2005 },
			{ title = 'Ogilala', year = 2017 },
			{ title = 'Cotillions', year = 2019 }
		}
	},
	['James Iha'] = {
		['albums'] = {
			{ title = 'Let It Come Down', year = 1998 },
			{ title = 'Look to the Sky', year = 2012 }
		}
	},
	['Jimmy Chamberlin Complex'] = {
		['albums'] = {
			{ title = 'Life Begins Again', year = 2005 },
			{ title = 'The Parable', year = 2017 }
		}
	},
	['Tribute'] = {
		['albums'] = {
			{ title = 'Ghost Children: A Tribute To The Smashing Pumpkins', year = 2001 },
			{ title = 'Ghost Children/Friends and Enemies', year = 2006 },
			{ title = 'MySpace Smashing Pumpkins Tribute', year = 2007 }
		}
	}
}

local function entry(row, kind, current)
	local formatting = "''" -- For albums
	if kind == 'singles' then
		formatting = '"'
	end
	if current then
		formatting = formatting .. "'''"
	end
	
	local link = row.title
	if row.link ~= nil then
		link = row.link .. "|" .. row.title
	end
	
	return formatting .. "[[" .. link .. "]]" .. formatting .. "<br/>(" .. row.year .. ")"
end

function p.main( frame )
	local artist = frame.args[1]
	local kind = frame.args[2]
	local title = frame.args[3]
	local albums = data[artist][kind]
	for i, subject in ipairs(albums) do
		if title == subject.title then
			local wikitext = "{| style='background: transparent; width: 100%; min-width: 100%; border-collapse: collapse'"
			wikitext = wikitext .. "\n|- style='line-height: 1.4em;'"
			wikitext = wikitext .. "\n| style='width: 33%; text-align: center; vertical-align: top; padding: .2em .1em .2em 0' |"
			
			if i > 1 then
				wikitext = wikitext .. entry(albums[i - 1], kind, false)
			end
			
			wikitext = wikitext .. "\n| style='width: 33%; text-align: center; vertical-align: top; padding: .2em .1em' |"
			wikitext = wikitext .. entry(subject, kind, true)
			wikitext = wikitext .. "\n| style='width: 33%; text-align: center; vertical-align: top; padding: .2em 0 .2em .1em' |"
			
			if albums[i + 1] ~= nil then
				wikitext = wikitext .. entry(albums[i + 1], kind, false)
			end

			return wikitext .. "\n|}"
		end
	end
	
	return "Unknown album! Please update Module:Chronology"
end

return p