-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 120c137
Showing
43 changed files
with
26,495 additions
and
0 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,3 @@ | ||
/.DS_Store | ||
/public/ | ||
/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 @@ | ||
web: node index.js |
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 childProcess = require('child_process'), | ||
exec = childProcess.exec, | ||
spawn = childProcess.spawn, | ||
fs = require('fs'), | ||
path = require('path'), | ||
port = process.env.PORT, | ||
execute = function(command, args, callback) { | ||
console.log(command + ' ' + args.join(' ')); | ||
var command = spawn(command, args); | ||
command.stdout.on('data', function (data) { | ||
process.stdout.write(data); | ||
}); | ||
command.stderr.on('data', function (data) { | ||
process.stderr.write(data); | ||
}); | ||
command.on('exit', callback || function(){}); | ||
}, | ||
startServer = function() { | ||
var express = require('express'), | ||
argv = require('optimist').argv, | ||
port = process.env.PORT; | ||
|
||
if (argv.watch) { | ||
var lumbar = spawn('lumbar', [ | ||
'watch', | ||
path.join(__dirname, 'lumbar.json'), | ||
path.join(__dirname, 'public') | ||
]); | ||
lumbar.stdout.on('data', function(data) { | ||
process.stdout.write(data.toString()); | ||
}); | ||
lumbar.stderr.on('data', function(data) { | ||
process.stdout.write(data.toString()); | ||
}); | ||
} | ||
|
||
var server = express.createServer(); | ||
server.use(express.logger()); | ||
server.use(express.bodyParser()); | ||
server.use(express.static(path.join(__dirname, 'public'))); | ||
|
||
function listen(foundPort) { | ||
console.log('Express server listening on port ' + foundPort); | ||
server.listen(foundPort); | ||
} | ||
|
||
if (!port) { | ||
require('portscanner').findAPortNotInUse(8000, 8025, 'localhost', function(error, foundPort) { | ||
listen(foundPort); | ||
}); | ||
} else { | ||
listen(port); | ||
} | ||
|
||
var serverPath = path.join(__dirname, 'server'); | ||
|
||
if (!path.existsSync(serverPath)) { | ||
fs.mkdirSync(serverPath); | ||
} | ||
|
||
fs.readdirSync(serverPath).forEach(function(file) { | ||
if (file.match(/\.js$/)) { | ||
//second parameter is reserved for future use, secureServer | ||
require(path.join(__dirname, 'server', file))(server, null, argv); | ||
} | ||
}); | ||
}; | ||
|
||
if (!path.existsSync(path.join(__dirname, 'node_modules'))) { | ||
execute('npm',['install'], startServer); | ||
} else { | ||
startServer(); | ||
} |
Binary file not shown.
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,3 @@ | ||
Application.Collection = Thorax.Collection.extend({ | ||
|
||
}); |
Empty 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//all templates are assumed to be in the templates directory | ||
Thorax.templatePathPrefix = 'templates/'; | ||
|
||
//create the Application object, Application.setView() will | ||
//place a view inside the {{layout}} | ||
var Application = window.Application = module.exports = new (Thorax.ViewController.extend(_.extend(module.exports, { | ||
//set a name so it will use the applications.handlebars template | ||
name: 'application' | ||
}))); | ||
|
||
//alias the special hashes for naming consitency | ||
Application.templates = Thorax.templates; | ||
Application.Views = Thorax.Views; | ||
Application.Models = Thorax.Models; | ||
Application.Collections = Thorax.Collections; | ||
Application.Routers = Thorax.Routers; | ||
|
||
//allows load:end and load:start events to propagate | ||
//to the application object | ||
Thorax.setRootObject(Application); | ||
|
||
$(function() { | ||
//Application and other templates included by the base | ||
//Application may want to use the link and url helpers | ||
//which use hasPushstate, etc. so setup history, then | ||
//render, then dispatch | ||
//initialize the lumbar-loader for backbone, which will | ||
//load modules if needed when a route is matched | ||
Application.initBackboneLoader(); | ||
Backbone.history.start({ | ||
pushState: false, | ||
root: '/', | ||
silent: true | ||
}); Application.render(); | ||
$('body').append(Application.el); | ||
//mimic when a ViewController will trigger the "ready" | ||
//event on a view, since this is the top level object | ||
//it needs to be triggered manually | ||
Application.trigger('ready'); | ||
Backbone.history.loadUrl(); | ||
}); |
Binary file not shown.
Oops, something went wrong.