diff --git a/Gruntfile.js b/Gruntfile.js
index a19e399..5f08384 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -640,7 +640,7 @@ module.exports = function(grunt) {
'ngtemplates',
'copy:dist',
//'cdnify',
- //'cssmin',
+ 'cssmin',
'uglify',
'rev',
'usemin'
diff --git a/config/config.json b/config/config.json
index 1f1a7a8..ebe49ca 100644
--- a/config/config.json
+++ b/config/config.json
@@ -7,7 +7,7 @@
"version": "0.1",
"email": "jonniespratley@me.com",
"host": "127.0.0.1",
- "port": 8585,
+ "port": 8009,
"apiBase": "/api/v2",
"version": "v2",
"security": {
@@ -35,10 +35,10 @@
"hostname": "127.0.0.1",
"port": 5001
},
- "staticDir": "dist",
- "publicDir": "www",
- "uploadsTmpDir": ".tmp",
- "uploadsDestDir": "www/cms-content/uploads",
+ "staticDir": "./app",
+ "publicDir": "./www",
+ "uploadsTmpDir": "./.tmp",
+ "uploadsDestDir": "./www/cms-content/uploads",
"uploadsUrl": "/cms-content/",
"logFormat": "[:date] - [:method] - :url - :status - :response-time ms",
"debug": true,
diff --git a/routes/cms-router.js b/routes/cms-router.js
index e8ccac4..7ddee1c 100644
--- a/routes/cms-router.js
+++ b/routes/cms-router.js
@@ -21,10 +21,8 @@ module.exports = function(config, app) {
var db = new PouchDB(config.db.local);
app.locals.db = db;
+ console.log('Connected to', config.db.local);
- db.info().then(function(resp) {
- console.log('Connected to', config.db.local, resp);
- });
var serverPort = process.env.PORT || config.port;
@@ -33,11 +31,11 @@ module.exports = function(config, app) {
require('./cms-db')(config);
require('./cms-auth')(config, app);
- require('./cms-passport')(config, app);
+ // require('./cms-passport')(config, app);
require('./cms-upload')(config, app);
require('./cms-server')(config, app);
require('./cms-rest')(config, app);
- require('./cms-proxy')(config, app);
+ //require('./cms-proxy')(config, app);
//require('./cms-sockets')(config, server);
this.mount = function() {
diff --git a/routes/cms-server.js b/routes/cms-server.js
index cf90fe8..c8540d7 100644
--- a/routes/cms-server.js
+++ b/routes/cms-server.js
@@ -1,12 +1,12 @@
var express = require('express'),
- path = require('path'),
- serveStatic = require('serve-static'),
- finalhandler = require('finalhandler'),
- bodyParser = require( 'body-parser' );
+ path = require('path'),
+ serveStatic = require('serve-static'),
+ finalhandler = require('finalhandler'),
+ bodyParser = require('body-parser');
-module.exports = function (config, app) {
- console.warn( 'cms-server initialized');
+module.exports = function(config, app) {
+ console.warn('cms-server initialized');
var router = express.Router();
@@ -15,34 +15,27 @@ module.exports = function (config, app) {
etag: false,
extensions: [
'js',
- 'png',
- 'html', 'jpeg', 'jpg', 'gif',
+ 'png',
+ 'html', 'jpeg', 'jpg', 'gif',
'css'
],
index: true,
maxAge: '1d',
redirect: false,
- setHeaders: function (res, path) {
+ setHeaders: function(res, path) {
res.set('x-timestamp', Date.now());
}
};
-
-
- app.use(express.static(config.publicDir, options));
- app.use(express.static(config.staticDir, options));
-
-
+
+
router.all('/', function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'X-Requested-With');
next();
console.log('cms-server', req.method);
});
- router.get('/', function(res, req, next){
- req.send(config.staticDir + path.sep + 'index.html');
- next();
- });
+
app.use('/', router);
diff --git a/server.js b/server.js
index ad770ea..0209c1e 100755
--- a/server.js
+++ b/server.js
@@ -3,10 +3,11 @@
* @object
*/
-var fs = require('fs');
-var cmsRouter = require('./routes/cms-router.js');
-
-var config = JSON.parse(fs.readFileSync('./config/config.json'));
+var fs = require('fs'),
+ cmsRouter = require('./routes/cms-router.js'),
+ path = require('path'),
+ serveStatic = require('serve-static'),
+ config = JSON.parse(fs.readFileSync('./config/config.json'));
//Test if services
if (process.env.VCAP_SERVICES) {
@@ -26,6 +27,40 @@ var app = express();
var router = new cmsRouter(config, app);
router.mount();
+var options = {
+ dotfiles: 'ignore',
+ etag: false,
+ extensions: [
+ 'js',
+ 'png',
+ 'html', 'jpeg', 'jpg', 'gif',
+ 'css'
+ ],
+ index: true,
+ maxAge: '1d',
+ redirect: false,
+ setHeaders: function(res, path) {
+ res.set('x-timestamp', Date.now());
+ }
+};
+var staticDir = config.publicDir;
+
+console.log('staticDir', staticDir);
+app.use(express.static(staticDir, options));
+app.use(express.static(path.resolve(__dirname, config.staticDir), options));
+app.all('/', function(req, res, next) {
+ res.header('Access-Control-Allow-Origin', '*');
+ res.header('Access-Control-Allow-Headers', 'X-Requested-With');
+ next();
+ console.log('cms-server', req.method);
+});
+
+app.get('/', function(res, req, next) {
+ var indexFile = config.publicDir + path.sep + 'index.html';
+ console.warn('Loading index', indexFile);
+ req.send(indexFile);
+});
+
app.listen(port, function() {
console.log('express server listening on port: ' + port);
});
diff --git a/www/index.html b/www/index.html
index e2c2521..7e403fa 100644
--- a/www/index.html
+++ b/www/index.html
@@ -46,13 +46,7 @@
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+