native location hash implementation
This commit is contained in:
parent
06cf101400
commit
b09e68dac9
|
@ -1,23 +1,20 @@
|
|||
#!/usr/bin/env coffee
|
||||
async = require 'async'
|
||||
{ _ } = require 'lodash'
|
||||
Router = require 'route66'
|
||||
|
||||
config = require './modules/config'
|
||||
render = require './modules/render'
|
||||
{ Repo } = require './modules/repo'
|
||||
|
||||
module.exports = ->
|
||||
# Show info notice?
|
||||
render 'body', 'info' unless location.hash
|
||||
route = ->
|
||||
if match = window.location.hash.match /^#!\/(.+)\/(.+)$/
|
||||
repo = match[1..3].join('/')
|
||||
|
||||
# A new router.
|
||||
new Router().path
|
||||
'/:user/:repo': ->
|
||||
repo = _.toArray(arguments).join('/')
|
||||
# We are loading.
|
||||
render 'body', 'loading', { repo }
|
||||
|
||||
# Get config/cache.
|
||||
async.waterfall [ config
|
||||
return async.waterfall [ config
|
||||
# Instantiate.
|
||||
, (conf, cb) ->
|
||||
cb null, new Repo _.extend { repo }, conf
|
||||
|
@ -26,3 +23,12 @@ module.exports = ->
|
|||
repo.render cb
|
||||
], (err) ->
|
||||
render 'body', 'error', { text: err.toString() } if err
|
||||
|
||||
# Info notice for you.
|
||||
render 'body', 'info'
|
||||
|
||||
module.exports = ->
|
||||
# Detect route changes.
|
||||
window.addEventListener 'hashchange', route, no
|
||||
# And route now.
|
||||
do route
|
|
@ -7,7 +7,6 @@
|
|||
"caolan/async": "*",
|
||||
"mbostock/d3": "*",
|
||||
"visionmedia/superagent": "*",
|
||||
"pazguille/route66": "*",
|
||||
"necolas/normalize.css": "*"
|
||||
},
|
||||
"scripts": [
|
||||
|
@ -24,6 +23,7 @@
|
|||
"templates/graph.eco",
|
||||
"templates/info.eco",
|
||||
"templates/label.eco",
|
||||
"templates/loading.eco",
|
||||
"templates/progress.eco"
|
||||
],
|
||||
"styles": [
|
||||
|
|
|
@ -21,8 +21,11 @@ h2
|
|||
color: #FFF
|
||||
box-shadow: 2px 4px 6px rgba(0,0,0,0.2)
|
||||
|
||||
&.info, &.error, &.success
|
||||
&.generic, &.info, &.error, &.success
|
||||
border-top: 4px solid #E2E2E2
|
||||
padding: 20px
|
||||
width: 50%
|
||||
margin: 0 auto
|
||||
|
||||
&.info
|
||||
border-top-color: #96CFFB
|
||||
|
@ -30,11 +33,6 @@ h2
|
|||
&.error
|
||||
border-top-color: #FE5D55
|
||||
|
||||
&.info, &.error
|
||||
padding: 20px
|
||||
width: 50%
|
||||
margin: 0 auto
|
||||
|
||||
&.success
|
||||
border-top-color: #4ACAB4
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="box info" id="info">
|
||||
<div class="box info">
|
||||
<h2>GitHub Burndown Chart</h2>
|
||||
<p>Use your browser's location hash to specify a repo: <a href="#!/radekstepan/disposable">#!/radekstepan/disposable</a>.</p>
|
||||
</div>
|
|
@ -0,0 +1,4 @@
|
|||
<div class="box generic">
|
||||
<h2>GitHub Burndown Chart</h2>
|
||||
<p>Loading <a href="#!/<%- @repo %>">#!/<%- @repo %></a>.</p>
|
||||
</div>
|
Loading…
Reference in New Issue