load pusher key from api endpoing (allows running locally against api.travis-ci.org)
This commit is contained in:
parent
b40dfe044b
commit
7b5e8445bc
|
@ -35,7 +35,7 @@ GIT
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/travis-ci/travis-api.git
|
remote: git://github.com/travis-ci/travis-api.git
|
||||||
revision: f05f841a46dbd9601e57676f8c4a356b21234cf2
|
revision: e8d2604ec3e466856f64f20c42b03829d7cff996
|
||||||
specs:
|
specs:
|
||||||
travis-api (0.0.1)
|
travis-api (0.0.1)
|
||||||
backports (~> 2.5)
|
backports (~> 2.5)
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
Travis.Pusher = ->
|
Travis.Pusher = ->
|
||||||
@active_channels = []
|
@active_channels = []
|
||||||
if Travis.Pusher.KEY
|
if Travis.config.pusher?.key?
|
||||||
@pusher = new Pusher(Travis.Pusher.KEY)
|
@pusher = new Pusher(Travis.config.pusher.key)
|
||||||
@subscribe(channel) for channel in Travis.Pusher.CHANNELS
|
@subscribe(channel) for channel in Travis.Pusher.CHANNELS
|
||||||
this
|
this
|
||||||
|
|
||||||
$.extend Travis.Pusher,
|
$.extend Travis.Pusher,
|
||||||
CHANNELS: ['common']
|
CHANNELS: ['common']
|
||||||
CHANNEL_PREFIX: ''
|
CHANNEL_PREFIX: ''
|
||||||
KEY: ''
|
|
||||||
|
|
||||||
$.extend Travis.Pusher.prototype,
|
$.extend Travis.Pusher.prototype,
|
||||||
subscribe: (channel) ->
|
subscribe: (channel) ->
|
||||||
|
|
|
@ -8,11 +8,14 @@ jQuery.support.cors = true
|
||||||
post: (url, data, callback) ->
|
post: (url, data, callback) ->
|
||||||
@ajax(url, 'post', data: data, success: callback)
|
@ajax(url, 'post', data: data, success: callback)
|
||||||
|
|
||||||
|
get: (url, callback) ->
|
||||||
|
@ajax(url, 'get', success: callback)
|
||||||
|
|
||||||
ajax: (url, method, options) ->
|
ajax: (url, method, options) ->
|
||||||
endpoint = Travis.config.api_endpoint || ''
|
endpoint = Travis.config.api_endpoint || ''
|
||||||
options = options || {}
|
options = options || {}
|
||||||
|
|
||||||
if access_token = Travis.app.get('accessToken')
|
if access_token = Travis.app?.get('accessToken')
|
||||||
options.headers ||= {}
|
options.headers ||= {}
|
||||||
options.headers['Authorization'] ||= "token #{access_token}"
|
options.headers['Authorization'] ||= "token #{access_token}"
|
||||||
|
|
||||||
|
@ -22,7 +25,19 @@ jQuery.support.cors = true
|
||||||
options.contentType = 'application/json; charset=utf-8'
|
options.contentType = 'application/json; charset=utf-8'
|
||||||
options.context = this
|
options.context = this
|
||||||
|
|
||||||
if options.data && method != 'GET'
|
if options.data && method != 'GET' && method != 'get'
|
||||||
options.data = JSON.stringify(options.data)
|
options.data = JSON.stringify(options.data)
|
||||||
|
|
||||||
$.ajax($.extend(options, @DEFAULT_OPTIONS))
|
$.ajax($.extend(options, @DEFAULT_OPTIONS))
|
||||||
|
|
||||||
|
@Travis.Ajax.instance = Em.Object.create(@Travis.Ajax)
|
||||||
|
|
||||||
|
$.extend @Travis,
|
||||||
|
get: (url, callback) ->
|
||||||
|
@Ajax.instance.get(url, callback)
|
||||||
|
|
||||||
|
post: (url, data, callback) ->
|
||||||
|
@Ajax.instance.post(url, data, callback)
|
||||||
|
|
||||||
|
ajax: (url, method, options) ->
|
||||||
|
@Ajax.instance.ajax(url, method, options)
|
||||||
|
|
|
@ -33,6 +33,11 @@ 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) ->
|
||||||
console.log "Connecting to #{Travis.config.api_endpoint}"
|
console.log "Connecting to #{Travis.config.api_endpoint}"
|
||||||
@app = Travis.App.create(attrs || {})
|
@app = Travis.App.create(attrs || {})
|
||||||
|
|
|
@ -10,13 +10,10 @@
|
||||||
<script>
|
<script>
|
||||||
// minispade.require('mocks')
|
// minispade.require('mocks')
|
||||||
minispade.require('app')
|
minispade.require('app')
|
||||||
|
|
||||||
if(location.hostname != 'localhost') {
|
|
||||||
Travis.Pusher.KEY = '23ed642e81512118260e'
|
|
||||||
}
|
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
Travis.run()
|
Travis.loadConfig(function() {
|
||||||
|
Travis.run()
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user