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/assets/javascripts/gg.js b/app/assets/javascripts/gg.js index 28ab5f7..e5e63e4 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,148 +405,13 @@ notifyAboutUploadLimit = _.once(function() { alert(apology + accountDescrip + " accounts are limited to " + uploadLimit() + " replay" + plural + " per upload. You can upload more any time you want."); }); -$(function() { - - fuconfig = { - url: 'https://' + gon.global.replays_bucket + '.s3.amazonaws.com', - type: 'POST', - autoUpload: true, - dataType: 'xml', - add: function(e, data) { -// console.log("add!", data.files.length); - - if (gg.state.iecompat) { - alert("Our apologies, but this browser can't upload replays to GGTracker. To upload replays, you can use Internet Explorer 10, Google Chrome, Firefox or Safari."); - return false; - } - - uploadScope = angular.element($('.uploads')).scope(); - - if (_.isUndefined(rootScope.creplays) || rootScope.creplays.length == 0) { - // creplays are the replays that are still being uploaded/processed. - // allreplays has all of the replays that were uploaded for this upload, regardless of their state - uploadScope.creplays = [] - uploadScope.allreplays = [] - // console.log("clearing arrays!"); - - $('#uploads') - .dialog({ - modal: true, - draggable: false, - resizable: false, - dialogClass: 'dialog-uploads', - width: 'auto', - position: { my: 'top', at: 'top+75' }, - collision: 'none', - show: 'slide' - }). - addClass('uploads-expanded'); - - $(window).bind('beforeunload', function () { - // console.log("beforeunload!", $('.button-upload input'), $('.button-upload input').data('fileupload'), uploadScope); - // return 'Foo!'; - if ($('.button-upload input').data('fileupload')._active > 0 && - uploadScope.creplays.length > 0) { - - // console.log("Not leaving yet", $('#upload input').data('fileupload'), $('#upload input').data('fileupload')._active); - return 'Leaving now will cancel your uploads in progress.'; - } - }); - } - - if (uploadScope.allreplays.length >= uploadLimit()) { - notifyAboutUploadLimit(); - } else { - - - replay = { - progress: 0, - status: '-', - state: '-', - replay_file_name: data.files[0].name - }; - uploadScope.creplays.push(replay); - uploadScope.allreplays.push(replay); - throttledUploadDigest(); - - $.ajax({ - url: "/signed_urls", - type: 'GET', - dataType: 'json', - data: {doc: {title: data.files[0].name}}, // send the file name to the server so it can generate the key param - async: false, - success: function(ajaxdata) { - data.formData = { - key: ajaxdata.key, - AWSAccessKeyId: gon.global.replays_access_key, - acl: 'public-read', - policy: ajaxdata.policy, - signature: ajaxdata.signature, - success_action_status: '201' - }; - data.submit(); - } - }); - } - }, - - send: function(e, data) { - uploadScope = angular.element($('.uploads')).scope(); - $.each(data.files, function(i, file) { - replay = _.find(uploadScope.creplays, function(rep) { return rep.replay_file_name == file.name }) - if (! _.isUndefined(replay)) { - replay.status = 'Uploading'; - setState(replay, 'Uploading'); - } - }); - throttledUploadDigest(); - }, - - drop: function(e, data) { - }, - - change: function(e, data) { - }, - - progress: function (e, data) { - // console.log("progress"); - - var progress = parseInt(data.loaded / data.total * 100, 10); - - uploadScope = angular.element($('.uploads')).scope(); - replay = _.find(uploadScope.creplays, function(rep) { return rep.replay_file_name == data.files[0].name }) +notifyAboutGGGReplays = function() { + 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."); +}; - if(! _.isUndefined(replay)) { - replay.progress = progress; - if(progress == 100) { - replay.status = 'Waiting to be processed'; - setState(replay, 'processing'); - } - } else { - // console.log('NNAYITS1238', data.files[0].name, rootScope.creplays, replay); - } - - throttledUploadDigest(); - }, - - done: function(e, data) { - // console.log("done! ", $(data.result.getElementsByTagName("Location")[0]).text(), data.files[0].name); - - $.ajax({ - url: '/replays/s3_drop', - type: 'POST', - data: { - file_name: data.files[0].name, - s3_key: $(data.result.getElementsByTagName("Key")[0]).text(), - channel: gg.settings.replay_channel - }, - async: true, - }); - } - }; // fuconfig +$(function() { - $('.button-upload input[name="file"]').fileupload(fuconfig); - $('.button-upload input[name="differentname"]').fileupload(fuconfig); + $('.button-upload').click(notifyAboutGGGReplays); join = function(which_one) { 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..bf6bba4 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1 +1,3 @@ -<%= render 'devise/aio' %> \ No newline at end of file +

Sign up

+ +Actually no, don't sign up. Go to gggreplays.com instead. diff --git a/app/views/devise/shared/_links.erb b/app/views/devise/shared/_links.erb index eab783a..cd883af 100644 --- a/app/views/devise/shared/_links.erb +++ b/app/views/devise/shared/_links.erb @@ -2,10 +2,6 @@ <%= link_to "Sign in", new_session_path(resource_name) %>
<% end -%> -<%- if devise_mapping.registerable? && controller_name != 'registrations' %> - <%= link_to "Sign up", new_registration_path(resource_name) %>
-<% end -%> - <%- if devise_mapping.recoverable? && controller_name != 'passwords' %> <%= link_to "Forgot your password?", new_password_path(resource_name) %>
<% end -%> diff --git a/app/views/dialogs/_join_aio.html.erb b/app/views/dialogs/_join_aio.html.erb index b5bc1ee..284215b 100644 --- a/app/views/dialogs/_join_aio.html.erb +++ b/app/views/dialogs/_join_aio.html.erb @@ -1,14 +1,6 @@
- <%= semantic_form_for(resource, :method => 'post', :url => registration_path(:user)) do |f| %> - <%= f.inputs do %> - <%= f.input :email, :label => false, :input_html => {:placeholder => 'E-Mail Address'} %> - <%= f.input :password, :label => false, :input_html => {:placeholder => 'Password'} %> - <%= f.action :submit, :as => :button, :label => 'sign up' %> - <% end %> - <% end %> - login forgot password?
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index f7feb85..9afc1d9 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
  • @@ -164,17 +160,15 @@ _\%_____/\%_____/\%_____/\%_/ /\%___fx/\%_____/\__/ /\%_____/\__/ /.com_
    -
    - <%= render('dialogs/join_aio', :resource => User.new) %> -
    - <% if !controller.is_a?(HomeController) %> diff --git a/config/environments/production.rb b/config/environments/production.rb index 205fb74..b8b186e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -13,7 +13,7 @@ # if source.end_with?('png') || source.end_with?('gif') || source.end_with?('jpg') # '' # else - request && request.ssl? ? 'https://ggtracker.com' : 'http://a1.ggtracker.com' + 'http://ggtracker.com' # end } @@ -25,7 +25,7 @@ config.action_controller.perform_caching = true # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false + config.serve_static_assets = true # Compress JavaScripts and CSS config.assets.compress = true diff --git a/config/initializers/recaptcha.rb b/config/initializers/recaptcha.rb new file mode 100644 index 0000000..62e06e9 --- /dev/null +++ b/config/initializers/recaptcha.rb @@ -0,0 +1,4 @@ +Recaptcha.configure do |config| + config.public_key = '6Lc35yoUAAAAACUODLMbUxj4pC7NfUt5s-i76Z7D' + config.private_key = Rails.application.secret('recaptcha_secret') +end