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