error messaging
This commit is contained in:
parent
abab523883
commit
06cf101400
|
@ -4,25 +4,18 @@ async = require 'async'
|
||||||
Router = require 'route66'
|
Router = require 'route66'
|
||||||
|
|
||||||
config = require './modules/config'
|
config = require './modules/config'
|
||||||
|
render = require './modules/render'
|
||||||
{ Repo } = require './modules/repo'
|
{ Repo } = require './modules/repo'
|
||||||
|
|
||||||
# Render an eco template into selector.
|
|
||||||
show = (selector, template, context = {}) ->
|
|
||||||
tml = require "./templates/#{template}"
|
|
||||||
document.querySelector(selector).innerHTML = tml context
|
|
||||||
|
|
||||||
module.exports = ->
|
module.exports = ->
|
||||||
# Show info notice?
|
# Show info notice?
|
||||||
show 'body', 'info' unless location.hash
|
render 'body', 'info' unless location.hash
|
||||||
|
|
||||||
# A new router.
|
# A new router.
|
||||||
new Router().path
|
new Router().path
|
||||||
'/:user/:repo': ->
|
'/:user/:repo': ->
|
||||||
repo = _.toArray(arguments).join('/')
|
repo = _.toArray(arguments).join('/')
|
||||||
|
|
||||||
# Render the body.
|
|
||||||
show 'body', 'graph'
|
|
||||||
|
|
||||||
# Get config/cache.
|
# Get config/cache.
|
||||||
async.waterfall [ config
|
async.waterfall [ config
|
||||||
# Instantiate.
|
# Instantiate.
|
||||||
|
@ -32,4 +25,4 @@ module.exports = ->
|
||||||
, (repo, cb) ->
|
, (repo, cb) ->
|
||||||
repo.render cb
|
repo.render cb
|
||||||
], (err) ->
|
], (err) ->
|
||||||
throw err if err
|
render 'body', 'error', { text: err.toString() } if err
|
|
@ -18,6 +18,7 @@
|
||||||
"modules/milestones.coffee",
|
"modules/milestones.coffee",
|
||||||
"modules/regex.coffee",
|
"modules/regex.coffee",
|
||||||
"modules/request.coffee",
|
"modules/request.coffee",
|
||||||
|
"modules/render.coffee",
|
||||||
"modules/repo.coffee",
|
"modules/repo.coffee",
|
||||||
"templates/error.eco",
|
"templates/error.eco",
|
||||||
"templates/graph.eco",
|
"templates/graph.eco",
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env coffee
|
||||||
|
|
||||||
|
# Render an eco template into a selector.
|
||||||
|
module.exports = (selector, template, context = {}) ->
|
||||||
|
tml = require "../templates/#{template}"
|
||||||
|
document.querySelector(selector).innerHTML = tml context
|
|
@ -7,6 +7,7 @@ issues = require './issues'
|
||||||
graph = require './graph'
|
graph = require './graph'
|
||||||
reg = require './regex'
|
reg = require './regex'
|
||||||
req = require './request'
|
req = require './request'
|
||||||
|
render = require './render'
|
||||||
|
|
||||||
# Eco templates as functions.
|
# Eco templates as functions.
|
||||||
tml = {}
|
tml = {}
|
||||||
|
@ -23,8 +24,10 @@ class exports.Repo
|
||||||
async.waterfall [ (cb) ->
|
async.waterfall [ (cb) ->
|
||||||
# Get the current milestone.
|
# Get the current milestone.
|
||||||
milestones.get_current self, (err, warn, milestone) ->
|
milestones.get_current self, (err, warn, milestone) ->
|
||||||
|
return cb err if err
|
||||||
|
return cb warn if warn
|
||||||
self.milestone = milestone
|
self.milestone = milestone
|
||||||
cb err
|
cb null
|
||||||
|
|
||||||
# Get all issues.
|
# Get all issues.
|
||||||
(cb) ->
|
(cb) ->
|
||||||
|
@ -52,8 +55,13 @@ class exports.Repo
|
||||||
_.partial(graph.actual, self.issues.closed.data, self.milestone.created_at, total)
|
_.partial(graph.actual, self.issues.closed.data, self.milestone.created_at, total)
|
||||||
_.partial(graph.ideal, self.milestone.created_at, self.milestone.due_on, total)
|
_.partial(graph.ideal, self.milestone.created_at, self.milestone.due_on, total)
|
||||||
], (err, values) ->
|
], (err, values) ->
|
||||||
document.querySelector('#progress').innerHTML = tml.progress { progress }
|
# Render the body.
|
||||||
|
render 'body', 'graph'
|
||||||
|
|
||||||
|
# Render the progress.
|
||||||
|
render '#progress', 'progress', { progress }
|
||||||
|
|
||||||
|
# Render the chart.
|
||||||
graph.render values, cb
|
graph.render values, cb
|
||||||
|
|
||||||
], cb
|
], cb
|
|
@ -1,3 +1,4 @@
|
||||||
<div class="box" id="info">
|
<div class="box error">
|
||||||
<p>Hello trouble</p>
|
<h2>Trouble</h2>
|
||||||
|
<p><%- @text %></p>
|
||||||
</div>
|
</div>
|
Loading…
Reference in New Issue