From 10b19b64b1d16f1f68e24f1863ce940080b46a09 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Mon, 13 Oct 2014 14:34:25 +0200 Subject: [PATCH 01/26] why did we use the minispade string strategy for development? --- Assetfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Assetfile b/Assetfile index edb50985..c4c50a97 100644 --- a/Assetfile +++ b/Assetfile @@ -49,7 +49,9 @@ input assets.scripts do match %r(^(?!vendor|spec).*\.js$) do modules = proc { |input| input.path.gsub(%r((^app/|lib/|\.js$)), '') } - minispade(string: assets.development?, rewrite_requires: true, module_id_generator: modules) + # why did we use the string strategy for development? makes it impossible to set breakpoints + # minispade(string: assets.development?, rewrite_requires: true, module_id_generator: modules) + minispade(string: false, rewrite_requires: true, module_id_generator: modules) end match %r(^(?!spec).*\.js$) do From 89826c70e0ca4efda5139f4fe37161313741aeeb Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 27 Aug 2013 12:56:20 +0200 Subject: [PATCH 02/26] pass pusher_host through config.ru --- config.ru | 1 + 1 file changed, 1 insertion(+) diff --git a/config.ru b/config.ru index ab243006..9eb6cec1 100644 --- a/config.ru +++ b/config.ru @@ -29,6 +29,7 @@ run Travis::Web::App.build( environment: ENV['RACK_ENV'] || 'development', api_endpoint: ENV['API_ENDPOINT'], pusher_key: ENV['PUSHER_KEY'], + pusher_host: ENV['PUSHER_HOST'] || 'ws.pusherapp.com', ga_code: ENV['GA_CODE'], root: File.expand_path('../public', __FILE__), server_start: Time.now, From 65ee0d548644fed4c8918c2e9665135bc60ae702 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 27 Aug 2013 12:53:32 +0200 Subject: [PATCH 03/26] allow setting the pusher host --- assets/scripts/app/app.coffee | 1 + assets/scripts/app/pusher.coffee | 5 +++-- assets/scripts/travis.coffee | 1 + public/index.html | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/scripts/app/app.coffee b/assets/scripts/app/app.coffee index 6514083f..5375c0bc 100644 --- a/assets/scripts/app/app.coffee +++ b/assets/scripts/app/app.coffee @@ -43,6 +43,7 @@ unless window.TravisApplication Travis.SshKey.adapter = Travis.SshKeyAdapter.create() @slider = new Travis.Slider() + @pusher = new Travis.Pusher(key: Travis.config.pusher_key, host: Travis.config.pusher_host) if Travis.config.pusher_key @pusher = new Travis.Pusher(Travis.config.pusher_key) if Travis.config.pusher_key @tailing = new Travis.Tailing($(window), '#tail', '#log') @toTop = new Travis.ToTop($(window), '.to-top', '#log-container') diff --git a/assets/scripts/app/pusher.coffee b/assets/scripts/app/pusher.coffee index faf00514..a18f27bd 100644 --- a/assets/scripts/app/pusher.coffee +++ b/assets/scripts/app/pusher.coffee @@ -10,9 +10,10 @@ $.extend Travis.Pusher, $.extend Travis.Pusher.prototype, active_channels: [] - init: (key) -> + init: (config) -> Pusher.warn = @warn.bind(this) - @pusher = new Pusher(key, encrypted: Travis.Pusher.ENCRYPTED) + Pusher.host = config.host if config.host + @pusher = new Pusher(config.key, encrypted: Travis.Pusher.ENCRYPTED) @subscribeAll(Travis.Pusher.CHANNELS) if Travis.Pusher.CHANNELS @callbacksToProcess = [] diff --git a/assets/scripts/travis.coffee b/assets/scripts/travis.coffee index 9fb252ce..f85a6efe 100644 --- a/assets/scripts/travis.coffee +++ b/assets/scripts/travis.coffee @@ -79,6 +79,7 @@ $.extend Travis, syncingPageRedirectionTime: 5000 api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href') pusher_key: $('meta[name="travis.pusher_key"]').attr('value') + pusher_host: $('meta[name="travis.pusher_host"]').attr('value') ga_code: $('meta[name="travis.ga_code"]').attr('value') code_climate: $('meta[name="travis.code_climate"]').attr('value') ssh_key_enabled: $('meta[name="travis.ssh_key_enabled"]').attr('value') == 'true' diff --git a/public/index.html b/public/index.html index e5348ebe..4d015f29 100644 --- a/public/index.html +++ b/public/index.html @@ -6,6 +6,7 @@ + From b2d3a6199df3acba05a8ca421f9be81aeed7ff3a Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Fri, 6 Sep 2013 02:32:51 +0200 Subject: [PATCH 04/26] config source_endpoint Conflicts: config.ru public/index.html --- assets/scripts/app/helpers/urls.coffee | 12 ++++++------ assets/scripts/travis.coffee | 9 +++++---- config.ru | 17 +++++++++-------- public/index.html | 1 + 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/assets/scripts/app/helpers/urls.coffee b/assets/scripts/app/helpers/urls.coffee index ab6f606f..cda9bbc5 100644 --- a/assets/scripts/app/helpers/urls.coffee +++ b/assets/scripts/app/helpers/urls.coffee @@ -3,22 +3,22 @@ "#{Travis.config.api_endpoint}/jobs/#{id}/log.txt?deansi=true" githubPullRequest: (slug, pullRequestNumber) -> - "https://github.com/#{slug}/pull/#{pullRequestNumber}" + "#{Travis.config.source_endpoint}/#{slug}/pull/#{pullRequestNumber}" githubCommit: (slug, sha) -> - "https://github.com/#{slug}/commit/#{sha}" + "#{Travis.config.source_endpoint}/#{slug}/commit/#{sha}" githubRepo: (slug) -> - "https://github.com/#{slug}" + "#{Travis.config.source_endpoint}/#{slug}" githubWatchers: (slug) -> - "https://github.com/#{slug}/watchers" + "#{Travis.config.source_endpoint}/#{slug}/watchers" githubNetwork: (slug) -> - "https://github.com/#{slug}/network" + "#{Travis.config.source_endpoint}/#{slug}/network" githubAdmin: (slug) -> - "https://github.com/#{slug}/settings/hooks#travis_minibucket" + "#{Travis.config.source_endpoint}/#{slug}/settings/hooks#travis_minibucket" statusImage: (slug, branch) -> "#{location.protocol}//#{location.host}/#{slug}.svg" + if branch then "?branch=#{encodeURIComponent(branch)}" else '' diff --git a/assets/scripts/travis.coffee b/assets/scripts/travis.coffee index f85a6efe..08835a6c 100644 --- a/assets/scripts/travis.coffee +++ b/assets/scripts/travis.coffee @@ -77,10 +77,11 @@ $.extend Travis, config: syncingPageRedirectionTime: 5000 - api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href') - pusher_key: $('meta[name="travis.pusher_key"]').attr('value') - pusher_host: $('meta[name="travis.pusher_host"]').attr('value') - ga_code: $('meta[name="travis.ga_code"]').attr('value') + api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href') + source_endpoint: $('meta[rel="travis.source_endpoint"]').attr('href') + pusher_key: $('meta[name="travis.pusher_key"]').attr('value') + pusher_host: $('meta[name="travis.pusher_host"]').attr('value') + ga_code: $('meta[name="travis.ga_code"]').attr('value') code_climate: $('meta[name="travis.code_climate"]').attr('value') ssh_key_enabled: $('meta[name="travis.ssh_key_enabled"]').attr('value') == 'true' code_climate_url: $('meta[name="travis.code_climate_url"]').attr('value') diff --git a/config.ru b/config.ru index 9eb6cec1..6d575869 100644 --- a/config.ru +++ b/config.ru @@ -26,13 +26,14 @@ use Travis::Web::ApiRedirect do |app| end run Travis::Web::App.build( - environment: ENV['RACK_ENV'] || 'development', - api_endpoint: ENV['API_ENDPOINT'], - pusher_key: ENV['PUSHER_KEY'], - pusher_host: ENV['PUSHER_HOST'] || 'ws.pusherapp.com', - ga_code: ENV['GA_CODE'], - root: File.expand_path('../public', __FILE__), - server_start: Time.now, - caches_enabled: ENV['CACHES_ENABLED'], + environment: ENV['RACK_ENV'] || 'development', + api_endpoint: ENV['API_ENDPOINT'], + source_endpoint: ENV['SOURCE_ENDPOINT'] || 'https://github.com', + pusher_key: ENV['PUSHER_KEY'], + pusher_host: ENV['PUSHER_HOST'] || 'ws.pusherapp.com', + ga_code: ENV['GA_CODE'], + root: File.expand_path('../public', __FILE__), + server_start: Time.now, + caches_enabled: ENV['CACHES_ENABLED'], ssh_key_enabled: ENV['SSH_KEY_ENABLED'] ) diff --git a/public/index.html b/public/index.html index 4d015f29..0d7eb6e9 100644 --- a/public/index.html +++ b/public/index.html @@ -4,6 +4,7 @@ + From bf8f944ab1f4c39af687de1a487ffbec434d1b2b Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Fri, 6 Sep 2013 16:11:03 +0200 Subject: [PATCH 05/26] fix ignoreWarning --- assets/scripts/app/pusher.coffee | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/scripts/app/pusher.coffee b/assets/scripts/app/pusher.coffee index a18f27bd..d12d2153 100644 --- a/assets/scripts/app/pusher.coffee +++ b/assets/scripts/app/pusher.coffee @@ -85,5 +85,9 @@ $.extend Travis.Pusher.prototype, when 'annotation:created', 'annotation:updated' { annotation: data } - warn: (type, warning) -> - console.warn(warning) + warn: (type, object) -> + console.warn(type, object.error) unless @ignoreWarning(type, object.error) + + ignoreWarning: (type, error) -> + if message = error?.data?.message + message.indexOf('Existing subscription') == 0 or message.indexOf('No current subscription') == 0 From 8b1dfd67f91e7cc77d5deb007298289a6d2e0723 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Fri, 6 Sep 2013 16:36:08 +0200 Subject: [PATCH 06/26] ignore pusher error code 1006 --- assets/scripts/app/pusher.coffee | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/assets/scripts/app/pusher.coffee b/assets/scripts/app/pusher.coffee index d12d2153..0e1c21ed 100644 --- a/assets/scripts/app/pusher.coffee +++ b/assets/scripts/app/pusher.coffee @@ -89,5 +89,13 @@ $.extend Travis.Pusher.prototype, console.warn(type, object.error) unless @ignoreWarning(type, object.error) ignoreWarning: (type, error) -> - if message = error?.data?.message - message.indexOf('Existing subscription') == 0 or message.indexOf('No current subscription') == 0 + code = error?.data?.code || 0 + message = error?.data?.message || '' + @ignoreCode(code) || @ignoreMessage(message) + + ignoreCode: (code) -> + code == 1006 + + ignoreMessage: (message) -> + message.indexOf('Existing subscription') == 0 or message.indexOf('No current subscription') == 0 + From 2aba520512d9f2e1bf5d5308b67d51658e2f73ae Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sun, 8 Sep 2013 23:56:56 +0200 Subject: [PATCH 07/26] more hardcoded github.com urls --- assets/scripts/app/helpers/helpers.coffee | 4 ++-- assets/scripts/app/models/account.coffee | 2 +- assets/scripts/app/models/hook.coffee | 4 ++-- assets/scripts/app/models/user.coffee | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/scripts/app/helpers/helpers.coffee b/assets/scripts/app/helpers/helpers.coffee index 42aa27b7..8f24bbd1 100644 --- a/assets/scripts/app/helpers/helpers.coffee +++ b/assets/scripts/app/helpers/helpers.coffee @@ -86,12 +86,12 @@ require 'config/emoij' _githubReferenceLink: (reference, current, matched) -> owner = matched.owner || current.owner repo = matched.repo || current.repo - "#{reference}" + "#{reference}" _githubUserRegexp: new RegExp("\\B@([\\w-]+)", 'g') _githubUserLink: (reference, username) -> - "#{reference}" + "#{reference}" _githubCommitReferenceRegexp: new RegExp("([\\w-]+)?\\/([\\w-]+)?@([0-9A-Fa-f]+)", 'g') diff --git a/assets/scripts/app/models/account.coffee b/assets/scripts/app/models/account.coffee index 03c29f79..513782db 100644 --- a/assets/scripts/app/models/account.coffee +++ b/assets/scripts/app/models/account.coffee @@ -7,7 +7,7 @@ require 'travis/model' _reposCount: Ember.attr(Number, key: 'repos_count') urlGithub: (-> - "https://github.com/#{@get('login')}" + "#{Travis.config.source_endpoint}/#{@get('login')}" ).property() # TODO: maybe it would be good to add a "default" value for Ember.attr diff --git a/assets/scripts/app/models/hook.coffee b/assets/scripts/app/models/hook.coffee index 4126292b..350706aa 100644 --- a/assets/scripts/app/models/hook.coffee +++ b/assets/scripts/app/models/hook.coffee @@ -16,11 +16,11 @@ require 'travis/model' ).property('ownerName', 'name') urlGithub: (-> - "https://github.com/#{@get('slug')}" + "#{Travis.config.source_endpoint}/#{@get('slug')}" ).property() urlGithubAdmin: (-> - "https://github.com/#{@get('slug')}/settings/hooks#travis_minibucket" + "#{Travis.config.source_endpoint}/#{@get('slug')}/settings/hooks#travis_minibucket" ).property() toggle: -> diff --git a/assets/scripts/app/models/user.coffee b/assets/scripts/app/models/user.coffee index bd2468a3..d6467085 100644 --- a/assets/scripts/app/models/user.coffee +++ b/assets/scripts/app/models/user.coffee @@ -26,7 +26,7 @@ require 'travis/model' ).observes('isSyncing') urlGithub: (-> - "https://github.com/#{@get('login')}" + "#{Travis.config.source_endpoint}/#{@get('login')}" ).property() _rawPermissions: (-> From 0468b1e327e3dbfc8ad64a65ad832c2b2b8e608d Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 11 Sep 2013 00:34:38 +0200 Subject: [PATCH 08/26] remove path from endpoint --- assets/scripts/app/auth.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/scripts/app/auth.coffee b/assets/scripts/app/auth.coffee index 43b88517..613c44d7 100644 --- a/assets/scripts/app/auth.coffee +++ b/assets/scripts/app/auth.coffee @@ -109,7 +109,7 @@ window.Auth = Ember.Object.extend expectedOrigin: -> endpoint = @get('endpoint') - if endpoint[0] == '/' then @receivingEnd else endpoint + if endpoint[0] == '/' then @receivingEnd else endpoint.match(/^https?:\/\/[^\/]*/)[0] sendToApp: (name) -> # TODO: this is an ugly solution, we need to do one of 2 things: From 73c98ef9dbb51635fe76ec39d90dc300535d7b24 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 11 Sep 2013 17:12:20 +0200 Subject: [PATCH 09/26] allow setting hsts for Rack::SSL --- lib/travis/web/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/web/app.rb b/lib/travis/web/app.rb index 0fc33d75..069524b2 100644 --- a/lib/travis/web/app.rb +++ b/lib/travis/web/app.rb @@ -33,7 +33,7 @@ class Travis::Web::App def build(options = {}) builder = Rack::Builder.new if options[:environment] == 'production' - builder.use Rack::SSL + builder.use Rack::SSL, hsts: Travis.config.ssl.hsts || true end builder.use Rack::Deflater builder.use Rack::Head From 0d062be3a0fe2c04ec29dbdce6ddd7e0a0c66198 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 11 Sep 2013 18:09:26 +0200 Subject: [PATCH 10/26] travis-web does not use travis-core --- Gemfile | 1 + Gemfile.lock | 10 +++++++- lib/travis/web.rb | 5 ++++ lib/travis/web/app.rb | 2 +- lib/travis/web/config.rb | 50 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 lib/travis/web/config.rb diff --git a/Gemfile b/Gemfile index 2a324fc8..64632540 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ gem 'rack-ssl', '~> 1.3' gem 'rack-protection', '~> 1.3' gem 'rack-mobile-detect' gem 'sinatra' +gem 'hashr' gem 'rake-pipeline', github: 'livingsocial/rake-pipeline' gem 'rake-pipeline-web-filters', github: 'wycats/rake-pipeline-web-filters' diff --git a/Gemfile.lock b/Gemfile.lock index 762adf84..45d47aee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -49,6 +49,11 @@ GEM pry (>= 0.9.10) terminal-table (>= 1.4.3) thor (>= 0.14.6) + handlebars (0.4.0) + commonjs (~> 0.2.3) + therubyracer (~> 0.11.1) + hashr (0.0.22) + i18n (0.6.3) json (1.7.7) libv8 (3.16.14.3) listen (2.7.9) @@ -119,7 +124,10 @@ DEPENDENCIES compass foreman guard - libv8 (~> 3.16.0) + handlebars + hashr + localeapp + localeapp-handlebars_i18n puma rack-mobile-detect rack-protection (~> 1.3) diff --git a/lib/travis/web.rb b/lib/travis/web.rb index 7d8a6f09..3aa51501 100644 --- a/lib/travis/web.rb +++ b/lib/travis/web.rb @@ -3,6 +3,11 @@ module Travis autoload :Allow, 'travis/web/allow' autoload :ApiRedirect, 'travis/web/api_redirect' autoload :App, 'travis/web/app' + autoload :Config, 'travis/web/config' autoload :SetToken, 'travis/web/set_token' end + + def self.config + @config ||= Travis::Web::Config.new + end end diff --git a/lib/travis/web/app.rb b/lib/travis/web/app.rb index 069524b2..31b436d0 100644 --- a/lib/travis/web/app.rb +++ b/lib/travis/web/app.rb @@ -33,7 +33,7 @@ class Travis::Web::App def build(options = {}) builder = Rack::Builder.new if options[:environment] == 'production' - builder.use Rack::SSL, hsts: Travis.config.ssl.hsts || true + builder.use Rack::SSL, hsts: Travis.config.ssl.hsts end builder.use Rack::Deflater builder.use Rack::Head diff --git a/lib/travis/web/config.rb b/lib/travis/web/config.rb new file mode 100644 index 00000000..902ef9f4 --- /dev/null +++ b/lib/travis/web/config.rb @@ -0,0 +1,50 @@ +require 'hashr' +require 'yaml' + +# Encapsulates the configuration necessary for travis-listener. +# +# Configuration values will be read from +# +# * either ENV['travis_config'] (this variable is set on Heroku by `travis config [env]`, +# see travis-cli) or +# * a local file config/travis.yml which contains the current env key (e.g. development, +# production, test) +# +# The env key can be set through various ENV variables, see Travis::Config.env. +# +module Travis + module Web + class Config < Hashr + class << self + def env + ENV['ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development' + end + + def load_env + @load_env ||= YAML.load(ENV['travis_config']) if ENV['travis_config'] + end + + def load_file + @load_file ||= YAML.load_file(filename)[env] if File.exists?(filename) rescue {} + end + + def filename + @filename ||= File.expand_path('config/travis.yml') + end + end + + define ssl: { hsts: true } + + default _access: [:key] + + def initialize(data = nil, *args) + data ||= self.class.load_env || self.class.load_file || {} + super + end + + def env + self.class.env + end + end + end +end From aa7baffb9fe701368d66724991731702971a6026 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 29 Oct 2013 16:53:58 +0100 Subject: [PATCH 11/26] use all roots for generating the version hash --- lib/travis/assets.rb | 2 +- lib/travis/assets/version.rb | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/travis/assets.rb b/lib/travis/assets.rb index 8f172e7d..27160a90 100644 --- a/lib/travis/assets.rb +++ b/lib/travis/assets.rb @@ -47,7 +47,7 @@ module Travis end def update_version - Travis::Assets::Version.new.update + Travis::Assets::Version.new(roots).update end TYPES.each { |type| define_method(type) { paths[type] } } diff --git a/lib/travis/assets/version.rb b/lib/travis/assets/version.rb index 616d1f81..af56ff6b 100644 --- a/lib/travis/assets/version.rb +++ b/lib/travis/assets/version.rb @@ -11,10 +11,10 @@ module Travis new.update end - attr_reader :root + attr_reader :roots - def initialize(root = nil) - @root = Pathname.new(root || File.expand_path('.')) + def initialize(roots = nil) + @roots = roots end def read @@ -29,8 +29,12 @@ module Travis protected + def cwd + Pathname.new(File.expand_path('.')) + end + def file - root.join(FILE_NAME) + cwd.join(FILE_NAME) end def write(version) @@ -42,14 +46,16 @@ module Travis end def digest - Digest::MD5.new << `ls -lAR #{sources.join(' ')} | awk '{print $5, $6, $7, $9}'` + Digest::MD5.new << `ls -lTAR #{sources.join(' ')} | awk '{ print $5, $6, $7, $8, $9, $10 }'` end def sources - SOURCES.map do |source| - source = root.join(source) - source.to_s if source.exist? - end.compact + roots.map do |root| + SOURCES.map do |source| + source = Pathname.new(root).join(source) + source.to_s if source.exist? + end + end.flatten.compact end end end From ef9b5d8646617bef60a859eb90fc937c41676141 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 29 Oct 2013 18:03:02 +0100 Subject: [PATCH 12/26] the joys of non-portable unix command options --- lib/travis/assets/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/assets/version.rb b/lib/travis/assets/version.rb index af56ff6b..0e619788 100644 --- a/lib/travis/assets/version.rb +++ b/lib/travis/assets/version.rb @@ -46,7 +46,7 @@ module Travis end def digest - Digest::MD5.new << `ls -lTAR #{sources.join(' ')} | awk '{ print $5, $6, $7, $8, $9, $10 }'` + Digest::MD5.new << `ls -lAR #{sources.join(' ')} | awk '{ print $5, $6, $7, $8, $9, $10 }'` end def sources From ce8237b4e75de8a6136123751abc4ceb7b262966 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 30 Oct 2013 15:13:00 +0100 Subject: [PATCH 13/26] Make sorting more in line with what we will do on a server --- assets/scripts/app/models/repo.coffee | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/assets/scripts/app/models/repo.coffee b/assets/scripts/app/models/repo.coffee index 91d12919..f3fb1ff5 100644 --- a/assets/scripts/app/models/repo.coffee +++ b/assets/scripts/app/models/repo.coffee @@ -107,12 +107,17 @@ require 'travis/model' ).property('_lastBuildDuration', 'lastBuildStartedAt', 'lastBuildFinishedAt') sortOrder: (-> - # cuz sortAscending seems buggy when set to false - if lastBuildFinishedAt = @get('lastBuildFinishedAt') - - new Date(lastBuildFinishedAt).getTime() + # this is prepared for ascending sort + if Ember.isNone(@get('lastBuildFinishedAt')) && @get('lastBuildStartedAt') + # if a build is running, it should be at the beginning + 0 + else if lastBuildStartedAt = @get('lastBuildStartedAt') + # if it's not running, but was already run, put newest builds first + new Date('9999').getTime() - Date.parse(lastBuildStartedAt) else - - new Date('9999').getTime() - parseInt(@get('lastBuildId')) - ).property('lastBuildFinishedAt', 'lastBuildId') + # if it's not started nor it was ran before, sort with newest id first + new Date('9999').getTime() - @get('id') + ).property('lastBuildFinishedAt', 'id', 'lastBuildStartedAt') stats: (-> if @get('slug') From be63d535e100011c7dc94ab7137092e2879ab0aa Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 30 Oct 2013 18:30:31 +0100 Subject: [PATCH 14/26] on the repos list remove "summary" elements for repos without a build --- assets/scripts/app/templates/repos/list.hbs | 2 ++ assets/styles/left/list.sass | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/scripts/app/templates/repos/list.hbs b/assets/scripts/app/templates/repos/list.hbs index 41acd7be..17ea50f4 100644 --- a/assets/scripts/app/templates/repos/list.hbs +++ b/assets/scripts/app/templates/repos/list.hbs @@ -20,6 +20,7 @@ {{/if}} {{/with}} + {{#if lastBuildHash.number }}

Duration: {{formatDuration lastBuildDuration}} @@ -28,6 +29,7 @@ Finished: {{formatTime lastBuildFinishedAt}}

+ {{/if}}
{{/with}} diff --git a/assets/styles/left/list.sass b/assets/styles/left/list.sass index d5b20aed..767097ba 100644 --- a/assets/styles/left/list.sass +++ b/assets/styles/left/list.sass @@ -83,7 +83,7 @@ span position: relative display: block - top: 45px + top: calc(50% - 10px) left: -15px width: 20px height: 20px From f827c155f5c28798c7b188481dadb8d5fffca5e2 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Fri, 15 Nov 2013 17:59:42 +0100 Subject: [PATCH 15/26] disable sending metrics to pusher --- assets/scripts/app/pusher.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/scripts/app/pusher.coffee b/assets/scripts/app/pusher.coffee index 0e1c21ed..efcaeb53 100644 --- a/assets/scripts/app/pusher.coffee +++ b/assets/scripts/app/pusher.coffee @@ -13,7 +13,7 @@ $.extend Travis.Pusher.prototype, init: (config) -> Pusher.warn = @warn.bind(this) Pusher.host = config.host if config.host - @pusher = new Pusher(config.key, encrypted: Travis.Pusher.ENCRYPTED) + @pusher = new Pusher(config.key, encrypted: Travis.Pusher.ENCRYPTED, disableStats: true) @subscribeAll(Travis.Pusher.CHANNELS) if Travis.Pusher.CHANNELS @callbacksToProcess = [] From aa286866a8a84ac6cd557bd8e016ec984b76125e Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Fri, 6 Sep 2013 14:03:25 +0200 Subject: [PATCH 16/26] try simplifying pusher channel subscriptions --- assets/scripts/app/pusher.coffee | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/assets/scripts/app/pusher.coffee b/assets/scripts/app/pusher.coffee index efcaeb53..6c9927ec 100644 --- a/assets/scripts/app/pusher.coffee +++ b/assets/scripts/app/pusher.coffee @@ -19,25 +19,22 @@ $.extend Travis.Pusher.prototype, @callbacksToProcess = [] Visibility.change (e, state) => - if state == 'visible' - @processSavedCallbacks() + @processSavedCallbacks() if state == 'visible' setInterval @processSavedCallbacks.bind(this), @processingIntervalWhenHidden subscribeAll: (channels) -> - for channel in channels - name = @prefix(channel) - channel = @pusher.subscribe(channel) - channel.bind_all((event, data) => @receive(event, data)) + @subscribe(channel) for channel in channels subscribe: (channel) -> - console.log("subscribing to #{channel}") channel = @prefix(channel) - @pusher.subscribe(channel).bind_all((event, data) => @receive(event, data)) unless @pusher?.channel(channel) + console.log("subscribing to #{channel}") + unless @pusher?.channel(channel) + @pusher.subscribe(channel).bind_all((event, data) => @receive(event, data)) unsubscribe: (channel) -> - console.log("unsubscribing from #{channel}") channel = @prefix(channel) + console.log("unsubscribing from #{channel}") @pusher.unsubscribe(channel) if @pusher?.channel(channel) prefix: (channel) -> From 1951784c28692304a006ae9cfab385e7d8348506 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sun, 27 Oct 2013 23:19:37 +0100 Subject: [PATCH 17/26] add private attribute to repo, prefix job channels based on the private status, otherwise use what api hands over --- assets/scripts/app/models/job.coffee | 7 ++++--- assets/scripts/app/models/repo.coffee | 1 + assets/scripts/app/pusher.coffee | 6 ------ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/assets/scripts/app/models/job.coffee b/assets/scripts/app/models/job.coffee index 23649a37..61da5527 100644 --- a/assets/scripts/app/models/job.coffee +++ b/assets/scripts/app/models/job.coffee @@ -93,17 +93,18 @@ require 'travis/model' return if @get('subscribed') @set('subscribed', true) if Travis.pusher - Travis.pusher.subscribe "job-#{@get('id')}" + prefix = if @get('repo.private') then 'private-' else '' + Travis.pusher.subscribe "#{prefix}job-#{@get('id')}", unsubscribe: -> return unless @get('subscribed') @set('subscribed', false) if Travis.pusher + prefix = if @get('repo.private') then 'private-' else '' Travis.pusher.unsubscribe "job-#{@get('id')}" onStateChange: (-> - if @get('state') == 'finished' && Travis.pusher - Travis.pusher.unsubscribe "job-#{@get('id')}" + @unsubscribe() if @get('state') == 'finished' && Travis.pusher ).observes('state') isPropertyLoaded: (key) -> diff --git a/assets/scripts/app/models/repo.coffee b/assets/scripts/app/models/repo.coffee index f3fb1ff5..a26d093c 100644 --- a/assets/scripts/app/models/repo.coffee +++ b/assets/scripts/app/models/repo.coffee @@ -5,6 +5,7 @@ require 'travis/model' id: Ember.attr('string') slug: Ember.attr('string') description: Ember.attr('string') + private: Ember.attr('boolean') lastBuildId: Ember.attr('string') lastBuildNumber: Ember.attr(Number) lastBuildState: Ember.attr('string') diff --git a/assets/scripts/app/pusher.coffee b/assets/scripts/app/pusher.coffee index 6c9927ec..17253183 100644 --- a/assets/scripts/app/pusher.coffee +++ b/assets/scripts/app/pusher.coffee @@ -4,7 +4,6 @@ Travis.Pusher = (key) -> $.extend Travis.Pusher, CHANNELS: ['common'] - CHANNEL_PREFIX: '' ENCRYPTED: false $.extend Travis.Pusher.prototype, @@ -27,19 +26,14 @@ $.extend Travis.Pusher.prototype, @subscribe(channel) for channel in channels subscribe: (channel) -> - channel = @prefix(channel) console.log("subscribing to #{channel}") unless @pusher?.channel(channel) @pusher.subscribe(channel).bind_all((event, data) => @receive(event, data)) unsubscribe: (channel) -> - channel = @prefix(channel) console.log("unsubscribing from #{channel}") @pusher.unsubscribe(channel) if @pusher?.channel(channel) - prefix: (channel) -> - "#{Travis.Pusher.CHANNEL_PREFIX}#{channel}" - # process pusher messages in batches every 5 minutes when the page is hidden processingIntervalWhenHidden: 1000 * 60 * 5 From 5130726389af3a432d3459031bf0d65a86c7ec93 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Mon, 28 Oct 2013 16:41:22 +0100 Subject: [PATCH 18/26] restore CHANNEL_PREFIX, but check if it is already present --- assets/scripts/app/models/job.coffee | 2 -- assets/scripts/app/pusher.coffee | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/scripts/app/models/job.coffee b/assets/scripts/app/models/job.coffee index 61da5527..64cac239 100644 --- a/assets/scripts/app/models/job.coffee +++ b/assets/scripts/app/models/job.coffee @@ -93,14 +93,12 @@ require 'travis/model' return if @get('subscribed') @set('subscribed', true) if Travis.pusher - prefix = if @get('repo.private') then 'private-' else '' Travis.pusher.subscribe "#{prefix}job-#{@get('id')}", unsubscribe: -> return unless @get('subscribed') @set('subscribed', false) if Travis.pusher - prefix = if @get('repo.private') then 'private-' else '' Travis.pusher.unsubscribe "job-#{@get('id')}" onStateChange: (-> diff --git a/assets/scripts/app/pusher.coffee b/assets/scripts/app/pusher.coffee index 17253183..459c690d 100644 --- a/assets/scripts/app/pusher.coffee +++ b/assets/scripts/app/pusher.coffee @@ -4,6 +4,7 @@ Travis.Pusher = (key) -> $.extend Travis.Pusher, CHANNELS: ['common'] + CHANNEL_PREFIX: '' ENCRYPTED: false $.extend Travis.Pusher.prototype, @@ -26,14 +27,19 @@ $.extend Travis.Pusher.prototype, @subscribe(channel) for channel in channels subscribe: (channel) -> + channel = @prefix(channel) console.log("subscribing to #{channel}") unless @pusher?.channel(channel) @pusher.subscribe(channel).bind_all((event, data) => @receive(event, data)) unsubscribe: (channel) -> + channel = @prefix(channel) console.log("unsubscribing from #{channel}") @pusher.unsubscribe(channel) if @pusher?.channel(channel) + prefix: (channel) -> + "#{Travis.Pusher.CHANNEL_PREFIX}#{channel}" unless channel.indexOf(Travis.Pusher.CHANNEL_PREFIX) == 0 + # process pusher messages in batches every 5 minutes when the page is hidden processingIntervalWhenHidden: 1000 * 60 * 5 From e9552a5f60bd78cfae26849458c89d2f1747e2be Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Mon, 28 Oct 2013 17:09:09 +0100 Subject: [PATCH 19/26] can channel be undefined? --- assets/scripts/app/pusher.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/scripts/app/pusher.coffee b/assets/scripts/app/pusher.coffee index 459c690d..4a86bb68 100644 --- a/assets/scripts/app/pusher.coffee +++ b/assets/scripts/app/pusher.coffee @@ -27,18 +27,20 @@ $.extend Travis.Pusher.prototype, @subscribe(channel) for channel in channels subscribe: (channel) -> + return unless channel channel = @prefix(channel) console.log("subscribing to #{channel}") unless @pusher?.channel(channel) @pusher.subscribe(channel).bind_all((event, data) => @receive(event, data)) unsubscribe: (channel) -> + return unless channel channel = @prefix(channel) console.log("unsubscribing from #{channel}") @pusher.unsubscribe(channel) if @pusher?.channel(channel) prefix: (channel) -> - "#{Travis.Pusher.CHANNEL_PREFIX}#{channel}" unless channel.indexOf(Travis.Pusher.CHANNEL_PREFIX) == 0 + "#{Travis.Pusher.CHANNEL_PREFIX}#{channel}" if channel && channel.indexOf(Travis.Pusher.CHANNEL_PREFIX) != 0 # process pusher messages in batches every 5 minutes when the page is hidden processingIntervalWhenHidden: 1000 * 60 * 5 From 6ab834f516bbeb942abb6814a4bd03cfb2a0dcc4 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 29 Oct 2013 14:12:51 +0100 Subject: [PATCH 20/26] fix Travis.Pusher.prefix --- assets/scripts/app/pusher.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/scripts/app/pusher.coffee b/assets/scripts/app/pusher.coffee index 4a86bb68..b2adb484 100644 --- a/assets/scripts/app/pusher.coffee +++ b/assets/scripts/app/pusher.coffee @@ -40,7 +40,10 @@ $.extend Travis.Pusher.prototype, @pusher.unsubscribe(channel) if @pusher?.channel(channel) prefix: (channel) -> - "#{Travis.Pusher.CHANNEL_PREFIX}#{channel}" if channel && channel.indexOf(Travis.Pusher.CHANNEL_PREFIX) != 0 + if channel.indexOf(Travis.Pusher.CHANNEL_PREFIX) != 0 + "#{Travis.Pusher.CHANNEL_PREFIX}#{channel}" + else + channel # process pusher messages in batches every 5 minutes when the page is hidden processingIntervalWhenHidden: 1000 * 60 * 5 From fa8a00194a6d799c84a3adf1806f140e2f7ab366 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 29 Oct 2013 18:31:06 +0100 Subject: [PATCH 21/26] remove stale prefix --- assets/scripts/app/models/job.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/scripts/app/models/job.coffee b/assets/scripts/app/models/job.coffee index 64cac239..d7fff3dd 100644 --- a/assets/scripts/app/models/job.coffee +++ b/assets/scripts/app/models/job.coffee @@ -93,7 +93,7 @@ require 'travis/model' return if @get('subscribed') @set('subscribed', true) if Travis.pusher - Travis.pusher.subscribe "#{prefix}job-#{@get('id')}", + Travis.pusher.subscribe "job-#{@get('id')}", unsubscribe: -> return unless @get('subscribed') From 1909c50647094fa63eccf63f57cbcc9ef58746ca Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Mon, 13 Oct 2014 15:08:15 +0200 Subject: [PATCH 22/26] bundle update --- Gemfile.lock | 149 +++++++++++++++++++++++++-------------------------- 1 file changed, 74 insertions(+), 75 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 45d47aee..72b86129 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,15 +1,15 @@ GIT remote: git://github.com/livingsocial/rake-pipeline.git - revision: 65b1e744defa208e313703d89f3453447cc103b2 + revision: a75d96fbadcc659a35a0ae59212e0bc60b58cc54 specs: rake-pipeline (0.8.0) json - rake (~> 10.0.0) + rake (~> 10.1.0) thor GIT remote: git://github.com/wycats/rake-pipeline-web-filters.git - revision: fd8d838491bd6b8de0bab72d90115b9a4f2da8a1 + revision: 7bd283aac83d7c46a8908f089033a6087d7cd68f specs: rake-pipeline-web-filters (0.6.0) rack @@ -18,103 +18,104 @@ GIT GEM remote: http://rubygems.org/ specs: - POpen4 (0.1.4) - Platform (>= 0.4.0) - open4 - Platform (0.4.0) - backports (3.0.3) - celluloid (0.15.2) - timers (~> 1.1.0) - chunky_png (1.2.7) - coderay (1.0.9) - coffee-script (2.2.0) + backports (3.6.3) + celluloid (0.16.0) + timers (~> 4.0.0) + chunky_png (1.3.1) + coderay (1.1.0) + coffee-script (2.3.0) coffee-script-source execjs - coffee-script-source (1.5.0) - compass (0.12.2) + coffee-script-source (1.8.0) + compass (1.0.1) chunky_png (~> 1.2) - fssm (>= 0.2.7) - sass (~> 3.1) - diff-lcs (1.2.1) - eventmachine (1.0.0) - execjs (1.4.0) + compass-core (~> 1.0.1) + compass-import-once (~> 1.0.5) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + sass (>= 3.3.13, < 3.5) + compass-core (1.0.1) multi_json (~> 1.0) - ffi (1.9.3) - foreman (0.61.0) - thor (>= 0.13.6) - fssm (0.2.10) - guard (1.6.2) - listen (>= 0.6.0) - lumberjack (>= 1.0.2) - pry (>= 0.9.10) - terminal-table (>= 1.4.3) - thor (>= 0.14.6) - handlebars (0.4.0) - commonjs (~> 0.2.3) - therubyracer (~> 0.11.1) + sass (>= 3.3.0, < 3.5) + compass-import-once (1.0.5) + sass (>= 3.2, < 3.5) + diff-lcs (1.2.5) + dotenv (0.11.1) + dotenv-deployment (~> 0.0.2) + dotenv-deployment (0.0.2) + execjs (2.2.1) + ffi (1.9.6) + foreman (0.75.0) + dotenv (~> 0.11.1) + thor (~> 0.19.1) + formatador (0.2.5) + guard (2.6.1) + formatador (>= 0.2.4) + listen (~> 2.7) + lumberjack (~> 1.0) + pry (>= 0.9.12) + thor (>= 0.18.1) hashr (0.0.22) - i18n (0.6.3) - json (1.7.7) - libv8 (3.16.14.3) - listen (2.7.9) + hitimes (1.2.2) + json (1.8.1) + libv8 (3.16.14.7) + listen (2.7.11) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) - lumberjack (1.0.2) - method_source (0.8.1) - multi_json (1.6.1) - open4 (1.3.0) - pry (0.9.12) - coderay (~> 1.0.5) - method_source (~> 0.8) + lumberjack (1.0.9) + method_source (0.8.2) + multi_json (1.10.1) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) slop (~> 3.4) - puma (2.6.0) + puma (2.9.1) rack (>= 1.1, < 2.0) rack (1.5.2) rack-mobile-detect (0.4.0) rack - rack-protection (1.3.2) + rack-protection (1.5.3) rack - rack-ssl (1.3.3) + rack-ssl (1.4.1) rack rack-test (0.6.2) rack (>= 1.0) - rake (10.0.3) - rb-fsevent (0.9.3) + rake (10.1.1) + rb-fsevent (0.9.4) rb-inotify (0.9.5) ffi (>= 0.5.0) rerun (0.10.0) listen (~> 2.7, >= 2.7.3) - rspec (2.13.0) - rspec-core (~> 2.13.0) - rspec-expectations (~> 2.13.0) - rspec-mocks (~> 2.13.0) - rspec-core (2.13.0) - rspec-expectations (2.13.0) + rspec (2.99.0) + rspec-core (~> 2.99.0) + rspec-expectations (~> 2.99.0) + rspec-mocks (~> 2.99.0) + rspec-core (2.99.2) + rspec-expectations (2.99.2) diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.13.0) - sass (3.2.6) - sinatra (1.3.5) + rspec-mocks (2.99.2) + sass (3.4.5) + sinatra (1.4.5) rack (~> 1.4) - rack-protection (~> 1.3) - tilt (~> 1.3, >= 1.3.3) - sinatra-contrib (1.3.2) + rack-protection (~> 1.4) + tilt (~> 1.3, >= 1.3.4) + sinatra-contrib (1.4.2) backports (>= 2.0) - eventmachine + multi_json rack-protection rack-test - sinatra (~> 1.3.0) + sinatra (~> 1.4.0) tilt (~> 1.3) - slop (3.4.3) - terminal-table (1.4.5) - thor (0.17.0) - tilt (1.3.3) - timers (1.1.0) - uglifier (1.3.0) + slop (3.6.0) + thor (0.19.1) + tilt (1.4.1) + timers (4.0.1) + hitimes + uglifier (2.5.3) execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - yui-compressor (0.9.6) - POpen4 (>= 0.1.4) + json (>= 1.8.0) + yui-compressor (0.12.0) PLATFORMS ruby @@ -124,10 +125,8 @@ DEPENDENCIES compass foreman guard - handlebars hashr - localeapp - localeapp-handlebars_i18n + libv8 (~> 3.16.0) puma rack-mobile-detect rack-protection (~> 1.3) From bd4c0aa0a04b11d876c4488380728fbe17a56c4a Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Mon, 13 Oct 2014 17:20:02 +0200 Subject: [PATCH 23/26] do not create two Pusher instances --- assets/scripts/app/app.coffee | 1 - assets/scripts/app/pusher.coffee | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/assets/scripts/app/app.coffee b/assets/scripts/app/app.coffee index 5375c0bc..d79fbb61 100644 --- a/assets/scripts/app/app.coffee +++ b/assets/scripts/app/app.coffee @@ -44,7 +44,6 @@ unless window.TravisApplication @slider = new Travis.Slider() @pusher = new Travis.Pusher(key: Travis.config.pusher_key, host: Travis.config.pusher_host) if Travis.config.pusher_key - @pusher = new Travis.Pusher(Travis.config.pusher_key) if Travis.config.pusher_key @tailing = new Travis.Tailing($(window), '#tail', '#log') @toTop = new Travis.ToTop($(window), '.to-top', '#log-container') diff --git a/assets/scripts/app/pusher.coffee b/assets/scripts/app/pusher.coffee index b2adb484..5cc394b9 100644 --- a/assets/scripts/app/pusher.coffee +++ b/assets/scripts/app/pusher.coffee @@ -1,5 +1,5 @@ -Travis.Pusher = (key) -> - @init(key) # if key +Travis.Pusher = (config) -> + @init(config) this $.extend Travis.Pusher, From bb034704d221c6926adef653e4aab98ce8df8542 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 14 Oct 2014 14:09:42 +0200 Subject: [PATCH 24/26] Patch pusher.js to set a default activity_timeout The current pusher.js throws an error if a connnection handshake reply does not include an activity_timeout. This seems to be new since 2.1.6, and would require changes in slanger for enterprise. --- assets/scripts/vendor/pusher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/scripts/vendor/pusher.js b/assets/scripts/vendor/pusher.js index 6bf133ac..97881a69 100644 --- a/assets/scripts/vendor/pusher.js +++ b/assets/scripts/vendor/pusher.js @@ -83,7 +83,7 @@ f={isSupported:function(){return!1},connect:function(a,b){var c=Pusher.Util.defe b))&&(!a.disabledTransports||-1===Pusher.Util.arrayIndexOf(a.disabledTransports,b))&&("flash"!==b||!0!==a.disableFlash)?new Pusher.TransportStrategy(b,d,n?n.getAssistant(q):q,Pusher.Util.extend({key:a.key,encrypted:a.encrypted,timeline:a.timeline,ignoreNullOrigin:a.ignoreNullOrigin},e)):f;d=a.def(a,b,c)[1];d.transports=a.transports||{};d.transports[b]=c;return[void 0,d]},transport_manager:b(function(a,b){return new Pusher.TransportManager(b)}),sequential:b(function(a,b){var c=Array.prototype.slice.call(arguments, 2);return new Pusher.SequentialStrategy(c,b)}),cached:b(function(a,b,c){return new Pusher.CachedStrategy(c,a.transports,{ttl:b,timeline:a.timeline,encrypted:a.encrypted})}),first_connected:b(function(a,b){return new Pusher.FirstConnectedStrategy(b)}),best_connected_ever:b(function(){var a=Array.prototype.slice.call(arguments,1);return new Pusher.BestConnectedEverStrategy(a)}),delayed:b(function(a,b,c){return new Pusher.DelayedStrategy(c,{delay:b})}),"if":b(function(a,b,c,d){return new Pusher.IfStrategy(b, c,d)}),is_supported:b(function(a,b){return function(){return b.isSupported()}})};Pusher.StrategyBuilder={build:function(a,b){var c=Pusher.Util.extend({},e,b);return d(a,c)[1].strategy}}}).call(this); -(function(){Pusher.Protocol={decodeMessage:function(b){try{var c=JSON.parse(b.data);if("string"===typeof c.data)try{c.data=JSON.parse(c.data)}catch(a){if(!(a instanceof SyntaxError))throw a;}return c}catch(d){throw{type:"MessageParseError",error:d,data:b.data};}},encodeMessage:function(b){return JSON.stringify(b)},processHandshake:function(b){b=this.decodeMessage(b);if("pusher:connection_established"===b.event){if(!b.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected", +(function(){Pusher.Protocol={decodeMessage:function(b){try{var c=JSON.parse(b.data);if("string"===typeof c.data)try{c.data=JSON.parse(c.data)}catch(a){if(!(a instanceof SyntaxError))throw a;}return c}catch(d){throw{type:"MessageParseError",error:d,data:b.data};}},encodeMessage:function(b){return JSON.stringify(b)},processHandshake:function(b){b=this.decodeMessage(b);if("pusher:connection_established"===b.event){if(!b.data.activity_timeout)b.data.activity_timeout=120;return{action:"connected", id:b.data.socket_id,activityTimeout:1E3*b.data.activity_timeout}}if("pusher:error"===b.event)return{action:this.getCloseAction(b.data),error:this.getCloseError(b.data)};throw"Invalid handshake";},getCloseAction:function(b){return 4E3>b.code?1002<=b.code&&1004>=b.code?"backoff":null:4E3===b.code?"ssl_only":4100>b.code?"refused":4200>b.code?"backoff":4300>b.code?"retry":"refused"},getCloseError:function(b){return 1E3!==b.code&&1001!==b.code?{type:"PusherError",data:{code:b.code,message:b.reason||b.message}}: null}}}).call(this); (function(){function b(a,b){Pusher.EventsDispatcher.call(this);this.id=a;this.transport=b;this.activityTimeout=b.activityTimeout;this.bindListeners()}var c=b.prototype;Pusher.Util.extend(c,Pusher.EventsDispatcher.prototype);c.handlesActivityChecks=function(){return this.transport.handlesActivityChecks()};c.send=function(a){return this.transport.send(a)};c.send_event=function(a,b,c){a={event:a,data:b};c&&(a.channel=c);Pusher.debug("Event sent",a);return this.send(Pusher.Protocol.encodeMessage(a))};c.ping= From b348ee0e4057534abdd885235ee3124a5ae4a1ab Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 14 Oct 2014 15:20:14 +0200 Subject: [PATCH 25/26] Revert "Make sorting more in line with what we will do on a server" This makes the timeline ordering odd when restarting: The repo will be sorted to be bottom of the timeline while in :created state, and then pops back up to the top when :started. One weird thing is that it only seems to behave this way on com (staging) and enterprise, but not on org (staging). This reverts commit ce8237b4e75de8a6136123751abc4ceb7b262966. --- assets/scripts/app/models/repo.coffee | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/assets/scripts/app/models/repo.coffee b/assets/scripts/app/models/repo.coffee index a26d093c..aa8c1e99 100644 --- a/assets/scripts/app/models/repo.coffee +++ b/assets/scripts/app/models/repo.coffee @@ -108,17 +108,12 @@ require 'travis/model' ).property('_lastBuildDuration', 'lastBuildStartedAt', 'lastBuildFinishedAt') sortOrder: (-> - # this is prepared for ascending sort - if Ember.isNone(@get('lastBuildFinishedAt')) && @get('lastBuildStartedAt') - # if a build is running, it should be at the beginning - 0 - else if lastBuildStartedAt = @get('lastBuildStartedAt') - # if it's not running, but was already run, put newest builds first - new Date('9999').getTime() - Date.parse(lastBuildStartedAt) + # cuz sortAscending seems buggy when set to false + if lastBuildFinishedAt = @get('lastBuildFinishedAt') + - new Date(lastBuildFinishedAt).getTime() else - # if it's not started nor it was ran before, sort with newest id first - new Date('9999').getTime() - @get('id') - ).property('lastBuildFinishedAt', 'id', 'lastBuildStartedAt') + - new Date('9999').getTime() - parseInt(@get('lastBuildId')) + ).property('lastBuildFinishedAt', 'lastBuildId') stats: (-> if @get('slug') From 7315efed5f1482967510853e3b9f7eb42c052a8b Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 14 Oct 2014 15:29:12 +0200 Subject: [PATCH 26/26] remove extra comma --- assets/scripts/app/models/job.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/scripts/app/models/job.coffee b/assets/scripts/app/models/job.coffee index d7fff3dd..58c5d271 100644 --- a/assets/scripts/app/models/job.coffee +++ b/assets/scripts/app/models/job.coffee @@ -93,7 +93,7 @@ require 'travis/model' return if @get('subscribed') @set('subscribed', true) if Travis.pusher - Travis.pusher.subscribe "job-#{@get('id')}", + Travis.pusher.subscribe "job-#{@get('id')}" unsubscribe: -> return unless @get('subscribed')