-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
serve through npm, dev and gh-pages; closes #106
- Loading branch information
1 parent
d4653f8
commit e9f6116
Showing
5 changed files
with
129 additions
and
32 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
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,21 +1,33 @@ | ||
#[burnchart v3](http://radekstepan.com/burnchart) | ||
#[burnchart](http://radekstepan.com/burnchart) | ||
|
||
A [React](http://facebook.github.io/react/) app utilizing a [Flux](http://facebook.github.io/flux/) architecture. | ||
##Quickstart | ||
|
||
- EventEmitter listeners can use RegExp paths thus allowing the use of namespaces | ||
- routing resets the whole UI between page changes and so Components are easier to reason about (`componentDidMount`) | ||
```bash | ||
$ npm install burnchart -g | ||
$ burnchart --port 8080 | ||
# burnchart/3.0.0 started on port 8080 | ||
``` | ||
|
||
##Quickstart | ||
##Development | ||
|
||
To run your local version of the app, install all the NPM dependencies, watch the source files in one window, and start the static file server in the other in `--dev` mode. | ||
|
||
```bash | ||
$ nvm use | ||
$ npm install | ||
$ make watch | ||
$ npm start | ||
# Server started on port 8080 | ||
$ make start --dev | ||
# burnchart/3.0.0 (dev) started on port 8080 | ||
``` | ||
|
||
##Changelog | ||
###GitHub Pages | ||
|
||
To serve the app from GitHub Pages that are in sync with master branch, add these two lines to `.git/config`, in the `[remote "origin"]` section: | ||
|
||
###v3.0.0 | ||
- switch to React & Flux architecture | ||
``` | ||
[remote "origin"] | ||
fetch = +refs/heads/*:refs/remotes/origin/* | ||
url = git@github.com:user/repo.git | ||
push = +refs/heads/master:refs/heads/gh-pages | ||
push = +refs/heads/master:refs/heads/master | ||
``` |
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,64 @@ | ||
#!/usr/bin/env node | ||
var Args = require('argparse').ArgumentParser, | ||
clrs = require('colors/safe'), | ||
stat = require('node-static'), | ||
path = require('path'), | ||
http = require('http'), | ||
exec = require('child_process').exec, | ||
pakg = require('../package.json'), | ||
fs = require('fs'); | ||
|
||
var parser = new Args({ | ||
version: pakg.version | ||
}); | ||
|
||
parser.addArgument( | ||
[ '-p', '--port' ], | ||
{ | ||
'help': 'Specify port number to start app on', | ||
'defaultValue': 8080, | ||
'type': 'int' | ||
} | ||
); | ||
parser.addArgument( | ||
[ '-d', '--dev' ], | ||
{ | ||
'help': 'Development mode, unminified builds are served', | ||
'nargs': 0 | ||
} | ||
); | ||
|
||
var args = parser.parseArgs(); | ||
|
||
var opts = { | ||
'serverInfo': 'burnchart/' + pakg.version | ||
}; | ||
|
||
var dir = path.resolve(__dirname, '../'); | ||
|
||
var pub = new stat.Server(dir, opts); | ||
|
||
// Be ready to serve unminified builds. | ||
var index = fs.readFileSync(dir + '/index.html', 'utf8'); | ||
index = index.replace(/bundle\.min/gm, 'bundle'); | ||
|
||
var server = http.createServer(function(req, res) { | ||
req.addListener('end', function() { | ||
// Serve a custom index file in dev mode. | ||
if (args.dev && req.url == '/') { | ||
res.writeHead(200, { | ||
'Content-Length': index.length, | ||
'Content-Type': 'text/html' | ||
}); | ||
res.end(index); | ||
} else { | ||
pub.serve(req, res); | ||
} | ||
}).resume(); | ||
}).listen(args.port); | ||
|
||
server.on('listening', function() { | ||
var addr = server.address(); | ||
var dev = args.dev ? ' (' + clrs.bold('dev') + ')' : ''; | ||
console.log('burnchart/' + pakg.version + dev + ' started on port ' + addr.port); | ||
}); |
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,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | ||
<link href="public/css/bundle.min.css" media="all" rel="stylesheet" type="text/css" /> | ||
</head> | ||
<body> | ||
<div id="app" /> | ||
<script type="text/javascript" src="public/js/bundle.min.js"></script> | ||
</body> | ||
</html> |
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