Initial commit of nodejs

This commit is contained in:
Thomas FORGIONE
2015-05-05 11:56:35 +02:00
parent 4cc35587ef
commit afe1d124ed
35 changed files with 336 additions and 138 deletions

View File

@@ -0,0 +1,11 @@
var pejs = require('pejs');
views = pejs();
module.exports.index = function(req, res) {
res.setHeader('Content-Type', 'text/html');
views.render('bouncing', res.locals, function(err, result) {
console.log(err);
res.send(result);
});
}

View File

@@ -0,0 +1,3 @@
module.exports = {
'/bouncing' : 'index'
}

View File

@@ -0,0 +1,10 @@
var pejs = require('pejs');
views = pejs();
module.exports.index = function(req, res) {
res.setHeader('Content-Type', 'text/html');
views.render('index', res.locals, function(err, result) {
res.send(result);
});
}

View File

@@ -0,0 +1,3 @@
module.exports = {
'/': 'index'
}

View File

@@ -0,0 +1,10 @@
var pejs = require('pejs');
views = pejs();
module.exports.index = function(req, res) {
res.setHeader('Content-Type', 'text/html');
views.render('multisphere', res.locals, function(err, result) {
res.send(result);
});
}

View File

@@ -0,0 +1,3 @@
module.exports = {
'/multisphere': 'index'
}

34
controllers/prototype/index.js vendored Normal file
View File

@@ -0,0 +1,34 @@
var express = require('express')
var pejs = require('pejs');
app = express();
views = pejs();
module.exports.index = function(req, res) {
res.setHeader('Content-Type', 'text/html');
views.render('prototype', res.locals, function(err, result) {
res.send(result);
});
}
module.exports.arrows = function(req, res) {
res.setHeader('Content-Type', 'text/html');
res.locals.extrajs = '<script src="/static/js/prototype/arrows/main.js"></script>';
views.render('prototype/prototype', res.locals, function(err, result) {
console.log(err);
res.send(result);
});
}
module.exports.viewports = function(req, res) {
res.setHeader('Content-Type', 'text/html');
res.locals.extrajs = '<script src="/static/js/prototype/viewports/main.js"></script>';
views.render('prototype/prototype', res.locals, function(err, result) {
res.send(result);
});
}

5
controllers/prototype/urls.js vendored Normal file
View File

@@ -0,0 +1,5 @@
module.exports = {
'/prototype': 'index',
'/prototype/arrows': 'arrows',
'/prototype/viewports': 'viewports'
}

View File

@@ -0,0 +1,28 @@
var pejs = require('pejs');
var tools = require('../../my_modules/filterInt')
views = pejs();
module.exports.index = function(req, res, next) {
// Parse get argument res
res.locals.resolution = req.params.res;
if (res.locals.resolution === undefined) {
res.locals.resolution = 5;
} else {
res.locals.resolution = tools.filterInt(res.locals.resolution);
}
if (isNaN(res.locals.resolution) || res.locals.resolution < 1 || res.locals.resolution > 25) {
var error = new Error("Resolution was not set properly");
error.status = 404;
next(error);
return;
}
res.setHeader('Content-Type', 'text/html');
views.render('stream/index.html', res.locals, function(err, result) {
res.send(result);
});
}

View File

@@ -0,0 +1,3 @@
module.exports = {
'/stream/:res?': 'index'
};