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
|
||||
remote: git://github.com/travis-ci/travis-api.git
|
||||
revision: f05f841a46dbd9601e57676f8c4a356b21234cf2
|
||||
revision: e8d2604ec3e466856f64f20c42b03829d7cff996
|
||||
specs:
|
||||
travis-api (0.0.1)
|
||||
backports (~> 2.5)
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
Travis.Pusher = ->
|
||||
@active_channels = []
|
||||
if Travis.Pusher.KEY
|
||||
@pusher = new Pusher(Travis.Pusher.KEY)
|
||||
if Travis.config.pusher?.key?
|
||||
@pusher = new Pusher(Travis.config.pusher.key)
|
||||
@subscribe(channel) for channel in Travis.Pusher.CHANNELS
|
||||
this
|
||||
|
||||
$.extend Travis.Pusher,
|
||||
CHANNELS: ['common']
|
||||
CHANNEL_PREFIX: ''
|
||||
KEY: ''
|
||||
|
||||
$.extend Travis.Pusher.prototype,
|
||||
subscribe: (channel) ->
|
||||
|
|
|
@ -8,11 +8,14 @@ jQuery.support.cors = true
|
|||
post: (url, data, callback) ->
|
||||
@ajax(url, 'post', data: data, success: callback)
|
||||
|
||||
get: (url, callback) ->
|
||||
@ajax(url, 'get', success: callback)
|
||||
|
||||
ajax: (url, method, options) ->
|
||||
endpoint = Travis.config.api_endpoint || ''
|
||||
options = options || {}
|
||||
|
||||
if access_token = Travis.app.get('accessToken')
|
||||
if access_token = Travis.app?.get('accessToken')
|
||||
options.headers ||= {}
|
||||
options.headers['Authorization'] ||= "token #{access_token}"
|
||||
|
||||
|
@ -22,7 +25,19 @@ jQuery.support.cors = true
|
|||
options.contentType = 'application/json; charset=utf-8'
|
||||
options.context = this
|
||||
|
||||
if options.data && method != 'GET'
|
||||
if options.data && method != 'GET' && method != 'get'
|
||||
options.data = JSON.stringify(options.data)
|
||||
|
||||
$.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 }
|
||||
|
||||
loadConfig: (callback) ->
|
||||
Travis.get '/config', (data) ->
|
||||
$.extend Travis.config, data.config
|
||||
callback()
|
||||
|
||||
run: (attrs) ->
|
||||
console.log "Connecting to #{Travis.config.api_endpoint}"
|
||||
@app = Travis.App.create(attrs || {})
|
||||
|
|
|
@ -10,13 +10,10 @@
|
|||
<script>
|
||||
// minispade.require('mocks')
|
||||
minispade.require('app')
|
||||
|
||||
if(location.hostname != 'localhost') {
|
||||
Travis.Pusher.KEY = '23ed642e81512118260e'
|
||||
}
|
||||
|
||||
$(function() {
|
||||
Travis.run()
|
||||
Travis.loadConfig(function() {
|
||||
Travis.run()
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</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