Permalink
Browse files

yeoman --stuff

  • Loading branch information...
1 parent fcdc60f commit d8f6e0530f7068f0af7d8e63f887a74307ea799c @ryansroberts ryansroberts committed Oct 26, 2013
View
@@ -0,0 +1,4 @@
+{
+ "directory": "public/components",
+ "json": "bower.json"
+}
View
@@ -0,0 +1,3 @@
+node_modules/
+public/components
+.sass-cache
View
@@ -1,42 +1,59 @@
+'use strict';
+
+var request = require('request');
+
module.exports = function (grunt) {
- grunt.initConfig({
- pkg: grunt.file.readJSON("package.json"),
- jshint: {
- all: [
- "*.js",
- "src/*.js",
- "spec/*.js",
- "!src/server.min.js"
- ]
- },
- watch: {
- files: [
- "*.js",
- "src/*.js",
- "spec/*.js",
- "!src/server.min.js"
- ],
- tasks: ["test"]
- },
- jasmine: {
- src: "src/server.js",
- options: {
- specs: "spec/spec.js"
- }
- },
- uglify: {
- my_target: {
- files: {
- "src/server.min.js": [
- "src/server.js"
- ]
- }
- }
- }
- });
- grunt.loadNpmTasks("grunt-contrib-watch");
- grunt.loadNpmTasks("grunt-contrib-jshint");
- grunt.loadNpmTasks("grunt-contrib-jasmine");
- grunt.loadNpmTasks("grunt-contrib-uglify");
- grunt.registerTask("test", ["jshint", "uglify", "jasmine"]);
-};
+ // show elapsed time at the end
+ require('time-grunt')(grunt);
+ // load all grunt tasks
+ require('load-grunt-tasks')(grunt);
+
+ var reloadPort = 35729, files;
+
+ grunt.initConfig({
+ pkg: grunt.file.readJSON('package.json'),
+ develop: {
+ server: {
+ file: 'app.js'
+ }
+ },
+ watch: {
+ options: {
+ nospawn: true,
+ livereload: reloadPort
+ },
+ js: {
+ files: [
+ 'app.js',
+ 'app/**/*.js',
+ 'config/*.js'
+ ],
+ tasks: ['develop', 'delayed-livereload']
+ },
+ jade: {
+ files: ['app/views/**/*.jade'],
+ options: { livereload: reloadPort }
+ }
+ }
+ });
+
+ grunt.config.requires('watch.js.files');
+ files = grunt.config('watch.js.files');
+ files = grunt.file.expand(files);
+
+ grunt.registerTask('delayed-livereload', 'Live reload after the node server has restarted.', function () {
+ var done = this.async();
+ setTimeout(function () {
+ request.get('http://localhost:' + reloadPort + '/changed?files=' + files.join(','), function(err, res) {
+ var reloaded = !err && res.statusCode === 200;
+ if (reloaded)
+ grunt.log.ok('Delayed live reload successful.');
+ else
+ grunt.log.error('Unable to make a delayed live reload.');
+ done(reloaded);
+ });
+ }, 500);
+ });
+
+ grunt.registerTask('default', ['develop', 'watch']);
+};
View
24 app.js
@@ -0,0 +1,24 @@
+var express = require('express'),
+ mongoose = require('mongoose'),
+ fs = require('fs'),
+ config = require('./config/config');
+
+mongoose.connect(config.db);
+var db = mongoose.connection;
+db.on('error', function () {
+ throw new Error('unable to connect to database at ' + config.db);
+});
+
+var modelsPath = __dirname + '/app/models';
+fs.readdirSync(modelsPath).forEach(function (file) {
+ if (file.indexOf('.js') >= 0) {
+ require(modelsPath + '/' + file);
+ }
+});
+
+var app = express();
+
+require('./config/express')(app, config);
+require('./config/routes')(app);
+
+app.listen(config.port);
View
@@ -0,0 +1,12 @@
+var mongoose = require('mongoose'),
+ Article = mongoose.model('Article');
+
+exports.index = function(req, res){
+ Article.find(function(err, articles){
+ if(err) throw new Error(err);
+ res.render('home/index', {
+ title: 'Generator-Express MVC',
+ articles: articles
+ });
+ });
+};
View
@@ -0,0 +1,17 @@
+// Example model
+
+var mongoose = require('mongoose'),
+ Schema = mongoose.Schema;
+
+var ArticleSchema = new Schema({
+ title: String,
+ url: String,
+ text: String
+});
+
+ArticleSchema.virtual('date')
+ .get(function(){
+ return this._id.getTimestamp();
+ });
+
+mongoose.model('Article', ArticleSchema);
View
@@ -0,0 +1,4 @@
+extends layout
+
+block content
+ h1 404 Page not found!
@@ -0,0 +1,4 @@
+extends ../layout
+
+block content
+ h1 I'm using generator-express MVC!
View
@@ -0,0 +1,12 @@
+doctype 5
+html(lang='en')
+ head
+ meta(charset='UTF-8')
+ meta(name='viewport', content='width=device-width')
+ title= title
+ block css
+ link(rel='stylesheet', href='/css/style.css')
+ block js
+ script(src='http://localhost:35729/livereload.js')
+ body
+ block content
View
@@ -0,0 +1,9 @@
+{
+ "name": "appsassin",
+ "version": "0.0.1",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "components"
+ ]
+}
View
@@ -0,0 +1,34 @@
+var path = require('path'),
+ rootPath = path.normalize(__dirname + '/..'),
+ env = process.env.NODE_ENV || 'development';
+
+var config = {
+ development: {
+ root: rootPath,
+ app: {
+ name: 'appsassin'
+ },
+ port: 3000,
+ db: 'mongodb://localhost/appsassin-development'
+ },
+
+ test: {
+ root: rootPath,
+ app: {
+ name: 'appsassin'
+ },
+ port: 3000,
+ db: 'mongodb://localhost/appsassin-test'
+ },
+
+ production: {
+ root: rootPath,
+ app: {
+ name: 'appsassin'
+ },
+ port: 3000,
+ db: 'mongodb://localhost/appsassin-production'
+ }
+};
+
+module.exports = config[env];
View
@@ -0,0 +1,19 @@
+var express = require('express');
+
+module.exports = function(app, config) {
+ app.configure(function () {
+ app.use(express.compress());
+ app.use(express.static(config.root + '/public'));
+ app.set('port', config.port);
+ app.set('views', config.root + '/app/views');
+ app.set('view engine', 'jade');
+ app.use(express.favicon(config.root + '/public/img/favicon.ico'));
+ app.use(express.logger('dev'));
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(app.router);
+ app.use(function(req, res) {
+ res.status(404).render('404', { title: '404' });
+ });
+ });
+};
View
@@ -0,0 +1,7 @@
+module.exports = function(app){
+
+ //home route
+ var home = require('../app/controllers/home');
+ app.get('/', home.index);
+
+};
View
@@ -1,29 +1,22 @@
{
- "name": "appsassin-server",
- "description": "#HackManchester",
- "homepage": "http://appsass.in",
+ "name": "appsassin",
"version": "0.0.1",
- "main": "src/server.min.js",
+ "private": true,
"scripts": {
- "test": "grunt test"
+ "start": "app.js"
},
- "repository": {
- "type": "git",
- "url": "git@github.com:leecrossley/appsassin.git"
- },
- "engines": {
- "node": ">= 0.8.x"
+ "dependencies": {
+ "express": "~3.3.4",
+ "jade": "~0.34.0",
+ "mongoose": "~3.6.14"
},
"devDependencies": {
"grunt": "~0.4.1",
- "grunt-shell": "~0.5.x",
- "grunt-contrib-watch": "~0.5.x",
- "grunt-contrib-jshint": "~0.6.x",
- "grunt-contrib-jasmine": "~0.5.x",
- "grunt-contrib-uglify": "~0.2.x",
- "grunt-cli": "~0.1.x"
- },
- "dependencies": {
- "functional.js": "~0.2.3"
+ "grunt-develop": "~0.1.1",
+ "grunt-contrib-watch": "~0.4.4",
+ "grunt-contrib-compass": "~0.2.0",
+ "request": "~2.22.0",
+ "time-grunt": "~0.1.1",
+ "load-grunt-tasks": "~0.2.0"
}
}
View
No changes.
View
No changes.

0 comments on commit d8f6e05

Please sign in to comment.