Module:Main Page: Difference between revisions
Jump to navigation
Jump to search
MannedTooth (talk | contribs) No edit summary |
MannedTooth (talk | contribs) No edit summary |
||
Line 11: | Line 11: | ||
-- Get all stored games | -- Get all stored games | ||
local tables = "Games" | local tables = "Games" | ||
local fields = "name, subtitle, initialism, mainrelease, type" | local fields = "name, subtitle, initialism, mainrelease, type, family, canonicity" | ||
local args = { | local args = { | ||
orderBy = "mainrelease DESC" | orderBy = "mainrelease DESC" |
Revision as of 22:22, 11 November 2019
Documentation for this module may be created at Module:Main Page/Documentation
local p = {}
local cargo = mw.ext.cargo
local tab2 = require("Module:Tab2")
local utilsCode = require("Module:UtilsCode")
function p._DisplayGameList(frame)
return p.DisplayGameList()
end
function p.DisplayGameList()
-- Get all stored games
local tables = "Games"
local fields = "name, subtitle, initialism, mainrelease, type, family, canonicity"
local args = {
orderBy = "mainrelease DESC"
}
local games = cargo.query(tables, fields, args)
-- Generate tabs
local maingames = mw.html.create("div")
:addClass("game-container main-games")
local remakes = mw.html.create("div")
:addClass("game-container remakes")
local spinoffs = mw.html.create("div")
:addClass("game-container spin-offs")
local frame = mw.getCurrentFrame()
for key, game in ipairs(games) do
local releaseYear = "TBA"
if not utilsCode.IsEmpty(game["mainrelease"]) then
releaseYear = string.sub(game["mainrelease"], 1, 4)
end
if game["type"] == "main" then
maingames:node(mw.html.create("div")
:addClass("game")
:wikitext("<span class='year'>" .. releaseYear .. "</span>[[" .. game["name"] .. "|" .. game["subtitle"] .. "]][[File:" .. game["initialism"] .. " Tile.png|link=]]"))
elseif game["type"] == "remake" then
remakes:node(mw.html.create("div")
:addClass("game")
:wikitext("<span class='year'>" .. releaseYear .. "</span>[[" .. game["name"] .. "|" .. game["subtitle"] .. "]][[File:" .. game["initialism"] .. " Tile.png|link=]]"))
elseif game["type"] == "spin-off" and utilsCode.IsEmpty(game["family"]) == true then
spinoffs:node(mw.html.create("div")
:addClass("game")
:wikitext("<span class='year'>" .. releaseYear .. "</span>[[" .. game["name"] .. "|" .. game["subtitle"] .. "]][[File:" .. game["initialism"] .. " Tile.png|link=]]"))
end
end
local tabs = {}
table.insert(tabs, 1, {tabName = "Main Series", tabCaption = "", tabContent = tostring(maingames)})
table.insert(tabs, 2, {tabName = "Remakes", tabCaption = "", tabContent = tostring(remakes)})
table.insert(tabs, 3, {tabName = "Spin-Offs", tabCaption = "", tabContent = tostring(spinoffs)})
return tab2.Main(tabs, 1, "top", 3, "", "100%", "", "center")
end
return p