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 @@ -
welcome
welcome