From e3947f0d11864f40a2c0a202af99e0b14ff14dcf Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Mon, 4 Sep 2017 20:12:23 +0200 Subject: Only show weeks that are available --- routes/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'routes') diff --git a/routes/index.js b/routes/index.js index 1ab2ba3..570fe5f 100644 --- a/routes/index.js +++ b/routes/index.js @@ -2,7 +2,7 @@ const express = require('express') const router = express.Router() -const users = require('../lib/getUserIndex') +const data = require('../lib/getUserIndex') /* GET home page. */ router.get('/', function (req, res, next) { @@ -12,8 +12,9 @@ router.get('/', function (req, res, next) { } const flagsStr = `var FLAGS = ${JSON.stringify(flags)};` - const usersStr = `var USERS = ${JSON.stringify(users.users)};` - res.render('index', { flagsStr, usersStr }) + const usersStr = `var USERS = ${JSON.stringify(data.users)};` + const validWeekNumbersStr = `var VALID_WEEK_NUMBERS = ${JSON.stringify(data.validWeekNumbers)}` + res.render('index', { flagsStr, usersStr, validWeekNumbersStr }) }) module.exports = router -- cgit v1.1 From 600128bda0390f2051ad20ee42930f036c79323c Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Tue, 5 Sep 2017 20:28:32 +0200 Subject: Clear cache automaticly --- routes/index.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'routes') diff --git a/routes/index.js b/routes/index.js index 570fe5f..68f29b7 100644 --- a/routes/index.js +++ b/routes/index.js @@ -2,19 +2,24 @@ const express = require('express') const router = express.Router() -const data = require('../lib/getUserIndex') +const getMeetingpointData = require('../lib/getMeetingpointData') /* GET home page. */ router.get('/', function (req, res, next) { - let flags = [] - if (req.query.nfd != null) { - flags.push('NO_FEATURE_DETECT') - } + getMeetingpointData().then(data => { + let flags = [] + if (req.query.nfd != null) { + flags.push('NO_FEATURE_DETECT') + } - const flagsStr = `var FLAGS = ${JSON.stringify(flags)};` - const usersStr = `var USERS = ${JSON.stringify(data.users)};` - const validWeekNumbersStr = `var VALID_WEEK_NUMBERS = ${JSON.stringify(data.validWeekNumbers)}` - res.render('index', { flagsStr, usersStr, validWeekNumbersStr }) + const flagsStr = `var FLAGS = ${JSON.stringify(flags)};` + const usersStr = `var USERS = ${JSON.stringify(data.users)};` + const validWeekNumbersStr = `var VALID_WEEK_NUMBERS = ${JSON.stringify(data.validWeekNumbers)}` + res.render('index', { flagsStr, usersStr, validWeekNumbersStr }) + }).catch(function () { + console.error('Unable to get user info, emergency redirect!') + res.redirect('http://www.meetingpointmco.nl/Roosters-AL/doc/') + }) }) module.exports = router -- cgit v1.1 From a03db5fb5d09b85df359a6e2828e6bab4efc1e9f Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Wed, 6 Sep 2017 19:20:36 +0200 Subject: Add user friendly error page --- routes/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'routes') diff --git a/routes/index.js b/routes/index.js index 68f29b7..d496b3c 100644 --- a/routes/index.js +++ b/routes/index.js @@ -18,7 +18,8 @@ router.get('/', function (req, res, next) { res.render('index', { flagsStr, usersStr, validWeekNumbersStr }) }).catch(function () { console.error('Unable to get user info, emergency redirect!') - res.redirect('http://www.meetingpointmco.nl/Roosters-AL/doc/') + // res.redirect('http://www.meetingpointmco.nl/Roosters-AL/doc/') + res.render('redirect') }) }) -- cgit v1.1