Added pages for replays

This commit is contained in:
Thomas FORGIONE
2015-05-20 11:17:14 +02:00
parent 7a6d4b0247
commit cfd8f77151
7 changed files with 43 additions and 20 deletions

View File

@@ -112,6 +112,20 @@ var addArrowsFromId = function(client, req, res, callback, id) {
);
}
var getAllUsers = function(req, res, callback) {
pg.connect(pgc.url, function(err, client, release) {
client.query(
"SELECT id, name FROM users;",
[],
function(err, result) {
res.locals.ids = result.rows;
callback();
release();
}
);
});
}
module.exports.index = function(req, res) {
res.setHeader('Content-Type', 'text/html');
@@ -193,3 +207,11 @@ module.exports.replay = function(req, res, next) {
}, res.locals.id);
}
module.exports.replay_index = function(req, res, next) {
getAllUsers(req, res, function() {
res.render("replay_index.jade", res.locals, function(err, result) {
res.send(result);
});
});
}

View File

@@ -3,6 +3,7 @@ module.exports = {
'/prototype/arrows': 'arrows',
'/prototype/viewports': 'viewports',
'/prototype/reverse': 'reverse',
'/prototype/replay': 'replay_index',
'/prototype/replay/:id': 'replay',
'/prototype/replay_info/:id': 'replay_info'
}

View File

@@ -5,7 +5,7 @@ block title
block content
h2 Index
p There are two prototypes here :
p There are three prototypes here :
ul
li
a(href="arrows/") Arrows
@@ -13,3 +13,4 @@ block content
a(href="reverse/") Reversed arrows looking like funnel
li
a(href="viewports/") Viewports
p You can also watch replays of previous experiences <a href="/prototype/replay/">here</a>

View File

@@ -0,0 +1,13 @@
extends ../../../views/main
block title
title #{title} - Prototype - Replays
block content
h2 Replays available
if ids.length == 0
p Sorry, there are no replays available... try later or do an experiment !
else
ol
each elt in ids
li <a href="/prototype/replay/#{elt.id}">#{elt.name}</a>