diff --git a/.gitignore b/.gitignore index 43f8c66..fc87a58 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,6 @@ lib node_modules tmp public/lib +public/views/*.html +public/views/includes/*.html diff --git a/bin/viewServer.js b/bin/webServer.js similarity index 70% rename from bin/viewServer.js rename to bin/webServer.js index a86a65e..69bc3f7 100644 --- a/bin/viewServer.js +++ b/bin/webServer.js @@ -1,10 +1,12 @@ +"use strict"; var express = require('express'), util = require('util'), path = require('path'), http = require('http'), fs = require('fs'), app = express(), - port = 3001; + port = 3001, + i; app.use("/", express.static('public')); // env @@ -12,12 +14,9 @@ app.use("/", express.static('public')); app.set('port', process.env.port || port); app.set('views', path.join(__dirname, '/public/views')); app.set('view engine', 'jade'); -//app.use(express.bodyParser()); app.disable('x-powered-by'); -/** - * route - */ +//routes app.get('/', function (req, res) { res.render('overview', {title: 'overview'}); }); @@ -27,12 +26,15 @@ app.get('/:page', function (req, res) { res.render(page, {title: page}); }); -/** - * read fs - */ -fs.readdirSync('public').forEach(function (file) { // iterate through every sub-folder - if (!file.match(/(\.ico$|views)/)) { - app.use(express.static('public/' + file)); +//public dir +fs.readdir("public", function (err, files) { + if (err) { + throw err; + } + for (i = 0; i < files.length; i++) { + if (!files[i].match(/(\.ico$|views)/)) { + app.use(express.static('public/' + files[i])); + } } }); @@ -40,4 +42,4 @@ fs.readdirSync('public').forEach(function (file) { // iterate through every sub http.createServer(app).listen(app.get('port'), function (req, res) { util.log('View server listening on port ' + port); }); -})(); +}()); diff --git a/public/views/404.html b/public/views/404.html deleted file mode 100644 index 2ade2e6..0000000 --- a/public/views/404.html +++ /dev/null @@ -1 +0,0 @@ -

404 Not Found

\ No newline at end of file diff --git a/public/views/includes/content.html b/public/views/includes/content.html deleted file mode 100644 index 822a6b2..0000000 --- a/public/views/includes/content.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/public/views/index.html b/public/views/index.html deleted file mode 100644 index 76209a1..0000000 --- a/public/views/index.html +++ /dev/null @@ -1 +0,0 @@ -

welcome

\ No newline at end of file diff --git a/public/views/layout.html b/public/views/layout.html deleted file mode 100644 index c13accb..0000000 --- a/public/views/layout.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/public/views/overview.html b/public/views/overview.html deleted file mode 100644 index 76209a1..0000000 --- a/public/views/overview.html +++ /dev/null @@ -1 +0,0 @@ -

welcome

\ No newline at end of file diff --git a/public/views/real-time.html b/public/views/real-time.html deleted file mode 100644 index 095060c..0000000 --- a/public/views/real-time.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/public/views/report.html b/public/views/report.html deleted file mode 100644 index 6cd86e8..0000000 --- a/public/views/report.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/public/views/test.html b/public/views/test.html deleted file mode 100644 index acf0559..0000000 --- a/public/views/test.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/public/views/usage.html b/public/views/usage.html deleted file mode 100644 index ec6ca66..0000000 --- a/public/views/usage.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file