-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrouter.js
executable file
·103 lines (85 loc) · 2.5 KB
/
router.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
var _ = require("underscore");
var url = require('url')
var fs = require('fs-extra');
var i18n = require('i18n');
module.exports = function(app,io,m){
/**
* routing event
*/
app.get("/", getIndex);
app.get("/select/:session", getSelect);
app.get("/select/:session/:projet", getProjet);
app.get("/select/:session/:projet/capture", getCapture);
app.get("/select/:session/:projet/flux", getFlux);
app.get("/select/:session/:projet/publi", getPubli);
// set a cookie to requested locale
app.get('/:locale', function (req, res) {
res.cookie('locale', req.params.locale);
});
/**
* routing functions
*/
// GET
function getIndex(req, res) {
res.render("index", {title : "Do.Doc"});
};
function getSelect(req, res) {
var session = req.param('session');
var sessionPath = 'sessions/'+session;
fs.ensureDirSync(sessionPath);
res.render("session", {
title : "Projets",
session : session,
sessionFormat : session.replace(/_/g," "),
});
};
function getProjet(req, res) {
var session = req.param('session');
var projet = req.param('projet');
var sessionPath = 'sessions/'+session + '/' + projet;
fs.ensureDirSync(sessionPath);
res.render("select", {
title : "Bibliotheque de media",
session : session,
sessionFormat : session.replace(/_/g," "),
projet : projet,
projetFormat : projet.replace(/_/g," "),
});
};
function getCapture(req, res) {
var session = req.param('session');
var projet = req.param('projet');
res.render("capture", {
title : "Prise de vue",
session : session,
sessionFormat : session.replace(/_/g," "),
projet : projet,
projetFormat : projet.replace(/_/g," "),
});
};
function getFlux(req, res) {
var session = req.param('session');
var projet = req.param('projet');
var sessionPath = 'sessions/'+session;
fs.ensureDirSync(sessionPath);
res.render("flux", {
title : "Dodoc Flux",
session : session,
sessionFormat : session.replace(/_/g," "),
projet : projet,
projetFormat : projet.replace(/_/g," "),
});
};
function getPubli(req, res) {
var session = req.param('session');
var projet = req.param('projet');
var sessionPath = 'sessions/'+session;
res.render("publication", {
title : "Publication",
session : session,
sessionFormat : session.replace(/_/g," "),
projet : projet,
projetFormat : projet.replace(/_/g," "),
});
};
};