From 3cc8e15aaaced6f515593cb247d58601e790900f Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Wed, 6 May 2015 16:32:00 +0200 Subject: [PATCH] Improved server and urls --- controllers/index/views/index.jade | 10 +++++----- server.js | 15 +++++++++++++-- views/main.jade | 4 ++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/controllers/index/views/index.jade b/controllers/index/views/index.jade index 3a4f6e1..5b915a4 100644 --- a/controllers/index/views/index.jade +++ b/controllers/index/views/index.jade @@ -1,25 +1,25 @@ extends ../../../views/main block title - title 3DUI - Index + title #{title} - Index block content h2 Index ul li - a(href="/bouncing/") A bouncing cube that jumps when you click on it + a(href="#{urls.bouncing}") A bouncing cube that jumps when you click on it p. Jumps and bounce when you click on it. li - a(href="/multisphere/") Sphere with multi-resolution + a(href="#{urls.multisphere}") Sphere with multi-resolution p. Lots of obj files loaded and displayed. When you click somewhere, the current obj is hidden and the next one, with a better resolution is shown. li - a(href="/prototype/") A proto of the real thing + a(href="#{urls.prototype}") A proto of the real thing p. You can move the camera with the arrow keys and move the angle of the camera with 2, 4, 6 and 8 (the arrows of the numpad), or you @@ -31,7 +31,7 @@ block content camera that you want, and move to it progressively. li - a(href="/stream/") Streaming simulation + a(href="#{urls.stream}") Streaming simulation p. A mesh of a sphere is fully loaded, and displayed progressively. This test is here to prove that we can diff --git a/server.js b/server.js index 48d9b86..8904856 100644 --- a/server.js +++ b/server.js @@ -4,7 +4,6 @@ var module = require('./my_modules/filterInt'); var jade = require('jade'); var app = express(); - var urls = require('./urls'); app.set('view engine', 'jade'); @@ -20,6 +19,7 @@ require('./lib/boot')(app, { verbose: !module.parent }); app.use('/static', express.static('static')); +// When error raised app.use(function(err, req, res, next) { if (err.status === 404) { res.setHeader('Content-Type', 'text/html'); @@ -30,6 +30,7 @@ app.use(function(err, req, res, next) { } }); +// When route not found, raise not found app.use(function(req, res) { res.setHeader('Content-Type', 'text/html'); @@ -38,4 +39,14 @@ app.use(function(req, res) { }); }); -app.listen(4000); +// Set ports and ip adress +var server_port, server_ip_adress; +if ( app.get('env') === 'development' ) { + server_port = 4000; + server_ip_adress = 'localhost'; +} else { + server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080; + server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1'; +} + +app.listen(server_port, server_ip_adress); diff --git a/views/main.jade b/views/main.jade index 49d39d2..6d0aa5a 100644 --- a/views/main.jade +++ b/views/main.jade @@ -16,10 +16,10 @@ html(lang='fr') .container .navbar-header button.navbar-toggle(type="button", data-toggle="collapse" data-target=".navbar-collapse") - span.sr-only Tootle navigation + span.sr-only Toggle navigation span.icon-bar span.icon-bar - a.navbar-brand(href="/") 3DUI + a.navbar-brand(href="#{urls.index}") 3DUI div.navbar-collapse.collapse ul.nav.navbar-nav