diff --git a/Brocfile.js b/Brocfile.js index 8aa39699..7aeb4dc2 100644 --- a/Brocfile.js +++ b/Brocfile.js @@ -25,6 +25,7 @@ app.import('bower_components/visibilityjs/lib/visibility.timers.js'); app.import('bower_components/JavaScript-MD5/js/md5.js'); app.import('vendor/ansiparse.js'); app.import('vendor/log.js'); +app.import('vendor/customerio.js'); app.import('bower_components/moment/moment.js'); // Use `app.import` to add additional libraries to the generated // output files. diff --git a/app/router.coffee b/app/router.coffee index 2fe48432..14bc693d 100644 --- a/app/router.coffee +++ b/app/router.coffee @@ -41,7 +41,7 @@ Router.map -> @route 'index', path: '/' @resource 'env_vars', -> @route 'new' - @resource 'ssh_key' if config.endpoints.ssh_key + @resource 'ssh_key' if config.endpoints.sshKey @route 'first_sync' @route 'insufficient_oauth_permissions' diff --git a/app/styles/app/layouts/footer.sass b/app/styles/app/layouts/footer.sass index b059d606..a3d35e0e 100644 --- a/app/styles/app/layouts/footer.sass +++ b/app/styles/app/layouts/footer.sass @@ -55,7 +55,6 @@ footer a:active a text-decoration : none - display : block color : $footer-color .status-circle diff --git a/app/utils/pusher.coffee b/app/utils/pusher.coffee index 15752ae6..1b741b9e 100644 --- a/app/utils/pusher.coffee +++ b/app/utils/pusher.coffee @@ -1,4 +1,4 @@ -`import config from 'travis/config/environment'` +`import ENV from 'travis/config/environment'` TravisPusher = (config) -> @init(config) @@ -38,7 +38,7 @@ TravisPusher.prototype.unsubscribe = (channel) -> @pusher.unsubscribe(channel) if @pusher?.channel(channel) TravisPusher.prototype.prefix = (channel) -> - prefix = config.pusher.channel_prefix || '' + prefix = ENV.pusher.channel_prefix || '' if channel.indexOf(prefix) != 0 "#{prefix}#{channel}" else @@ -100,9 +100,9 @@ TravisPusher.prototype.ignoreCode = (code) -> TravisPusher.prototype.ignoreMessage = (message) -> message.indexOf('Existing subscription') == 0 or message.indexOf('No current subscription') == 0 -Pusher.SockJSTransport.isSupported = -> false if config.pusher.host != 'ws.pusherapp.com' +Pusher.SockJSTransport.isSupported = -> false if ENV.pusher.host != 'ws.pusherapp.com' -if config.pro +if ENV.pro Pusher.channel_auth_transport = 'bulk_ajax' Pusher.authorizers.bulk_ajax = (socketId, _callback) -> @@ -110,7 +110,7 @@ if config.pro channels.callbacks ||= [] name = this.channel.name - names = $.keys(channels.channels) + names = Object.keys(channels.channels) channels.callbacks.push (auths) -> _callback(false, auth: auths[name]) @@ -125,8 +125,8 @@ if config.pro Pusher.getDefaultStrategy = (config) -> [ [":def", "ws_options", { - hostUnencrypted: config.wsHost + ":" + config.wsPort + (config.pusher.path && "/#{config.pusher.path}" || ''), - hostEncrypted: config.wsHost + ":" + config.wssPort + (config.pusher.path && "/#{config.pusher.path}" || '') + hostUnencrypted: config.wsHost + ":" + config.wsPort + (ENV.pusher.path && "/#{config.pusher.path}" || ''), + hostEncrypted: config.wsHost + ":" + config.wssPort + (ENV.pusher.path && "/#{config.pusher.path}" || '') path: config.path }], [":def", "sockjs_options", { diff --git a/config/environment.js b/config/environment.js index 5c30ae39..47f5277a 100644 --- a/config/environment.js +++ b/config/environment.js @@ -31,6 +31,26 @@ module.exports = function(environment) { intervals: { updateTimes: 1000 } }; + if (typeof process !== 'undefined') { + if (process.env.TRAVIS_PRO) { + // set defaults for pro if it's used + // TODO: we have the same defaults also in ruby process, + // it would be nice to move it to one place. In theory + // we could just remove it from ruby process and rely + // on things set here, but I haven't tested that yet. + ENV.pro = true; + ENV.apiEndpoint = 'https://api.travis-ci.com'; + ENV.pusher.key = '59236bc0716a551eab40'; + ENV.pagesEndpoint = 'https://billing.travis-ci.com'; + ENV.billingEndpoint = 'https://billing.travis-ci.com'; + ENV.endpoints = { + sshKey: true, + caches: true + } + + } + } + if (environment === 'development') { // ENV.APP.LOG_RESOLVER = true; // ENV.APP.LOG_ACTIVE_GENERATION = true; @@ -57,15 +77,20 @@ module.exports = function(environment) { } + // TODO: I insert values from ENV here, but in production + // this file is compiled and is not executed on runtime. + // We don't use CSP at the moment outside of development (ie. we don't + // set CSP headers), but it would be nice to do it and then we need to + // think about a better way to override it ENV.contentSecurityPolicy = { 'default-src': "'none'", 'script-src': "'self'", - 'font-src': "'self' https://fonts.googleapis.com/css", - 'connect-src': "'self' https://api.travis-ci.org ws://ws.pusherapp.com wss://ws.pusherapp.com http://sockjs.pusher.com", + 'font-src': "'self' https://fonts.googleapis.com/css https://fonts.gstatic.com", + 'connect-src': "'self' " + ENV.apiEndpoint + " ws://ws.pusherapp.com wss://ws.pusherapp.com http://sockjs.pusher.com https://s3.amazonaws.com/archive.travis-ci.com/ https://s3.amazonaws.com/archive.travis-ci.org/", 'img-src': "'self' data: https://www.gravatar.com http://www.gravatar.com", - 'style-src': "'self'", + 'style-src': "'self' https://fonts.googleapis.com", 'media-src': "'self'", - 'frame-src': "'self' https://api.travis-ci.org" + 'frame-src': "'self' " + ENV.apiEndpoint } return ENV; diff --git a/vendor/customerio.js b/vendor/customerio.js new file mode 100644 index 00000000..10522d01 --- /dev/null +++ b/vendor/customerio.js @@ -0,0 +1,14 @@ +var _cio = _cio || []; + +function setupCustomerio(siteId) { + var a,b,c;a=function(f){return function(){_cio.push([f]. + concat(Array.prototype.slice.call(arguments,0)))}};b=["load","identify", + "sidentify","track","page"];for(c=0;c options[:ssh_key_enabled], + 'caches' => options[:caches_enabled] + } + regexp = %r(