2013-11-05 12:44:15 +00:00
( function ( ) {
/ * *
* Require the given path .
*
* @ param { String } path
* @ return { Object } exports
* @ api public
* /
2013-12-05 15:17:32 +00:00
var require = function ( path , parent , orig ) {
2013-11-05 12:44:15 +00:00
var resolved = require . resolve ( path ) ;
// lookup failed
2013-12-30 11:48:29 +00:00
if ( null === resolved ) {
2013-11-05 12:44:15 +00:00
orig = orig || path ;
parent = parent || 'root' ;
var err = new Error ( 'Failed to require "' + orig + '" from "' + parent + '"' ) ;
err . path = orig ;
err . parent = parent ;
err . require = true ;
throw err ;
}
var module = require . modules [ resolved ] ;
// perform real require()
// by invoking the module's
// registered function
if ( ! module . _resolving && ! module . exports ) {
var mod = { } ;
mod . exports = { } ;
mod . client = mod . component = true ;
module . _resolving = true ;
module . call ( this , mod . exports , require . relative ( resolved ) , mod ) ;
delete module . _resolving ;
module . exports = mod . exports ;
}
return module . exports ;
2013-12-30 11:48:29 +00:00
} ;
2013-11-05 12:44:15 +00:00
/ * *
* Registered modules .
* /
require . modules = { } ;
/ * *
* Registered aliases .
* /
require . aliases = { } ;
/ * *
* Resolve ` path ` .
*
* Lookup :
*
* - PATH / index . js
* - PATH . js
* - PATH
*
* @ param { String } path
* @ return { String } path or null
* @ api private
* /
require . resolve = function ( path ) {
if ( path . charAt ( 0 ) === '/' ) path = path . slice ( 1 ) ;
var paths = [
path ,
path + '.js' ,
path + '.json' ,
path + '/index.js' ,
path + '/index.json'
] ;
for ( var i = 0 ; i < paths . length ; i ++ ) {
2013-12-30 11:48:29 +00:00
path = paths [ i ] ;
2013-11-05 12:44:15 +00:00
if ( require . modules . hasOwnProperty ( path ) ) return path ;
if ( require . aliases . hasOwnProperty ( path ) ) return require . aliases [ path ] ;
}
} ;
/ * *
* Normalize ` path ` relative to the current path .
*
* @ param { String } curr
* @ param { String } path
* @ return { String }
* @ api private
* /
require . normalize = function ( curr , path ) {
var segs = [ ] ;
if ( '.' != path . charAt ( 0 ) ) return path ;
curr = curr . split ( '/' ) ;
path = path . split ( '/' ) ;
for ( var i = 0 ; i < path . length ; ++ i ) {
if ( '..' == path [ i ] ) {
curr . pop ( ) ;
2013-12-30 11:48:29 +00:00
} else if ( '.' !== path [ i ] && '' !== path [ i ] ) {
2013-11-05 12:44:15 +00:00
segs . push ( path [ i ] ) ;
}
}
return curr . concat ( segs ) . join ( '/' ) ;
} ;
/ * *
* Register module at ` path ` with callback ` definition ` .
*
* @ param { String } path
* @ param { Function } definition
* @ api private
* /
require . register = function ( path , definition ) {
require . modules [ path ] = definition ;
} ;
/ * *
* Alias a module definition .
*
* @ param { String } from
* @ param { String } to
* @ api private
* /
require . alias = function ( from , to ) {
if ( ! require . modules . hasOwnProperty ( from ) ) {
throw new Error ( 'Failed to alias "' + from + '", it does not exist' ) ;
}
require . aliases [ to ] = from ;
} ;
/ * *
* Return a require function relative to the ` parent ` path .
*
* @ param { String } parent
* @ return { Function }
* @ api private
* /
require . relative = function ( parent ) {
var p = require . normalize ( parent , '..' ) ;
/ * *
* lastIndexOf helper .
* /
function lastIndexOf ( arr , obj ) {
var i = arr . length ;
while ( i -- ) {
if ( arr [ i ] === obj ) return i ;
}
return - 1 ;
}
/ * *
* The relative require ( ) itself .
* /
2013-12-05 15:17:32 +00:00
var localRequire = function ( path ) {
2013-11-05 12:44:15 +00:00
var resolved = localRequire . resolve ( path ) ;
return require ( resolved , parent , path ) ;
2013-12-30 11:48:29 +00:00
} ;
2013-11-05 12:44:15 +00:00
/ * *
* Resolve relative to the parent .
* /
localRequire . resolve = function ( path ) {
var c = path . charAt ( 0 ) ;
if ( '/' == c ) return path . slice ( 1 ) ;
if ( '.' == c ) return require . normalize ( p , path ) ;
// resolve deps by returning
// the dep in the nearest "deps"
// directory
var segs = parent . split ( '/' ) ;
var i = lastIndexOf ( segs , 'deps' ) + 1 ;
if ( ! i ) i = 0 ;
path = segs . slice ( 0 , i + 1 ) . join ( '/' ) + '/deps/' + path ;
return path ;
} ;
/ * *
* Check if module is defined at ` path ` .
* /
localRequire . exists = function ( path ) {
return require . modules . hasOwnProperty ( localRequire . resolve ( path ) ) ;
} ;
return localRequire ;
} ;
2013-11-16 11:22:28 +00:00
// Global on server, window in browser.
var root = this ;
// Do we already have require loader?
2013-12-05 15:17:32 +00:00
root . require = ( typeof root . require !== 'undefined' ) ? root . require : require ;
2013-11-16 11:22:28 +00:00
2013-12-05 15:17:32 +00:00
// All our modules will use global require.
2013-11-05 12:44:15 +00:00
( function ( ) {
2013-11-16 11:22:28 +00:00
// app.coffee
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/app.js' , function ( exports , require , module ) {
2013-11-16 11:22:28 +00:00
var config , regex , render , repo , route ;
config = require ( './modules/config' ) ;
regex = require ( './modules/regex' ) ;
render = require ( './modules/render' ) ;
repo = require ( './modules/repo' ) ;
route = function ( ) {
var m , match , opts , path , r , u , _ref ;
if ( match = window . location . hash . match ( regex . location ) ) {
path = match [ 1 ] . slice ( 1 ) ;
render ( 'body' , 'loading' , {
path : path
} ) ;
_ref = path . split ( '/' ) , u = _ref [ 0 ] , r = _ref [ 1 ] , m = _ref [ 2 ] ;
opts = m ? {
'path' : "" + u + "/" + r ,
'milestone' : m
} : {
path : path
} ;
return async . waterfall ( [
config , function ( conf , cb ) {
return repo ( _ . extend ( opts , conf ) , cb ) ;
}
] , function ( err ) {
if ( err ) {
return render ( 'body' , 'error' , {
'text' : err . toString ( )
} ) ;
}
} ) ;
}
return render ( 'body' , 'info' ) ;
} ;
module . exports = function ( ) {
if ( 'onhashchange' in window && 'hash' in window . location ) {
window . addEventListener ( 'hashchange' , route , false ) ;
return route ( ) ;
}
return render ( 'body' , 'error' , {
'text' : 'URL fragment identifier not supported'
} ) ;
} ;
} ) ;
2013-11-05 12:44:15 +00:00
// config.coffee
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/modules/config.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
var config , defaults , queue , regex , request , validators , wait , _ ,
_ _indexOf = [ ] . indexOf || function ( item ) { for ( var i = 0 , l = this . length ; i < l ; i ++ ) { if ( i in this && this [ i ] === item ) return i ; } return - 1 ; } ;
_ = require ( './require' ) . _ ;
request = require ( './request' ) ;
regex = require ( './regex' ) ;
config = null ;
wait = false ;
queue = [ ] ;
defaults = {
'host' : 'api.github.com' ,
'protocol' : 'https'
} ;
validators = {
'host' : function ( value ) {
return _ . isString ( value ) ;
} ,
'protocol' : function ( value ) {
return _ . isString ( value ) && value . match ( /^http(s?)$/ ) ;
} ,
'token' : function ( value ) {
return _ . isString ( value ) ;
} ,
'off_days' : function ( value ) {
var day , _i , _len ;
if ( ! _ . isArray ( value ) ) {
return false ;
}
for ( _i = 0 , _len = value . length ; _i < _len ; _i ++ ) {
day = value [ _i ] ;
if ( _ _indexOf . call ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] , day ) < 0 ) {
return false ;
}
}
return true ;
}
} ;
module . exports = function ( cb ) {
if ( typeof window === 'undefined' ) {
config = null ;
}
if ( config ) {
return cb ( null , config ) ;
}
queue . push ( cb ) ;
if ( ! wait ) {
wait = true ;
return request . config ( function ( err , result ) {
var field , validator , _results ;
wait = false ;
config = _ . defaults ( result || { } , defaults ) ;
if ( config . size _label ) {
config . size _label = new RegExp ( config . size _label ) ;
} else {
config . size _label = regex . size _label ;
}
for ( field in validators ) {
validator = validators [ field ] ;
if ( config [ field ] ) {
if ( ! validator ( config [ field ] ) ) {
return cb ( "Config field `" + field + "` misconfigured" ) ;
}
}
}
_results = [ ] ;
while ( queue . length ) {
_results . push ( queue . pop ( ) ( null , config ) ) ;
}
return _results ;
} ) ;
}
} ;
} ) ;
// graph.coffee
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/modules/graph.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
var d3 , reg , _ , _ref ,
_ _indexOf = [ ] . indexOf || function ( item ) { for ( var i = 0 , l = this . length ; i < l ; i ++ ) { if ( i in this && this [ i ] === item ) return i ; } return - 1 ; } ;
_ref = require ( './require' ) , _ = _ref . _ , d3 = _ref . d3 ;
reg = require ( './regex' ) ;
module . exports = {
'actual' : function ( collection , created _at , total , cb ) {
var head , max , min , range , rest ;
head = [
{
date : new Date ( created _at ) ,
points : total
}
] ;
min = + Infinity ;
max = - Infinity ;
rest = _ . map ( collection , function ( issue ) {
var closed _at , size ;
size = issue . size , closed _at = issue . closed _at ;
if ( size < min ) {
min = size ;
}
if ( size > max ) {
max = size ;
}
return _ . extend ( { } , issue , {
date : new Date ( closed _at ) ,
points : total -= size
} ) ;
} ) ;
range = d3 . scale . linear ( ) . domain ( [ min , max ] ) . range ( [ 5 , 8 ] ) ;
rest = _ . map ( rest , function ( issue ) {
issue . radius = range ( issue . size ) ;
return issue ;
} ) ;
return cb ( null , [ ] . concat ( head , rest ) ) ;
} ,
'ideal' : function ( a , b , off _days , total , cb ) {
var cutoff , d , days , length , m , now , once , velocity , y , _ref1 , _ref2 ;
if ( b < a ) {
_ref1 = [ a , b ] , b = _ref1 [ 0 ] , a = _ref1 [ 1 ] ;
}
_ref2 = _ . map ( a . match ( reg . datetime ) [ 1 ] . split ( '-' ) , function ( v ) {
return parseInt ( v ) ;
} ) , y = _ref2 [ 0 ] , m = _ref2 [ 1 ] , d = _ref2 [ 2 ] ;
cutoff = new Date ( b ) ;
days = [ ] ;
length = 0 ;
( once = function ( inc ) {
var day , day _of ;
day = new Date ( y , m - 1 , d + inc ) ;
if ( ! ( day _of = day . getDay ( ) ) ) {
day _of = 7 ;
}
if ( _ _indexOf . call ( off _days , day _of ) >= 0 ) {
days . push ( {
date : day ,
off _day : true
} ) ;
} else {
length += 1 ;
days . push ( {
date : day
} ) ;
}
if ( ! ( day > cutoff ) ) {
return once ( inc + 1 ) ;
}
} ) ( 0 ) ;
velocity = total / ( length - 1 ) ;
days = _ . map ( days , function ( day , i ) {
day . points = total ;
if ( days [ i ] && ! days [ i ] . off _day ) {
total -= velocity ;
}
return day ;
} ) ;
if ( ( now = new Date ( ) ) > cutoff ) {
days . push ( {
date : now ,
points : 0
} ) ;
}
return cb ( null , days ) ;
} ,
'trendline' : function ( actual , created _at , due _on ) {
var a , b , b1 , c1 , e , fn , intercept , l , last , slope , start , values ;
start = + actual [ 0 ] . date ;
values = _ . map ( actual , function ( _arg ) {
var date , points ;
date = _arg . date , points = _arg . points ;
return [ + date - start , points ] ;
} ) ;
last = actual [ actual . length - 1 ] ;
values . push ( [ + new Date ( ) - start , last . points ] ) ;
b1 = 0 ;
e = 0 ;
c1 = 0 ;
a = ( l = values . length ) * _ . reduce ( values , function ( sum , _arg ) {
var a , b ;
a = _arg [ 0 ] , b = _arg [ 1 ] ;
b1 += a ;
e += b ;
c1 += Math . pow ( a , 2 ) ;
return sum + ( a * b ) ;
} , 0 ) ;
slope = ( a - ( b1 * e ) ) / ( ( l * c1 ) - ( Math . pow ( b1 , 2 ) ) ) ;
intercept = ( e - ( slope * b1 ) ) / l ;
fn = function ( x ) {
return slope * x + intercept ;
} ;
created _at = new Date ( created _at ) ;
due _on = due _on ? new Date ( due _on ) : new Date ( ) ;
a = created _at - start ;
b = due _on - start ;
return [
{
date : created _at ,
points : fn ( a )
} , {
date : due _on ,
points : fn ( b )
}
] ;
} ,
'render' : function ( _arg , cb ) {
var actual , height , ideal , line , m , mAxis , margin , svg , tooltip , trendline , width , x , xAxis , y , yAxis , _ref1 ;
actual = _arg [ 0 ] , ideal = _arg [ 1 ] , trendline = _arg [ 2 ] ;
document . querySelector ( '#svg' ) . innerHTML = '' ;
_ref1 = document . querySelector ( '#graph' ) . getBoundingClientRect ( ) , height = _ref1 . height , width = _ref1 . width ;
margin = {
top : 30 ,
right : 30 ,
bottom : 40 ,
left : 50
} ;
width -= margin . left + margin . right ;
height -= margin . top + margin . bottom ;
x = d3 . time . scale ( ) . range ( [ 0 , width ] ) ;
y = d3 . scale . linear ( ) . range ( [ height , 0 ] ) ;
xAxis = d3 . svg . axis ( ) . scale ( x ) . orient ( "bottom" ) . tickSize ( - height ) . tickFormat ( function ( d ) {
return d . getDate ( ) ;
} ) . tickPadding ( 10 ) ;
yAxis = d3 . svg . axis ( ) . scale ( y ) . orient ( "left" ) . tickSize ( - width ) . ticks ( 5 ) . tickPadding ( 10 ) ;
line = d3 . svg . line ( ) . interpolate ( "linear" ) . x ( function ( d ) {
return x ( d . date ) ;
} ) . y ( function ( d ) {
return y ( d . points ) ;
} ) ;
x . domain ( [ ideal [ 0 ] . date , ideal [ ideal . length - 1 ] . date ] ) ;
y . domain ( [ 0 , ideal [ 0 ] . points ] ) . nice ( ) ;
svg = d3 . select ( "#svg" ) . append ( "svg" ) . attr ( "width" , width + margin . left + margin . right ) . attr ( "height" , height + margin . top + margin . bottom ) . append ( "g" ) . attr ( "transform" , "translate(" + margin . left + "," + margin . top + ")" ) ;
svg . append ( "g" ) . attr ( "class" , "x axis day" ) . attr ( "transform" , "translate(0," + height + ")" ) . call ( xAxis ) ;
m = [ 'Jan' , 'Feb' , 'Mar' , 'Apr' , 'May' , 'Jun' , 'Jul' , 'Aug' , 'Sep' , 'Oct' , 'Nov' , 'Dec' ] ;
mAxis = xAxis . orient ( "top" ) . tickSize ( height ) . tickFormat ( function ( d ) {
return m [ d . getMonth ( ) ] ;
} ) . ticks ( 2 ) ;
svg . append ( "g" ) . attr ( "class" , "x axis month" ) . attr ( "transform" , "translate(0," + height + ")" ) . call ( mAxis ) ;
svg . append ( "g" ) . attr ( "class" , "y axis" ) . call ( yAxis ) ;
svg . append ( "svg:line" ) . attr ( "class" , "today" ) . attr ( "x1" , x ( new Date ( ) ) ) . attr ( "y1" , 0 ) . attr ( "x2" , x ( new Date ( ) ) ) . attr ( "y2" , height ) ;
svg . append ( "path" ) . attr ( "class" , "ideal line" ) . attr ( "d" , line . interpolate ( "basis" ) ( ideal ) ) ;
svg . append ( "path" ) . attr ( "class" , "trendline line" ) . attr ( "d" , line . interpolate ( "linear" ) ( trendline ) ) ;
svg . append ( "path" ) . attr ( "class" , "actual line" ) . attr ( "d" , line . interpolate ( "linear" ) . y ( function ( d ) {
return y ( d . points ) ;
} ) ( actual ) ) ;
tooltip = d3 . tip ( ) . attr ( 'class' , 'd3-tip' ) . html ( function ( _arg1 ) {
var number , title ;
number = _arg1 . number , title = _arg1 . title ;
return "#" + number + ": " + title ;
} ) ;
svg . call ( tooltip ) ;
svg . selectAll ( "a.issue" ) . data ( actual . slice ( 1 ) ) . enter ( ) . append ( 'svg:a' ) . attr ( "xlink:href" , function ( _arg1 ) {
var html _url ;
html _url = _arg1 . html _url ;
return html _url ;
} ) . attr ( "xlink:show" , 'new' ) . append ( 'svg:circle' ) . attr ( "cx" , function ( _arg1 ) {
var date ;
date = _arg1 . date ;
return x ( date ) ;
} ) . attr ( "cy" , function ( _arg1 ) {
var points ;
points = _arg1 . points ;
return y ( points ) ;
} ) . attr ( "r" , function ( _arg1 ) {
var radius ;
radius = _arg1 . radius ;
return 5 ;
} ) . on ( 'mouseover' , tooltip . show ) . on ( 'mouseout' , tooltip . hide ) ;
return cb ( null ) ;
}
} ;
} ) ;
// issues.coffee
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/modules/issues.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
var async , reg , req , _ , _ref ;
_ref = require ( './require' ) , _ = _ref . _ , async = _ref . async ;
req = require ( './request' ) ;
reg = require ( './regex' ) ;
module . exports = {
'get_all' : function ( repo , cb ) {
var one _status ;
one _status = function ( state , cb ) {
var fetch _page , results ;
results = [ ] ;
return ( fetch _page = function ( page ) {
return req . all _issues ( repo , {
milestone : repo . milestone . number ,
state : state ,
page : page
} , function ( err , data ) {
if ( err ) {
return cb ( err ) ;
}
if ( ! data . length ) {
return cb ( null , results ) ;
}
results = results . concat ( _ . sortBy ( data , 'closed_at' ) ) ;
if ( data . length < 100 ) {
return cb ( null , results ) ;
}
return fetch _page ( page + 1 ) ;
} ) ;
} ) ( 1 ) ;
} ;
return async . parallel ( [ _ . partial ( one _status , 'open' ) , _ . partial ( one _status , 'closed' ) ] , cb ) ;
} ,
'filter' : function ( collection , regex , cb ) {
var filtered , total ;
total = 0 ;
filtered = _ . filter ( collection , function ( issue ) {
var labels ;
if ( ! ( labels = issue . labels ) ) {
return false ;
}
issue . size = _ . reduce ( labels , function ( sum , label ) {
var matches ;
if ( ! ( matches = label . name . match ( regex ) ) ) {
return sum ;
}
return sum += parseInt ( matches [ 1 ] ) ;
} , 0 ) ;
total += issue . size ;
return ! ! issue . size ;
} ) ;
return cb ( null , filtered , total ) ;
}
} ;
} ) ;
// milestones.coffee
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/modules/milestones.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
var marked , request , _ , _ref ;
_ref = require ( './require' ) , _ = _ref . _ , marked = _ref . marked ;
request = require ( './request' ) ;
module . exports = function ( repo , cb ) {
var parse ;
parse = function ( data ) {
if ( data . description ) {
data . description = marked ( data . description ) . slice ( 3 , - 5 ) ;
}
return data ;
} ;
if ( repo . milestone ) {
return request . one _milestone ( repo , repo . milestone , function ( err , m ) {
if ( err ) {
return cb ( err ) ;
}
if ( m . open _issues + m . closed _issues === 0 ) {
return cb ( null , "No issues for milestone `" + m . title + "`" ) ;
}
m = parse ( m ) ;
return cb ( null , null , m ) ;
} ) ;
} else {
return request . all _milestones ( repo , function ( err , data ) {
var m ;
if ( err ) {
return cb ( err ) ;
}
if ( ! data . length ) {
return cb ( null , "No open milestones for repo " + repo . path ) ;
}
m = data [ 0 ] ;
m = _ . rest ( data , {
'due_on' : null
} ) ;
m = m [ 0 ] ? m [ 0 ] : data [ 0 ] ;
if ( m . open _issues + m . closed _issues === 0 ) {
return cb ( null , "No issues for milestone `" + m . title + "`" ) ;
}
m = parse ( m ) ;
return cb ( null , null , m ) ;
} ) ;
}
} ;
} ) ;
// regex.coffee
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/modules/regex.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
module . exports = {
'datetime' : /^(\d{4}-\d{2}-\d{2})T(.*)/ ,
'size_label' : /^size (\d+)$/ ,
'location' : /^#!((\/[^\/]+){2,3})$/
} ;
} ) ;
// render.coffee
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/modules/render.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
module . exports = function ( selector , template , context ) {
var tml ;
if ( context == null ) {
context = { } ;
}
tml = require ( "../templates/" + template ) ;
return document . querySelector ( selector ) . innerHTML = tml ( context ) ;
} ;
} ) ;
// repo.coffee
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/modules/repo.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
var async , graph , issues , milestones , regex , render , _ , _ref ;
_ref = require ( './require' ) , _ = _ref . _ , async = _ref . async ;
milestones = require ( './milestones' ) ;
issues = require ( './issues' ) ;
graph = require ( './graph' ) ;
regex = require ( './regex' ) ;
render = require ( './render' ) ;
module . exports = function ( opts , cb ) {
return async . waterfall ( [
function ( cb ) {
return milestones ( opts , function ( err , warn , milestone ) {
if ( err ) {
return cb ( err ) ;
}
if ( warn ) {
return cb ( warn ) ;
}
opts . milestone = milestone ;
return cb ( null ) ;
} ) ;
} , function ( cb ) {
return issues . get _all ( opts , cb ) ;
} , function ( all , cb ) {
return async . map ( all , function ( array , cb ) {
return issues . filter ( array , opts . size _label , function ( err , filtered , total ) {
return cb ( err , [ filtered , total ] ) ;
} ) ;
} , function ( err , _arg ) {
var closed , open ;
open = _arg [ 0 ] , closed = _arg [ 1 ] ;
if ( err ) {
return cb ( err ) ;
}
if ( open [ 1 ] + closed [ 1 ] === 0 ) {
return cb ( 'No matching issues found' ) ;
}
opts . issues = {
closed : {
points : closed [ 1 ] ,
data : closed [ 0 ]
} ,
open : {
points : open [ 1 ] ,
data : open [ 0 ]
}
} ;
return cb ( null ) ;
} ) ;
} , function ( cb ) {
var progress , total ;
progress = 100 * opts . issues . closed . points / ( total = opts . issues . open . points + opts . issues . closed . points ) ;
return async . parallel ( [ _ . partial ( graph . actual , opts . issues . closed . data , opts . milestone . created _at , total ) , _ . partial ( graph . ideal , opts . milestone . created _at , opts . milestone . due _on , opts . off _days || [ ] , total ) ] , function ( err , values ) {
var doit ;
render ( 'body' , 'graph' , {
'repo' : opts . path ,
'milestone' : opts . milestone
} ) ;
render ( '#progress' , 'progress' , {
progress : progress
} ) ;
if ( values [ 0 ] . length ) {
values . push ( graph . trendline ( values [ 0 ] , opts . milestone . created _at , opts . milestone . due _on ) ) ;
}
( doit = function ( ) {
return graph . render ( values , cb ) ;
} ) ( ) ;
if ( 'onresize' in window ) {
return window . onresize = doit ;
}
} ) ;
}
] , cb ) ;
} ;
} ) ;
// request.coffee
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/modules/request.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
var request , respond , superagent , _ , _ref ;
_ref = require ( './require' ) , superagent = _ref . superagent , _ = _ref . _ ;
superagent . parse = {
'application/json' : function ( res ) {
var e ;
try {
return JSON . parse ( res ) ;
} catch ( _error ) {
e = _error ;
return { } ;
}
}
} ;
module . exports = {
'all_milestones' : function ( repo , cb ) {
var query ;
query = {
'state' : 'open' ,
'sort' : 'due_date' ,
'direction' : 'asc'
} ;
return request ( repo , query , 'milestones' , cb ) ;
} ,
'one_milestone' : function ( repo , number , cb ) {
var query ;
query = {
'state' : 'open' ,
'sort' : 'due_date' ,
'direction' : 'asc'
} ;
return request ( repo , query , "milestones/" + number , cb ) ;
} ,
'all_issues' : function ( repo , query , cb ) {
_ . extend ( query , {
'per_page' : '100'
} ) ;
return request ( repo , query , 'issues' , cb ) ;
} ,
'config' : function ( cb ) {
return superagent . get ( "http://" + ( window . location . host + window . location . pathname ) + "config.json" ) . set ( 'Content-Type' , 'application/json' ) . end ( _ . partialRight ( respond , cb ) ) ;
}
} ;
request = function ( _arg , query , noun , cb ) {
var host , k , path , protocol , q , req , token , v ;
protocol = _arg . protocol , host = _arg . host , token = _arg . token , path = _arg . path ;
q = ( ( function ( ) {
var _results ;
_results = [ ] ;
for ( k in query ) {
v = query [ k ] ;
_results . push ( "" + k + "=" + v ) ;
}
return _results ;
} ) ( ) ) . join ( '&' ) ;
2013-12-30 11:48:29 +00:00
req = superagent . get ( "" + protocol + "://" + host + "/repos/" + path + "/" + noun + "?" + q ) . set ( 'Content-Type' , 'application/json' ) . set ( 'Accept' , 'application/vnd.github.v3' ) ;
2013-11-05 12:44:15 +00:00
if ( token ) {
req = req . set ( 'Authorization' , "token " + token ) ;
}
return req . end ( _ . partialRight ( respond , cb ) ) ;
} ;
respond = function ( data , cb ) {
var _ref1 ;
if ( data . statusType !== 2 ) {
if ( ( data != null ? ( _ref1 = data . body ) != null ? _ref1 . message : void 0 : void 0 ) != null ) {
return cb ( data . body . message ) ;
}
return cb ( data . error . message ) ;
}
return cb ( null , data . body ) ;
} ;
} ) ;
// require.coffee
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/modules/require.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
module . exports = {
_ : _ ,
superagent : superagent ,
d3 : d3 ,
async : async ,
marked : marked
} ;
} ) ;
// error.eco
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/templates/error.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
module . exports = function ( _ _obj ) {
if ( ! _ _obj ) _ _obj = { } ;
var _ _out = [ ] , _ _capture = function ( callback ) {
var out = _ _out , result ;
_ _out = [ ] ;
callback . call ( this ) ;
result = _ _out . join ( '' ) ;
_ _out = out ;
return _ _safe ( result ) ;
} , _ _sanitize = function ( value ) {
if ( value && value . ecoSafe ) {
return value ;
} else if ( typeof value !== 'undefined' && value != null ) {
return _ _escape ( value ) ;
} else {
return '' ;
}
} , _ _safe , _ _objSafe = _ _obj . safe , _ _escape = _ _obj . escape ;
_ _safe = _ _obj . safe = function ( value ) {
if ( value && value . ecoSafe ) {
return value ;
} else {
if ( ! ( typeof value !== 'undefined' && value != null ) ) value = '' ;
var result = new String ( value ) ;
result . ecoSafe = true ;
return result ;
}
} ;
if ( ! _ _escape ) {
_ _escape = _ _obj . escape = function ( value ) {
return ( '' + value )
. replace ( /&/g , '&' )
. replace ( /</g , '<' )
. replace ( />/g , '>' )
. replace ( /"/g , '"' ) ;
} ;
}
( function ( ) {
( function ( ) {
_ _out . push ( '<div class="box error">\n <h2>Trouble</h2>\n <p>' ) ;
_ _out . push ( this . text ) ;
_ _out . push ( '</p>\n</div>' ) ;
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
}
} ) ;
// graph.eco
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/templates/graph.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
module . exports = function ( _ _obj ) {
if ( ! _ _obj ) _ _obj = { } ;
var _ _out = [ ] , _ _capture = function ( callback ) {
var out = _ _out , result ;
_ _out = [ ] ;
callback . call ( this ) ;
result = _ _out . join ( '' ) ;
_ _out = out ;
return _ _safe ( result ) ;
} , _ _sanitize = function ( value ) {
if ( value && value . ecoSafe ) {
return value ;
} else if ( typeof value !== 'undefined' && value != null ) {
return _ _escape ( value ) ;
} else {
return '' ;
}
} , _ _safe , _ _objSafe = _ _obj . safe , _ _escape = _ _obj . escape ;
_ _safe = _ _obj . safe = function ( value ) {
if ( value && value . ecoSafe ) {
return value ;
} else {
if ( ! ( typeof value !== 'undefined' && value != null ) ) value = '' ;
var result = new String ( value ) ;
result . ecoSafe = true ;
return result ;
}
} ;
if ( ! _ _escape ) {
_ _escape = _ _obj . escape = function ( value ) {
return ( '' + value )
. replace ( /&/g , '&' )
. replace ( /</g , '<' )
. replace ( />/g , '>' )
. replace ( /"/g , '"' ) ;
} ;
}
( function ( ) {
( function ( ) {
_ _out . push ( '<div class="box">\n <h1>' ) ;
_ _out . push ( this . milestone . title ) ;
_ _out . push ( '@' ) ;
_ _out . push ( this . repo ) ;
_ _out . push ( '</h1>\n ' ) ;
if ( this . milestone . description ) {
_ _out . push ( '\n <p class="description">' ) ;
_ _out . push ( this . milestone . description ) ;
_ _out . push ( '</p>\n ' ) ;
}
_ _out . push ( '\n <div id="graph">\n <div id="tooltip"></div>\n <div id="svg"></div>\n </div>\n <div id="progress"></div>\n</div>' ) ;
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
}
} ) ;
// info.eco
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/templates/info.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
module . exports = function ( _ _obj ) {
if ( ! _ _obj ) _ _obj = { } ;
var _ _out = [ ] , _ _capture = function ( callback ) {
var out = _ _out , result ;
_ _out = [ ] ;
callback . call ( this ) ;
result = _ _out . join ( '' ) ;
_ _out = out ;
return _ _safe ( result ) ;
} , _ _sanitize = function ( value ) {
if ( value && value . ecoSafe ) {
return value ;
} else if ( typeof value !== 'undefined' && value != null ) {
return _ _escape ( value ) ;
} else {
return '' ;
}
} , _ _safe , _ _objSafe = _ _obj . safe , _ _escape = _ _obj . escape ;
_ _safe = _ _obj . safe = function ( value ) {
if ( value && value . ecoSafe ) {
return value ;
} else {
if ( ! ( typeof value !== 'undefined' && value != null ) ) value = '' ;
var result = new String ( value ) ;
result . ecoSafe = true ;
return result ;
}
} ;
if ( ! _ _escape ) {
_ _escape = _ _obj . escape = function ( value ) {
return ( '' + value )
. replace ( /&/g , '&' )
. replace ( /</g , '<' )
. replace ( />/g , '>' )
. replace ( /"/g , '"' ) ;
} ;
}
( function ( ) {
( function ( ) {
_ _out . push ( '<div class="box info">\n <h2>GitHub Burndown Chart</h2>\n <p>Use your browser\'s location hash to specify a <strong>repo</strong>: <a href="#!/radekstepan/disposable">#!/radekstepan/disposable</a>.</p>\n <p>You can choose a specific <strong>milestone</strong> like so: <a href="#!/radekstepan/disposable/1">#!/radekstepan/disposable/1</a>.</p>\n</div>' ) ;
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
}
} ) ;
// label.eco
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/templates/label.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
module . exports = function ( _ _obj ) {
if ( ! _ _obj ) _ _obj = { } ;
var _ _out = [ ] , _ _capture = function ( callback ) {
var out = _ _out , result ;
_ _out = [ ] ;
callback . call ( this ) ;
result = _ _out . join ( '' ) ;
_ _out = out ;
return _ _safe ( result ) ;
} , _ _sanitize = function ( value ) {
if ( value && value . ecoSafe ) {
return value ;
} else if ( typeof value !== 'undefined' && value != null ) {
return _ _escape ( value ) ;
} else {
return '' ;
}
} , _ _safe , _ _objSafe = _ _obj . safe , _ _escape = _ _obj . escape ;
_ _safe = _ _obj . safe = function ( value ) {
if ( value && value . ecoSafe ) {
return value ;
} else {
if ( ! ( typeof value !== 'undefined' && value != null ) ) value = '' ;
var result = new String ( value ) ;
result . ecoSafe = true ;
return result ;
}
} ;
if ( ! _ _escape ) {
_ _escape = _ _obj . escape = function ( value ) {
return ( '' + value )
. replace ( /&/g , '&' )
. replace ( /</g , '<' )
. replace ( />/g , '>' )
. replace ( /"/g , '"' ) ;
} ;
}
( function ( ) {
( function ( ) {
var points ;
points = Math . ceil ( this . points ) ;
_ _out . push ( '\n' ) ;
if ( points > 1 ) {
_ _out . push ( '\n ' ) ;
_ _out . push ( points ) ;
_ _out . push ( ' points left\n' ) ;
} else {
_ _out . push ( '\n ' ) ;
if ( points === 1 ) {
_ _out . push ( '\n 1 point left\n ' ) ;
} else {
_ _out . push ( '\n Done\n ' ) ;
}
_ _out . push ( '\n' ) ;
}
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
}
} ) ;
// loading.eco
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/templates/loading.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
module . exports = function ( _ _obj ) {
if ( ! _ _obj ) _ _obj = { } ;
var _ _out = [ ] , _ _capture = function ( callback ) {
var out = _ _out , result ;
_ _out = [ ] ;
callback . call ( this ) ;
result = _ _out . join ( '' ) ;
_ _out = out ;
return _ _safe ( result ) ;
} , _ _sanitize = function ( value ) {
if ( value && value . ecoSafe ) {
return value ;
} else if ( typeof value !== 'undefined' && value != null ) {
return _ _escape ( value ) ;
} else {
return '' ;
}
} , _ _safe , _ _objSafe = _ _obj . safe , _ _escape = _ _obj . escape ;
_ _safe = _ _obj . safe = function ( value ) {
if ( value && value . ecoSafe ) {
return value ;
} else {
if ( ! ( typeof value !== 'undefined' && value != null ) ) value = '' ;
var result = new String ( value ) ;
result . ecoSafe = true ;
return result ;
}
} ;
if ( ! _ _escape ) {
_ _escape = _ _obj . escape = function ( value ) {
return ( '' + value )
. replace ( /&/g , '&' )
. replace ( /</g , '<' )
. replace ( />/g , '>' )
. replace ( /"/g , '"' ) ;
} ;
}
( function ( ) {
( function ( ) {
_ _out . push ( '<div class="box generic">\n <h2>GitHub Burndown Chart</h2>\n <p>Loading <a href="#!/' ) ;
_ _out . push ( this . path ) ;
_ _out . push ( '">#!/' ) ;
_ _out . push ( this . path ) ;
_ _out . push ( '</a>.</p>\n</div>' ) ;
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
}
} ) ;
// progress.eco
2013-12-05 15:17:32 +00:00
root . require . register ( 'ghbc/src/templates/progress.js' , function ( exports , require , module ) {
2013-11-05 12:44:15 +00:00
module . exports = function ( _ _obj ) {
if ( ! _ _obj ) _ _obj = { } ;
var _ _out = [ ] , _ _capture = function ( callback ) {
var out = _ _out , result ;
_ _out = [ ] ;
callback . call ( this ) ;
result = _ _out . join ( '' ) ;
_ _out = out ;
return _ _safe ( result ) ;
} , _ _sanitize = function ( value ) {
if ( value && value . ecoSafe ) {
return value ;
} else if ( typeof value !== 'undefined' && value != null ) {
return _ _escape ( value ) ;
} else {
return '' ;
}
} , _ _safe , _ _objSafe = _ _obj . safe , _ _escape = _ _obj . escape ;
_ _safe = _ _obj . safe = function ( value ) {
if ( value && value . ecoSafe ) {
return value ;
} else {
if ( ! ( typeof value !== 'undefined' && value != null ) ) value = '' ;
var result = new String ( value ) ;
result . ecoSafe = true ;
return result ;
}
} ;
if ( ! _ _escape ) {
_ _escape = _ _obj . escape = function ( value ) {
return ( '' + value )
. replace ( /&/g , '&' )
. replace ( /</g , '<' )
. replace ( />/g , '>' )
. replace ( /"/g , '"' ) ;
} ;
}
( function ( ) {
( function ( ) {
_ _out . push ( '<div class="bars">\n ' ) ;
if ( this . progress === 100 ) {
_ _out . push ( '\n <div class="closed done" style="width:100%"></div>\n ' ) ;
} else {
_ _out . push ( '\n <div class="closed" style="width:' ) ;
_ _out . push ( _ _sanitize ( this . progress ) ) ;
_ _out . push ( '%"></div>\n ' ) ;
}
_ _out . push ( '\n <div class="opened"></div>\n</div>\n<h2 class="closed">Closed / ' ) ;
_ _out . push ( _ _sanitize ( Math . floor ( this . progress ) ) ) ;
_ _out . push ( '%</h2>\n<h2 class="opened">Open / ' ) ;
_ _out . push ( _ _sanitize ( 100 - Math . floor ( this . progress ) ) ) ;
_ _out . push ( '%</h2>' ) ;
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
}
} ) ;
} ) ( ) ;
// Return the main app.
2013-12-05 15:17:32 +00:00
var main = root . require ( "ghbc/src/app.js" ) ;
2013-11-05 12:44:15 +00:00
// AMD/RequireJS.
if ( typeof define !== 'undefined' && define . amd ) {
define ( "ghbc" , [ /* load deps ahead of time */ ] , function ( ) {
return main ;
} ) ;
define ( "ghb" , [ /* load deps ahead of time */ ] , function ( ) {
return main ;
} ) ;
define ( "github-burndown-chart" , [ /* load deps ahead of time */ ] , function ( ) {
return main ;
} ) ;
}
// CommonJS.
else if ( typeof module !== 'undefined' && module . exports ) {
module . exports = main ;
}
// Globally exported.
else {
root [ "ghbc" ] = main ;
root [ "ghb" ] = main ;
root [ "github-burndown-chart" ] = main ;
}
// Alias our app.
2013-12-05 15:17:32 +00:00
root . require . alias ( "ghbc/src/app.js" , "ghbc/index.js" ) ;
2013-11-05 12:44:15 +00:00
2013-12-05 15:17:32 +00:00
root . require . alias ( "ghbc/src/app.js" , "ghb/index.js" ) ;
2013-11-05 12:44:15 +00:00
2013-12-05 15:17:32 +00:00
root . require . alias ( "ghbc/src/app.js" , "github-burndown-chart/index.js" ) ;
2013-11-05 12:44:15 +00:00
} ) ( ) ;