ukrainian and flatiron version of the app

This commit is contained in:
Radek 2012-12-08 19:54:43 +00:00
parent 0d38cd9bbc
commit fbda3311c5
8 changed files with 98 additions and 99 deletions

View File

@ -49,13 +49,17 @@ If you have days when you do not work on a project, edit the `config.yml` file w
weekend: [ 6, 7 ]
```
### Base URL to app
If the app does not live in the root path of your server, edit the `base_url` property in the config file.
## Use:
```bash
$ npm start
$ node start.js
```
Then visit [http://127.0.0.1:3000/](http://127.0.0.1:3000/).
Then visit [http://127.0.0.1:3000/](http://127.0.0.1:3000/) or whichever port was configured in `process.env.PORT`.
The **orange line** - this represents you closing the Issues as you go through them. When you hover over it you will see, for each day, what the closed Issues were and how many points are left.
@ -63,44 +67,4 @@ The **blue line** - this represents the dropping size of the outstanding Issues
There is nothing to save in a database so each refresh of the page fetches all of the latest information from GitHub.
Enjoy!
## Redhat OpenShift:
Create an account at [http://openshift.redhat.com](http://openshift.redhat.com) specifying a Node.js 0.6 "Web Cartridge" specifying the url for the app.
Install the OpenShift [client tools](https://openshift.redhat.com/app/getting_started).
Add your public key from `~/.ssh/id_rsa.pub` to your account. You can use xclip to copy the key to the clipboard:
```bash
$ xclip -sel clip < ~/.ssh/id_rsa.pub
```
Add the remote repository, like:
```bash
$ git remote add openshift ssh://[username_hash]@burndown-intermine.rhcloud.com/~/git/burndown.git/
```
Push your changes:
```bash
$ git push -u openshift master
```
### Debugging
In case of trouble, use the OpenShift client tools to debug:
```bash
$ /var/lib/gems/1.8/bin/rhc domain status
```
To determine the status of the app, run:
```bash
$ /var/lib/gems/1.8/bin/rhc-app status -a burndown
```
You can also SFTP into your instance on port `22` [sftp://burndown-intermine.rhcloud.com](sftp://burndown-intermine.rhcloud.com) or SSH to it.
Enjoy!

View File

@ -1,8 +1,9 @@
express = require 'express'
eco = require 'eco'
https = require 'https'
fs = require "fs"
yaml = require "js-yaml"
flatiron = require 'flatiron'
connect = require 'connect'
https = require 'https'
fs = require "fs"
yaml = require "js-yaml"
eco = require 'eco'
# Helper object for GitHub Issues.
Issues =
@ -46,38 +47,33 @@ Issues =
issue
# Express.
app = express()
# Config filters.
app = flatiron.app
app.use flatiron.plugins.http,
'before': [
connect.favicon()
connect.static __dirname + '/public'
]
app.configure ->
app.use express.logger()
app.use express.bodyParser()
app.set 'view engine', 'eco'
app.set 'views', './templates'
# Register a custom .eco compiler.
app.engine 'eco', (path, options, callback) ->
fs.readFile "./#{path}", "utf8", (err, str) ->
callback eco.render str, options
app.use express.static('./public')
app.configure 'development', ->
app.use express.errorHandler
dumpExceptions: true
showStack: true
app.configure 'production', ->
app.use express.errorHandler()
# Redirect to chart from index.
app.get '/', (req, res) -> res.redirect '/burndown'
# Eco templating.
app.use
name: "eco-templating"
attach: (options) ->
app.eco = (path, data, cb) ->
fs.readFile "./templates/#{path}.eco", "utf8", (err, template) ->
if err then cb err, null
else
try
cb null, eco.render template, data
catch e
cb e, null
# Show burndown chart.
app.get '/burndown', (req, res) ->
getBurndown = ->
console.log 'Get burndown chart'
resources = 3 ; store = { 'issues': [], 'milestones': [] }
done = (data, type) ->
done = (data, type) =>
# One less to do.
resources--
@ -164,17 +160,26 @@ app.get '/burndown', (req, res) ->
days[day].ideal = ideal
# Finally send to client.
res.render 'burndown',
app.eco 'burndown',
'days': days
'project': Issues.config.project_name
, (html) -> res.send html, 'Content-Type': 'text/html', 200
'base_url': Issues.config.base_url
, (err, html) =>
throw err if err
@res.writeHead 200, "content-type": "text/html"
@res.write html
@res.end()
else
# No current milestone.
res.render 'empty',
app.eco 'empty',
'project': Issues.config.project_name
, (html) -> res.send html, 'Content-Type': 'text/html', 200
'base_url': Issues.config.base_url
, (err, html) =>
throw err if err
@res.writeHead 200, "content-type": "text/html"
@res.write html
@res.end()
# Get Milestones, Opened and Closed Tickets.
Issues.getMilestones done
@ -182,20 +187,38 @@ app.get '/burndown', (req, res) ->
Issues.getClosedIssues done
# Show open issues.
app.get '/issues', (req, res) ->
Issues.getOpenIssues (issues) ->
getIssues = ->
console.log 'Get open issues'
Issues.getOpenIssues (issues) =>
# Replace the dates in issues with nice dates.
issues = ( Issues.format(issue) for issue in issues )
res.render 'issues',
app.eco 'issues',
'issues': issues
'project': Issues.config.project_name
, (html) -> res.send html, 'Content-Type': 'text/html', 200
'base_url': Issues.config.base_url
, (err, html) =>
throw err if err
@res.writeHead 200, "content-type": "text/html"
@res.write html
@res.end()
# Routes
app.router.path '/', ->
@get getBurndown
app.router.path '/burndown', ->
@get getBurndown
app.router.path '/issues', ->
@get getIssues
# Fetch config and start server.
fs.readFile "config.yml", "utf8", (err, data) ->
Issues.config = yaml.load data
app.listen process.env.OPENSHIFT_INTERNAL_PORT or 3000, process.env.OPENSHIFT_INTERNAL_IP, ->
console.log "Express server listening to port #{process.env.OPENSHIFT_INTERNAL_PORT or 3000}"
app.start process.env.PORT, (err) ->
throw err if err
console.log "Listening on port #{app.server.address().port}"

View File

@ -1,4 +1,5 @@
github_user: 'intermine'
github_project: 'intermine'
project_name: 'Core InterMine Project'
weekend: [ 6, 7 ]
weekend: [ 6, 7 ]
base_url: 'github-burndown-chart'

View File

@ -1,14 +1,16 @@
{
"name": "github-burndown-chart",
"version": "0.1.4",
"version": "0.2.0",
"private": true,
"dependencies": {
"coffee-script": "1.3.3",
"express": ">= 3.0",
"eco": "latest",
"js-yaml": "latest"
"flatiron": "0.2.5",
"union": "0.3.4",
"connect": "2.4.3",
"eco": "1.1.0-rc-3",
"js-yaml": "1.0.3"
},
"scripts": {
"start": "./node_modules/.bin/coffee app.coffee"
"start": "start.js"
}
}

3
start.js Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env node
require('coffee-script');
require('./app.coffee');

View File

@ -6,6 +6,8 @@
<title>Burndown App</title>
<base href="<%= @base_url %>"/>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/rickshaw.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
@ -35,12 +37,12 @@
<ul>
<li class="active">
<figure>
<a href="/burndown"><i class="icon-signal"></i> Burndown Chart</a>
<a href="burndown"><i class="icon-signal"></i> Burndown Chart</a>
</figure>
</li>
<li>
<figure>
<a href="/issues"><i class="icon-tasks"></i> Issues</a>
<a href="issues"><i class="icon-tasks"></i> Issues</a>
</figure>
</li>
</ul>

View File

@ -6,6 +6,8 @@
<title>Burndown App</title>
<base href="<%= @base_url %>"/>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
@ -30,12 +32,12 @@
<ul>
<li class="active">
<figure>
<a href="/burndown"><i class="icon-signal"></i> Burndown Chart</a>
<a href="burndown"><i class="icon-signal"></i> Burndown Chart</a>
</figure>
</li>
<li>
<figure>
<a href="/issues"><i class="icon-tasks"></i> Issues</a>
<a href="issues"><i class="icon-tasks"></i> Issues</a>
</figure>
</li>
</ul>

View File

@ -6,6 +6,8 @@
<title>Burndown App</title>
<base href="<%= @base_url %>"/>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
@ -30,12 +32,12 @@
<ul>
<li>
<figure>
<a href="/burndown"><i class="icon-signal"></i> Burndown Chart</a>
<a href="burndown"><i class="icon-signal"></i> Burndown Chart</a>
</figure>
</li>
<li class="active">
<figure>
<a href="/issues"><i class="icon-tasks"></i> Issues</a>
<a href="issues"><i class="icon-tasks"></i> Issues</a>
</figure>
</li>
</ul>