move loadConfig to Travis.run

This commit is contained in:
Sven Fuchs 2012-09-29 21:40:51 +02:00
parent b9179e3439
commit 1566595cda
7 changed files with 34 additions and 59 deletions

View File

@ -42,7 +42,7 @@ GIT
GIT
remote: git://github.com/travis-ci/travis-api.git
revision: 3e371251f7ae5c3ebf4ce0186783183afaabd599
revision: 6cdfd6a8a450baa169e105a85627b1bf7bbe800e
specs:
travis-api (0.0.1)
backports (~> 2.5)
@ -60,7 +60,7 @@ GIT
GIT
remote: git://github.com/travis-ci/travis-core.git
revision: 6c974f0c0ad529748e95222c3145a0f085311ad1
revision: e7a811451c9497c564aacf1dc26a6db7236da520
branch: sf-more-services
specs:
travis-core (0.0.1)

View File

@ -34,8 +34,7 @@ Travis.reopen
@set('auth', Travis.Auth.create(store: @store, endpoint: Travis.config.api_endpoint))
@slider = new Travis.Slider()
@pusher = new Travis.Pusher()
@pusher = new Travis.Pusher(Travis.config.pusher)
@tailing = new Travis.Tailing()
signIn: ->

View File

@ -1,9 +1,5 @@
Travis.Pusher = ->
@active_channels = []
if Travis.config.pusher?.key?
Pusher.warn = @warn.bind(this)
@pusher = new Pusher(Travis.config.pusher.key)
@subscribe(channel) for channel in Travis.Pusher.CHANNELS
Travis.Pusher = (config) ->
@init(config) if config
this
$.extend Travis.Pusher,
@ -11,6 +7,13 @@ $.extend Travis.Pusher,
CHANNEL_PREFIX: ''
$.extend Travis.Pusher.prototype,
active_channels: []
init: (config) ->
Pusher.warn = @warn.bind(this)
@pusher = new Pusher(config.key)
@subscribe(channel) for channel in Travis.Pusher.CHANNELS
subscribe: (channel) ->
if @pusher && @active_channels.indexOf(channel) == -1
@active_channels.push(channel)
@ -42,8 +45,8 @@ $.extend Travis.Pusher.prototype,
{ worker: data }
warn: (type, warning) ->
# console.warn(warning) unless @ignoreWarning(warning)
console.warn(warning) unless @ignoreWarning(warning)
# ignoreWarning: (warning) ->
# if message = warning.data?.message
# message.indexOf('Existing subscription') == 0 || message.indexOf('No current subscription') == 0
ignoreWarning: (warning) ->
if message = warning.data?.message
message.indexOf('Existing subscription') == 0 or message.indexOf('No current subscription') == 0

View File

@ -1,26 +0,0 @@
# window.onTrue = (object, path, callback) ->
# if object.get(path)
# callback()
# else
# observer = ->
# object.removeObserver path, observer
# callback()
# object.addObserver path, observer
#
# window.onceLoaded = ->
# objects = Array.prototype.slice.apply(arguments)
# callback = objects.pop()
#
# # sadly Ember.Enumerable.compact does not remove undefined values
# objects = ((object || null) for object in objects).compact()
# object = objects.shift()
#
# if object
# path = if Ember.isArray(object) then 'firstObject.isLoaded' else 'isLoaded'
# onTrue object, path, ->
# if objects.length == 0
# callback(object)
# else
# onceLoaded.apply(objects + [callback])
# else
# callback object

View File

@ -33,14 +33,10 @@ require 'ext/ember/namespace'
INTERVALS: { sponsors: -1, times: -1, updateTimes: 1000 }
loadConfig: (callback) ->
Travis.get '/config', (data) ->
$.extend Travis.config, data.config
callback()
run: (attrs) ->
@redirectOnHashbang()
@loadConfig (config) =>
console.log "Connecting to #{Travis.config.api_endpoint}"
app = Travis.App.create(attrs || {})
# TODO: router expects the classes for controllers on main namespace, so
@ -56,3 +52,8 @@ require 'ext/ember/namespace'
redirectOnHashbang: ->
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
loadConfig: (callback) ->
Travis.get '/config', (data) =>
$.extend @config, data.config
callback(data.config)

View File

@ -11,10 +11,8 @@
// minispade.require('mocks')
minispade.require('app')
$(function() {
Travis.loadConfig(function() {
Travis.run()
});
});
</script>
</head>
<body id="home"></body>

File diff suppressed because one or more lines are too long