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 GIT
remote: git://github.com/travis-ci/travis-api.git remote: git://github.com/travis-ci/travis-api.git
revision: 3e371251f7ae5c3ebf4ce0186783183afaabd599 revision: 6cdfd6a8a450baa169e105a85627b1bf7bbe800e
specs: specs:
travis-api (0.0.1) travis-api (0.0.1)
backports (~> 2.5) backports (~> 2.5)
@ -60,7 +60,7 @@ GIT
GIT GIT
remote: git://github.com/travis-ci/travis-core.git remote: git://github.com/travis-ci/travis-core.git
revision: 6c974f0c0ad529748e95222c3145a0f085311ad1 revision: e7a811451c9497c564aacf1dc26a6db7236da520
branch: sf-more-services branch: sf-more-services
specs: specs:
travis-core (0.0.1) 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)) @set('auth', Travis.Auth.create(store: @store, endpoint: Travis.config.api_endpoint))
@slider = new Travis.Slider() @slider = new Travis.Slider()
@pusher = new Travis.Pusher(Travis.config.pusher)
@pusher = new Travis.Pusher()
@tailing = new Travis.Tailing() @tailing = new Travis.Tailing()
signIn: -> signIn: ->

View File

@ -1,9 +1,5 @@
Travis.Pusher = -> Travis.Pusher = (config) ->
@active_channels = [] @init(config) if config
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
this this
$.extend Travis.Pusher, $.extend Travis.Pusher,
@ -11,6 +7,13 @@ $.extend Travis.Pusher,
CHANNEL_PREFIX: '' CHANNEL_PREFIX: ''
$.extend Travis.Pusher.prototype, $.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) -> subscribe: (channel) ->
if @pusher && @active_channels.indexOf(channel) == -1 if @pusher && @active_channels.indexOf(channel) == -1
@active_channels.push(channel) @active_channels.push(channel)
@ -42,8 +45,8 @@ $.extend Travis.Pusher.prototype,
{ worker: data } { worker: data }
warn: (type, warning) -> warn: (type, warning) ->
# console.warn(warning) unless @ignoreWarning(warning) console.warn(warning) unless @ignoreWarning(warning)
# ignoreWarning: (warning) -> ignoreWarning: (warning) ->
# if message = warning.data?.message if message = warning.data?.message
# message.indexOf('Existing subscription') == 0 || message.indexOf('No current subscription') == 0 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,26 +33,27 @@ require 'ext/ember/namespace'
INTERVALS: { sponsors: -1, times: -1, updateTimes: 1000 } INTERVALS: { sponsors: -1, times: -1, updateTimes: 1000 }
loadConfig: (callback) ->
Travis.get '/config', (data) ->
$.extend Travis.config, data.config
callback()
run: (attrs) -> run: (attrs) ->
@redirectOnHashbang() @redirectOnHashbang()
console.log "Connecting to #{Travis.config.api_endpoint}" @loadConfig (config) =>
app = Travis.App.create(attrs || {}) console.log "Connecting to #{Travis.config.api_endpoint}"
# TODO: router expects the classes for controllers on main namespace, so app = Travis.App.create(attrs || {})
# if we want to keep app at Travis.app, we need to copy that, it would # TODO: router expects the classes for controllers on main namespace, so
# be ideal to send a patch to ember and get rid of this # if we want to keep app at Travis.app, we need to copy that, it would
$.each Travis, (key, value) -> # be ideal to send a patch to ember and get rid of this
app[key] = value if value && value.isClass && key != 'constructor' $.each Travis, (key, value) ->
app[key] = value if value && value.isClass && key != 'constructor'
@app = app @app = app
@store = app.store @store = app.store
app.initialize() app.initialize()
redirectOnHashbang: -> redirectOnHashbang: ->
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!' 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,9 +11,7 @@
// minispade.require('mocks') // minispade.require('mocks')
minispade.require('app') minispade.require('app')
$(function() { $(function() {
Travis.loadConfig(function() { Travis.run()
Travis.run()
});
}); });
</script> </script>
</head> </head>

File diff suppressed because one or more lines are too long