Merge branch 'paglias/grunt' into develop

This commit is contained in:
Tyler Renelle
2013-09-06 22:23:02 -04:00
60 changed files with 263 additions and 80 deletions

2
.gitignore vendored
View File

@@ -7,7 +7,7 @@ config.json
npm-debug.log
lib
public/bower_components
builtAssets/
public/build
src/*/*.map
src/*/*/*.map

View File

@@ -1,2 +1,2 @@
/public/*
/assets/*
/views/*
/public/build/*

145
Gruntfile.js Normal file
View File

@@ -0,0 +1,145 @@
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
clean: {
build: ['public/build']
},
uglify: {
buildApp: {
files: {
'public/build/app.js': [
'public/bower_components/jquery/jquery.min.js',
'public/bower_components/bootstrap-growl/jquery.bootstrap-growl.min.js',
'public/bower_components/angular/angular.min.js',
'public/bower_components/angular-sanitize/angular-sanitize.min.js',
'public/bower_components/angular-route/angular-route.min.js',
'public/bower_components/angular-resource/angular-resource.min.js',
'public/bower_components/angular-ui/build/angular-ui.min.js',
'public/bower_components/angular-ui-utils/modules/keypress/keypress.js',
// we'll remove this once angular-bootstrap is fixed
'public/bower_components/bootstrap/docs/assets/js/bootstrap.min.js',
'public/bower_components/angular-bootstrap/ui-bootstrap.min.js',
'public/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
// Sortable
'public/bower_components/jquery-ui/ui/minified/jquery.ui.core.min.js',
'public/bower_components/jquery-ui/ui/minified/jquery.ui.widget.min.js',
'public/bower_components/jquery-ui/ui/minified/jquery.ui.mouse.min.js',
'public/bower_components/jquery-ui/ui/minified/jquery.ui.sortable.min.js',
// habitrpg-shared
'public/bower_components/habitrpg-shared/dist/habitrpg-shared.js',
// app
'public/js/app.js',
'public/js/services/authServices.js',
'public/js/services/notificationServices.js',
'public/js/services/sharedServices.js',
'public/js/services/userServices.js',
'public/js/services/groupServices.js',
'public/js/filters/filters.js',
'public/js/directives/directives.js',
'public/js/controllers/authCtrl.js',
'public/js/controllers/characterCtrl.js',
'public/js/controllers/menuCtrl.js',
'public/js/controllers/notificationCtrl.js',
'public/js/controllers/rootCtrl.js',
'public/js/controllers/settingsCtrl.js',
'public/js/controllers/statsCtrl.js',
'public/js/controllers/tasksCtrl.js',
'public/js/controllers/taskDetailsCtrl.js',
'public/js/controllers/filtersCtrl.js',
'public/js/controllers/userAvatarCtrl.js',
'public/js/controllers/groupsCtrl.js',
'public/js/controllers/petsCtrl.js',
'public/js/controllers/inventoryCtrl.js',
'public/js/controllers/marketCtrl.js',
'public/js/controllers/footerCtrl.js'
]
}
},
buildStatic: {
files: {
'public/build/static.js': [
'public/bower_components/jquery/jquery.min.js',
'public/bower_components/habitrpg-shared/dist/habitrpg-shared.js',
'public/bower_components/angular/angular.min.js',
'public/bower_components/bootstrap/docs/assets/js/bootstrap.min.js',
'public/js/static.js',
'public/js/services/userServices.js',
'public/js/controllers/authCtrl.js'
]
}
}
},
stylus: {
build: {
options: {
compress: false, // AFTER
'include css': true,
paths: ['public']
},
files: {
'public/build/app.css': ['public/css/index.styl'],
'public/build/static.css': ['public/css/static.styl']
}
}
},
cssmin: {
build: {
files: {
'public/build/app.css': ['public/build/app.css'],
'public/build/static.css': ['public/build/static.css']
}
}
},
exec: {
start: {
cmd: function(mode){
if(mode && mode == 'production'){
return 'nodemon --exec "./start.sh" production'
}else{
return 'nodemon --exec "./start.sh"'
}
}
}
}
/*hashres: {
options: {
fileNameFormat: '${name}-${hash}.${ext}',
},
build: {
src: [
'public/build/app.js',
'public/build/static.js'
],
dest: 'views/i-do-not-exist.jade' // Non existing file!
}
}*/
});
// Register tasks.
grunt.registerTask('production', ['clean:build', 'uglify', 'stylus', 'cssmin']);
grunt.registerTask('development', ['clean:build', 'stylus', 'cssmin']);
grunt.registerTask('start:production', ['exec:start:production']);
grunt.registerTask('start', ['exec:start']);
// Load tasks
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-hashres');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-exec');
};

View File

@@ -15,7 +15,7 @@ Or, expressed in commands on the command line:
1. `git clone --recursive -b angular_rewrite https://github.com/lefnire/habitrpg.git`
1. `cd habitrpg && npm install`
1. `npm start`
1. `grunt start` (`grunt start:production` to concat & minify js)
To access the site, open http://localhost:3000 in your browser.
@@ -76,7 +76,7 @@ Ignore this error and proceed with the following:
1. Run 'npm install -g bower'
1. Run 'bower install -f'
1. Run 'copy config.json.example config.json'
1. Run 'npm start'
1. `grunt start` (`grunt start:production` to concat & minify js)
Open a browser to URL http://localhost:3000 to test the application.

View File

@@ -1,27 +0,0 @@
//= require app
//= require services/authServices
//= require services/notificationServices
//= require services/sharedServices
//= require services/userServices
//= require services/groupServices
//= require filters/filters
//= require directives/directives
//= require controllers/authCtrl
//= require controllers/characterCtrl
//= require controllers/menuCtrl
//= require controllers/notificationCtrl
//= require controllers/rootCtrl
//= require controllers/settingsCtrl
//= require controllers/statsCtrl
//= require controllers/tasksCtrl
//= require controllers/taskDetailsCtrl
//= require controllers/filtersCtrl
//= require controllers/userAvatarCtrl
//= require controllers/groupsCtrl
//= require controllers/petsCtrl
//= require controllers/inventoryCtrl
//= require controllers/marketCtrl
//= require controllers/footerCtrl

View File

@@ -1,3 +0,0 @@
//= require static
//= require services/userServices
//= require controllers/authCtrl

View File

@@ -35,7 +35,6 @@
},
"resolutions": {
"jquery": "~2.0.3",
"bootstrap": "v2.3.2",
"angular-sanitize": "1.2.0-rc.1"
"bootstrap": "v2.3.2"
}
}

View File

@@ -25,7 +25,13 @@
"optimist": "~0.5.2",
"mongoose": "~3.6.18",
"stylus": "~0.37.0",
"connect-assets": "~2.5.2",
"grunt": "~0.4.1",
"grunt-contrib-uglify": "~0.2.4",
"grunt-hashres": "~0.3.2",
"grunt-contrib-stylus": "~0.8.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-cssmin": "~0.6.1",
"grunt-exec": "~0.4.x",
"bower": "~1.2.4",
"nib": "~1.0.1",
"jade": "~0.35.0",
@@ -44,7 +50,6 @@
"npm": "1.2.x"
},
"scripts": {
"start": "nodemon src/server.js",
"test": "mocha test/api.mocha.coffee",
"postinstall": "./node_modules/bower/bin/bower install -f"
}

View File

@@ -1,7 +1,10 @@
@import "nib/vendor"
// Vendor Includes - include first so we can override
@import "../../../public/bower_components/bootstrap-datepicker/css/datepicker.css"
// Import only styles that do not have urls to images! Include them directly in the page!
@import "../bower_components/bootstrap-datepicker/css/datepicker.css"
@import "../bower_components/angular-ui/build/angular-ui.min.css"
@import "../bower_components/bootstrap/docs/assets/css/bootstrap-responsive.css"
// Custom includes
@import "./tasks.styl"

5
public/css/static.styl Normal file
View File

@@ -0,0 +1,5 @@
// Vendor Includes - include first so we can override
// Import only styles that do not have urls to images! Include them directly in the page!
@import "./static-pages.css"
@import "./footer.css"

View File

@@ -29,7 +29,7 @@ module.exports.cors = function(req, res, next) {
module.exports.locals = function(req, res, next) {
res.locals.habitrpg = res.locals.habitrpg || {}
_.defaults(res.locals.habitrpg, {
NODE_ENV: req.url.split('/')[1] == 'static' ? 'production' : nconf.get('NODE_ENV'), // Don't show debugging options on static pages
NODE_ENV: nconf.get('NODE_ENV'), // Don't show debugging options on static pages
IS_MOBILE: /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(req.header('User-Agent')),
STRIPE_PUB_KEY: nconf.get('STRIPE_PUB_KEY')
});

View File

@@ -12,17 +12,17 @@ router.get('/', function(req, res) {
});
router.get('/partials/tasks', function(req, res) {
res.render('tasks/index');
res.render('tasks/index', {env: res.locals.habitrpg});
});
router.get('/partials/options', function(req, res) {
res.render('options');
res.render('options', {env: res.locals.habitrpg});
});
// -------- Marketing --------
router.get('/splash.html', function(req, res) {
res.redirect('/static/front');
res.redirect('/static/front', {env: res.locals.habitrpg});
});
router.get('/static/front', function(req, res) {

View File

@@ -67,14 +67,14 @@ passport.use(new FacebookStrategy({
// ------------ Server Configuration ------------
app.set("port", nconf.get('PORT'));
app.use(express.logger("dev"));
app.use(express.compress());
app.set("views", __dirname + "/../views");
app.set("view engine", "jade");
app.use(express.favicon());
app.use(express.logger("dev"));
app.use(middleware.cors);
app.use(middleware.forceSSL);
app.use(express.bodyParser());
app.use(require('connect-assets')());
app.use(express.methodOverride());
//app.use(express.cookieParser(nconf.get('SESSION_SECRET')));
app.use(express.cookieParser());

11
start.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
if [ $1 = "production" ]; then
echo "Starting production server";
grunt production;
else
echo "Starting development server";
grunt development;
fi
node ./src/server.js

View File

@@ -13,14 +13,16 @@ html
// CSS
link(rel='stylesheet', href='/bower_components/bootstrap/docs/assets/css/bootstrap.css')
link(rel='stylesheet', href='/bower_components/bootstrap/docs/assets/css/bootstrap-responsive.css')
link(rel='stylesheet', href='/bower_components/angular-ui/build/angular-ui.min.css')
!= css('index')
link(rel='stylesheet', href='/build/app.css')
// HabitRPG Shared
link(rel='stylesheet', href='/bower_components/habitrpg-shared/dist/spritesheets.css')
// JS
- if(env.NODE_ENV == 'production'){
script(type='text/javascript', src='build/app.js')
- }else{
// Remember to update the file list in Gruntfile.js!
script(type='text/javascript', src='/bower_components/jquery/jquery.min.js')
script(type='text/javascript', src='/bower_components/bootstrap-growl/jquery.bootstrap-growl.min.js')
script(type='text/javascript', src='/bower_components/angular/angular.min.js')
@@ -33,16 +35,42 @@ html
script(type='text/javascript', src='/bower_components/bootstrap/docs/assets/js/bootstrap.min.js')
script(type='text/javascript', src='/bower_components/angular-bootstrap/ui-bootstrap.min.js')
script(type='text/javascript', src='/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js')
// Sortable
script(type='text/javascript', src='/bower_components/jquery-ui/ui/minified/jquery.ui.core.min.js')
script(type='text/javascript', src='/bower_components/jquery-ui/ui/minified/jquery.ui.widget.min.js')
script(type='text/javascript', src='/bower_components/jquery-ui/ui/minified/jquery.ui.mouse.min.js')
script(type='text/javascript', src='/bower_components/jquery-ui/ui/minified/jquery.ui.sortable.min.js')
// habitrpg-shared
script(type='text/javascript', src='/bower_components/habitrpg-shared/dist/habitrpg-shared.js')
// app
script(type='text/javascript', src='/js/app.js')
script(type='text/javascript', src='/js/services/authServices.js')
script(type='text/javascript', src='/js/services/notificationServices.js')
script(type='text/javascript', src='/js/services/sharedServices.js')
script(type='text/javascript', src='/js/services/userServices.js')
script(type='text/javascript', src='/js/services/groupServices.js')
!= js('appMain')
script(type='text/javascript', src='/js/filters/filters.js')
script(type='text/javascript', src='/js/directives/directives.js')
script(type='text/javascript', src='/js/controllers/authCtrl.js')
script(type='text/javascript', src='/js/controllers/characterCtrl.js')
script(type='text/javascript', src='/js/controllers/menuCtrl.js')
script(type='text/javascript', src='/js/controllers/notificationCtrl.js')
script(type='text/javascript', src='/js/controllers/rootCtrl.js')
script(type='text/javascript', src='/js/controllers/settingsCtrl.js')
script(type='text/javascript', src='/js/controllers/statsCtrl.js')
script(type='text/javascript', src='/js/controllers/tasksCtrl.js')
script(type='text/javascript', src='/js/controllers/taskDetailsCtrl.js')
script(type='text/javascript', src='/js/controllers/filtersCtrl.js')
script(type='text/javascript', src='/js/controllers/userAvatarCtrl.js')
script(type='text/javascript', src='/js/controllers/groupsCtrl.js')
script(type='text/javascript', src='/js/controllers/petsCtrl.js')
script(type='text/javascript', src='/js/controllers/inventoryCtrl.js')
script(type='text/javascript', src='/js/controllers/marketCtrl.js')
script(type='text/javascript', src='/js/controllers/footerCtrl.js')
-}
//webfonts
link(href='//fonts.googleapis.com/css?family=Lato:300,400,700,400italic,700italic', rel='stylesheet', type='text/css')

View File

@@ -1,4 +1,7 @@
extends ./layout
//Trick needed to pass 'env' to ./layout
block vars
- var layoutEnv = env
block title
title HabitRPG | Gamify Your Life

View File

@@ -1,3 +1,5 @@
//Trick needed to pass 'env' to ./layout
block vars
doctype 5
html
@@ -10,24 +12,30 @@ html
// CSS
link(rel='stylesheet', href='/bower_components/bootstrap/docs/assets/css/bootstrap.css')
// Keep this out of build because the one after has some images and would like not to override it
link(rel='stylesheet', href='/bower_components/bootstrap/docs/assets/css/bootstrap-responsive.css')
link(href='/bower_components/bootstrap/docs/assets/css/docs.css', rel='stylesheet')
link(href='/css/static-pages.css', rel='stylesheet')
link(href='/css/footer.css', rel='stylesheet')
// FIXME we gotta get rid of all these requirements in userServices. we don't need habitrpg-shared, lodash, moment, etc here
// and habitrpg-shared alone is ~700kb
link(rel='stylesheet', href='/build/static.css')
// JS
- if(layoutEnv.NODE_ENV == 'production'){
script(type='text/javascript', src='/build/static.js')
- }else{
// Remember to update the file list in Gruntfile.js!
script(type='text/javascript', src='/bower_components/jquery/jquery.min.js')
script(type='text/javascript', src='/bower_components/habitrpg-shared/dist/habitrpg-shared.js')
script(type='text/javascript', src='/bower_components/angular/angular.min.js')
script(type='text/javascript', src='/bower_components/bootstrap/docs/assets/js/bootstrap.min.js')
script(type='text/javascript', src='/js/static.js')
script(type='text/javascript', src='/js/services/userServices.js')
script(type='text/javascript', src='/js/controllers/authCtrl.js')
-}
script(type='text/javascript').
$.getScript("//s7.addthis.com/js/250/addthis_widget.js#pubid=lefnire");
!= js('staticMain')
body
block content

View File

@@ -1,4 +1,7 @@
extends ./layout
//Trick needed to pass 'env' to ./layout
block vars
- var layoutEnv = env
block title
title HabitRPG | Privacy

View File

@@ -1,4 +1,7 @@
extends ./layout
//Trick needed to pass 'env' to ./layout
block vars
- var layoutEnv = env
block title
title HabitRPG | Terms