Skip to content
Permalink
Browse files
Merge branch 'feature/game-category-filter' into feature/individual-page
  • Loading branch information
soperd committed Nov 29, 2019
2 parents 6e2c524 + 7fb3cea commit a1190dcf05bdd97470a13122480b4109a8357683
Show file tree
Hide file tree
Showing 38 changed files with 2,223 additions and 1,769 deletions.
0 .githooks/post-commit 100755 → 100644
Empty file.
0 .githooks/pre-commit 100755 → 100644
Empty file.
15 app.js
@@ -12,10 +12,6 @@ const serve = require('./controllers/middleware/serve')
const session = require('koa-session')
const bodyParser = require('koa-bodyparser')

// const findPartials = (folder) =>
// fs.readdirSync(folder)
// .filter(x => x.endsWith('partial.hbs'))

const app = new Koa()
const handlebars = new Views(
path.join(__dirname, '/views'),
@@ -31,10 +27,6 @@ const handlebars = new Views(
)
app.use(session({key: 'session_id', renew: true}, app))

const list = require('./controllers/list')
const approval = require('./controllers/approval')
const adding = require('./controllers/adding')

const SECRET_KEY = process.env.SECRET_KEY || 'dummy'
app.keys = [SECRET_KEY]

@@ -59,9 +51,13 @@ app.context.db = dbcontext
const login = require('./controllers/login')
const home = require('./controllers/home')
const logout = require('./controllers/logout')
const games = require('./controllers/listrouter')
const game = require('./controllers/game')
const homepage = require('./controllers/homepage')
const signup = require('./controllers/signup')
const list = require('./controllers/list')
const approval = require('./controllers/approval')
const adding = require('./controllers/adding')

app.use(handlebars)
app.use(game.routes())
@@ -70,6 +66,9 @@ app.use(list.routes())
app.use(approval.routes())
app.use(logout.routes())
app.use(game.routes())
app.use(games.routes())
app.use(list.routes())
app.use(approval.routes())
app.use(adding.routes())
app.use(homepage.routes())
app.use(signup.routes())
@@ -1,7 +1,6 @@
INSERT INTO `games` VALUES
(1,
'The Last of Us',
'31',
'Hope is the key to survival.',
'Set in the post-apocalyptic United States, the game tells the story of survivors Joel and Ellie as they work together to survive their westward journey across what remains of the country to find a possible cure for the modern fungal plague that has nearly decimated the entire human race.',
'04/06/2013',
@@ -15,7 +14,6 @@ INSERT INTO `games` VALUES
INSERT INTO `games` VALUES
(2,
'The Legend of Zelda: Breath of the Wild',
'34,37',
'Step into a world of discovery, exploration and adventure.',
'No kingdom. No memories. After a 100-year slumber, Link wakes up alone in a world he no longer remembers. Now the legendary hero must explore a vast and dangerous land and regain his memories before Hyrule is lost forever. Armed only with what he can scavenge, Link sets out to find answers and the resources needed to survive.',
'03/03/2017',
@@ -29,7 +27,6 @@ INSERT INTO `games` VALUES
INSERT INTO `games` VALUES
(3,
"Marvel's Spider-Man",
'36',
'Be Greater.',
'After eight years behind the mask, Peter Parker is a crime-fighting expert. Feel the full power of a more experienced Spider-Man with improvisational combat, dynamic acrobatics, fluid urban traversal, and environmental interactions. A rookie no longer, this is the most masterful Spider-Man you’ve ever played.',
'07/09/2018',
@@ -43,7 +40,6 @@ INSERT INTO `games` VALUES
INSERT INTO `games` VALUES
(4,
"Football Manager 2020",
'38,37,39,40,41',
'Your club, your way.',
'Manage your football club, your way. Every decision counts in FM20 with new features rewarding planning and progression like never before, empowering managers to develop both your club’s and your own unique managerial identity.',
'19/11/2019',
@@ -57,7 +53,6 @@ INSERT INTO `games` VALUES
INSERT INTO `games` VALUES
(5,
"Star Wars Jedi: Fallen Order",
'36,35,38',
'Become a Jedi.',
'The Empire seeks to eradicate all Jedi after the execution of Order 66. You, a Jedi Padawan-turned-fugitive, must fight for your survival as you explore the mysteries of a long-extinct civilization in hopes of rebuilding the Jedi Order.',
'15/11/2019',
@@ -111,5 +106,18 @@ INSERT INTO 'platforms' VALUES (40, 'iOS');
INSERT INTO 'platforms' VALUES (41, 'Google Stadia');
INSERT INTO 'platforms' VALUES (42, 'Linux');

INSERT INTO
`gamePlatforms`
VALUES
(1, 31),
(2, 34),
(2, 37),
(3, 36),
(4, 38),
(4, 37),
(4, 39),
(4, 40),
(4, 41);

INSERT INTO `users` (`username`, `hash`, `isAdmin`) VALUES ('admin', '$2b$12$niVK8DnXKSyYzAIOUun2C.PZ51waVc2NU/e7DQ9cYM6zxNwUiiOCG', 'yes');
INSERT INTO `users` (`username`, `hash`, `isAdmin`) VALUES ('user', '$2b$12$niVK8DnXKSyYzAIOUun2C.PZ51waVc2NU/e7DQ9cYM6zxNwUiiOCG', 'no');
@@ -9,6 +9,8 @@ const sqlite = require('sqlite')
const { runSQLScript } = require('./utils')

sqlite.open('app.db').then(async db => {
const sqlPath = path.join(__dirname, 'build_db.sql')
await runSQLScript(db, sqlPath)
const buildSQL = path.join(__dirname, 'build_db.sql')
const dataSQL = path.join(__dirname, 'add_data.sql')
await runSQLScript(db, buildSQL)
await runSQLScript(db, dataSQL)
})
@@ -1,25 +1,38 @@
CREATE TABLE IF NOT EXISTS `users`
(
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`username` TEXT UNIQUE,
`hash` TEXT,
`isAdmin` TEXT
);

CREATE TABLE IF NOT EXISTS `games`
CREATE TABLE IF NOT EXISTS `categories`
(
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`name` TEXT UNIQUE
);

CREATE TABLE IF NOT EXISTS `gameCategories`
(
`gameID` INTEGER REFERENCES `games` (`id`),
`categoryID` INTEGER REFERENCES `categories` (`id`),

PRIMARY KEY (`gameID`, `categoryID`)
);

CREATE TABLE IF NOT EXISTS `games`
(
`gameID` INTEGER PRIMARY KEY AUTOINCREMENT,
`title` TEXT NOT NULL UNIQUE,
`platforms` TEXT,
`slugline` TEXT,
`summary` TEXT,
`releaseDate` TEXT,
`developer` TEXT,
`publisher` TEXT,
`submittedBy` INT,
`approved` TEXT,
`poster` TEXT,
`splash` TEXT
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`title` TEXT NOT NULL,
`slugline` TEXT,
`summary` TEXT,
`releaseDate` TEXT,
`developer` TEXT,
`publisher` TEXT,
`submittedBy` INT,
`approved` TEXT,
`poster` TEXT,
`splash` TEXT
);

CREATE TABLE IF NOT EXISTS `reviews`
@@ -36,133 +49,23 @@ CREATE TABLE IF NOT EXISTS `reviews`
CREATE TABLE IF NOT EXISTS `reviewComments`
(
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
'gameID' INTEGER,
`gameID` INTEGER,
`reviewID` INTEGER,
`user` TEXT,
`commentDate` DATE,
`commentTime` TEXT,
`commentText` TEXT
);

CREATE TABLE IF NOT EXISTS 'platforms'
CREATE TABLE IF NOT EXISTS `platforms`
(
'id' INTEGER PRIMARY KEY,
'name' TEXT
`id` INTEGER PRIMARY KEY,
`name` TEXT
);

CREATE TABLE IF NOT EXISTS `gamePlatforms` (
`gameID` INTEGER REFERENCES `games` (`id`),
`platformID` INTEGER REFERENCES `platforms` (`id`),

INSERT INTO `games` VALUES
(1,
'The Last of Us',
'31',
'Hope is the key to survival.',
'Set in the post-apocalyptic United States, the game tells the story of survivors Joel and Ellie as they work together to survive their westward journey across what remains of the country to find a possible cure for the modern fungal plague that has nearly decimated the entire human race.',
'04/06/2013',
'Naughty Dog',
'Sony Computer Entertainment',
1,
'yes',
'tlou.jpg',
'tlousplash.jpg');

INSERT INTO `games` VALUES
(2,
'The Legend of Zelda: Breath of the Wild',
'34,37',
'Step into a world of discovery, exploration and adventure.',
'No kingdom. No memories. After a 100-year slumber, Link wakes up alone in a world he no longer remembers. Now the legendary hero must explore a vast and dangerous land and regain his memories before Hyrule is lost forever. Armed only with what he can scavenge, Link sets out to find answers and the resources needed to survive.',
'03/03/2017',
'Nintendo EPD',
'Nintendo',
2,
'yes',
'botw.jpg',
'botwsplash.jpg');

INSERT INTO `games` VALUES
(3,
"Marvel's Spider-Man",
'36',
'Be Greater.',
'After eight years behind the mask, Peter Parker is a crime-fighting expert. Feel the full power of a more experienced Spider-Man with improvisational combat, dynamic acrobatics, fluid urban traversal, and environmental interactions. A rookie no longer, this is the most masterful Spider-Man you’ve ever played.',
'07/09/2018',
'Insomniac Games',
'Sony Interactive Entertainment',
2,
'yes',
'spiderman.jpg',
'spidermansplash.jpg');

INSERT INTO `games` VALUES
(4,
"Football Manager 2020",
'38,37,39,40,41',
'Your club, your way.',
'Manage your football club, your way. Every decision counts in FM20 with new features rewarding planning and progression like never before, empowering managers to develop both your club’s and your own unique managerial identity.',
'19/11/2019',
'Sports Interactive',
'SEGA',
1,
'yes',
'fm20poster.jpg',
'fm20splash.jpg');

INSERT INTO `games` VALUES
(5,
"Star Wars Jedi: Fallen Order",
'36,35,38',
'Become a Jedi.',
'The Empire seeks to eradicate all Jedi after the execution of Order 66. You, a Jedi Padawan-turned-fugitive, must fight for your survival as you explore the mysteries of a long-extinct civilization in hopes of rebuilding the Jedi Order.',
'15/11/2019',
'Respawn Entertainment',
'Electronic Arts',
2,
'yes',
'starwarsjfoposter.jpg',
'starwarsjfosplash.jpg');

INSERT INTO 'platforms' VALUES (1, 'Atari 2600');
INSERT INTO 'platforms' VALUES (2, 'Color TV-Game');
INSERT INTO 'platforms' VALUES (3, 'Magnavox Odyssey');
INSERT INTO 'platforms' VALUES (4, 'Intellivision');
INSERT INTO 'platforms' VALUES (5, 'Atari 5200');
INSERT INTO 'platforms' VALUES (6, 'ColecoVision');
INSERT INTO 'platforms' VALUES (7, 'Nintendo Entertainment System');
INSERT INTO 'platforms' VALUES (8, 'Master System');
INSERT INTO 'platforms' VALUES (9, 'TurboGrafx-16');
INSERT INTO 'platforms' VALUES (10, 'Sega Genesis');
INSERT INTO 'platforms' VALUES (11, 'Atari Lynx');
INSERT INTO 'platforms' VALUES (12, 'Game Boy');
INSERT INTO 'platforms' VALUES (13, 'SNES');
INSERT INTO 'platforms' VALUES (14, 'Sega Game Gear');
INSERT INTO 'platforms' VALUES (15, 'Philips CD-i');
INSERT INTO 'platforms' VALUES (16, 'Sega Pico');
INSERT INTO 'platforms' VALUES (17, 'Sega Saturn');
INSERT INTO 'platforms' VALUES (18, 'PlayStation');
INSERT INTO 'platforms' VALUES (19, 'Nintendo 64');
INSERT INTO 'platforms' VALUES (20, 'Dreamcast');
INSERT INTO 'platforms' VALUES (21, 'WonderSwan');
INSERT INTO 'platforms' VALUES (22, 'PlayStation 2');
INSERT INTO 'platforms' VALUES (23, 'Xbox');
INSERT INTO 'platforms' VALUES (24, 'Game Boy Advance');
INSERT INTO 'platforms' VALUES (25, 'GameCube');
INSERT INTO 'platforms' VALUES (26, 'N-Gage');
INSERT INTO 'platforms' VALUES (27, 'Nintendo DS');
INSERT INTO 'platforms' VALUES (28, 'PlayStation Portable');
INSERT INTO 'platforms' VALUES (29, 'Xbox 360');
INSERT INTO 'platforms' VALUES (30, 'Nintendo Wii');
INSERT INTO 'platforms' VALUES (31, 'PlayStation 3');
INSERT INTO 'platforms' VALUES (32, 'Nintendo 3DS ');
INSERT INTO 'platforms' VALUES (33, 'PlayStation Vita');
INSERT INTO 'platforms' VALUES (34, 'Wii U');
INSERT INTO 'platforms' VALUES (35, 'Xbox One');
INSERT INTO 'platforms' VALUES (36, 'PlayStation 4');
INSERT INTO 'platforms' VALUES (37, 'Nintendo Switch');
INSERT INTO 'platforms' VALUES (38, 'Microsoft Windows');
INSERT INTO 'platforms' VALUES (39, 'macOS');
INSERT INTO 'platforms' VALUES (40, 'iOS');
INSERT INTO 'platforms' VALUES (41, 'Google Stadia');
INSERT INTO 'platforms' VALUES (42, 'Linux');

INSERT INTO `users` (`username`, `hash`, `isAdmin`) VALUES ('admin', '$2b$12$niVK8DnXKSyYzAIOUun2C.PZ51waVc2NU/e7DQ9cYM6zxNwUiiOCG', 'yes');
INSERT INTO `users` (`username`, `hash`, `isAdmin`) VALUES ('user', '$2b$12$niVK8DnXKSyYzAIOUun2C.PZ51waVc2NU/e7DQ9cYM6zxNwUiiOCG', 'no');
PRIMARY KEY (`gameID`, `platformID`)
);

This file was deleted.

@@ -4,12 +4,14 @@ const Router = require('koa-router')

const adding = new Router({prefix: '/adding'})

adding.get('/game', async ctx => {

const { authenticateUser } = require('../controllers/middleware/auth')

adding.get('/game', authenticateUser, async ctx => {

const a = ctx.session.userID
const user = await ctx.db.getUser(Number(a))
const user = await ctx.db.getUser(a)
const platformnames = await ctx.db.getAllPlatforms()
await ctx.render('addingGames.hbs', {platforms: platformnames, user: ctx.session.authorised,
await ctx.render('addingGames.hbs', {platforms: platformnames, user: ctx.session.userID,
admin: await ctx.db.isUserAdmin(ctx.session.userID)})

if(!user) {
@@ -19,7 +21,7 @@ adding.get('/game', async ctx => {
})


adding.post('/game', async ctx => {
adding.post('/game', authenticateUser, async ctx => {
const body = ctx.request.body
body.submittedBy = ctx.session.userID
const platforms = body.platforms

0 comments on commit a1190dc

Please sign in to comment.