Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into relative-require
Conflicts: bones.js test/assets.test.js
- Loading branch information
Showing
69 changed files
with
676 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
## Bones 2.x.x | ||
|
||
- Upgraded to backbone.js 0.5.1. Most important changes affecting Bones applications: | ||
- `Backbone.Controller` is now `Backbone.Router` | ||
- `Backbone.sync(model, method, success, error)` changed to `Backbone.sync(model, method, options)` | ||
- Removed hashbang #! support. | ||
- Removed 'attach' mechanism, use *.server.bones style overrides instead #18 | ||
|
||
## Bones 1.3.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// ---- start __FILE__ ---- | ||
|
||
Bones.initialize('router', function(models, views, routers) { | ||
var router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if (router && !router.title) router.title = '__NAME__'; | ||
return router; | ||
}); | ||
|
||
// ---- end __FILE__ ---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#header { | ||
height: 30px; | ||
background: #666; | ||
} | ||
|
||
#header ul { | ||
width: 800px; | ||
margin: 0px auto; | ||
} | ||
#header ul li { | ||
list-style: none; | ||
float: left; | ||
padding-right: 20px; | ||
} | ||
#header ul li a { | ||
color: #eee; | ||
font-size: 16px; | ||
line-height: 30px; | ||
} | ||
|
||
#page { | ||
width: 800px; | ||
margin: 0px auto; | ||
} | ||
|
||
pre { | ||
border: 1px solid #666; | ||
background: #ffb; | ||
color: #666; | ||
padding: 5px; | ||
overflow: auto; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
#!/usr/bin/env node | ||
require('bones').load(__dirname); | ||
|
||
var bones = require('bones') | ||
|
||
// Bones load views/models/etc.. in alphabetical order. To explicity load | ||
// certain ones early simply require them here. | ||
require('./views/Main'); | ||
|
||
bones.load(__dirname); | ||
|
||
if (!module.parent) { | ||
require('bones').start(); | ||
bones.start(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
model = Backbone.Model.extend({ | ||
url: function() { | ||
return '/api/Project/' + encodeURIComponent(this.get('id')); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
var fs = require('fs'), | ||
path = require('path'); | ||
|
||
/** | ||
* The only method we need to override for on the server is `sync` which is | ||
* called to load the resource. By default Backbone models will attempt to | ||
* retrieve their state from a URI returned from their 'URL' method. Clearly | ||
* that won't work on the server, as we're trying to power that very same | ||
* URI. Here we do the hard work! | ||
*/ | ||
models.Project.prototype.sync = function(method, model, options) { | ||
// Project data can only be read, so return an error it the client is | ||
// trying to do anything else. | ||
if (method != 'read') return options.error('Unsupported method'); | ||
|
||
var projectDir = path.dirname(require.resolve('bones')) + '/node_modules/' + model.id, | ||
resp = {id: model.id}; | ||
|
||
var fetchPackage = function(callback) { | ||
fs.readFile(projectDir +'/package.json', 'utf8', function(err, data) { | ||
if (err) return callback('Could not retrieve project information.'); | ||
data = JSON.parse(data); | ||
resp = _.extend(resp, data); | ||
callback(); | ||
}); | ||
}; | ||
|
||
var fetchReadme = function(callback) { | ||
// Setup the regex we'll use for detecting README files. | ||
var re = /^readme(|\.\w*)$/i; | ||
|
||
// Scan the project directory, and send a readme back to the client. | ||
fs.readdir(projectDir, function(err, files) { | ||
if (err) return callback('Project not found.'); | ||
|
||
for (var i = 0; i < files.length; i++) { | ||
var match = re.exec(files[i]); | ||
if (match) { | ||
fs.readFile(projectDir +'/'+ match.input, 'utf8', function(err, data) { | ||
if (err) return callback('Could not retrieve project information.'); | ||
// 80 chars folks... | ||
data = wrap(data); | ||
resp.readme = data; | ||
callback(); | ||
}); | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
|
||
fetchPackage(function(err) { | ||
if (err) return options.error(err); | ||
fetchReadme(function(err) { | ||
if (err) return options.error(err); | ||
options.success(resp); | ||
}); | ||
}); | ||
}; | ||
|
||
var wrap = function(str) { | ||
var lines = []; | ||
_(str.split(/\n/)).each(function(v) { | ||
if (v.length > 80) { | ||
var parts = v.match(/.{80}|.+$/g); | ||
lines.push(parts.join('\n')); | ||
} else { | ||
lines.push(v); | ||
} | ||
}); | ||
|
||
return lines.join('\n'); | ||
}; |
Oops, something went wrong.