diff --git a/package.json b/package.json index 438b3a2c4e..a1fc143003 100755 --- a/package.json +++ b/package.json @@ -37,4 +37,4 @@ "grunt-concurrent": "latest", "grunt-mocha-test": "latest" } -} +} \ No newline at end of file diff --git a/public/css/common.css b/public/css/common.css deleted file mode 100755 index e91ae24026..0000000000 --- a/public/css/common.css +++ /dev/null @@ -1,25 +0,0 @@ -.navbar .nav>li>a.brand { - padding-left:20px; - margin-left:0 -} - -.content { - margin-top:50px; - width:100% -} - -footer { - position:fixed; - left:0px; - bottom:0px; - height:30px; - width:100%; - background:#ddd; - -webkit-box-shadow:0 8px 6px 6px black; - -moz-box-shadow:0 8px 6px 6px black; - box-shadow:0 8px 6px 6px black -} - -footer p { - padding:5px 0 12px 10px -} \ No newline at end of file diff --git a/public/css/views/articles.css b/public/css/views/articles.css deleted file mode 100755 index 163b1fa54d..0000000000 --- a/public/css/views/articles.css +++ /dev/null @@ -1,7 +0,0 @@ -h1 { - text-align:center -} - -ul.articles li:not(:last-child) { - border-bottom:1px solid #ccc -} \ No newline at end of file diff --git a/public/humans.txt b/public/humans.txt deleted file mode 100755 index 5b037cf2e1..0000000000 --- a/public/humans.txt +++ /dev/null @@ -1,15 +0,0 @@ -# humanstxt.org/ -# The humans responsible & technology colophon - -# TEAM - - -- -- - -# THANKS - - - -# TECHNOLOGY COLOPHON - - HTML5, CSS3 - jQuery, Modernizr diff --git a/public/img/.gitignore b/public/img/.gitignore deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/public/img/apple/apple-touch-icon-114x114-precomposed.png b/public/img/apple/apple-touch-icon-114x114-precomposed.png deleted file mode 100755 index 172f1b621b..0000000000 Binary files a/public/img/apple/apple-touch-icon-114x114-precomposed.png and /dev/null differ diff --git a/public/img/apple/apple-touch-icon-144x144-precomposed.png b/public/img/apple/apple-touch-icon-144x144-precomposed.png deleted file mode 100755 index 20746cf0ee..0000000000 Binary files a/public/img/apple/apple-touch-icon-144x144-precomposed.png and /dev/null differ diff --git a/public/img/apple/apple-touch-icon-57x57-precomposed.png b/public/img/apple/apple-touch-icon-57x57-precomposed.png deleted file mode 100755 index 88ff2efea4..0000000000 Binary files a/public/img/apple/apple-touch-icon-57x57-precomposed.png and /dev/null differ diff --git a/public/img/apple/apple-touch-icon-72x72-precomposed.png b/public/img/apple/apple-touch-icon-72x72-precomposed.png deleted file mode 100755 index 61c017c743..0000000000 Binary files a/public/img/apple/apple-touch-icon-72x72-precomposed.png and /dev/null differ diff --git a/public/img/apple/apple-touch-icon-precomposed.png b/public/img/apple/apple-touch-icon-precomposed.png deleted file mode 100755 index a70d9fd5d4..0000000000 Binary files a/public/img/apple/apple-touch-icon-precomposed.png and /dev/null differ diff --git a/public/img/apple/apple-touch-icon.png b/public/img/apple/apple-touch-icon.png deleted file mode 100755 index 94e2042f18..0000000000 Binary files a/public/img/apple/apple-touch-icon.png and /dev/null differ diff --git a/public/img/apple/splash.png b/public/img/apple/splash.png deleted file mode 100755 index 5d3dbbded5..0000000000 Binary files a/public/img/apple/splash.png and /dev/null differ diff --git a/public/img/apple/splash2x.png b/public/img/apple/splash2x.png deleted file mode 100755 index 977f37af77..0000000000 Binary files a/public/img/apple/splash2x.png and /dev/null differ diff --git a/public/img/icons/facebook.png b/public/img/icons/facebook.png deleted file mode 100755 index 3a04a89c80..0000000000 Binary files a/public/img/icons/facebook.png and /dev/null differ diff --git a/public/img/icons/favicon.ico b/public/img/icons/favicon.ico deleted file mode 100755 index b459f5c485..0000000000 Binary files a/public/img/icons/favicon.ico and /dev/null differ diff --git a/public/img/icons/github.png b/public/img/icons/github.png deleted file mode 100755 index 15e02097f7..0000000000 Binary files a/public/img/icons/github.png and /dev/null differ diff --git a/public/img/icons/google.png b/public/img/icons/google.png deleted file mode 100755 index 401000a126..0000000000 Binary files a/public/img/icons/google.png and /dev/null differ diff --git a/public/img/icons/twitter.png b/public/img/icons/twitter.png deleted file mode 100755 index 6403a67e84..0000000000 Binary files a/public/img/icons/twitter.png and /dev/null differ diff --git a/public/img/loaders/loader.gif b/public/img/loaders/loader.gif deleted file mode 100755 index 72a9b35972..0000000000 Binary files a/public/img/loaders/loader.gif and /dev/null differ diff --git a/public/img/sprites/glyphicons-halflings-white.png b/public/img/sprites/glyphicons-halflings-white.png deleted file mode 100755 index 3bf6484a29..0000000000 Binary files a/public/img/sprites/glyphicons-halflings-white.png and /dev/null differ diff --git a/public/img/sprites/glyphicons-halflings.png b/public/img/sprites/glyphicons-halflings.png deleted file mode 100755 index a996999320..0000000000 Binary files a/public/img/sprites/glyphicons-halflings.png and /dev/null differ diff --git a/public/index-async.html b/public/index-async.html new file mode 100755 index 0000000000..fd3913a4f3 --- /dev/null +++ b/public/index-async.html @@ -0,0 +1,58 @@ + + + + + + + My AngularJS App + + + + + +
+ +
Angular seed app: v
+ + + diff --git a/public/index.html b/public/index.html new file mode 100755 index 0000000000..4cf94ed75b --- /dev/null +++ b/public/index.html @@ -0,0 +1,29 @@ + + + + + My AngularJS App + + + + + +
+ +
Angular seed app: v
+ + + + + + + + + + + diff --git a/public/js/app.js b/public/js/app.js index a69b8d6761..d990ec7c9d 100755 --- a/public/js/app.js +++ b/public/js/app.js @@ -1,4 +1,16 @@ -window.app = angular.module('mean', ['ngCookies', 'ngResource', 'ui.bootstrap', 'ui.route', 'mean.system', 'mean.articles']); +'use strict'; -angular.module('mean.system', []); -angular.module('mean.articles', []); \ No newline at end of file + +// Declare app level module which depends on filters, and services +angular.module('myApp', [ + 'ngRoute', + 'myApp.filters', + 'myApp.services', + 'myApp.directives', + 'myApp.controllers' +]). +config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: 'MyCtrl1'}); + $routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: 'MyCtrl2'}); + $routeProvider.otherwise({redirectTo: '/view1'}); +}]); diff --git a/public/js/config.js b/public/js/config.js deleted file mode 100755 index dc6ca36945..0000000000 --- a/public/js/config.js +++ /dev/null @@ -1,31 +0,0 @@ -//Setting up route -window.app.config(['$routeProvider', - function($routeProvider) { - $routeProvider. - when('/articles', { - templateUrl: 'views/articles/list.html' - }). - when('/articles/create', { - templateUrl: 'views/articles/create.html' - }). - when('/articles/:articleId/edit', { - templateUrl: 'views/articles/edit.html' - }). - when('/articles/:articleId', { - templateUrl: 'views/articles/view.html' - }). - when('/', { - templateUrl: 'views/index.html' - }). - otherwise({ - redirectTo: '/' - }); - } -]); - -//Setting HTML5 Location Mode -window.app.config(['$locationProvider', - function($locationProvider) { - $locationProvider.hashPrefix("!"); - } -]); \ No newline at end of file diff --git a/public/js/controllers/articles.js b/public/js/controllers/articles.js deleted file mode 100755 index 18bece8217..0000000000 --- a/public/js/controllers/articles.js +++ /dev/null @@ -1,52 +0,0 @@ -angular.module('mean.articles').controller('ArticlesController', ['$scope', '$routeParams', '$location', 'Global', 'Articles', function ($scope, $routeParams, $location, Global, Articles) { - $scope.global = Global; - - $scope.create = function() { - var article = new Articles({ - title: this.title, - content: this.content - }); - article.$save(function(response) { - $location.path("articles/" + response._id); - }); - - this.title = ""; - this.content = ""; - }; - - $scope.remove = function(article) { - article.$remove(); - - for (var i in $scope.articles) { - if ($scope.articles[i] == article) { - $scope.articles.splice(i, 1); - } - } - }; - - $scope.update = function() { - var article = $scope.article; - if (!article.updated) { - article.updated = []; - } - article.updated.push(new Date().getTime()); - - article.$update(function() { - $location.path('articles/' + article._id); - }); - }; - - $scope.find = function() { - Articles.query(function(articles) { - $scope.articles = articles; - }); - }; - - $scope.findOne = function() { - Articles.get({ - articleId: $routeParams.articleId - }, function(article) { - $scope.article = article; - }); - }; -}]); \ No newline at end of file diff --git a/public/js/controllers/header.js b/public/js/controllers/header.js deleted file mode 100755 index 1c1b04fcf2..0000000000 --- a/public/js/controllers/header.js +++ /dev/null @@ -1,13 +0,0 @@ -angular.module('mean.system').controller('HeaderController', ['$scope', 'Global', function ($scope, Global) { - $scope.global = Global; - - $scope.menu = [{ - "title": "Articles", - "link": "articles" - }, { - "title": "Create New Article", - "link": "articles/create" - }]; - - $scope.isCollapsed = false; -}]); \ No newline at end of file diff --git a/public/js/controllers/index.js b/public/js/controllers/index.js deleted file mode 100755 index 2687573559..0000000000 --- a/public/js/controllers/index.js +++ /dev/null @@ -1,3 +0,0 @@ -angular.module('mean.system').controller('IndexController', ['$scope', 'Global', function ($scope, Global) { - $scope.global = Global; -}]); \ No newline at end of file diff --git a/public/js/directives.js b/public/js/directives.js index e69de29bb2..9fc16cc4cb 100755 --- a/public/js/directives.js +++ b/public/js/directives.js @@ -0,0 +1,11 @@ +'use strict'; + +/* Directives */ + + +angular.module('myApp.directives', []). + directive('appVersion', ['version', function(version) { + return function(scope, elm, attrs) { + elm.text(version); + }; + }]); diff --git a/public/js/filters.js b/public/js/filters.js index e69de29bb2..259dd4ee02 100755 --- a/public/js/filters.js +++ b/public/js/filters.js @@ -0,0 +1,10 @@ +'use strict'; + +/* Filters */ + +angular.module('myApp.filters', []). + filter('interpolate', ['version', function(version) { + return function(text) { + return String(text).replace(/\%VERSION\%/mg, version); + } + }]); diff --git a/public/js/init.js b/public/js/init.js deleted file mode 100755 index f77b4f2ae1..0000000000 --- a/public/js/init.js +++ /dev/null @@ -1,15 +0,0 @@ -window.bootstrap = function() { - angular.bootstrap(document, ['mean']); -}; - -window.init = function() { - window.bootstrap(); -}; - -angular.element(document).ready(function() { - //Fixing facebook bug with redirect - if (window.location.hash == "#_=_") window.location.hash = ""; - - //Then init the app - window.init(); -}); \ No newline at end of file diff --git a/public/js/services/articles.js b/public/js/services/articles.js deleted file mode 100755 index 2d496701ca..0000000000 --- a/public/js/services/articles.js +++ /dev/null @@ -1,10 +0,0 @@ -//Articles service used for articles REST endpoint -angular.module('mean.articles').factory("Articles", ['$resource', function($resource) { - return $resource('articles/:articleId', { - articleId: '@_id' - }, { - update: { - method: 'PUT' - } - }); -}]); \ No newline at end of file diff --git a/public/js/services/global.js b/public/js/services/global.js deleted file mode 100755 index 95eb0117a0..0000000000 --- a/public/js/services/global.js +++ /dev/null @@ -1,9 +0,0 @@ -angular.module('mean.system').factory("Global", [function() { - var _this = this; - _this._data = { - user: window.user, - authenticated: !! window.user - }; - - return _this._data; -}]); \ No newline at end of file diff --git a/public/robots.txt b/public/robots.txt deleted file mode 100755 index ee2cc216a6..0000000000 --- a/public/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# robotstxt.org/ - -User-agent: * diff --git a/public/views/articles/create.html b/public/views/articles/create.html deleted file mode 100755 index 222464accd..0000000000 --- a/public/views/articles/create.html +++ /dev/null @@ -1,21 +0,0 @@ -
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
-
\ No newline at end of file diff --git a/public/views/articles/edit.html b/public/views/articles/edit.html deleted file mode 100755 index 12d6c2b234..0000000000 --- a/public/views/articles/edit.html +++ /dev/null @@ -1,25 +0,0 @@ -
-
-
- - -
- - -
-
-
- - -
- -
-
-
-
- -
-
-
-
\ No newline at end of file diff --git a/public/views/articles/list.html b/public/views/articles/list.html deleted file mode 100755 index 40b4fba8f1..0000000000 --- a/public/views/articles/list.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
    -
  • - {{article.created | date:'medium'}} / - {{article.user.name}} -

    {{article.title}}

    -
    {{article.content}}
    -
  • -
-

No articles yet.
Why don't you Create One?

-
\ No newline at end of file diff --git a/public/views/articles/view.html b/public/views/articles/view.html deleted file mode 100755 index 821d0b670c..0000000000 --- a/public/views/articles/view.html +++ /dev/null @@ -1,6 +0,0 @@ -
- {{article.created | date:'medium'}} / - {{article.user.name}} -

{{article.title}} edit

-
{{article.content}}
-
\ No newline at end of file diff --git a/public/views/header.html b/public/views/header.html deleted file mode 100755 index 7567812559..0000000000 --- a/public/views/header.html +++ /dev/null @@ -1,28 +0,0 @@ - \ No newline at end of file diff --git a/public/views/index.html b/public/views/index.html deleted file mode 100755 index f245897ac9..0000000000 --- a/public/views/index.html +++ /dev/null @@ -1,3 +0,0 @@ -
-

This is the home view

-
\ No newline at end of file diff --git a/server.js b/server.js index c8a0daf3ba..fc17318645 100755 --- a/server.js +++ b/server.js @@ -1,21 +1,8 @@ var express = require('express'), mongoose = require('mongoose'), - mongoStore = require('connect-mongo')(express), fs = require('fs'), - flash = require('connect-flash'), - helpers = require('view-helpers'), config = require('./conf'), - passport = require('passport'), - logger = require('mean-logger'); - -/** - * Main application entry file. - * Please note that the order of loading is important. - */ - -//Load configurations -//if test env, load example file -var env = process.env.NODE_ENV = process.env.NODE_ENV || 'development'; + passport = require('passport'); /** * Generic require login routing middleware @@ -219,278 +206,35 @@ ArticleSchema.statics = { mongoose.model('Article', ArticleSchema); -//bootstrap passport config -var LocalStrategy = require('passport-local').Strategy, - TwitterStrategy = require('passport-twitter').Strategy, - FacebookStrategy = require('passport-facebook').Strategy, - GitHubStrategy = require('passport-github').Strategy, - GoogleStrategy = require('passport-google-oauth').OAuth2Strategy; - -//Serialize sessions -passport.serializeUser(function(user, done) { - done(null, user.id); -}); - -passport.deserializeUser(function(id, done) { - User.findOne({ - _id: id - }, function(err, user) { - done(err, user); - }); -}); - -//Use local strategy -passport.use(new LocalStrategy({ - usernameField: 'email', - passwordField: 'password' - }, - function(email, password, done) { - User.findOne({ - email: email - }, function(err, user) { - if (err) { - return done(err); - } - if (!user) { - return done(null, false, { - message: 'Unknown user' - }); - } - if (!user.authenticate(password)) { - return done(null, false, { - message: 'Invalid password' - }); - } - return done(null, user); - }); - } -)); - -//Use twitter strategy -passport.use(new TwitterStrategy({ - consumerKey: config.twitter.clientID, - consumerSecret: config.twitter.clientSecret, - callbackURL: config.twitter.callbackURL - }, - function(token, tokenSecret, profile, done) { - User.findOne({ - 'twitter.id_str': profile.id - }, function(err, user) { - if (err) { - return done(err); - } - if (!user) { - user = new User({ - name: profile.displayName, - username: profile.username, - provider: 'twitter', - twitter: profile._json - }); - user.save(function(err) { - if (err) console.log(err); - return done(err, user); - }); - } else { - return done(err, user); - } - }); - } -)); - -//Use facebook strategy -passport.use(new FacebookStrategy({ - clientID: config.facebook.clientID, - clientSecret: config.facebook.clientSecret, - callbackURL: config.facebook.callbackURL - }, - function(accessToken, refreshToken, profile, done) { - User.findOne({ - 'facebook.id': profile.id - }, function(err, user) { - if (err) { - return done(err); - } - if (!user) { - user = new User({ - name: profile.displayName, - email: profile.emails[0].value, - username: profile.username, - provider: 'facebook', - facebook: profile._json - }); - user.save(function(err) { - if (err) console.log(err); - return done(err, user); - }); - } else { - return done(err, user); - } - }); - } -)); - -//Use github strategy -passport.use(new GitHubStrategy({ - clientID: config.github.clientID, - clientSecret: config.github.clientSecret, - callbackURL: config.github.callbackURL - }, - function(accessToken, refreshToken, profile, done) { - User.findOne({ - 'github.id': profile.id - }, function(err, user) { - if (!user) { - user = new User({ - name: profile.displayName, - email: profile.emails[0].value, - username: profile.username, - provider: 'github', - github: profile._json - }); - user.save(function(err) { - if (err) console.log(err); - return done(err, user); - }); - } else { - return done(err, user); - } - }); - } -)); - -//Use google strategy -passport.use(new GoogleStrategy({ - clientID: config.google.clientID, - clientSecret: config.google.clientSecret, - callbackURL: config.google.callbackURL - }, - function(accessToken, refreshToken, profile, done) { - User.findOne({ - 'google.id': profile.id - }, function(err, user) { - if (!user) { - user = new User({ - name: profile.displayName, - email: profile.emails[0].value, - username: profile.username, - provider: 'google', - google: profile._json - }); - user.save(function(err) { - if (err) console.log(err); - return done(err, user); - }); - } else { - return done(err, user); - } - }); - } -)); - var app = express(); + /** * Express Settings */ -app.set('showStackError', true); app.set('port', process.env.PORT || 3000); -app.locals.pretty = true; -app.use(express.compress({ - filter: function(req, res) { - return (/json|text|javascript|css/).test(res.getHeader('Content-Type')); - }, - level: 9 -})); app.use(express.favicon()); -app.use(express.static(config.root + '/public')); -app.set('views', config.root + '/app/views'); -app.set('view engine', 'jade'); -app.enable("jsonp callback"); -app.use(express.cookieParser()); -app.use(express.bodyParser()); +app.use(express.logger('dev')); +app.use(express.json()); +app.use(express.urlencoded()); app.use(express.methodOverride()); -app.use(express.session({ - secret: '1337', - store: new mongoStore({ - db: db.connection.db, - collection: 'sessions' - }) -})); -app.use(flash()); -app.use(helpers(config.app.name)); -app.use(passport.initialize()); -app.use(passport.session()); app.use(app.router); - -app.use(function(err, req, res, next) { - //Treat as 404 - if (~err.message.indexOf('not found')) return next(); - - //Log it - console.error(err.stack); - - //Error page - res.status(500).render('500', { - error: err.stack - }); -}); - -app.use(function(req, res, next) { - res.status(404).render('404', { - url: req.originalUrl, - error: 'Not found' - }); -}); +app.use(express.static(config.root + '/public')); -//User Routes -app.post('/users', users.create); -app.get('/users/me', users.me); -app.get('/users/:userId', users.show); - -//Setting the facebook oauth routes -app.get('/auth/facebook', passport.authenticate('facebook', { - scope: ['email', 'user_about_me'], - failureRedirect: '/signin' -}), users.signin); - -app.get('/auth/facebook/callback', passport.authenticate('facebook', { - failureRedirect: '/signin' -}), users.authCallback); - -//Setting the github oauth routes -app.get('/auth/github', passport.authenticate('github', { failureRedirect: '/signin' }), users.signin); -app.get('/auth/github/callback', passport.authenticate('github', { failureRedirect: '/signin' }), users.authCallback); - -//Setting the twitter oauth routes -app.get('/auth/twitter', passport.authenticate('twitter', { failureRedirect: '/signin' }), users.signin); -app.get('/auth/twitter/callback', passport.authenticate('twitter', { failureRedirect: '/signin' }), users.authCallback); - -//Setting the google oauth routes -app.get('/auth/google', passport.authenticate('google', { - failureRedirect: '/signin', - scope: [ - 'https://www.googleapis.com/auth/userinfo.profile', - 'https://www.googleapis.com/auth/userinfo.email' - ] -}), users.signin); -app.get('/auth/google/callback', passport.authenticate('google', { failureRedirect: '/signin' }), users.authCallback); - -//Finish with setting up the userId param -app.param('userId', users.user); - -//Article Routes -var articles = require('../app/controllers/articles'); -app.get('/articles', articles.all); -app.post('/articles', auth.requiresLogin, articles.create); -app.get('/articles/:articleId', articles.show); -app.put('/articles/:articleId', auth.requiresLogin, auth.article.hasAuthorization, articles.update); -app.del('/articles/:articleId', auth.requiresLogin, auth.article.hasAuthorization, articles.destroy); +/** + * API Routes + */ +app.post('/api/users', users.create); +app.get('/api/users/me', users.me); +app.get('/api/users/:userId', users.show); +app.get('/api/articles', articles.all); +app.post('/api/articles', requiresLogin, articles.create); +app.get('/api/articles/:articleId', articles.show); +app.put('/api/articles/:articleId', auth.requiresLogin, auth.article.hasAuthorization, articles.update); +app.del('/api/articles/:articleId', auth.requiresLogin, auth.article.hasAuthorization, articles.destroy); -//Home route -var index = require('../app/controllers/index'); -app.get('/', index.render); - -console.log('Express app started on port ' + app.get('port')); -app.listen(app.get('port')); +app.listen(app.get('port'), function() { + console.log('Express server listening on port ' + app.get('port')); +}); \ No newline at end of file