Skip to content

Commit

Permalink
Merge remote branch 'origin/improvements'
Browse files Browse the repository at this point in the history
  • Loading branch information
tosh committed Apr 21, 2011
2 parents cba4a95 + 717ef4a commit 7751957
Show file tree
Hide file tree
Showing 22 changed files with 10,484 additions and 70 deletions.
35 changes: 16 additions & 19 deletions lib/brunch.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,11 @@
process.exit(0);
}
fileUtil.mkdirsSync(exports.options.brunchPath, 0755);
return helpers.recursiveCopy(path.join(projectTemplatePath, 'src/'), path.join(exports.options.brunchPath, 'src'), function() {
fileUtil.mkdirsSync(exports.options.buildPath, 0755);
return helpers.recursiveCopy(projectTemplatePath, exports.options.brunchPath, function() {
return helpers.recursiveCopy(path.join(projectTemplatePath, 'build/'), exports.options.buildPath, function() {
return helpers.copyFile(path.join(projectTemplatePath, 'config.yaml'), path.join(exports.options.brunchPath, 'config.yaml'), function() {
if (exports.options.projectTemplate === "express") {
helpers.recursiveCopy(path.join(projectTemplatePath, 'server/'), path.join(exports.options.brunchPath, 'server'), function() {
return callback();
});
} else {
callback();
}
return helpers.log("brunch: " + (colors.green('created', true)) + " brunch directory layout\n");
});
callback();
return helpers.log("brunch: " + (colors.green('created', true)) + " brunch directory layout\n");
});
});
});
Expand Down Expand Up @@ -119,15 +112,19 @@
};
exports.compilePackage = function() {
return package.compile(function(err, source) {
if (err) {
console.log(colors.lred(err, true));
if (err != null) {
helpers.log("brunch: " + (colors.lred('There was a problem during compilation.', true)) + "\n");
return helpers.log("" + (colors.lgray(err, true)) + "\n");
} else {
return fs.writeFile(path.join(exports.options.buildPath, 'web/js/app.js'), source, function(err) {
if (err != null) {
helpers.log("brunch: " + (colors.lred('Couldn\'t write compiled file.', true)) + "\n");
return helpers.log("" + (colors.lgray(err, true)) + "\n");
} else {
return helpers.log("stitch: " + (colors.green('compiled', true)) + " application\n");
}
});
}
return fs.writeFile(path.join(exports.options.buildPath, 'web/js/app.js'), source, function(err) {
if (err) {
console.log(colors.lred(err, true));
}
return helpers.log("stitch: " + (colors.green('compiled', true)) + " application\n");
});
});
};
exports.spawnStylus = function() {
Expand Down
33 changes: 16 additions & 17 deletions src/brunch.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,12 @@ exports.new = (options, callback) ->
process.exit 0

fileUtil.mkdirsSync exports.options.brunchPath, 0755
helpers.recursiveCopy path.join(projectTemplatePath, 'src/'), path.join(exports.options.brunchPath, 'src'), ->
helpers.recursiveCopy path.join(projectTemplatePath, 'build/'), exports.options.buildPath, ->
helpers.copyFile path.join(projectTemplatePath, 'config.yaml'), path.join(exports.options.brunchPath, 'config.yaml'), ->

if(exports.options.projectTemplate is "express")
helpers.recursiveCopy path.join(projectTemplatePath, 'server/'), path.join(exports.options.brunchPath, 'server'), ->
callback()
else
callback()
fileUtil.mkdirsSync exports.options.buildPath, 0755

# TODO inform user which template was used and give futher instructions how to use brunch
helpers.log "brunch: #{colors.green('created', true)} brunch directory layout\n"
helpers.recursiveCopy projectTemplatePath, exports.options.brunchPath, ->
helpers.recursiveCopy path.join(projectTemplatePath, 'build/'), exports.options.buildPath, ->
callback()
helpers.log "brunch: #{colors.green('created', true)} brunch directory layout\n"

# file watcher
exports.watch = (options) ->
Expand Down Expand Up @@ -141,12 +135,17 @@ exports.dispatch = (file, options) ->
# each file will be saved into a module
exports.compilePackage = ->
package.compile( (err, source) ->
console.log colors.lred(err, true) if err

fs.writeFile(path.join(exports.options.buildPath, 'web/js/app.js'), source, (err) ->
console.log colors.lred(err, true) if err
helpers.log "stitch: #{colors.green('compiled', true)} application\n"
)
if err?
helpers.log "brunch: #{colors.lred('There was a problem during compilation.', true)}\n"
helpers.log "#{colors.lgray(err, true)}\n"
else
fs.writeFile(path.join(exports.options.buildPath, 'web/js/app.js'), source, (err) ->
if err?
helpers.log "brunch: #{colors.lred('Couldn\'t write compiled file.', true)}\n"
helpers.log "#{colors.lgray(err, true)}\n"
else
helpers.log "stitch: #{colors.green('compiled', true)} application\n"
)
)

# spawn a new stylus process which compiles main.styl
Expand Down
64 changes: 33 additions & 31 deletions template/base/src/vendor/backbone-master.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

// Save a reference to the global object.
var root = this;

// Save the previous value of the `Backbone` variable.
var previousBackbone = root.Backbone;

// The top-level namespace. All public Backbone classes and modules will
// be attached to this. Exported for both CommonJS and the browser.
var Backbone;
Expand All @@ -28,19 +28,19 @@
Backbone.VERSION = '0.3.3';

// Require Underscore, if we're on the server, and it's not already present.
var _ = root._;
var _ = root._ || root.$;
if (!_ && (typeof require !== 'undefined')) _ = require('underscore')._;

// For Backbone's purposes, either jQuery or Zepto owns the `$` variable.
var $ = root.jQuery || root.Zepto;
// For Backbone's purposes, jQuery, Zepto, or Ender owns the `$` variable.
var $ = root.jQuery || root.Zepto || root.$;

// Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
// to its previous owner. Returns a reference to this Backbone object.
Backbone.noConflict = function() {
root.Backbone = previousBackbone;
return this;
};

// Turn on `emulateHTTP` to use support legacy HTTP servers. Setting this option will
// fake `"PUT"` and `"DELETE"` requests via the `_method` parameter and set a
// `X-Http-Method-Override` header.
Expand Down Expand Up @@ -90,7 +90,7 @@
if (!list) return this;
for (var i = 0, l = list.length; i < l; i++) {
if (callback === list[i]) {
list.splice(i, 1);
list[i] = null;
break;
}
}
Expand All @@ -102,19 +102,21 @@
// Trigger an event, firing all bound callbacks. Callbacks are passed the
// same arguments as `trigger` is, apart from the event name.
// Listening for `"all"` passes the true event name as the first argument.
trigger : function(ev) {
var list, calls, i, l;
trigger : function(eventName) {
var list, calls, ev, callback, args, i, l;
var both = 2;
if (!(calls = this._callbacks)) return this;
if (calls[ev]) {
list = calls[ev].slice(0);
for (i = 0, l = list.length; i < l; i++) {
list[i].apply(this, Array.prototype.slice.call(arguments, 1));
}
}
if (calls['all']) {
list = calls['all'].slice(0);
for (i = 0, l = list.length; i < l; i++) {
list[i].apply(this, arguments);
while (both--) {
ev = both ? eventName : 'all';
if (list = calls[ev]) {
for (i = 0, l = list.length; i < l; i++) {
if (!(callback = list[i])) {
list.splice(i, 1); i--; l--;
} else {
args = both ? Array.prototype.slice.call(arguments, 1) : arguments;
callback.apply(this, args);
}
}
}
}
return this;
Expand Down Expand Up @@ -277,8 +279,7 @@
if (success) success(model, resp);
};
options.error = wrapError(options.error, model, options);
(this.sync || Backbone.sync).call(this, 'read', this, options);
return this;
return (this.sync || Backbone.sync).call(this, 'read', this, options);
},

// Set a hash of model attributes, and sync the model to the server.
Expand All @@ -295,8 +296,7 @@
};
options.error = wrapError(options.error, model, options);
var method = this.isNew() ? 'create' : 'update';
(this.sync || Backbone.sync).call(this, method, this, options);
return this;
return (this.sync || Backbone.sync).call(this, method, this, options);
},

// Destroy this model on the server. Upon success, the model is removed
Expand All @@ -310,8 +310,7 @@
if (success) success(model, resp);
};
options.error = wrapError(options.error, model, options);
(this.sync || Backbone.sync).call(this, 'delete', this, options);
return this;
return (this.sync || Backbone.sync).call(this, 'delete', this, options);
},

// Default URL for the model's representation on the server -- if you're
Expand Down Expand Up @@ -520,8 +519,7 @@
if (success) success(collection, resp);
};
options.error = wrapError(options.error, collection, options);
(this.sync || Backbone.sync).call(this, 'read', this, options);
return this;
return (this.sync || Backbone.sync).call(this, 'read', this, options);
},

// Create a new instance of a model in this collection. After the model
Expand All @@ -541,7 +539,8 @@
coll.add(nextModel);
if (success) success(nextModel, resp);
};
return model.save(null, options);
model.save(null, options);
return model;
},

// **parse** converts a response into a list of models to be added to the
Expand Down Expand Up @@ -619,7 +618,7 @@
if (ev == 'destroy') {
this._remove(model, options);
}
if (ev === 'change:' + model.idAttribute) {
if (model && ev === 'change:' + model.idAttribute) {
delete this._byId[model.previous(model.idAttribute)];
this._byId[model.id] = model;
}
Expand Down Expand Up @@ -733,6 +732,9 @@
// Cached regex for cleaning hashes.
var hashStrip = /^#*/;

// Cached regex for detecting MSIE.
var isExplorer = /msie [\w.]+/;

// Has the history handling already been started?
var historyStarted = false;

Expand All @@ -753,7 +755,7 @@
start : function() {
if (historyStarted) throw new Error("Backbone.history has already been started");
var docMode = document.documentMode;
var oldIE = ($.browser.msie && (!docMode || docMode <= 7));
var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7));
if (oldIE) {
this.iframe = $('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow;
}
Expand Down Expand Up @@ -1019,7 +1021,7 @@
}

// Make the request.
$.ajax(params);
return $.ajax(params);
};

// Helpers
Expand Down
1 change: 0 additions & 1 deletion template/express/build

This file was deleted.

11 changes: 11 additions & 0 deletions template/express/build/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="web/css/main.css" type="text/css" media="screen">
<script src="web/js/app.js"></script>
<script>require('main');</script>
</head>
<body>
</body>
Empty file.
Empty file.
1 change: 0 additions & 1 deletion template/express/config.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions template/express/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dependencies:
- ConsoleDummy.js
- jquery-1.5.2.js
- underscore-1.1.5.js
- backbone-master.js
1 change: 0 additions & 1 deletion template/express/src

This file was deleted.

Empty file.
9 changes: 9 additions & 0 deletions template/express/src/app/controllers/main_controller.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class exports.MainController extends Backbone.Controller
routes :
"home": "home"

constructor: ->
super

home: ->
$('body').html app.views.home.render().el
17 changes: 17 additions & 0 deletions template/express/src/app/main.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
window.app = {}
app.controllers = {}
app.models = {}
app.collections = {}
app.views = {}

MainController = require('controllers/main_controller').MainController
HomeView = require('views/home_view').HomeView

# app bootstrapping on document ready
$(document).ready ->
app.initialize = ->
app.controllers.main = new MainController()
app.views.home = new HomeView()
Backbone.history.saveLocation("home") if Backbone.history.getFragment() is ''
app.initialize()
Backbone.history.start()
Empty file.
27 changes: 27 additions & 0 deletions template/express/src/app/styles/main.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@import "reset"

body
background #91A2C0
font bold 18px "Helvetica Neue", Arial, Helvetica, sans-serif

ul
list-style-type none

a, a:visited
color #F95A5A
text-decoration none

a:hover
color #665248

#home-view
width 600px
height 200px
margin 20px auto

#content
background #FFF
padding 20px
-webkit-border-radius 4px
-moz-border-radius 4px
border-radius 4px
47 changes: 47 additions & 0 deletions template/express/src/app/styles/reset.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// reset css from blueprint 1.0

html
margin 0
padding 0
border 0

body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, dialog, figure, footer, header, hgroup, nav, section
margin 0
padding 0
border 0
font-weight inherit
font-style inherit
font-size 100%
font-family inherit
vertical-align baseline

article, aside, dialog, figure, footer, header, hgroup, nav, section
display block

body
line-height 1.5
background white

table
border-collapse separate
border-spacing 0

caption, th, td
text-align left
font-weight normal
float none

table, th, td
vertical-align middle

blockquote:before, blockquote:after, q:before, q:after
content ''

blockquote, q
quotes "" ""

a img
border none

:focus
outline 0
Loading

0 comments on commit 7751957

Please sign in to comment.