Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonnie Spratley committed Jul 16, 2015
1 parent f805a8a commit 5d171a7
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 102 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ module.exports = function(grunt) {
'ngtemplates',
'copy:dist',
//'cdnify',
//'cssmin',
'cssmin',
'uglify',
'rev',
'usemin'
Expand Down
10 changes: 5 additions & 5 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"version": "0.1",
"email": "[email protected]",
"host": "127.0.0.1",
"port": 8585,
"port": 8009,
"apiBase": "/api/v2",
"version": "v2",
"security": {
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 3 additions & 5 deletions routes/cms-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down
31 changes: 12 additions & 19 deletions routes/cms-server.js
Original file line number Diff line number Diff line change
@@ -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();

Expand All @@ -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);

Expand Down
43 changes: 39 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
});
72 changes: 4 additions & 68 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@
<meta name="msapplication-square310x310logo" content="images/mstile-310x310.png">
<meta name="msapplication-wide310x150logo" content="images/mstile-310x150.png">

<!-- build:css({.tmp,app}) styles/app.css -->
<link rel="stylesheet" href="bower_components/angular-motion/dist/angular-motion.min.css">
<link rel="stylesheet" href="bower_components/bootstrap-additions/dist/bootstrap-additions.min.css">
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
<link rel="stylesheet" href="styles/457abfed.app.css"/>
<link rel="stylesheet" ng-href="{{App.settings.cdn}}/bootswatch.com/{{App.theme | lowercase}}/bootstrap.min.css">

<!--[if lt IE 9]>
Expand Down Expand Up @@ -91,70 +85,12 @@
</script>


<!-- build:js({.tmp,app}) scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/jquery-ui/ui/jquery-ui.js"></script>
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/json3/lib/json3.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="libs/parse-1.2.17.min.js"></script>
<script src="libs/md5.js"></script>
<script src="libs/markdown.js"></script>
<!-- endbuild -->
<script src="scripts/d386388a.vendor.js"></script>

<!-- build:js({.tmp,app}) scripts/modules.js -->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-ui-utils/ui-utils.js"></script>
<script src="bower_components/angular-strap/dist/angular-strap.min.js"></script>
<script src="bower_components/angular-strap/dist/angular-strap.tpl.min.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-form-gen/dist/angular-form-gen.js"></script>
<!-- endbuild -->
<script src="scripts/0d1af2ed.modules.js"></script>

<!-- endbower -->

<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="scripts/config.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/templates.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/controllers/docs.js"></script>
<script src="scripts/controllers/admin.js"></script>
<script src="scripts/controllers/login.js"></script>
<script src="scripts/controllers/profile.js"></script>
<script src="scripts/controllers/plugins.js"></script>
<script src="scripts/controllers/themes.js"></script>
<script src="scripts/controllers/widgets.js"></script>
<script src="scripts/controllers/media.js"></script>
<script src="scripts/controllers/settings.js"></script>
<script src="scripts/controllers/dashboard.js"></script>
<script src="scripts/controllers/users.js"></script>
<script src="scripts/controllers/register.js"></script>
<script src="scripts/controllers/pages.js"></script>
<script src="scripts/controllers/forgot-password.js"></script>
<script src="scripts/controllers/sidebar.js"></script>
<script src="scripts/controllers/help.js"></script>
<script src="scripts/controllers/app.js"></script>
<script src="scripts/filters/gravatar.js"></script>
<script src="scripts/directives/cms-formgroup.js"></script>
<script src="scripts/directives/cms-widgets.js"></script>
<script src="scripts/directives/cms-widget.js"></script>
<script src="scripts/directives/cms-uploader.js"></script>
<script src="scripts/directives/cms-header.js"></script>
<script src="scripts/directives/cms-gravatar.js"></script>
<script src="scripts/services/dataservice.js"></script>
<!--script src="scripts/services/cmsdataserviceprovider.js"></script-->
<script src="scripts/services/cms-dataservicefactory.js"></script>
<script src="scripts/services/cms-usersfactory.js"></script>
<script src="scripts/services/cms-authservice.js"></script>
<script src="scripts/services/cms-sessionservice.js"></script>
<script src="scripts/services/cms-socketservice.js"></script>
<script src="scripts/services/cms-notify.js"></script>
<!-- endbuild -->
<script src="scripts/99c979b1.scripts.js"></script>
</body>
</html></html>

0 comments on commit 5d171a7

Please sign in to comment.