diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..59a1cfd --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "public/libs" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72fc50d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +public/libs \ No newline at end of file diff --git a/app/models/nerd.js b/app/models/nerd.js new file mode 100644 index 0000000..5a09532 --- /dev/null +++ b/app/models/nerd.js @@ -0,0 +1,12 @@ +// app/models/nerd.js +// grab the mongoose module +var mongoose = require('mongoose'); + +// define our nerd model +// module.exports allows us to pass this to other files when it is called +module.exports = mongoose.model('Nerd', { + name: { + type: String, + default: '' + } +}); \ No newline at end of file diff --git a/app/routes.js b/app/routes.js new file mode 100644 index 0000000..fd6036c --- /dev/null +++ b/app/routes.js @@ -0,0 +1,35 @@ + // app/routes.js + + // grab the nerd model we just created + var Nerd = require('./models/nerd'); + + module.exports = function (app) { + + // server routes =========================================================== + // handle things like api calls + // authentication routes + + // sample api route + app.get('/api/nerds', function (req, res) { + // use mongoose to get all nerds in the database + Nerd.find(function (err, nerds) { + + // if there is an error retrieving, send the error. + // nothing after res.send(err) will execute + if (err) + res.send(err); + + res.json(nerds); // return all nerds in JSON format + }); + }); + + // route to handle creating goes here (app.post) + // route to handle delete goes here (app.delete) + + // frontend routes ========================================================= + // route to handle all angular requests + app.get('*', function (req, res) { + res.sendfile('./public/views/index.html'); // load our public/index.html file + }); + + }; \ No newline at end of file diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..dd5d95e --- /dev/null +++ b/bower.json @@ -0,0 +1,11 @@ +{ + "name": "ci-site", + "version": "0.0.1", + "dependencies": { + "bootstrap": "latest", + "font-awesome": "latest", + "animate.css": "latest", + "angular": "latest", + "angular-route": "latest" + } +} \ No newline at end of file diff --git a/config/db.js b/config/db.js new file mode 100644 index 0000000..921d49b --- /dev/null +++ b/config/db.js @@ -0,0 +1,4 @@ +// config/db.js +module.exports = { + url: 'mongodb://localhost/' +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..2c07849 --- /dev/null +++ b/package.json @@ -0,0 +1,10 @@ +{ + "name": "ci-site", + "main": "server.js", + "dependencies": { + "body-parser": "^1.12.0", + "express": "^4.12.2", + "method-override": "^2.3.1", + "mongoose": "^3.8.25" + } +} diff --git a/public/js/app.js b/public/js/app.js new file mode 100644 index 0000000..145886e --- /dev/null +++ b/public/js/app.js @@ -0,0 +1,2 @@ +// public/js/app.js +angular.module('sampleApp', ['ngRoute', 'appRoutes', 'MainCtrl', 'NerdCtrl', 'NerdService']); \ No newline at end of file diff --git a/public/js/appRoutes.js b/public/js/appRoutes.js new file mode 100644 index 0000000..0816e66 --- /dev/null +++ b/public/js/appRoutes.js @@ -0,0 +1,22 @@ +// public/js/appRoutes.js +angular.module('appRoutes', []).config(['$routeProvider', '$locationProvider', + function ($routeProvider, $locationProvider) { + + $routeProvider + + // home page + .when('/', { + templateUrl: 'views/home.html', + controller: 'MainController' + }) + + // nerds page that will use the NerdController + .when('/nerds', { + templateUrl: 'views/nerd.html', + controller: 'NerdController' + }); + + $locationProvider.html5Mode(true); + + } +]); \ No newline at end of file diff --git a/public/js/controllers/MainCtrl.js b/public/js/controllers/MainCtrl.js new file mode 100644 index 0000000..fa569cb --- /dev/null +++ b/public/js/controllers/MainCtrl.js @@ -0,0 +1,6 @@ +// public/js/controllers/MainCtrl.js +angular.module('MainCtrl', []).controller('MainController', function ($scope) { + + $scope.tagline = 'To the moon and back!'; + +}); \ No newline at end of file diff --git a/public/js/controllers/NerdCtrl.js b/public/js/controllers/NerdCtrl.js new file mode 100644 index 0000000..4d9fe4b --- /dev/null +++ b/public/js/controllers/NerdCtrl.js @@ -0,0 +1,6 @@ +// public/js/controllers/NerdCtrl.js +angular.module('NerdCtrl', []).controller('NerdController', function ($scope) { + + $scope.tagline = 'Nothing beats a pocket protector!'; + +}); \ No newline at end of file diff --git a/public/js/services/NerdService.js b/public/js/services/NerdService.js new file mode 100644 index 0000000..9739b86 --- /dev/null +++ b/public/js/services/NerdService.js @@ -0,0 +1,25 @@ +// public/js/services/NerdService.js +angular.module('NerdService', []).factory('Nerd', ['$http', + function ($http) { + + return { + // call to get all nerds + get: function () { + return $http.get('/api/nerds'); + }, + + + // these will work when more API routes are defined on the Node side of things + // call to POST and create a new nerd + create: function (nerdData) { + return $http.post('/api/nerds', nerdData); + }, + + // call to DELETE a nerd + delete: function (id) { + return $http.delete('/api/nerds/' + id); + } + } + + } +]); \ No newline at end of file diff --git a/public/views/home.html b/public/views/home.html new file mode 100644 index 0000000..b12bc2e --- /dev/null +++ b/public/views/home.html @@ -0,0 +1,7 @@ + + +
{{ tagline }}
+{{ tagline }}
+