-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
167 lines (143 loc) · 2.87 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
const express = require('express')
const fs = require('fs');
var path = require('path');
const app = express();
var io = require('socket.io')(3010);
var isLoggedin = false;
app.set('port', (process.env.PORT || 3000));
// set up static files
app.use(express.static(path.join(__dirname, '/public/static')));
io.on('connection', function(socket){
console.log("Hey");
socket.on('login', function(msg){
console.log("logged in, from app.js")
isLoggedin = true;
});
socket.on('logout', function(msg){
console.log("logged out, from app.js")
isLoggedin = false;
});
});
// set up views
app.use(express.static(__dirname + '/views'));
app.set('view engine', 'pug');
// show the home page (will also have our login links)
app.get('/', function(req, res) {
if(isLoggedin) {
res.render('profile')
}
else {
res.render('index')
}
});
app.get('/index', function(req, res) {
if(isLoggedin) {
res.render('profile')
}
else {
res.render('index')
}
});
app.get('/index.html', function(req, res) {
if(isLoggedin) {
res.render('profile')
}
else {
res.render('index')
}
});
app.get('/inventory', function(req, res) {
if(isLoggedin) {
res.render('inventory')
}
else {
res.render('index')
}
});
app.get('/freerun', function(req, res) {
res.render('freerun')
});
app.get('/friends', function(req, res) {
if(isLoggedin) {
res.render('friends')
}
else {
res.render('index')
}
});
app.get('/glossary', function(req, res) {
res.render('glossary')
});
app.get('/success', function (req, res) {
if(isLoggedin) {
res.render('success')
}
else {
res.render('index')
}
});
app.get('/profile', function (req, res) {
if(isLoggedin) {
res.render('profile')
}
else {
res.render('index')
}
});
app.get('/results', function (req, res) {
if(isLoggedin) {
res.render('results')
}
else {
res.render('index')
}
});
app.get('/map', function(req, res) {
if(isLoggedin) {
res.render('map')
}
else {
res.render('index')
}
});
app.get('/modules', function (req, res) {
if(isLoggedin) {
res.render('modules')
}
else {
res.render('index')
}
});
app.get('/freerun1', function (req, res) {
res.render('freerun1')
});
app.get('/module/:modNum', function (req, res) {
if(isLoggedin) {
res.render('exercises')
}
else {
res.render('index')
}
});
app.get('/module/:modNum/exercise/:excNum', function (req, res) {
if(isLoggedin) {
res.render('questionblock')
}
else {
res.render('index')
}
});
app.get('/module/:modNum/exercise/:excNum/questionblock/:qBlockNum/question/:qNum', function (req, res) {
if(isLoggedin) {
res.render('question')
}
else {
res.render('index')
}
});
app.get('/tos', function (req, res) {
res.send("Nothing!");
});
app.listen(app.get('port'), function () {
console.log('Ukie app listening on port 3000')
});