From ba79405ec24783245d63ec021d82478fd879f5d7 Mon Sep 17 00:00:00 2001 From: Anders Nickelsen Date: Fri, 14 Oct 2016 07:11:32 +0200 Subject: [PATCH 01/17] Display base completion and saturation times on LotV time-scale. --- .../javascripts/angular/resources/match.js | 28 +++++++++++++++---- app/views/matches/show.html.erb | 6 ++-- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/angular/resources/match.js b/app/assets/javascripts/angular/resources/match.js index 3081285..bfa5047 100644 --- a/app/assets/javascripts/angular/resources/match.js +++ b/app/assets/javascripts/angular/resources/match.js @@ -103,20 +103,20 @@ Entity.prototype.race_macro_pretty = function() { Entity.prototype.mdelta2 = function() { if (this.stats == null || - this.stats.mineral_saturation_2 == null || - this.stats.miningbase_2 == null) { + this.stats.mineral_saturation_2_adjusted == null || + this.stats.miningbase_2_adjusted == null) { return null; } - return Math.max(0, this.stats.mineral_saturation_2 - this.stats.miningbase_2); + return Math.max(0, this.stats.mineral_saturation_2_adjusted - this.stats.miningbase_2_adjusted); } Entity.prototype.mdelta3 = function() { if (this.stats == null || - this.stats.mineral_saturation_3 == null || - this.stats.miningbase_3 == null) { + this.stats.mineral_saturation_3_adjusted == null || + this.stats.miningbase_3_adjusted == null) { return null; } - return Math.max(0, this.stats.mineral_saturation_3 - this.stats.miningbase_3); + return Math.max(0, this.stats.mineral_saturation_3_adjusted - this.stats.miningbase_3_adjusted); } Entity.prototype.color_style = function() { @@ -640,6 +640,22 @@ gg.factory('Match', ['$ggResource', '$compile', 'Matchnote', function($ggResourc } entity.summary.resource_collection_rate_adjusted = Math.round(entity.summary.resource_collection_rate*speed_multiplier) + if (entity.stats.mineral_saturation_1 != null) { + entity.stats.mineral_saturation_1_adjusted = Math.round(entity.stats.mineral_saturation_1/speed_multiplier) + } + if (entity.stats.mineral_saturation_2 != null) { + entity.stats.mineral_saturation_2_adjusted = Math.round(entity.stats.mineral_saturation_2/speed_multiplier) + } + if (entity.stats.mineral_saturation_3 != null) { + entity.stats.mineral_saturation_3_adjusted = Math.round(entity.stats.mineral_saturation_3/speed_multiplier) + } + + if (entity.stats.miningbase_2 != null) { + entity.stats.miningbase_2_adjusted = Math.round(entity.stats.miningbase_2/speed_multiplier) + } + if (entity.stats.miningbase_3 != null) { + entity.stats.miningbase_3_adjusted = Math.round(entity.stats.miningbase_3/speed_multiplier) + } } if(this.MineralsCurrent && this.MineralsCurrent[entity.identity.id]) { diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index 343be75..8af259a 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -164,12 +164,12 @@ 2nd Mining Base Complete - {{ entity.stats.miningbase_2 | minutes_seconds }} + {{ entity.stats.miningbase_2_adjusted | minutes_seconds }} 3rd Mining Base Complete - {{ entity.stats.miningbase_3 | minutes_seconds}} + {{ entity.stats.miningbase_3_adjusted | minutes_seconds}} Saturation Speed {{ entity.identity.name }} @@ -181,7 +181,7 @@ 1 Base Mineral Income (870) - {{ entity.stats.mineral_saturation_1 | minutes_seconds }} + {{ entity.stats.mineral_saturation_1_adjusted | minutes_seconds }} From daa00e5a542b6413eda857351cd6dd8b2dfbde8b Mon Sep 17 00:00:00 2001 From: dsjoerg Date: Tue, 28 Feb 2017 17:03:08 -0500 Subject: [PATCH 02/17] adjust LotV time multiplier to 1.36 to be consistent with ggpyjobs --- app/assets/javascripts/angular/helpers/sc2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/angular/helpers/sc2.js b/app/assets/javascripts/angular/helpers/sc2.js index 7e96edb..9955c33 100644 --- a/app/assets/javascripts/angular/helpers/sc2.js +++ b/app/assets/javascripts/angular/helpers/sc2.js @@ -256,7 +256,7 @@ for (var expansion_tag in Sc2.armyUnits) { } } -Sc2.LOTV_SPEEDUP = 1.4; +Sc2.LOTV_SPEEDUP = 1.36; Sc2.frameToTime = function(frame, expansion) { fps = 16; From 1aa622d99593022b8a427befa9d814d73c6e4a90 Mon Sep 17 00:00:00 2001 From: dsjoerg Date: Tue, 28 Feb 2017 17:03:38 -0500 Subject: [PATCH 03/17] adjust LotV time multiplier to 1.36 to be consistent with ggpyjobs --- app/assets/javascripts/angular/helpers/sc2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/angular/helpers/sc2.js b/app/assets/javascripts/angular/helpers/sc2.js index 7e96edb..9955c33 100644 --- a/app/assets/javascripts/angular/helpers/sc2.js +++ b/app/assets/javascripts/angular/helpers/sc2.js @@ -256,7 +256,7 @@ for (var expansion_tag in Sc2.armyUnits) { } } -Sc2.LOTV_SPEEDUP = 1.4; +Sc2.LOTV_SPEEDUP = 1.36; Sc2.frameToTime = function(frame, expansion) { fps = 16; From cbe0ca49444b0d883d3a8ff2b826b7d0418aa499 Mon Sep 17 00:00:00 2001 From: dsjoerg Date: Sat, 29 Jul 2017 12:16:18 -0400 Subject: [PATCH 04/17] implement recaptcha. its ugly as hell but it works and this way we can keep emailing --- Gemfile | 1 + Gemfile.lock | 14 +++++++++++++- app/controllers/users_controller.rb | 10 ++++++++++ app/views/devise/registrations/new.html.erb | 18 +++++++++++++++++- config/initializers/recaptcha.rb | 4 ++++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 config/initializers/recaptcha.rb diff --git a/Gemfile b/Gemfile index 6e8ae15..16ef52b 100644 --- a/Gemfile +++ b/Gemfile @@ -147,3 +147,4 @@ gem 'rack-attack' gem 'unf_ext', '0.0.6' gem 'foreman' +gem "recaptcha", :git => 'git://github.com/brendon/recaptcha.git', :ref => 'remove-ruby-restriction', require: "recaptcha/rails" diff --git a/Gemfile.lock b/Gemfile.lock index 410f5bc..cfd390e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,6 +5,14 @@ GIT compass-rails (2.0.alpha.0) compass (>= 0.12.2, < 0.14) +GIT + remote: git://github.com/brendon/recaptcha.git + revision: 21473e536b93c0237ec02edcc78cf4f7a547a221 + ref: remove-ruby-restriction + specs: + recaptcha (1.3.0) + json + GIT remote: git://github.com/chriseppstein/compass.git revision: 0a74e91931e53fb798323cd8684198c38a2b76b8 @@ -331,6 +339,7 @@ DEPENDENCIES rack-attack rails (= 3.2.22) rails-dev-boost! + recaptcha! resque rspec rspec-rails @@ -340,5 +349,8 @@ DEPENDENCIES unf_ext (= 0.0.6) unicorn +RUBY VERSION + ruby 1.9.3p484 + BUNDLED WITH - 1.11.2 + 1.15.3 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index fa9844b..e8b2b46 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,6 @@ class UsersController < Devise::RegistrationsController before_filter :authenticate_user!, :except => [:auth] + prepend_before_filter :check_captcha, only: [:create] # Change this to be any actions you want to protect. respond_to :html, :json, :xml # Overriding devise helpers @@ -38,4 +39,13 @@ def update current_user.update_attributes(params[:user]) render :text => "OK" end + + private + def check_captcha + unless verify_recaptcha + self.resource = resource_class.new sign_up_params + respond_with_navigational(resource) { render :new } + else + end + end end diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 66879f5..a68de3c 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1 +1,17 @@ -<%= render 'devise/aio' %> \ No newline at end of file +

Sign up

+ +<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> + <%= devise_error_messages! %> + <%= flash[:recaptcha_error] %> + +
<%= f.label :email %>
+ <%= f.email_field :email, :autofocus => true %>
+ +
<%= f.label :password %>
+ <%= f.password_field :password %>
+ +
+ <%= recaptcha_tags(stoken: false, ajax: true) %> +
+
<%= f.submit "Sign up" %>
+<% end %> diff --git a/config/initializers/recaptcha.rb b/config/initializers/recaptcha.rb new file mode 100644 index 0000000..35132d2 --- /dev/null +++ b/config/initializers/recaptcha.rb @@ -0,0 +1,4 @@ +Recaptcha.configure do |config| + config.public_key = '6Lcg3SkUAAAAAO4yYqDriPdh-er7islVavz1m-X2' + config.private_key = '6Lcg3SkUAAAAAEKwJT0Xy-U8XRC8_Qhc1w6FlZRv' +end From 5b2b1b6b12b527128beb06a446f76e4bd4be135a Mon Sep 17 00:00:00 2001 From: dsjoerg Date: Sat, 29 Jul 2017 12:36:33 -0400 Subject: [PATCH 05/17] dont expose secret key for recaptcha --- config/initializers/recaptcha.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/initializers/recaptcha.rb b/config/initializers/recaptcha.rb index 35132d2..62e06e9 100644 --- a/config/initializers/recaptcha.rb +++ b/config/initializers/recaptcha.rb @@ -1,4 +1,4 @@ Recaptcha.configure do |config| - config.public_key = '6Lcg3SkUAAAAAO4yYqDriPdh-er7islVavz1m-X2' - config.private_key = '6Lcg3SkUAAAAAEKwJT0Xy-U8XRC8_Qhc1w6FlZRv' + config.public_key = '6Lc35yoUAAAAACUODLMbUxj4pC7NfUt5s-i76Z7D' + config.private_key = Rails.application.secret('recaptcha_secret') end From 1d730a07eb37a315251242a3ffc2ebb5be3f38f2 Mon Sep 17 00:00:00 2001 From: dsjoerg Date: Fri, 27 Oct 2017 13:31:49 -0400 Subject: [PATCH 06/17] remove go_pro --- app/views/layouts/application.html.erb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index f7feb85..6891d21 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -149,11 +149,7 @@ _\%_____/\%_____/\%_____/\%_/ /\%___fx/\%_____/\__/ /\%_____/\__/ /.com_
  • Scelight
  • - <% if signed_in? && !current_user.pro? %> -
  • go pro
  • - <% else %> -
  • tour
  • - <% end %> +
  • tour
  • From 9fe1307024f1aed4b177a7bd78271bbbc15db2c2 Mon Sep 17 00:00:00 2001 From: dsjoerg Date: Wed, 29 Nov 2017 12:17:32 -0500 Subject: [PATCH 07/17] start preventing uploads with a configurable percentage of uploaders --- app/assets/javascripts/gg.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/assets/javascripts/gg.js b/app/assets/javascripts/gg.js index 28ab5f7..b0e2729 100644 --- a/app/assets/javascripts/gg.js +++ b/app/assets/javascripts/gg.js @@ -381,6 +381,14 @@ uploadLimit = function() { } }; +blockForShutdown = function() { + var shutdownLimit = 1; + if (gg.limits) { + shutdownLimit = gg.limits[3]; + } + return (Math.random() * 100 < shutdownLimit); +} + notifyAboutUploadLimit = _.once(function() { accountDescrip = ["Anonymous", "Free", "Pro"][userLevel()]; ul = uploadLimit(); @@ -397,6 +405,10 @@ notifyAboutUploadLimit = _.once(function() { alert(apology + accountDescrip + " accounts are limited to " + uploadLimit() + " replay" + plural + " per upload. You can upload more any time you want."); }); +notifyAboutGGGReplays = _.once(function() { + alert("Hi, GGTracker is shutting down but you can upload your replays to GGGReplays.com (a GGTracker clone), or to SC2ReplayStats.com or Drop.sc."); +}); + $(function() { fuconfig = { @@ -448,6 +460,8 @@ $(function() { if (uploadScope.allreplays.length >= uploadLimit()) { notifyAboutUploadLimit(); + } else if (blockForShutdown()) { + notifyAboutGGGReplays(); } else { From e29ca4929f1b3afb4021daab181ab392cf7170c6 Mon Sep 17 00:00:00 2001 From: dsjoerg Date: Wed, 29 Nov 2017 12:25:07 -0500 Subject: [PATCH 08/17] not working perfectly yet --- app/assets/javascripts/gg.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/gg.js b/app/assets/javascripts/gg.js index b0e2729..7b35917 100644 --- a/app/assets/javascripts/gg.js +++ b/app/assets/javascripts/gg.js @@ -459,9 +459,11 @@ $(function() { } if (uploadScope.allreplays.length >= uploadLimit()) { - notifyAboutUploadLimit(); + notifyAboutUploadLimit(); + return false; } else if (blockForShutdown()) { - notifyAboutGGGReplays(); + notifyAboutGGGReplays(); + return false; } else { From 4e234bc6da8bdd426a8469c58f4addb625284ceb Mon Sep 17 00:00:00 2001 From: dsjoerg Date: Mon, 11 Dec 2017 09:51:28 -0500 Subject: [PATCH 09/17] GGGReplays clarification --- app/assets/javascripts/gg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/gg.js b/app/assets/javascripts/gg.js index 7b35917..370bba5 100644 --- a/app/assets/javascripts/gg.js +++ b/app/assets/javascripts/gg.js @@ -406,7 +406,7 @@ notifyAboutUploadLimit = _.once(function() { }); notifyAboutGGGReplays = _.once(function() { - alert("Hi, GGTracker is shutting down but you can upload your replays to GGGReplays.com (a GGTracker clone), or to SC2ReplayStats.com or Drop.sc."); + alert("Hi, GGTracker is shutting down but you can upload your replays to GGGReplays.com (a GGTracker clone; note three Gs in the name), or to SC2ReplayStats.com or Drop.sc."); }); $(function() { From 0f5015b8188f1edd33a16006fc154016ee7ad637 Mon Sep 17 00:00:00 2001 From: dsjoerg Date: Mon, 11 Dec 2017 09:51:38 -0500 Subject: [PATCH 10/17] no more uploading or signing up --- app/views/layouts/application.html.erb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6891d21..51424d6 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -160,17 +160,10 @@ _\%_____/\%_____/\%_____/\%_/ /\%___fx/\%_____/\__/ /\%_____/\__/ /.com_