2014-08-28 19:55:45 -07:00
// Concat modules and export them as an app.
( function ( root ) {
// All our modules will use global require.
( function ( ) {
// app.coffee
root . require . register ( 'burnchart/src/app.js' , function ( exports , require , module ) {
2014-09-26 21:01:58 -07:00
var App , Header , Notify , key , router , _i , _len , _ref ;
2014-08-30 13:13:11 -07:00
2014-09-14 13:14:57 -07:00
_ref = [ 'utils/mixins' , 'models/projects' ] ;
2014-09-12 20:05:05 -07:00
for ( _i = 0 , _len = _ref . length ; _i < _len ; _i ++ ) {
key = _ref [ _i ] ;
2014-09-14 13:14:57 -07:00
require ( "./" + key ) ;
2014-09-12 20:05:05 -07:00
}
2014-08-28 19:55:45 -07:00
2014-09-21 11:37:47 -07:00
Header = require ( './views/header' ) ;
2014-08-28 21:25:38 -07:00
2014-09-25 20:16:23 -07:00
Notify = require ( './views/notify' ) ;
2014-09-26 21:01:58 -07:00
router = require ( './modules/router' ) ;
2014-08-28 20:52:45 -07:00
App = Ractive . extend ( {
2014-10-08 20:04:10 -07:00
'template' : require ( './templates/app' ) ,
2014-08-30 13:13:11 -07:00
'components' : {
2014-09-25 20:16:23 -07:00
Header : Header ,
Notify : Notify
2014-09-01 20:28:28 -07:00
} ,
2014-10-02 21:00:31 -07:00
onrender : function ( ) {
2014-09-26 21:01:58 -07:00
return router . init ( '/' ) ;
2014-08-30 10:17:46 -07:00
}
2014-08-28 20:52:45 -07:00
} ) ;
module . exports = new App ( ) ;
} ) ;
2014-09-18 19:30:31 -07:00
// config.coffee
2014-09-13 19:10:10 -07:00
root . require . register ( 'burnchart/src/models/config.js' , function ( exports , require , module ) {
2014-09-01 20:28:28 -07:00
2014-09-18 19:30:31 -07:00
var Model ;
Model = require ( '../utils/model' ) ;
module . exports = new Model ( {
2014-10-08 20:04:10 -07:00
'name' : 'models/config' ,
2014-09-18 19:30:31 -07:00
"data" : {
2014-09-13 19:10:10 -07:00
"firebase" : "burnchart" ,
2014-09-14 13:14:57 -07:00
"provider" : "github" ,
"fields" : {
2014-09-18 19:30:31 -07:00
"milestone" : [ "closed_issues" , "created_at" , "description" , "due_on" , "number" , "open_issues" , "title" , "updated_at" ]
} ,
"chart" : {
2014-09-18 20:55:40 -07:00
"off_days" : [ ] ,
2014-09-18 19:30:31 -07:00
"datetime" : /^(\d{4}-\d{2}-\d{2})T(.*)/ ,
"size_label" : /^size (\d+)$/ ,
"location" : /^#!((\/[^\/]+){2,3})$/ ,
2014-10-09 19:21:23 -07:00
"points" : 'LABELS'
2014-09-14 13:14:57 -07:00
}
2014-09-18 19:30:31 -07:00
}
} ) ;
2014-09-13 19:10:10 -07:00
} ) ;
// projects.coffee
root . require . register ( 'burnchart/src/models/projects.js' , function ( exports , require , module ) {
2014-09-14 13:14:57 -07:00
var Model , config , date , mediator , request , user ;
2014-09-01 20:28:28 -07:00
2014-09-18 19:30:31 -07:00
config = require ( '../models/config' ) ;
2014-09-01 20:28:28 -07:00
mediator = require ( '../modules/mediator' ) ;
2014-09-14 13:14:57 -07:00
request = require ( '../modules/request' ) ;
2014-09-13 19:10:10 -07:00
Model = require ( '../utils/model' ) ;
2014-09-02 19:42:11 -07:00
2014-09-14 13:14:57 -07:00
date = require ( '../utils/date' ) ;
2014-09-13 19:10:10 -07:00
user = require ( './user' ) ;
module . exports = new Model ( {
2014-10-08 20:04:10 -07:00
'name' : 'models/projects' ,
find : function ( project ) {
return _ . find ( this . data . list , project ) ;
2014-09-01 20:28:28 -07:00
} ,
2014-10-08 20:04:10 -07:00
exists : function ( ) {
return ! ! this . find . apply ( this , arguments ) ;
2014-10-02 21:00:31 -07:00
} ,
2014-10-08 20:04:10 -07:00
add : function ( project ) {
if ( ! this . exists ( project ) ) {
return this . push ( 'list' , project ) ;
}
2014-10-02 21:00:31 -07:00
} ,
clear : function ( ) {
return this . set ( 'list' , [ ] ) ;
} ,
onconstruct : function ( ) {
mediator . on ( '!projects/add' , _ . bind ( this . add , this ) ) ;
return mediator . on ( '!projects/clear' , _ . bind ( this . clear , this ) ) ;
} ,
onrender : function ( ) {
2014-10-08 20:04:10 -07:00
this . set ( 'list' , lscache . get ( 'projects' ) || [ ] ) ;
2014-10-02 21:00:31 -07:00
return this . observe ( 'list' , function ( projects ) {
2014-10-08 20:04:10 -07:00
return lscache . set ( 'projects' , _ . pluckMany ( projects , [ 'owner' , 'name' ] ) ) ;
} , {
'init' : false
2014-09-01 21:54:20 -07:00
} ) ;
2014-09-13 19:10:10 -07:00
}
2014-08-30 13:13:11 -07:00
} ) ;
} ) ;
2014-09-29 21:31:51 -07:00
// system.coffee
root . require . register ( 'burnchart/src/models/system.js' , function ( exports , require , module ) {
var Model , async , counter , mediator , system ;
mediator = require ( '../modules/mediator' ) ;
Model = require ( '../utils/model' ) ;
system = new Model ( {
2014-10-08 20:04:10 -07:00
'name' : 'models/system' ,
2014-09-29 21:31:51 -07:00
'data' : {
'loading' : false
}
} ) ;
counter = 0 ;
async = function ( ) {
counter += 1 ;
system . set ( 'loading' , true ) ;
return function ( ) {
counter -= 1 ;
return system . set ( 'loading' , + counter ) ;
} ;
} ;
module . exports = {
system : system ,
async : async
} ;
} ) ;
2014-09-13 19:10:10 -07:00
// user.coffee
root . require . register ( 'burnchart/src/models/user.js' , function ( exports , require , module ) {
2014-09-12 20:05:05 -07:00
2014-09-13 19:10:10 -07:00
var Model , mediator ;
2014-09-12 20:05:05 -07:00
mediator = require ( '../modules/mediator' ) ;
2014-09-13 19:10:10 -07:00
Model = require ( '../utils/model' ) ;
2014-09-12 20:05:05 -07:00
2014-09-13 19:10:10 -07:00
module . exports = new Model ( {
2014-10-08 20:04:10 -07:00
'name' : 'models/user' ,
2014-09-12 20:05:05 -07:00
'data' : {
2014-09-13 19:10:10 -07:00
'provider' : "local" ,
'id' : "0" ,
2014-09-14 13:14:57 -07:00
'uid' : "local:0" ,
'token' : null
2014-09-13 19:10:10 -07:00
}
2014-09-12 20:05:05 -07:00
} ) ;
} ) ;
2014-09-18 19:30:31 -07:00
// chart.coffee
root . require . register ( 'burnchart/src/modules/chart.js' , function ( exports , require , module ) {
var config ,
_ _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 ; } ;
config = require ( '../models/config' ) ;
module . exports = {
'actual' : function ( collection , created _at , total , cb ) {
var head , max , min , range , rest ;
head = [
{
2014-09-18 20:55:40 -07:00
'date' : new Date ( created _at ) ,
'points' : total
2014-09-18 19:30:31 -07:00
}
] ;
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 ;
}
2014-09-18 20:55:40 -07:00
issue . date = new Date ( closed _at ) ;
issue . points = total -= size ;
return issue ;
2014-09-18 19:30:31 -07:00
} ) ;
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 , total , cb ) {
var cutoff , d , days , length , m , now , once , velocity , y , _ref , _ref1 ;
if ( b < a ) {
_ref = [ a , b ] , b = _ref [ 0 ] , a = _ref [ 1 ] ;
}
_ref1 = _ . map ( a . match ( config . get ( 'chart.datetime' ) ) [ 1 ] . split ( '-' ) , function ( v ) {
return parseInt ( v ) ;
} ) , y = _ref1 [ 0 ] , m = _ref1 [ 1 ] , d = _ref1 [ 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 ( config . get ( 'chart.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 , _ref ;
actual = _arg [ 0 ] , ideal = _arg [ 1 ] , trendline = _arg [ 2 ] ;
document . querySelector ( '#svg' ) . innerHTML = '' ;
_ref = document . querySelector ( '#chart' ) . getBoundingClientRect ( ) , height = _ref . height , width = _ref . width ;
margin = {
2014-09-18 20:55:40 -07:00
'top' : 30 ,
'right' : 30 ,
'bottom' : 40 ,
'left' : 50
2014-09-18 19:30:31 -07:00
} ;
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 ) ;
}
} ;
} ) ;
2014-08-30 09:00:11 -07:00
// firebase.coffee
2014-08-30 10:17:46 -07:00
root . require . register ( 'burnchart/src/modules/firebase.js' , function ( exports , require , module ) {
2014-08-30 09:00:11 -07:00
2014-09-04 21:23:59 -07:00
var Class , config , user ;
2014-08-30 09:00:11 -07:00
2014-09-13 19:10:10 -07:00
user = require ( '../models/user' ) ;
2014-08-30 09:00:11 -07:00
2014-09-18 19:30:31 -07:00
config = require ( '../models/config' ) ;
2014-09-04 21:23:59 -07:00
Class = ( function ( ) {
function Class ( ) {
var _this = this ;
2014-09-18 19:30:31 -07:00
this . client = new Firebase ( "https://" + ( config . get ( 'firebase' ) ) + ".firebaseio.com" ) ;
2014-08-30 10:17:46 -07:00
this . auth = new FirebaseSimpleLogin ( this . client , function ( err , obj ) {
2014-10-03 19:39:35 -07:00
user . set ( 'loaded' , true ) ;
2014-08-30 09:00:11 -07:00
if ( err || ! obj ) {
2014-09-04 21:23:59 -07:00
return _this . authCb ( err ) ;
2014-08-30 09:00:11 -07:00
}
2014-09-01 20:28:28 -07:00
return user . set ( obj ) ;
2014-08-30 10:17:46 -07:00
} ) ;
}
2014-09-04 21:23:59 -07:00
Class . prototype . authCb = function ( ) { } ;
Class . prototype . login = function ( cb ) {
2014-08-30 09:00:11 -07:00
if ( ! this . client ) {
return cb ( 'Client is not setup' ) ;
}
2014-09-04 21:23:59 -07:00
this . authCb = cb ;
2014-09-18 19:30:31 -07:00
return this . auth . login ( config . get ( 'provider' ) , {
2014-08-30 09:00:11 -07:00
'rememberMe' : true ,
'scope' : 'public_repo'
} ) ;
2014-08-30 10:17:46 -07:00
} ;
2014-09-04 21:23:59 -07:00
Class . prototype . logout = function ( ) {
2014-08-30 09:00:11 -07:00
var _ref ;
if ( ( _ref = this . auth ) != null ) {
2014-08-30 10:17:46 -07:00
_ref . logout ;
2014-08-30 09:00:11 -07:00
}
2014-09-01 20:28:28 -07:00
return user . reset ( ) ;
2014-08-30 10:17:46 -07:00
} ;
2014-09-04 21:23:59 -07:00
return Class ;
2014-08-30 10:17:46 -07:00
} ) ( ) ;
2014-09-04 21:23:59 -07:00
module . exports = new Class ( ) ;
2014-08-30 10:17:46 -07:00
} ) ;
2014-09-18 19:30:31 -07:00
// issues.coffee
root . require . register ( 'burnchart/src/modules/issues.js' , function ( exports , require , module ) {
var config , request ;
config = require ( '../models/config' ) ;
request = require ( './request' ) ;
module . exports = {
'get_all' : function ( opts , cb ) {
var one _status ;
one _status = function ( state , cb ) {
var fetch _page , results ;
results = [ ] ;
return ( fetch _page = function ( page ) {
return request . allIssues ( opts , {
2014-09-19 20:12:12 -07:00
'milestone' : opts . milestone . number ,
2014-09-18 19:30:31 -07:00
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 ) ;
} ,
2014-09-18 20:55:40 -07:00
'filter' : function ( collection , cb ) {
2014-09-18 19:30:31 -07:00
var filtered , total ;
total = 0 ;
switch ( config . get ( 'chart.points' ) ) {
2014-09-19 20:12:12 -07:00
case 'ONE_SIZE' :
2014-09-18 19:30:31 -07:00
total = collection . length ;
filtered = _ . map ( collection , function ( issue ) {
issue . size = 1 ;
return issue ;
} ) ;
break ;
case 'LABELS' :
filtered = _ . filter ( collection , function ( issue ) {
var labels ;
if ( ! ( labels = issue . labels ) ) {
return false ;
}
issue . size = _ . reduce ( labels , function ( sum , label ) {
var matches ;
2014-09-18 20:55:40 -07:00
if ( ! ( matches = label . name . match ( config . get ( 'chart.size_label' ) ) ) ) {
2014-09-18 19:30:31 -07:00
return sum ;
}
return sum += parseInt ( matches [ 1 ] ) ;
} , 0 ) ;
total += issue . size ;
return ! ! issue . size ;
} ) ;
}
return cb ( null , filtered , total ) ;
}
} ;
} ) ;
2014-09-14 13:14:57 -07:00
// mediator.coffee
root . require . register ( 'burnchart/src/modules/mediator.js' , function ( exports , require , module ) {
2014-10-08 20:04:10 -07:00
var Mediator ;
Mediator = Ractive . extend ( { } ) ;
module . exports = new Mediator ( ) ;
2014-09-14 13:14:57 -07:00
} ) ;
2014-09-19 20:33:25 -07:00
// milestone.coffee
root . require . register ( 'burnchart/src/modules/milestone.js' , function ( exports , require , module ) {
2014-09-18 19:30:31 -07:00
var request ;
request = require ( './request' ) ;
2014-09-19 20:33:25 -07:00
module . exports = {
get : function ( repo , cb ) {
if ( repo . milestone ) {
return request . oneMilestone ( 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 + "`" ) ;
}
return cb ( null , null , m ) ;
2014-09-18 19:30:31 -07:00
} ) ;
2014-09-19 20:33:25 -07:00
}
2014-10-08 20:04:10 -07:00
} ,
getAll : function ( repo , cb ) {
return request . allMilestones ( repo , function ( err , data ) {
return cb ( err , null , data ) ;
} ) ;
2014-09-18 19:30:31 -07:00
}
} ;
} ) ;
// project.coffee
root . require . register ( 'burnchart/src/modules/project.js' , function ( exports , require , module ) {
2014-09-19 20:33:25 -07:00
var chart , issues ;
2014-09-18 19:30:31 -07:00
issues = require ( './issues' ) ;
chart = require ( './chart' ) ;
module . exports = function ( opts , cb ) {
return async . waterfall ( [
function ( cb ) {
return issues . get _all ( opts , cb ) ;
} , function ( all , cb ) {
return async . map ( all , function ( array , cb ) {
2014-09-18 20:55:40 -07:00
return issues . filter ( array , function ( err , filtered , total ) {
2014-09-18 19:30:31 -07:00
return cb ( err , [ filtered , total ] ) ;
} ) ;
} , function ( err , _arg ) {
2014-09-18 20:55:40 -07:00
var closed , open , start ;
2014-09-18 19:30:31 -07:00
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 = {
2014-09-18 20:55:40 -07:00
'closed' : {
2014-09-18 19:30:31 -07:00
'points' : closed [ 1 ] ,
'data' : closed [ 0 ]
} ,
2014-09-18 20:55:40 -07:00
'open' : {
2014-09-18 19:30:31 -07:00
'points' : open [ 1 ] ,
'data' : open [ 0 ]
}
} ;
2014-09-18 20:55:40 -07:00
if ( ( start = closed [ 0 ] [ 0 ] . closed _at ) < opts . milestone . created _at ) {
opts . milestone . created _at = start ;
}
2014-09-18 19:30:31 -07:00
return cb ( null ) ;
} ) ;
} , function ( cb ) {
var total ;
total = opts . issues . open . points + opts . issues . closed . points ;
return async . parallel ( [ _ . partial ( chart . actual , opts . issues . closed . data , opts . milestone . created _at , total ) , _ . partial ( chart . ideal , opts . milestone . created _at , opts . milestone . due _on , total ) ] , function ( err , values ) {
if ( values [ 0 ] . length ) {
values . push ( chart . trendline ( values [ 0 ] , opts . milestone . created _at , opts . milestone . due _on ) ) ;
}
return chart . render ( values , cb ) ;
} ) ;
}
] , cb ) ;
} ;
} ) ;
2014-09-14 13:14:57 -07:00
// request.coffee
root . require . register ( 'burnchart/src/modules/request.js' , function ( exports , require , module ) {
2014-09-02 19:42:11 -07:00
2014-09-14 13:14:57 -07:00
var defaults , error , headers , request , response , user ;
2014-09-02 19:42:11 -07:00
2014-09-13 19:10:10 -07:00
user = require ( '../models/user' ) ;
2014-09-02 19:42:11 -07:00
2014-09-14 13:14:57 -07:00
superagent . parse = {
'application/json' : function ( res ) {
var e ;
try {
return JSON . parse ( res ) ;
} catch ( _error ) {
e = _error ;
return { } ;
}
}
} ;
2014-09-02 19:42:11 -07:00
2014-09-14 13:14:57 -07:00
defaults = {
'github' : {
'host' : 'api.github.com' ,
'protocol' : 'https'
}
} ;
module . exports = {
'repo' : function ( repo , cb ) {
var data ;
data = _ . defaults ( {
'path' : "/repos/" + repo . owner + "/" + repo . name ,
'headers' : headers ( user . get ( 'token' ) )
} , defaults . github ) ;
return request ( data , cb ) ;
} ,
'allMilestones' : function ( repo , cb ) {
var data ;
data = _ . defaults ( {
'path' : "/repos/" + repo . owner + "/" + repo . name + "/milestones" ,
'query' : {
'state' : 'open' ,
'sort' : 'due_date' ,
'direction' : 'asc'
} ,
'headers' : headers ( user . get ( 'token' ) )
} , defaults . github ) ;
return request ( data , cb ) ;
} ,
'oneMilestone' : function ( repo , number , cb ) {
2014-09-18 19:30:31 -07:00
var data ;
data = _ . defaults ( {
2014-09-14 13:14:57 -07:00
'path' : "/repos/" + repo . owner + "/" + repo . name + "/milestones/" + number ,
'query' : {
'state' : 'open' ,
'sort' : 'due_date' ,
'direction' : 'asc'
} ,
'headers' : headers ( user . get ( 'token' ) )
2014-09-18 19:30:31 -07:00
} , defaults . github ) ;
return request ( data , cb ) ;
2014-09-14 13:14:57 -07:00
} ,
'allIssues' : function ( repo , query , cb ) {
2014-09-18 19:30:31 -07:00
var data ;
data = _ . defaults ( {
2014-09-14 13:14:57 -07:00
'path' : "/repos/" + repo . owner + "/" + repo . name + "/issues" ,
'query' : _ . extend ( query , {
'per_page' : '100'
} ) ,
'headers' : headers ( user . get ( 'token' ) )
2014-09-18 19:30:31 -07:00
} , defaults . github ) ;
return request ( data , cb ) ;
2014-09-14 13:14:57 -07:00
}
} ;
2014-09-02 19:42:11 -07:00
2014-09-14 13:14:57 -07:00
request = function ( _arg , cb ) {
var exited , headers , host , k , path , protocol , q , query , req , timeout , v ;
protocol = _arg . protocol , host = _arg . host , path = _arg . path , query = _arg . query , headers = _arg . headers ;
exited = false ;
q = query ? '?' + ( ( function ( ) {
var _results ;
_results = [ ] ;
for ( k in query ) {
v = query [ k ] ;
_results . push ( "" + k + "=" + v ) ;
}
return _results ;
} ) ( ) ) . join ( '&' ) : '' ;
req = superagent . get ( "" + protocol + "://" + host + path + q ) ;
for ( k in headers ) {
v = headers [ k ] ;
req . set ( k , v ) ;
}
timeout = setTimeout ( function ( ) {
exited = true ;
return cb ( 'Request has timed out' ) ;
} , 1e4 ) ;
return req . end ( function ( err , data ) {
if ( exited ) {
return ;
}
exited = true ;
clearTimeout ( timeout ) ;
return response ( err , data , cb ) ;
2014-09-02 19:42:11 -07:00
} ) ;
2014-09-14 13:14:57 -07:00
} ;
2014-09-02 19:42:11 -07:00
2014-09-14 13:14:57 -07:00
response = function ( err , data , cb ) {
var _ref ;
if ( err ) {
return cb ( error ( err ) ) ;
}
if ( data . statusType !== 2 ) {
if ( ( data != null ? ( _ref = data . body ) != null ? _ref . message : void 0 : void 0 ) != null ) {
return cb ( data . body . message ) ;
}
return cb ( data . error . message ) ;
}
return cb ( null , data . body ) ;
} ;
2014-09-02 19:42:11 -07:00
2014-09-14 13:14:57 -07:00
headers = function ( token ) {
var h ;
h = _ . extend ( { } , {
'Content-Type' : 'application/json' ,
'Accept' : 'application/vnd.github.v3'
} ) ;
if ( token != null ) {
h . Authorization = "token " + token ;
}
return h ;
} ;
2014-09-02 19:42:11 -07:00
2014-09-14 13:14:57 -07:00
error = function ( err ) {
var message ;
switch ( false ) {
case ! _ . isString ( err ) :
message = err ;
break ;
case ! _ . isArray ( err ) :
message = err [ 1 ] ;
break ;
case ! ( _ . isObject ( err ) && _ . isString ( err . message ) ) :
message = err . message ;
}
if ( ! message ) {
try {
message = JSON . stringify ( err ) ;
} catch ( _error ) {
message = err . toString ( ) ;
}
}
return message ;
} ;
2014-09-01 20:28:28 -07:00
} ) ;
2014-09-21 11:37:47 -07:00
// router.coffee
root . require . register ( 'burnchart/src/modules/router.js' , function ( exports , require , module ) {
2014-10-08 20:04:10 -07:00
var addProject , c , el , mediator , route , routes , system , view ,
2014-09-26 20:17:06 -07:00
_ _slice = [ ] . slice ;
2014-09-21 11:37:47 -07:00
mediator = require ( './mediator' ) ;
2014-09-29 21:31:51 -07:00
system = require ( '../models/system' ) ;
2014-09-21 11:37:47 -07:00
el = '#page' ;
2014-10-08 20:04:10 -07:00
addProject = function ( page , owner , name ) {
return mediator . fire ( '!projects/add' , {
owner : owner ,
name : name
} ) ;
} ;
c = function ( name , fns ) {
var fn , _i , _len , _results ;
if ( fns == null ) {
fns = [ ] ;
}
_results = [ ] ;
for ( _i = 0 , _len = fns . length ; _i < _len ; _i ++ ) {
fn = fns [ _i ] ;
_results . push ( _ . partial ( fn , name ) ) ;
}
return _results ;
} ;
view = null ;
2014-09-26 20:17:06 -07:00
route = function ( ) {
var Page , args , page ;
page = arguments [ 0 ] , args = 2 <= arguments . length ? _ _slice . call ( arguments , 1 ) : [ ] ;
2014-10-08 20:04:10 -07:00
if ( view != null ) {
view . teardown ( ) ;
}
mediator . fire ( '!app/notify/hide' ) ;
2014-09-21 11:37:47 -07:00
Page = require ( "../views/pages/" + page ) ;
2014-10-08 20:04:10 -07:00
return view = new Page ( {
2014-09-21 11:37:47 -07:00
el : el ,
'data' : {
2014-09-26 20:17:06 -07:00
'route' : args
2014-09-21 11:37:47 -07:00
}
} ) ;
} ;
2014-10-02 21:00:31 -07:00
routes = {
2014-10-08 20:04:10 -07:00
'/' : c ( 'index' , [ route ] ) ,
'/new/project' : c ( 'new' , [ route ] ) ,
'/:owner/:name' : c ( 'project' , [ addProject , route ] ) ,
'/:owner/:name/:milestone' : c ( 'chart' , [ addProject , route ] ) ,
2014-09-26 20:17:06 -07:00
'/reset' : function ( ) {
2014-09-21 11:37:47 -07:00
mediator . fire ( '!projects/clear' ) ;
return window . location . hash = '#' ;
2014-09-25 19:57:55 -07:00
} ,
2014-09-26 20:17:06 -07:00
'/notify' : function ( ) {
2014-09-29 21:31:51 -07:00
var done ;
done = system . async ( ) ;
2014-09-26 21:01:58 -07:00
mediator . fire ( '!app/notify' , {
'text' : 'You have some interesting news in your inbox. Go check it out now.' ,
2014-09-30 20:16:47 -07:00
'type' : 'warn'
2014-09-26 21:01:58 -07:00
} ) ;
2014-09-29 21:31:51 -07:00
window . location . hash = '#' ;
return _ . delay ( done , 3e3 ) ;
2014-09-21 11:37:47 -07:00
}
2014-10-02 21:00:31 -07:00
} ;
module . exports = Router ( routes ) . configure ( {
2014-10-08 20:04:10 -07:00
'strict' : false ,
notfound : function ( ) {
throw 404 ;
}
2014-09-26 20:17:06 -07:00
} ) ;
2014-09-21 11:37:47 -07:00
} ) ;
2014-10-08 20:04:10 -07:00
// app.mustache
root . require . register ( 'burnchart/src/templates/app.js' , function ( exports , require , module ) {
module . exports = [ "<div id=\"app\">" , " <Notify/>" , " <Header/>" , "" , " <div id=\"page\">" , " <!-- content loaded from a router -->" , " </div>" , "" , " <div id=\"footer\">" , " <div class=\"wrap\">" , " © 2012-2014 <a href=\"http://cloudfi.re\">Cloudfire Systems</a>" , " </div>" , " </div>" , "</div>" ] . join ( "\n" ) ;
} ) ;
2014-09-13 19:10:10 -07:00
// header.mustache
root . require . register ( 'burnchart/src/templates/header.js' , function ( exports , require , module ) {
2014-09-12 20:05:05 -07:00
2014-10-03 19:39:35 -07:00
module . exports = [ "<div id=\"head\">" , " {{#with user}}" , " {{#loaded}}" , " <div class=\"right\" intro=\"fade\">" , " {{#displayName}}" , " {{displayName}} logged in" , " {{else}}" , " <a class=\"github\" on-click=\"!login\"><Icons icon=\"github\"/> Sign In</a>" , " {{/displayName}}" , " </div>" , " {{/loaded}}" , " {{/with}}" , "" , " <a id=\"icon\" href=\"#\">" , " <Icons icon=\"{{icon}}\"/>" , " </a>" , "" , " <div class=\"q\">" , " <Icons icon=\"search\"/>" , " <Icons icon=\"down-open\"/>" , " <input type=\"text\" placeholder=\"Jump to...\">" , " </div>" , "" , " <ul>" , " <li><a href=\"#new/project\" class=\"add\"><Icons icon=\"plus-circled\"/> Add a Project</a></li>" , " <li><a href=\"#\" class=\"faq\">FAQ</a></li>" , " <li><a href=\"#reset\">DB Reset</a></li>" , " <li><a href=\"#notify\">Notify</a></li>" , " </ul>" , "</div>" ] . join ( "\n" ) ;
2014-09-12 20:05:05 -07:00
} ) ;
2014-09-13 19:10:10 -07:00
// hero.mustache
root . require . register ( 'burnchart/src/templates/hero.js' , function ( exports , require , module ) {
2014-09-26 20:17:06 -07:00
module . exports = [ "{{^projects.list}}" , " <div id=\"hero\">" , " <div class=\"content\">" , " <Icons icon=\"address\"/>" , " <h2>See your project progress</h2>" , " <p>Not sure where to start? Just add a demo repo to see a chart. There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.</p>" , " <div class=\"cta\">" , " <a href=\"#new/project\" class=\"primary\"><Icons icon=\"plus-circled\"/> Add your project</a>" , " <a href=\"#\" class=\"secondary\">Read the Guide</a>" , " </div>" , " </div>" , " </div>" , "{{/projects.list}}" ] . join ( "\n" ) ;
2014-09-25 19:57:55 -07:00
} ) ;
// icons.mustache
root . require . register ( 'burnchart/src/templates/icons.js' , function ( exports , require , module ) {
module . exports = [ "{{#code}}" , " <span class=\"icon {{icon}}\">{{{ '&#' + code + ';' }}}</span>" , "{{/code}}" ] . join ( "\n" ) ;
2014-09-13 19:10:10 -07:00
} ) ;
2014-09-26 21:01:58 -07:00
// milestones.mustache
root . require . register ( 'burnchart/src/templates/milestones.js' , function ( exports , require , module ) {
2014-10-09 19:21:23 -07:00
module . exports = [ "<div id=\"projects\">" , " <div class=\"header\">" , " <a href=\"#\" class=\"sort\"><Icons icon=\"sort-alphabet\"/> Sorted by priority</a>" , " <h2>Milestones</h2>" , " </div>" , "" , " <table>" , " {{#project.milestones}}" , " <tr>" , " <td>" , " <a class=\"milestone\" href=\"#{{project.owner}}/{{project.name}}/{{number}}\">{{ title }}</a>" , " </td>" , " <td style=\"width:1%\">" , " <div class=\"progress\">" , " <span class=\"percent\">{{Math.floor(progress)}}%</span>" , " <span class=\"due\">{{{ due }}}</span>" , " <div class=\"outer bar\">" , " <div class=\"inner bar {{on_time}}\" style=\"width:{{progress}}%\"></div>" , " </div>" , " </div>" , " </td>" , " </tr>" , " {{/project.milestones}}" , " </table>" , "" , " <div class=\"footer\">" , " <a href=\"#\"><Icons icon=\"cog\"/> Edit</a>" , " </div>" , "</div>" ] . join ( "\n" ) ;
2014-09-26 21:01:58 -07:00
} ) ;
2014-09-25 19:57:55 -07:00
// notify.mustache
root . require . register ( 'burnchart/src/templates/notify.js' , function ( exports , require , module ) {
2014-09-30 20:16:47 -07:00
module . exports = [ "{{#text}}" , " {{#system}}" , " <div id=\"notify\" class=\"{{type}} system\" style=\"top:{{top}}%\">" , " <Icons icon=\"{{icon}}\"/>" , " <p>{{text}}</p>" , " </div>" , " {{else}}" , " <div id=\"notify\" class=\"{{type}}\" style=\"top:{{-top}}px\">" , " <span class=\"close\" on-click=\"close\" />" , " <Icons icon=\"{{icon}}\"/>" , " <p>{{text}}</p>" , " </div>" , " {{/system}}" , "{{/text}}" ] . join ( "\n" ) ;
2014-09-13 19:10:10 -07:00
} ) ;
2014-09-26 20:17:06 -07:00
// chart.mustache
root . require . register ( 'burnchart/src/templates/pages/chart.js' , function ( exports , require , module ) {
2014-09-13 19:10:10 -07:00
2014-09-26 20:17:06 -07:00
module . exports = [ "<div id=\"title\">" , " <div class=\"wrap\">" , " <h2 class=\"title\">{{ format.title(milestone.title) }}</h2>" , " <span class=\"sub\">{{{ format.due(milestone.due_on) }}}</span>" , " <p class=\"description\">{{{ format.markdown(milestone.description) }}}</p>" , " </div>" , "</div>" , "" , "<div id=\"content\" class=\"wrap\">" , " <div id=\"chart\">" , " <div id=\"svg\"></div>" , " </div>" , "</div>" ] . join ( "\n" ) ;
2014-09-13 19:10:10 -07:00
} ) ;
// index.mustache
root . require . register ( 'burnchart/src/templates/pages/index.js' , function ( exports , require , module ) {
2014-09-25 19:57:55 -07:00
module . exports = [ "<div id=\"content\" class=\"wrap\">" , " <Hero/>" , " <Projects/>" , "</div>" ] . join ( "\n" ) ;
2014-09-13 19:10:10 -07:00
} ) ;
2014-09-26 20:17:06 -07:00
// new.mustache
root . require . register ( 'burnchart/src/templates/pages/new.js' , function ( exports , require , module ) {
2014-09-17 20:00:01 -07:00
2014-10-03 20:11:40 -07:00
module . exports = [ "<div id=\"content\" class=\"wrap\">" , " <div id=\"add\">" , " <div class=\"header\">" , " <h2>Add a Project</h2>" , " <p>Type in the name of the repository as you would normally. If you'd like to add a private GitHub project, <a href=\"#\">Sign In</a> first.</p>" , " </div>" , "" , " <div class=\"form\">" , " <table>" , " <tr>" , " <td>" , " <input type=\"text\" placeholder=\"user/repo\" autocomplete=\"off\" value=\"{{value}}\" on-keyup=\"submit:{{value}}\">" , " </td>" , " <td>" , " <a on-click=\"submit:{{value}}\">Add</a>" , " </td>" , " </tr>" , " </table>" , " </div>" , " </div>" , "</div>" ] . join ( "\n" ) ;
2014-09-26 20:17:06 -07:00
} ) ;
// project.mustache
root . require . register ( 'burnchart/src/templates/pages/project.js' , function ( exports , require , module ) {
2014-10-09 19:21:23 -07:00
module . exports = [ "<div intro=\"fade\">" , " {{#ready}}" , " <div id=\"title\">" , " <div class=\"wrap\">" , " <h2 class=\"title\">{{route.join('/')}}</h2>" , " </div>" , " </div>" , "" , " <div id=\"content\" class=\"wrap\">" , " <Milestones project=\"{{project}}\"/>" , " </div>" , " {{/ready}}" , "</div>" ] . join ( "\n" ) ;
2014-09-17 20:00:01 -07:00
} ) ;
2014-09-13 19:10:10 -07:00
// projects.mustache
root . require . register ( 'burnchart/src/templates/projects.js' , function ( exports , require , module ) {
2014-09-26 21:01:58 -07:00
module . exports = [ "{{#projects.list.length}}" , " <div id=\"projects\">" , " <div class=\"header\">" , " <a href=\"#\" class=\"sort\"><Icons icon=\"sort-alphabet\"/> Sorted by priority</a>" , " <h2>Projects</h2>" , " </div>" , "" , " <table>" , " {{#projects.list}}" , " {{#milestones}}" , " <tr>" , " <td class=\"repo\">" , " <a class=\"project\" href=\"#{{owner}}/{{name}}\">{{owner}}/{{name}}</a>" , " </td>" , " <td>" , " <a class=\"milestone\" href=\"#{{owner}}/{{name}}/{{number}}\">{{ title }}</a>" , " </td>" , " <td style=\"width:1%\">" , " <div class=\"progress\">" , " <span class=\"percent\">{{Math.floor(format.progress(closed_issues, open_issues))}}%</span>" , " <span class=\"due\">{{{ format.due(due_on) }}}</span>" , " <div class=\"outer bar\">" , " <div class=\"inner bar {{format.onTime(this)}}\" style=\"width:{{format.progress(closed_issues, open_issues)}}%\"></div>" , " </div>" , " </div>" , " </td>" , " </tr>" , " {{/milestones}}" , " {{/projects.list}}" , " </table>" , "" , " <div class=\"footer\">" , " <a href=\"#\"><Icons icon=\"cog\"/> Edit</a>" , " </div>" , " </div>" , "{{/projects.list.length}}" , "" , "<!--" , " <tr>" , " <td><a class=\"repo\" href=\"#\">radekstepan/disposable</a></td>" , " <td><span class=\"milestone\">Milestone 1.0 <span class=\"icon down-open\"></span></td>" , " <td>" , " <div class=\"progress\">" , " <span class=\"percent\">40%</span>" , " <span class=\"due\">due on Friday</span>" , " <div class=\"outer bar\">" , " <div class=\"inner bar red\" style=\"width:40%\"></div>" , " </div>" , " </div>" , " </td>" , " </tr>" , " <tr class=\"done\">" , " <td><a class=\"repo\" href=\"#\">radekstepan/burnchart</a></td>" , " <td><span class=\"milestone\">Beta Milestone <span class=\"icon down-open\"></span></a></td>" , " <td>" , " <div class=\"progress\">" , " <span class=\"percent\">100%</span>" , " <span class=\"due\">due tomorrow</span>" , " <div class=\"outer bar\">" , " <div class=\"inner bar green\" style=\"width:100%\"></div>" , " </div>" , " </div>" , " </td>" , " </tr>" , " <tr>" , " <td><a class=\"repo\" href=\"#\">intermine/intermine</a></td>" , " <td><span class=\"milestone\">Emma Release 96 <span class=\"icon down-open\"></span></a></td>" , " <td>" , " <div class=\"progress\">" , " <span class=\"percent\">27%</span>" , " <span class=\"due\">due in 2 weeks</span>" , " <div class=\"outer bar\">" , " <div class=\"inner bar red\" style=\"width:27%\"></div>" , " </div>" , " </div>" , " </td>" , " </tr>" , " <tr>" , " <td><a class=\"repo\" href=\"#\">microsoft/windows</a></td>" , " <td><span class=\"milestone\">RC 9 <span class=\"icon down-open\"></span></a></td>" , " <td>" , " <div class=\"progress\">" , " <span class=\"percent\">90%</span>" , " <span class=\"due red\">overdue by a month</span>" , " <div class=\"outer bar\">" , " <div class=\"inner bar red\" style=\"width:90%\"></div>" , " </div>" , " </div>" , " </td>" , " </tr>" , "-->" ] . join ( "\n" ) ;
2014-09-14 13:14:57 -07:00
} ) ;
// date.coffee
root . require . register ( 'burnchart/src/utils/date.js' , function ( exports , require , module ) {
module . exports = {
now : function ( ) {
return new Date ( ) . toJSON ( ) ;
}
} ;
} ) ;
// format.coffee
root . require . register ( 'burnchart/src/utils/format.js' , function ( exports , require , module ) {
2014-09-20 11:45:28 -07:00
var config ;
config = require ( '../models/config' ) ;
2014-09-14 13:14:57 -07:00
module . exports = {
'progress' : _ . memoize ( function ( a , b ) {
return 100 * ( a / ( b + a ) ) ;
} ) ,
'onTime' : _ . memoize ( function ( milestone ) {
2014-10-09 19:21:23 -07:00
var a , b , c , time ;
2014-09-20 11:45:28 -07:00
if ( ! milestone . due _on ) {
return 'green' ;
}
2014-09-14 13:14:57 -07:00
a = + new Date ( milestone . created _at ) ;
b = + ( new Date ) ;
c = + new Date ( milestone . due _on ) ;
time = this . progress ( b - a , c - b ) ;
2014-10-09 19:21:23 -07:00
return [ 'red' , 'green' ] [ + ( milestone . progress > time ) ] ;
2014-09-20 11:45:28 -07:00
} , function ( m ) {
return [ m . created _at , m . number ] . join ( '/' ) ;
2014-09-14 13:14:57 -07:00
} ) ,
'fromNow' : _ . memoize ( function ( jsonDate ) {
return moment ( new Date ( jsonDate ) ) . fromNow ( ) ;
2014-09-19 20:33:25 -07:00
} ) ,
'due' : function ( jsonDate ) {
2014-09-20 11:45:28 -07:00
if ( ! jsonDate ) {
return ' ' ;
}
2014-09-19 20:33:25 -07:00
return [ 'due' , this . fromNow ( jsonDate ) ] . join ( ' ' ) ;
} ,
'markdown' : function ( markup ) {
return marked ( markup ) ;
2014-09-21 14:26:01 -07:00
} ,
'title' : function ( text ) {
if ( text . toLowerCase ( ) . indexOf ( 'milestone' ) > - 1 ) {
return text ;
} else {
return [ 'Milestone' , text ] . join ( ' ' ) ;
}
2014-09-25 19:57:55 -07:00
} ,
hexToDecimal : function ( hex ) {
return parseInt ( hex , 16 ) ;
2014-09-19 20:33:25 -07:00
}
2014-09-14 13:14:57 -07:00
} ;
} ) ;
2014-10-03 20:11:40 -07:00
// key.coffee
root . require . register ( 'burnchart/src/utils/key.js' , function ( exports , require , module ) {
module . exports = {
is : function ( evt ) {
var _ref ;
return ( _ref = evt . original . type ) === 'keyup' || _ref === 'keydown' ;
} ,
isEnter : function ( evt ) {
return evt . original . which === 13 ;
}
} ;
} ) ;
2014-09-14 13:14:57 -07:00
// mixins.coffee
root . require . register ( 'burnchart/src/utils/mixins.js' , function ( exports , require , module ) {
_ . mixin ( {
'pluckMany' : function ( source , keys ) {
if ( ! _ . isArray ( keys ) ) {
throw '`keys` needs to be an Array' ;
}
return _ . map ( source , function ( item ) {
var obj ;
obj = { } ;
_ . each ( keys , function ( key ) {
return obj [ key ] = item [ key ] ;
} ) ;
return obj ;
} ) ;
}
} ) ;
2014-09-13 19:10:10 -07:00
} ) ;
// model.coffee
root . require . register ( 'burnchart/src/utils/model.js' , function ( exports , require , module ) {
2014-09-12 20:05:05 -07:00
module . exports = function ( opts ) {
var Model , model ;
Model = Ractive . extend ( opts ) ;
model = new Model ( ) ;
model . render ( ) ;
return model ;
} ;
} ) ;
2014-09-13 19:10:10 -07:00
// header.coffee
root . require . register ( 'burnchart/src/views/header.js' , function ( exports , require , module ) {
2014-08-30 10:17:46 -07:00
2014-09-29 21:31:51 -07:00
var Icons , firebase , system , user ;
2014-09-12 20:05:05 -07:00
2014-09-29 21:31:51 -07:00
system = require ( '../models/system' ) . system ;
2014-09-12 20:05:05 -07:00
2014-09-29 21:31:51 -07:00
firebase = require ( '../modules/firebase' ) ;
2014-09-12 20:05:05 -07:00
2014-09-13 19:10:10 -07:00
user = require ( '../models/user' ) ;
2014-09-25 19:57:55 -07:00
Icons = require ( './icons' ) ;
2014-09-13 19:10:10 -07:00
module . exports = Ractive . extend ( {
2014-10-08 20:04:10 -07:00
'name' : 'views/header' ,
2014-09-13 19:10:10 -07:00
'template' : require ( '../templates/header' ) ,
2014-09-25 19:57:55 -07:00
'data' : {
'user' : user ,
'icon' : 'fire-station'
} ,
2014-10-08 20:04:10 -07:00
'components' : {
Icons : Icons
} ,
'adapt' : [ Ractive . adaptors . Ractive ] ,
2014-10-02 21:00:31 -07:00
onconstruct : function ( ) {
return this . on ( '!login' , function ( ) {
2014-09-13 19:10:10 -07:00
return firebase . login ( function ( err ) {
if ( err ) {
throw err ;
}
} ) ;
2014-09-12 20:05:05 -07:00
} ) ;
2014-10-02 21:00:31 -07:00
} ,
onrender : function ( ) {
var _this = this ;
2014-09-29 21:31:51 -07:00
return system . observe ( 'loading' , function ( ya ) {
2014-09-25 20:45:31 -07:00
return _this . set ( 'icon' , ya ? 'spinner1' : 'fire-station' ) ;
2014-09-25 19:57:55 -07:00
} ) ;
2014-10-08 20:04:10 -07:00
}
2014-09-13 19:10:10 -07:00
} ) ;
} ) ;
// hero.coffee
root . require . register ( 'burnchart/src/views/hero.js' , function ( exports , require , module ) {
2014-09-25 19:57:55 -07:00
var Icons , mediator , projects ;
2014-09-13 19:10:10 -07:00
mediator = require ( '../modules/mediator' ) ;
projects = require ( '../models/projects' ) ;
2014-09-25 19:57:55 -07:00
Icons = require ( './icons' ) ;
2014-09-13 19:10:10 -07:00
module . exports = Ractive . extend ( {
2014-10-08 20:04:10 -07:00
'name' : 'views/hero' ,
2014-09-13 19:10:10 -07:00
'template' : require ( '../templates/hero' ) ,
'data' : {
projects : projects
} ,
2014-09-25 19:57:55 -07:00
'components' : {
Icons : Icons
} ,
2014-09-13 19:10:10 -07:00
'adapt' : [ Ractive . adaptors . Ractive ]
2014-09-12 20:05:05 -07:00
} ) ;
2014-08-30 09:00:11 -07:00
} ) ;
2014-09-25 19:57:55 -07:00
// icons.coffee
root . require . register ( 'burnchart/src/views/icons.js' , function ( exports , require , module ) {
var codes , utils ;
utils = require ( '../utils/format' ) ;
codes = {
'cog' : '\e800' ,
'search' : '\e801' ,
'github' : '\e802' ,
'address' : '\e803' ,
'plus-circled' : '\e804' ,
'fire-station' : '\e805' ,
'sort-alphabet' : '\e806' ,
'down-open' : '\e807' ,
'spin6' : '\e808' ,
'megaphone' : '\e809' ,
2014-09-25 20:45:31 -07:00
'spin4' : '\e80a' ,
'spinner1' : '\e80b'
2014-09-25 19:57:55 -07:00
} ;
module . exports = Ractive . extend ( {
2014-10-08 20:04:10 -07:00
'name' : 'views/icons' ,
2014-09-25 19:57:55 -07:00
'template' : require ( '../templates/icons' ) ,
'isolated' : true ,
2014-10-02 21:00:31 -07:00
onrender : function ( ) {
2014-09-25 19:57:55 -07:00
return this . observe ( 'icon' , function ( icon ) {
var hex ;
if ( icon && ( hex = codes [ icon ] ) ) {
return this . set ( 'code' , utils . hexToDecimal ( hex ) ) ;
} else {
return this . set ( 'code' , null ) ;
}
} ) ;
}
} ) ;
} ) ;
2014-09-26 21:01:58 -07:00
// milestones.coffee
root . require . register ( 'burnchart/src/views/milestones.js' , function ( exports , require , module ) {
var Icons , mediator , projects ;
mediator = require ( '../modules/mediator' ) ;
projects = require ( '../models/projects' ) ;
Icons = require ( './icons' ) ;
module . exports = Ractive . extend ( {
2014-10-08 20:04:10 -07:00
'name' : 'views/milestones' ,
2014-09-26 21:01:58 -07:00
'template' : require ( '../templates/milestones' ) ,
'components' : {
Icons : Icons
} ,
2014-10-08 20:04:10 -07:00
'adapt' : [ Ractive . adaptors . Ractive ]
2014-09-26 21:01:58 -07:00
} ) ;
} ) ;
2014-09-25 20:16:23 -07:00
// notify.coffee
root . require . register ( 'burnchart/src/views/notify.js' , function ( exports , require , module ) {
var HEIGHT , Icons , mediator ;
mediator = require ( '../modules/mediator' ) ;
Icons = require ( './icons' ) ;
HEIGHT = 68 ;
module . exports = Ractive . extend ( {
2014-10-08 20:04:10 -07:00
'name' : 'views/notify' ,
2014-09-25 20:16:23 -07:00
'template' : require ( '../templates/notify' ) ,
'data' : {
2014-10-02 21:00:31 -07:00
'top' : HEIGHT ,
'hidden' : true ,
'defaults' : {
2014-09-26 21:01:58 -07:00
'text' : '' ,
'type' : '' ,
'system' : false ,
2014-09-27 12:19:14 -07:00
'icon' : 'megaphone' ,
'ttl' : 5e3
2014-10-02 21:00:31 -07:00
}
} ,
2014-10-08 20:04:10 -07:00
'components' : {
Icons : Icons
} ,
'adapt' : [ Ractive . adaptors . Ractive ] ,
2014-10-02 21:00:31 -07:00
show : function ( opts ) {
var pos ;
this . set ( 'hidden' , false ) ;
this . set ( opts = _ . defaults ( opts , this . data . defaults ) ) ;
pos = [ 0 , 50 ] [ + opts . system ] ;
this . animate ( 'top' , pos , {
'easing' : d3 . ease ( 'bounce' ) ,
'duration' : 800
} ) ;
if ( ! opts . ttl ) {
return ;
}
return _ . delay ( _ . bind ( this . hide , this ) , opts . ttl ) ;
} ,
hide : function ( ) {
var _this = this ;
if ( this . data . hidden ) {
return ;
}
this . set ( 'hidden' , true ) ;
return this . animate ( 'top' , HEIGHT , {
'easing' : d3 . ease ( 'back' ) ,
'complete' : function ( ) {
return _this . set ( 'text' , null ) ;
2014-09-30 20:16:47 -07:00
}
2014-10-02 21:00:31 -07:00
} ) ;
} ,
onconstruct : function ( ) {
mediator . on ( '!app/notify' , _ . bind ( this . show , this ) ) ;
mediator . on ( '!app/notify/hide' , _ . bind ( this . hide , this ) ) ;
return this . on ( 'close' , this . hide ) ;
2014-10-08 20:04:10 -07:00
}
2014-09-25 20:16:23 -07:00
} ) ;
} ) ;
2014-09-26 20:17:06 -07:00
// chart.coffee
root . require . register ( 'burnchart/src/views/pages/chart.js' , function ( exports , require , module ) {
2014-09-01 20:28:28 -07:00
2014-09-29 21:31:51 -07:00
var format , milestone , project , system ;
system = require ( '../../models/system' ) ;
2014-09-13 19:10:10 -07:00
2014-09-26 20:17:06 -07:00
milestone = require ( '../../modules/milestone' ) ;
2014-09-13 19:10:10 -07:00
2014-09-26 20:17:06 -07:00
project = require ( '../../modules/project' ) ;
format = require ( '../../utils/format' ) ;
2014-09-01 20:28:28 -07:00
module . exports = Ractive . extend ( {
2014-10-08 20:04:10 -07:00
'name' : 'views/pages/chart' ,
2014-09-26 20:17:06 -07:00
'template' : require ( '../../templates/pages/chart' ) ,
'adapt' : [ Ractive . adaptors . Ractive ] ,
2014-09-13 19:10:10 -07:00
'data' : {
2014-09-26 20:17:06 -07:00
format : format
2014-09-13 19:10:10 -07:00
} ,
2014-10-02 21:00:31 -07:00
onrender : function ( ) {
2014-09-26 20:17:06 -07:00
var name , owner , route , _ref ,
_this = this ;
2014-10-08 20:04:10 -07:00
return ;
2014-09-26 20:17:06 -07:00
_ref = this . get ( 'route' ) , owner = _ref [ 0 ] , name = _ref [ 1 ] , milestone = _ref [ 2 ] ;
route = {
owner : owner ,
name : name ,
milestone : milestone
} ;
document . title = "" + owner + "/" + name + "/" + milestone ;
return milestone . get ( route , function ( err , warn , obj ) {
if ( err ) {
throw err ;
}
if ( warn ) {
throw warn ;
}
_this . set ( 'milestone' , obj ) ;
route . milestone = obj ;
return project ( route , function ( err ) {
if ( err ) {
throw err ;
}
2014-09-13 19:10:10 -07:00
} ) ;
} ) ;
2014-09-01 20:28:28 -07:00
}
} ) ;
} ) ;
// index.coffee
2014-09-13 19:10:10 -07:00
root . require . register ( 'burnchart/src/views/pages/index.js' , function ( exports , require , module ) {
2014-09-01 20:28:28 -07:00
2014-09-14 13:14:57 -07:00
var Hero , Projects , format ;
2014-09-12 20:05:05 -07:00
2014-09-13 19:10:10 -07:00
Hero = require ( '../hero' ) ;
2014-09-12 20:05:05 -07:00
2014-09-13 19:10:10 -07:00
Projects = require ( '../projects' ) ;
2014-09-12 20:05:05 -07:00
2014-09-14 13:14:57 -07:00
format = require ( '../../utils/format' ) ;
2014-09-01 20:28:28 -07:00
module . exports = Ractive . extend ( {
2014-10-08 20:04:10 -07:00
'name' : 'views/pages/index' ,
2014-09-13 19:10:10 -07:00
'template' : require ( '../../templates/pages/index' ) ,
2014-09-12 20:05:05 -07:00
'components' : {
Hero : Hero ,
Projects : Projects
2014-09-14 13:14:57 -07:00
} ,
'data' : {
2014-09-17 20:00:01 -07:00
format : format
2014-09-21 11:37:47 -07:00
} ,
2014-10-02 21:00:31 -07:00
onrender : function ( ) {
return document . title = 'Burnchart: GitHub Burndown Chart as a Service' ;
2014-09-17 20:00:01 -07:00
}
} ) ;
} ) ;
2014-09-26 20:17:06 -07:00
// new.coffee
root . require . register ( 'burnchart/src/views/pages/new.js' , function ( exports , require , module ) {
2014-09-17 20:00:01 -07:00
2014-10-03 20:11:40 -07:00
var key , mediator , system , user ;
2014-09-19 20:33:25 -07:00
2014-09-26 20:17:06 -07:00
mediator = require ( '../../modules/mediator' ) ;
2014-09-18 19:30:31 -07:00
2014-10-03 20:11:40 -07:00
system = require ( '../../models/system' ) ;
2014-09-26 20:17:06 -07:00
user = require ( '../../models/user' ) ;
2014-10-03 20:11:40 -07:00
key = require ( '../../utils/key' ) ;
2014-09-26 20:17:06 -07:00
module . exports = Ractive . extend ( {
2014-10-08 20:04:10 -07:00
'name' : 'views/pages/new' ,
2014-09-26 20:17:06 -07:00
'template' : require ( '../../templates/pages/new' ) ,
'data' : {
'value' : 'radekstepan/disposable' ,
user : user
} ,
'adapt' : [ Ractive . adaptors . Ractive ] ,
2014-10-03 20:11:40 -07:00
submit : function ( evt , value ) {
var done , name , owner , _ref ;
if ( key . is ( evt ) && ! key . isEnter ( evt ) ) {
return ;
}
_ref = value . split ( '/' ) , owner = _ref [ 0 ] , name = _ref [ 1 ] ;
done = system . async ( ) ;
return mediator . fire ( '!projects/add' , {
owner : owner ,
name : name
} , function ( err ) {
done ( ) ;
mediator . fire ( '!app/notify' , {
'text' : err || ( "Project " + value + " saved." ) ,
'type' : err ? 'error' : 'success'
} ) ;
return window . location . hash = '#' ;
} ) ;
} ,
2014-10-02 21:00:31 -07:00
onrender : function ( ) {
2014-09-26 20:17:06 -07:00
var autocomplete ;
document . title = 'Add a new project' ;
autocomplete = function ( value ) { } ;
this . observe ( 'value' , _ . debounce ( autocomplete , 200 ) , {
'init' : false
} ) ;
2014-10-03 20:11:40 -07:00
this . el . querySelector ( 'input' ) . focus ( ) ;
return this . on ( 'submit' , this . submit ) ;
2014-09-26 20:17:06 -07:00
}
} ) ;
} ) ;
// project.coffee
root . require . register ( 'burnchart/src/views/pages/project.js' , function ( exports , require , module ) {
2014-10-09 19:21:23 -07:00
var Milestones , config , format , issues , mediator , milestones , projects , system ;
2014-09-26 20:17:06 -07:00
2014-09-26 21:01:58 -07:00
Milestones = require ( '../milestones' ) ;
2014-09-19 20:33:25 -07:00
2014-10-08 20:04:10 -07:00
projects = require ( '../../models/projects' ) ;
system = require ( '../../models/system' ) ;
2014-10-09 19:21:23 -07:00
config = require ( '../../models/config' ) ;
milestones = require ( '../../modules/milestone' ) ;
issues = require ( '../../modules/issues' ) ;
2014-10-08 20:04:10 -07:00
mediator = require ( '../../modules/mediator' ) ;
2014-10-09 19:21:23 -07:00
format = require ( '../../utils/format' ) ;
2014-09-17 20:00:01 -07:00
module . exports = Ractive . extend ( {
2014-10-08 20:04:10 -07:00
'name' : 'views/pages/project' ,
2014-09-26 20:17:06 -07:00
'template' : require ( '../../templates/pages/project' ) ,
'components' : {
2014-09-26 21:01:58 -07:00
Milestones : Milestones
2014-09-19 20:33:25 -07:00
} ,
2014-10-08 20:04:10 -07:00
'data' : {
'ready' : false
} ,
2014-10-02 21:00:31 -07:00
onrender : function ( ) {
2014-10-08 20:04:10 -07:00
var done , name , owner , project , _ref ,
_this = this ;
2014-09-26 20:17:06 -07:00
_ref = this . get ( 'route' ) , owner = _ref [ 0 ] , name = _ref [ 1 ] ;
2014-10-08 20:04:10 -07:00
document . title = "" + owner + "/" + name ;
this . set ( 'project' , project = projects . find ( {
owner : owner ,
name : name
} ) ) ;
if ( ! project ) {
throw 500 ;
}
if ( project . milestones ) {
return this . set ( 'ready' , true ) ;
}
done = system . async ( ) ;
2014-10-09 19:21:23 -07:00
return milestones . getAll ( project , function ( err , warn , list ) {
if ( err || warn ) {
done ( ) ;
if ( err ) {
return mediator . fire ( '!app/notify' , {
'text' : err . toString ( ) ,
'type' : 'alert' ,
'system' : true ,
'ttl' : null
} ) ;
}
if ( warn ) {
return mediator . fire ( '!app/notify' , {
'text' : warn . toString ( ) ,
'type' : 'warn' ,
'system' : true ,
'ttl' : null
} ) ;
}
2014-10-08 20:04:10 -07:00
}
2014-10-09 19:21:23 -07:00
switch ( config . data . chart . points ) {
case 'ONE_SIZE' :
list = _ . map ( list , function ( m ) {
m . progress = format . progress ( m . closed _issues , m . open _issues ) ;
m . on _time = format . onTime ( m ) ;
m . due = format . due ( m . due _on ) ;
return m ;
} ) ;
done ( ) ;
return _this . set ( {
'project.milestones' : list ,
'ready' : true
} ) ;
case 'LABELS' :
return async . map ( list , function ( m , cb ) {
return issues . get _all ( _ . extend ( project , {
'milestone' : m
} ) , function ( err , arr ) {
if ( err ) {
return cb ( err ) ;
}
return issues . filter ( arr , function ( err , filtered , total ) {
return console . log ( filtered , total ) ;
} ) ;
} ) ;
} , function ( err , list ) {
done ( ) ;
if ( err ) {
return mediator . fire ( '!app/notify' , {
'text' : err . toString ( ) ,
'type' : 'alert' ,
'system' : true ,
'ttl' : null
} ) ;
}
return this . set ( {
'project.milestones' : list ,
'ready' : true
} ) ;
} ) ;
2014-10-08 20:04:10 -07:00
}
} ) ;
2014-09-01 20:28:28 -07:00
}
} ) ;
} ) ;
2014-09-13 19:10:10 -07:00
// projects.coffee
root . require . register ( 'burnchart/src/views/projects.js' , function ( exports , require , module ) {
2014-09-12 20:05:05 -07:00
2014-09-25 19:57:55 -07:00
var Icons , mediator , projects ;
2014-09-13 19:10:10 -07:00
mediator = require ( '../modules/mediator' ) ;
projects = require ( '../models/projects' ) ;
2014-09-25 19:57:55 -07:00
Icons = require ( './icons' ) ;
2014-09-13 19:10:10 -07:00
module . exports = Ractive . extend ( {
2014-10-08 20:04:10 -07:00
'name' : 'views/projects' ,
2014-09-13 19:10:10 -07:00
'template' : require ( '../templates/projects' ) ,
'data' : {
projects : projects
} ,
2014-09-25 19:57:55 -07:00
'components' : {
Icons : Icons
} ,
2014-09-13 19:10:10 -07:00
'adapt' : [ Ractive . adaptors . Ractive ]
} ) ;
2014-08-28 19:55:45 -07:00
} ) ;
} ) ( ) ;
// Return the main app.
var main = root . require ( "burnchart/src/app.js" ) ;
// AMD/RequireJS.
if ( typeof define !== 'undefined' && define . amd ) {
define ( "burnchart" , [ /* load deps ahead of time */ ] , function ( ) {
return main ;
} ) ;
}
// CommonJS.
else if ( typeof module !== 'undefined' && module . exports ) {
module . exports = main ;
}
// Globally exported.
else {
root [ "burnchart" ] = main ;
}
// Alias our app.
root . require . alias ( "burnchart/src/app.js" , "burnchart/index.js" ) ;
} ) ( this ) ;