diff --git a/README.md b/README.md
index 29dc63a..d3758eb 100755
--- a/README.md
+++ b/README.md
@@ -3,11 +3,17 @@ This is a boilerplate CMS built with Angular, Twitter Bootstrap and Node; it is
[![Build Status](https://travis-ci.org/jonniespratley/angular-cms.png)](https://travis-ci.org/jonniespratley/angular-cms)
+[![Codacy Badge](https://www.codacy.com/project/badge/0825389c11854c23a05cc512385ec82d)](https://www.codacy.com/public/jonniespratley/angular-cms)
+
+[![Coverage Status](https://coveralls.io/repos/jonniespratley/angular-cms/badge.png)](https://coveralls.io/r/jonniespratley/angular-cms)
+
+
[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/jonniespratley/angular-cms/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
-[![Coverage Status](https://coveralls.io/repos/jonniespratley/angular-cms/badge.png)](https://coveralls.io/r/jonniespratley/angular-cms)
+
+
### Technologies
Some featured technologies used in this project include the following:
@@ -65,8 +71,8 @@ To run the application on your local machine please take the following steps.
To start mongodb execute the following command:
$ sh ./bin/db.sh
-
-> **Note:** If errors when executing command remove the `db/mongod.lock` file.
+
+> **Note:** If errors when executing command remove the `db/mongod.lock` file.
#### Step 2 - Start REST server
To start the server execute the following command:
@@ -133,7 +139,7 @@ $ grunt protractor
---
## RESTful Server
-The server is a Node.js server that supports dynamic RESTful API calls to resource endpoints. It will automatically create a database if it does not exist and collection(s).
+The server is a Node.js server that supports dynamic RESTful API calls to resource endpoints. It will automatically create a database if it does not exist and collection(s).
The base URL is `http://localhost:8181/api/v2`
@@ -194,7 +200,7 @@ my-theme/
sidebar.html
footer.html
content.html
-```
+```
@@ -230,7 +236,7 @@ Please don't edit files in the `dist` subdirectory as they are generated via Gru
## Modifying the code
First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.
-Test that Grunt's CLI and Bower are installed by running `grunt --version` and `bower --version`.
+Test that Grunt's CLI and Bower are installed by running `grunt --version` and `bower --version`.
1. Fork and clone the repo.
1. Run `npm install` to install all build dependencies (including Grunt).
@@ -275,4 +281,3 @@ The following list is features that are comming.
* SEO consideration for duplicate content (e.g use of canonical tag)
---
-
diff --git a/app/scripts/controllers/users.coffee b/app/scripts/controllers/users.coffee
index 380f7bb..f96a44c 100644
--- a/app/scripts/controllers/users.coffee
+++ b/app/scripts/controllers/users.coffee
@@ -1,63 +1,62 @@
'use strict'
angular.module('angularCmsApp').controller('UsersCtrl', ($scope, DataService) ->
- $scope.awesomeThings = [
- 'HTML5 Boilerplate'
- 'AngularJS'
- 'Karma'
- ]
-
- $scope.user =
- username: null
- email: null
- password: null
- role: null
- created: new Date()
- modified: new Date()
- metadata:
- avatar: ''
- name: null
- aboue: null
-
- #Hold the users
- $scope.users = []
-
- #Holds the user groups
- $scope.groups = ['Admin', 'Member', 'Public']
-
- $scope.getGroups = () ->
- DataService.fetch('groups').then((data) ->
- $scope.groups = data
- console.log(data)
- )
+ $scope.awesomeThings = [
+ 'HTML5 Boilerplate'
+ 'AngularJS'
+ 'Karma'
+ ]
- #Select user
- $scope.selectUser = (user) ->
- $scope.user = user
+ $scope.user =
+ username: null
+ email: null
+ password: null
+ role: null
+ created: new Date()
+ modified: new Date()
+ metadata:
+ avatar: ''
+ name: null
+ aboue: null
- #Get users
- $scope.getUsers = () ->
- DataService.fetch('users').then((data) ->
- $scope.users = data
- $scope.getGroups() unless $scope.groups
- )
+ #Hold the users
+ $scope.users = []
+
+ #Holds the user groups
+ $scope.groups = ['Admin', 'Member', 'Public']
- #Delete user
- $scope.deleteUser = (index, user) ->
- ask = confirm "Delete #{user.email}?"
+ $scope.getGroups = () ->
+ DataService.fetch('groups').then((results) ->
+ $scope.groups = results.data
+ console.log(data)
+ )
- if ask
- DataService.destroy('users', user).then((data) ->
- $scope.users.pop(index)
- $scope.getUsers()
- )
+ #Select user
+ $scope.selectUser = (user) ->
+ $scope.user = user
- #Add user to database
- $scope.addUser = (user) ->
- DataService.save('users', user).then((data) ->
+ #Get users
+ $scope.getUsers = () ->
+ DataService.fetch('users').then((results) ->
+ $scope.users = results.data
+ $scope.getGroups() unless $scope.groups
+ )
+
+ #Delete user
+ $scope.deleteUser = (index, user) ->
+ ask = confirm "Delete #{user.email}?"
+
+ if ask
+ DataService.destroy('users', user).then((data) ->
+ $scope.users.pop(index)
$scope.getUsers()
- #$scope.users.push(user) unless user._id
- $scope.user = {}
- $('#user-modal').modal('hide')
)
-
+
+ #Add user to database
+ $scope.addUser = (user) ->
+ DataService.save('users', user).then((data) ->
+ $scope.getUsers()
+ #$scope.users.push(user) unless user._id
+ $scope.user = {}
+ $('#user-modal').modal('hide')
+ )
)
\ No newline at end of file
diff --git a/app/views/users.html b/app/views/users.html
index 3951581..2b32083 100755
--- a/app/views/users.html
+++ b/app/views/users.html
@@ -3,7 +3,9 @@
Users
+
+
+
diff --git a/package.json b/package.json
index 41c81b6..fcdf248 100755
--- a/package.json
+++ b/package.json
@@ -83,6 +83,7 @@
"jasmine-core": "^2.1.2",
"jasmine-node": "~1.11.0",
"jasmine-reporters": "^1.0.1",
+ "jasmine-spec-reporter": "^1.1.0",
"karma": "^0.12.28",
"karma-chrome-launcher": "^0.1.5",
"karma-coverage": "^0.2.6",
diff --git a/protractor.conf.js b/protractor.conf.js
index ee43245..d1a63fa 100644
--- a/protractor.conf.js
+++ b/protractor.conf.js
@@ -1,23 +1,32 @@
// An example configuration file.
exports.config = {
- // The address of a running selenium server.
- seleniumAddress: 'http://localhost:4444/wd/hub',
+ // The address of a running selenium server.
+ seleniumAddress: 'http://localhost:4444/wd/hub',
+ params: {
+ baseUrl: 'http://localhost:9000/#'
+ },
- // Capabilities to be passed to the webdriver instance.
- capabilities: {
- 'browserName': 'chrome'
- },
+ // Capabilities to be passed to the webdriver instance.
+ capabilities: {
+ 'browserName': 'chrome'
+ }
+ ,
- // Spec patterns are relative to the current working directly when
- // protractor is called.
- specs: [
- '.tmp/protractor/*.js',
- 'test/protractor/*.js'
- ],
+// Spec patterns are relative to the current working directly when
+// protractor is called.
+ specs: [
+ '.tmp/protractor/*.js',
+ 'test/protractor/*.js'
+ ],
- // Options to be passed to Jasmine-node.
- jasmineNodeOpts: {
- showColors: true,
- defaultTimeoutInterval: 30000
- }
+ // Options to be passed to Jasmine-node.
+ jasmineNodeOpts: {
+ showColors: true,
+ defaultTimeoutInterval: 30000
+ },
+ onPrepare: function () {
+ var SpecReporter = require( 'jasmine-spec-reporter' );
+ // add jasmine spec reporter
+ jasmine.getEnv().addReporter( new SpecReporter( {displayStacktrace: true} ) );
+ }
};
diff --git a/routes/rest.js b/routes/rest.js
index ca2d61d..68a7b22 100755
--- a/routes/rest.js
+++ b/routes/rest.js
@@ -24,6 +24,7 @@ var path = require('path');
var Db = mongo.Db;
var BSON = mongo.BSONPure;
var express = require('express');
+var utils = require('util');
var fs = require('fs');
var app = express();
var request = require('request');
@@ -49,6 +50,8 @@ var _ds = new DS({
host: 'localhost/angular-cms'
});
+
+
function delay(ms, value) {
// create a new Deferred
var deferred = new Deferred();
@@ -959,7 +962,7 @@ exports.rest = {
app.use(function (req, res, next) {
- console.log('%s %s', req.method, req.body, req.url);
+ console.log('%s %s', req.method, utils.inspect(req.body, {colors: true}), req.url);
next();
});
});
diff --git a/routes/socketserver.js b/routes/socketserver.js
index bf5afb0..188ae37 100644
--- a/routes/socketserver.js
+++ b/routes/socketserver.js
@@ -18,126 +18,124 @@
//Start the websocket server
//SocketServer.init(proxyServer);
-var sio = require('socket.io');
+var sio = require( 'socket.io' );
//Hold the ncmss of events that this socket server listens for and emits
var CmsSocket = {
- events : {
- session : {
- pageView : 'cms:session:pageView',
- hashChange : 'cms:session:hashChange',
- login : 'cms:session:login',
- logout : 'cms:session:logout'
+ events: {
+ session: {
+ pageView: 'cms:session:pageView',
+ hashChange: 'cms:session:hashChange',
+ login: 'cms:session:login',
+ logout: 'cms:session:logout'
},
- server : {
- message : 'cms:server:message',
- connected : 'cms:server:connect',
- disconnected : 'cms:server:disconnect'
+ server: {
+ message: 'cms:server:message',
+ connected: 'cms:server:connect',
+ disconnected: 'cms:server:disconnect'
},
- client : {
- message : 'cms:client:message',
- connected : 'cms:client:connect',
- disconnected : 'cms:client:disconnect'
+ client: {
+ message: 'cms:client:message',
+ connected: 'cms:client:connect',
+ disconnected: 'cms:client:disconnect'
}
}
};
var SocketServer = {
- connections : [],
- events : {
- session : {
- pageView : 'cms:session:pageView',
- hashChange : 'cms:session:hashChange',
- login : 'cms:session:login',
- logout : 'cms:session:logout'
+ connections: [],
+ events: {
+ session: {
+ pageView: 'cms:session:pageView',
+ hashChange: 'cms:session:hashChange',
+ login: 'cms:session:login',
+ logout: 'cms:session:logout'
},
- server : {
- message : 'cms:server:message',
- connected : 'cms:server:connect',
- disconnected : 'cms:server:disconnect'
+ server: {
+ message: 'cms:server:message',
+ connected: 'cms:server:connect',
+ disconnected: 'cms:server:disconnect'
},
- client : {
- message : 'cms:client:message',
- connected : 'cms:client:connect',
- disconnected : 'cms:client:disconnect'
+ client: {
+ message: 'cms:client:message',
+ connected: 'cms:client:connect',
+ disconnected: 'cms:client:disconnect'
}
},
//###init(app)
//I setup the socket server and listen for any routing requests from the express app.
- init : function(app) {
- var self = this,
- io = sio.listen(app);
- io.configure(function() {
- io.set('authorization', function(handshakeData, callback) {
- if(handshakeData.xdomain) {
- callback('Cross-domain connections are not allowed');
+ init: function (app) {
+ var self = this;
+
+ io = sio.listen( app );
+ io.configure( function () {
+ io.set( 'authorization', function (handshakeData, callback) {
+ if (handshakeData.xdomain) {
+ callback( 'Cross-domain connections are not allowed' );
} else {
- callback(null, true);
+ callback( null, true );
}
- });
- });
+ } );
+ } );
//Store a list of the connected clients
var connections = [];
//Handle when a client is connected.
- io.sockets.on('connection', function(socket) {
+ io.sockets.on( 'connection', function (socket) {
//push to connections array
- self.connections.push(socket);
+ self.connections.push( socket );
//Publish the server connected event
- io.sockets.emit(CmsSocket.events.server.connected, {
- data : self.connections.length
- });
+ io.sockets.emit( CmsSocket.events.server.connected, {
+ data: self.connections.length
+ } );
//Listen for client connected
- socket.on(CmsSocket.events.client.connected, function(msg) {
- console.log(CmsSocket.events.client.connected, msg);
- });
-
+ socket.on( CmsSocket.events.client.connected, function (msg) {
+ console.log( CmsSocket.events.client.connected, msg );
+ } );
//Listen for any messages from the client
- socket.on(CmsSocket.events.client.message, function(content) {
+ socket.on( CmsSocket.events.client.message, function (content) {
- console.log(CmsSocket.events.client.message, JSON.stringify(content).debug);
+ console.log( CmsSocket.events.client.message, JSON.stringify( content ).debug );
//Broadcast the event
- socket.emit(CmsSocket.events.server.message, {
- id : socket.id,
- data : content
- });
- socket.broadcast.emit(CmsSocket.events.server.message, {
- id : socket.id,
- data : content
- });
- });
+ socket.emit( CmsSocket.events.server.message, {
+ id: socket.id,
+ data: content
+ } );
+ socket.broadcast.emit( CmsSocket.events.server.message, {
+ id: socket.id,
+ data: content
+ } );
+ } );
//Listen for any pageView events from the client
- socket.on(CmsSocket.events.session.pageView, function(message) {
- console.log(CmsSocket.events.session.pageView + message);
+ socket.on( CmsSocket.events.session.pageView, function (message) {
+ console.log( CmsSocket.events.session.pageView + message );
ip = socket.handshake.address.address;
url = message;
//Broadcast the event
- io.sockets.emit(CmsSocket.events.session.pageView, {
- 'connections' : Object.keys(io.connected).length,
- 'ip' : ip,
- 'url' : url,
- 'xdomain' : socket.handshake.xdomain,
- 'timestamp' : new Date()
- });
- });
-
-
+ io.sockets.emit( CmsSocket.events.session.pageView, {
+ 'connections': Object.keys( io.connected ).length,
+ 'ip': ip,
+ 'url': url,
+ 'xdomain': socket.handshake.xdomain,
+ 'timestamp': new Date()
+ } );
+ } );
//handle disconnections
- socket.on('disconnect', function() {
- console.log("Socket disconnected");
+ socket.on( 'disconnect', function () {
+ console.log( "Socket disconnected" );
- io.sockets.emit('cms:session:pageview', {
- 'connections' : Object.keys(io.connected).length
- });
+ io.sockets.emit( 'cms:session:pageview', {
+ 'connections': Object.keys( io.connected ).length
+ } );
- });
- });
- return this;
+ } );
+ } );
+ return this;
}
};
diff --git a/server.js b/server.js
index 5b85f40..352d04f 100755
--- a/server.js
+++ b/server.js
@@ -78,10 +78,7 @@ var rest = require('./routes/rest').rest;
//Socket server
var socket = require('./routes/socketserver').SocketServer;
-//Initialize socket server and rest server
-socket.init(
- rest.init(config)
-);
+
//Create proxy server and proxy requests
@@ -116,6 +113,14 @@ proxyServer = httpProxy.createServer(options, function (req, res, proxy) {
}
});
+//Initialize socket server and rest server
+socket.init(proxyServer);
+
+
+config.staticDir = __dirname + '/app';
+config.publicDir = __dirname + '/.tmp';
+//config.publicDir = __dirname + '/www';
+rest.init(config);
//Start the proxy server
proxyServer.listen(options.port);
diff --git a/test/protractor/App.js b/test/protractor/App.js
index baba5b7..2233513 100644
--- a/test/protractor/App.js
+++ b/test/protractor/App.js
@@ -1,54 +1,54 @@
-
-/*
- App.coffee
-
- This is the protractor spec that will test the different areas of the application.
+/**
+ * This is the protractor spec that will test the different areas of the application.
*/
-var UsersPage = function() {
-
- this.newUserBtn = element(by.buttonText('New User'));
- this.submitBtn = element(by.buttonText('Submit'));
+/**
+ * UsersPage - This page object controls actions on the /users page.
+ * @constructor
+ */
+var UsersPage = function () {
+ this.newUserBtn = element( by.buttonText( 'New User' ) );
+ this.submitBtn = element( by.buttonText( 'Submit' ) );
this.inputs = {
- email: element(protractor.By.model('user.email')),
- username: element(protractor.By.model('user.username')),
- password: element(protractor.By.model('user.password')),
- name: element(protractor.By.model('user.meta.name')),
- summary: element(protractor.By.model('user.meta.summary'))
+ email: element( protractor.By.model( 'user.email' ) ),
+ username: element( protractor.By.model( 'user.username' ) ),
+ password: element( protractor.By.model( 'user.password' ) ),
+ name: element( protractor.By.model( 'user.meta.name' ) ),
+ summary: element( protractor.By.model( 'user.meta.summary' ) )
};
- this.get = function() {
- browser.get('http://localhost:9000/#/users');
+ this.get = function () {
+ browser.get( 'http://localhost:9000/#/users' );
};
- this.setForm = function(email, username, password, name, summary) {
+ this.setForm = function (email, username, password, name, summary) {
this.newUserBtn.click();
- browser.sleep(500);
- this.inputs.username.sendKeys(username);
- this.inputs.email.sendKeys(email);
- this.inputs.password.sendKeys(password);
- this.inputs.name.sendKeys(name);
- this.inputs.summary.sendKeys(summary);
+ browser.sleep( 500 );
+ this.inputs.username.sendKeys( username );
+ this.inputs.email.sendKeys( email );
+ this.inputs.password.sendKeys( password );
+ this.inputs.name.sendKeys( name );
+ this.inputs.summary.sendKeys( summary );
this.submitBtn.click();
- browser.sleep(1000);
+ browser.sleep( 1000 );
};
};
-describe('Angular-CMS', function() {
+describe( 'Angular-CMS', function () {
var usersPage = null;
- describe('Users Page:', function() {
- beforeEach(function() {
+ describe( 'Users Page:', function () {
+ beforeEach( function () {
usersPage = new UsersPage();
usersPage.get();
- });
+ } );
- it('should be able to create a new user', function() {
+ it( 'should be able to create a new user', function () {
var username = 'protractor' + Date.now();
- usersPage.setForm(username+'@test.com', username, 'test', 'John Doe', 'This is an example user.');
- });
- });
-});
+ usersPage.setForm( username + '@test.com', username, 'test', 'John Doe', 'This is an example user.' );
+ } );
+ } );
+} );