Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kenwheeler committed Oct 9, 2013
0 parents commit 72a62f2
Show file tree
Hide file tree
Showing 30 changed files with 900 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "bower_components"
}
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
bower_components
public/css
public/js
22 changes: 22 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"node": true,
"es5": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"white": true
}
251 changes: 251 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
module.exports = function(grunt) {
grunt.option('stack', true);

var port = process.env.PORT || 8000,
hostname = 'localhost',
templates = {},
paths = {
'public': 'public',
output: {
js: 'public/js',
css: 'public/css'
},
js: 'js',
css: 'css',
templates: 'js/templates',
views: 'js/views',
models: 'js/models',
collections: 'js/collections'
};

// Register required tasks
grunt.loadTasks('tasks');
grunt.loadNpmTasks('thorax-inspector');
require('matchdep').filterDev('grunt-*').forEach(function(task) {
if (task !== 'grunt-cli') {
grunt.loadNpmTasks(task);
}
});

grunt.config.init({
pkg: grunt.file.readJSON('package.json'),
paths: paths,
clean: {
output: [
paths.output.js,
paths.output.css
]
},
copy: {
requirejs: {
files: [
{
src: 'bower_components/requirejs/require.js',
dest: 'public/js/require.js'
}
]
},
styles: {
files: [
{
expand: true,
cwd: paths.css,
src: '*.css',
dest: paths.output.css
}
]
},
bootstrap: {
files: [
{
src: ['bower_components/bootstrap/dist/js/bootstrap.js'],
dest: 'public/js/bootstrap.js'
},
{
src: ['bower_components/bootstrap/dist/css/bootstrap.css'],
dest: 'public/css/bootstrap.css'
},
{
expand: true,
flatten: true,
src: ['bower_components/bootstrap/fonts/*'],
dest: 'public/fonts'
}
]
}
},
connect: {
development: {
options: {
hostname: hostname,
base: paths.public,
port: port
}
},
production: {
options: {
hostname: hostname,
base: paths.public,
port: port,
keepalive: true
}
}
},
thorax: {
inspector: {
editor: 'subl',
background: true,
paths: {
views: paths.views,
models: paths.models,
collections: paths.collections,
templates: paths.templates
}
}
},
requirejs: {
development: getRequireJSOptions('development'),
production: getRequireJSOptions('production')
},
handlebars: {
templates: {
options: {
namespace: false,
amd: true
}
}
},
watch: {
handlebars: {
files: [paths.templates + '/**/*.hbs'],
tasks: ['templates']
},
scripts: {
files: [
paths.js + '/**/*.js'
],
tasks: ['scripts:development']
},
styles: {
files: [paths.css + '/**/*'],
tasks: ['copy:styles']
}
}
});

function getRequireJSOptions(env) {
var options = {
appDir: paths.js,
baseUrl: './',
dir: paths.output.js,
modules: [
{
name: 'main'
}
],
paths: {
'jquery': '../bower_components/jquery/jquery',
'underscore': '../bower_components/underscore/underscore',
'handlebars': '../bower_components/handlebars/handlebars.runtime',
'backbone': '../bower_components/backbone/backbone',
'thorax': '../bower_components/thorax/thorax',
'bootstrap': '../bower_components/bootstrap/js/bootstrap'
},
shim: {
'handlebars': {
exports: 'Handlebars'
},
'backbone': {
exports: 'Backbone',
deps: ['jquery', 'underscore']
},
'underscore': {
exports: '_'
},
'thorax': {
exports: 'Thorax',
deps: ['handlebars', 'backbone']
},
'bootstrap': {
deps: ['jquery']
}
}
};
if (env === 'production') {
/*
TODO
options.keepBuildDir = true;
options.optimize = 'uglify';
*/
}
if (env === 'development') {
options.keepBuildDir = true;
options.optimize = 'none';
}
return {
options: options
};
}

grunt.registerTask('open-browser', function () {
var open = require('open');
open('http://' + hostname + ':' + port);
});

grunt.registerTask('scripts:development', [
'copy:requirejs',
'requirejs:development'
]);

grunt.registerTask('scripts:production', [
'copy:requirejs',
'requirejs:production'
]);

grunt.registerTask('update-templates-list', function() {
// Set up the templates object for Handlebars
grunt.file.glob.sync(paths.templates + '/**/*.{handlebars,hbs}').forEach(function (file) {
var target = paths.output.js + '/templates' + file.substr(paths.templates.length).replace(/\.(?:handlebars|hbs)$/, '.js');
templates[target] = file;
});
grunt.config.set('handlebars.templates.files', templates);
});

grunt.registerTask('create-output-directories', function() {
grunt.file.mkdir('public/js');
grunt.file.mkdir('public/css');
});

grunt.registerTask('templates', [
'update-templates-list',
'handlebars:templates'
]);

grunt.registerTask('styles', [
'copy:styles',
'copy:bootstrap'
]);

grunt.registerTask('default', [
'ensure-installed',
'clean:output',
'create-output-directories',
'styles',
'templates',
'scripts:development',
'thorax:inspector',
'connect:development',
'open-browser',
'watch'
]);

grunt.registerTask('production', [
'clean:output',
'create-output-directories',
'styles',
'templates',
'scripts:production',
'open-browser',
'connect:production'
]);
};
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Thorax & Parse Todo Seed
========================

### *Example of persistent ToDos with Facebook authentication using Thorax and Parse*



Configuration
-------------



- Create a [Facebook Application]

- Register & Create a new app at Parse.com

- Edit your /js/routers/todo-list.js and replace the placeholders with your
Parse initialize script & Facebook App ID

Parse.initialize("REPLACE ME", "REPLACE ME");

window.fbAsyncInit = function() {

Parse.FacebookUtils.init({

appId : 'REPLACE ME',

cookie : true,

xfbml : true

});

};

- Run npm start

- ?

- PROFIT
9 changes: 9 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "-todo-parse",
"version": "0.0.0",
"dependencies": {
"requirejs": "~2.1",
"thorax": "~2.0",
"bootstrap": "~3.0"
}
}
1 change: 1 addition & 0 deletions css/base.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
body { padding-top: 50px; }
5 changes: 5 additions & 0 deletions css/todo-list.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.done {
text-decoration: line-through;
}
input[type="checkbox"] { margin-right: 10px; }
button { width: 100%; }
5 changes: 5 additions & 0 deletions js/collection-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
define(['thorax'], function (Thorax) {
return Thorax.CollectionView.extend({

});
});
5 changes: 5 additions & 0 deletions js/collection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
define(['thorax'], function (Thorax) {
return Thorax.Collection.extend({

});
});
Empty file added js/collections/todo-collection
Empty file.
5 changes: 5 additions & 0 deletions js/layout-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
define(['thorax'], function (Thorax) {
return Thorax.LayoutView.extend({

});
});
Loading

0 comments on commit 72a62f2

Please sign in to comment.