Skip to content

Commit

Permalink
Merge branch 'auth'
Browse files Browse the repository at this point in the history
  • Loading branch information
mjallday committed Apr 9, 2013
2 parents ed8de12 + 0749ac6 commit 4392028
Show file tree
Hide file tree
Showing 37 changed files with 9,244 additions and 279 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pids
logs
results
build/*
dist/*

npm-debug.log
node_modules
Expand All @@ -19,4 +20,4 @@ test/runner.html

# emacs and other IDEs
*~
*.iml
*.iml
6 changes: 5 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
"eqnull": true,
"browser": true,
"jquery": true,
"camelcase": false,
"globals": {
"test": true,
"module": true,
"equal": true,
"notEqual": true,
"ok": true,
"sinon": true,
"require": true,
"Ember": true,
"Balanced": true
"Balanced": true,
"DS": true
}
}
145 changes: 140 additions & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,21 @@ module.exports = function (grunt) {
production.
*/
neuter: {
options: {
includeSourceURL: true
dev: {
options: {
includeSourceURL: true
},
src: ['app/app.js'],
dest: 'build/application.js'
},
prod: {
src: ['app/dashboard.js'],
dest: 'build/dashboard.js'
},
'build/application.js': 'app/app.js'
lib: {
src: ['app/lib.js'],
dest: 'build/lib.js'
}
},

/*
Expand Down Expand Up @@ -137,18 +148,124 @@ module.exports = function (grunt) {
*/
build_test_runner_file: {
all: ['test/**/*_test.js']
},

/*
* A test server used for casperjs tests
* */
connect: {
server: {
options: {
port: 9876,
base: '.'
}
}
},

casperjs: {
options: {
// Task-specific options go here.
},
files: ['test/casperjs/**/*.js']
},

uglify: {
dashboard: {
files: {
'dist/js/dashboard.min.js': [
'build/dashboard.js'
]
}
},
lib: {
files: {
'dist/js/lib.min.js': [
'build/lib.js'
]
}
}
},

copy: {
html: {
files: [
{
src: ['prod.html'],
dest: 'dist/index.html'
}
]
},
css: {
files: [
{
cwd: 'build/css/',
expand: true,
src: ['**'],
dest: 'dist/css/'
}
]
}
},

hashres: {
options: {
fileNameFormat: '${name}-${hash}.${ext}'
},
css: {
src: ['dist/**/*.js', 'dist/**/*.css'],
dest: 'dist/index.html'
}
},

clean: {
files: {
src: ['build/', 'dist/']
}
},

s3: {
options: {
bucket: 'balanced-dashboard',
access: 'public-read',
region: 'us-west-1',
headers: {
'Cache-Control': 'public',
'Expires': 'Fri, Apr 23 2021 10:18:36 GMT',
'X-Employment': 'aXdhbnR0b21ha2VhZGlmZmVyZW5jZStobkBiYWxhbmNlZHBheW1lbnRzLmNvbQ=='
}
},
prod: {
upload: [
{
src: 'dist/js/*',
dest: 'js/'
},
{
src: 'dist/css/*',
dest: 'css/'
},
{
src: 'dist/*',
dest: ''
}
]
}
}

});

// grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-neuter');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-ember-templates');

grunt.loadNpmTasks('grunt-casperjs');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-hashres');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-s3');

/*
A task to build the test runner html file that get place in
Expand All @@ -168,6 +285,17 @@ module.exports = function (grunt) {
grunt.file.write('test/runner.html', grunt.template.process(tmpl, renderingContext));
});

grunt.registerMultiTask('clean', 'Deletes files', function () {
this.files.forEach(function (file) {
file.orig.src.forEach(function (f) {
if (grunt.file.exists(f)) {
grunt.file.delete(f);
}
});
});
});


/*
A task to run the application's unit tests via the command line.
It will
Expand All @@ -178,10 +306,17 @@ module.exports = function (grunt) {
- headlessy load this page and print the test runner results
*/
grunt.registerTask('test', ['ember_templates', 'neuter', 'jshint', 'build_test_runner_file', 'qunit']);
grunt.registerTask('itest', ['connect:server', 'casperjs']);

/*
Default task. Compiles templates, neuters application code, and begins
watching for changes.
*/
grunt.registerTask('default', ['ember_templates', 'neuter', 'less', 'watch']);

/*
Builds for production. Concatenates files together, minifies and then uploads to s3
*/
grunt.registerTask('build', ['clean', 'ember_templates', 'neuter', 'less', 'uglify', 'copy', 'hashres']);
grunt.registerTask('deploy', ['build', 's3']);
};
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ You will need node installed as a development dependency. See
3. Build - `grunt`
4. To view in a browser `open index.html`
5. To run unit tests `grunt test`
6. To run browser tests `grunt itest`

### Building and Deploying

1. To build everything `grunt build`
2. To deploy `grunt deploy`

**Note**: You must have the appropriate `AWS_ACCESS_KEY_ID` and
`AWS_SECRET_ACCESS_KEY` environment variables set

### Contributing

Expand Down
69 changes: 3 additions & 66 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,70 +14,7 @@
* These are the dependencies for an Ember application
* and they have to be loaded before any application code.
*/
require('static/lib/jquery-1.9.1');
require('app/lib');

/*
* Since we're precompiling our templates, we only need the
* handlebars-runtime microlib instead of the
* entire handlebars library and its string parsing functions.
*/
require('static/lib/handlebars.runtime-1.0.0-rc.3');

/* This is Ember. I think you'll like it */
require('static/lib/ember-1.0.0-rc.1');

/*
this file is generated as part of the build process.
If you haven't run that yet, you won't see it.
It is excluded from git commits since it's a
generated file.
*/
require('build/compiled/templates');

/*
Creates a new instance of an Ember application and
specifies what HTML element inside index.html Ember
should manage for you.
*/
window.Balanced = Ember.Application.create({
rootElement: window.TESTING ? '#qunit-fixture' : '#balanced-app'
});

if (window.TESTING) {
window.Balanced.deferReadiness();
}

/*
* Model layer.
* Ember.Object itself provides most of what
* model layers elsewhere provide. Since TodoMVC
* doesn't communicate with a server, plain
* Ember.Objects will do.
*/
require('app/models/marketplaces');

/*
* Views layer.
* You'll notice that there are only a few views.
* Ember accomplishes a lot in its templates and
* Views are only necessary if you have view-specific
* programming to do.
*/

/*
* Controller layer.
* Controllers wrap objects and provide a place
* to implement properties for display
* whose value is computed from the content of the
* controllers wrapped objects.
*/
require('app/controllers/marketplaces_controller');

/*
* States (i.e. Routes)
* Handles serialization of the application's current state
* which results in view hierarchy updates. Responds to
* actions.
*/
require('app/routes/router');
/* This is us! */
require('app/dashboard');
7 changes: 7 additions & 0 deletions app/controllers/_base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Balanced.ObjectController = Ember.ObjectController.extend({

});

Balanced.ArrayController = Ember.ArrayController.extend({

});
31 changes: 31 additions & 0 deletions app/controllers/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Balanced.LoginCreateController = Balanced.ObjectController.extend({
model: function () {
return Balanced.Login.find('current');
},
login: function (data) {
var login = Balanced.Login.createRecord(data);
// this appears to force the op to be flushed to the API. probably not
// the way to do this but done for now.
login.transaction.commit();
login.addObserver('isLoaded', this.refresh);
},
logout: function (data) {
Ember.set('Balanced.currentLogin', null);
},
refresh: function (login, event) {
if (!login) {
return;
}
// isLoaded seems to be set to true even when the object hasn't loaded
// the data (e.g. uri is null). checking for password is a hack around
// this.
if (login.get('isLoaded') && !login.get('password')) {
// no url indicates failed login attempt, it's probably better to
// have a failure handler but i haven't figured this out yet.
if (!login.get('uri')) {
login = null;
}
Ember.set('Balanced.currentLogin', login);
}
}
});
8 changes: 8 additions & 0 deletions app/controllers/marketplaces.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Balanced.MarketplacesIndexController = Balanced.ArrayController.extend({

});


Balanced.ShowController = Balanced.ObjectController.extend({

});
10 changes: 0 additions & 10 deletions app/controllers/marketplaces_controller.js

This file was deleted.

0 comments on commit 4392028

Please sign in to comment.