diff --git a/app.rb b/app.rb index 364d3212..8206bc54 100644 --- a/app.rb +++ b/app.rb @@ -308,7 +308,7 @@ post '/plan/update' do }) end - redirect '/plan/thanks' + redirect params[:plan_type] == 'free' ? '/plan' : '/plan/thanks' end get '/plan/thanks' do @@ -591,7 +591,8 @@ post '/create' do password: params[:password], email: params[:email], new_tags_string: params[:tags], - ip: request.ip + ip: request.ip, + created_at: Time.now ) black_box_answered = BlackBox.valid? params[:blackbox_answer], request.ip diff --git a/environment.rb b/environment.rb index ea977c0d..a41cc725 100644 --- a/environment.rb +++ b/environment.rb @@ -88,7 +88,6 @@ Sequel.extension :core_extensions Sequel.extension :migration Sequel::Model.plugin :validation_helpers Sequel::Model.plugin :force_encoding, 'UTF-8' -Sequel::Model.plugin :timestamps, create: :created_at, update: :updated_at Sequel::Model.plugin :defaults_setter Sequel.default_timezone = 'UTC' Sequel::Migrator.apply DB, './migrations' diff --git a/models/site.rb b/models/site.rb index 5a5d9268..9e981108 100644 --- a/models/site.rb +++ b/models/site.rb @@ -34,9 +34,6 @@ class Site < Sequel::Model geojson csv tsv mf ico pdf asc key pgp xml mid midi } - FREE_MAXIMUM = 20 * Numeric::ONE_MEGABYTE - SUPPORTER_MAXIMUM = 1000 * Numeric::ONE_MEGABYTE - MINIMUM_PASSWORD_LENGTH = 5 BAD_USERNAME_REGEX = /[^\w-]/i VALID_HOSTNAME = /^[a-z0-9][a-z0-9-]+?[a-z0-9]$/i # http://tools.ietf.org/html/rfc1123 @@ -457,7 +454,7 @@ class Site < Sequel::Model path = files_path path if File.exist?(path) && - Digest::SHA2.file(path).digest == Digest::SHA2.file(uploaded.path).digest + Digest::SHA1.file(path).digest == Digest::SHA1.file(uploaded.path).digest return false end @@ -802,32 +799,32 @@ class Site < Sequel::Model end def file_size_too_large?(size) - return true if size + used_space > maximum_space + return true if size + space_used > maximum_space false end - def used_space + def actual_space_used space = Dir.glob(File.join(files_path, '*')).collect {|p| File.size(p)}.inject {|sum,x| sum += x} space.nil? ? 0 : space end - def total_used_space + def total_space_used total = 0 - account_sites.each {|s| total += s.used_space} + account_sites.each {|s| total += s.space_used} total end def remaining_space - remaining = maximum_space - total_used_space + remaining = maximum_space - total_space_used remaining < 0 ? 0 : remaining end def maximum_space - (parent? ? self : parent).supporter? ? SUPPORTER_MAXIMUM : FREE_MAXIMUM + PLAN_FEATURES[(parent? ? self : parent).plan_type.to_sym][:space] end def space_percentage_used - ((total_used_space.to_f / maximum_space) * 100).round(1) + ((total_space_used.to_f / maximum_space) * 100).round(1) end def supporter? diff --git a/views/dashboard.erb b/views/dashboard.erb index 0189274d..11bf1dff 100644 --- a/views/dashboard.erb +++ b/views/dashboard.erb @@ -34,7 +34,7 @@ <% if current_site.updated_at %>
  • Last updated <%= current_site.updated_at.ago.downcase %>
  • <% end %> -
  • Using <%= current_site.space_percentage_used %>% (<%= current_site.total_used_space.to_space_pretty %>) of your <%= current_site.maximum_space.to_space_pretty %>. +
  • Using <%= current_site.space_percentage_used %>% (<%= current_site.total_space_used.to_space_pretty %>) of your <%= current_site.maximum_space.to_space_pretty %>.
    <% if !current_site.supporter? %>Need more space? Become a Supporter!<% end %>
  • <%= current_site.hits.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse %> hits
  • diff --git a/views/plan/_pricing.erb b/views/plan/_pricing.erb index fb3b914c..b2a0ac65 100644 --- a/views/plan/_pricing.erb +++ b/views/plan/_pricing.erb @@ -332,7 +332,7 @@ It's affordable. As low as $<%= Site::PLAN_FEATURES[:supporter][:price] %>/month (billed once every year). Higher tiers are optional (and appreciated!)
  • - You can cancel or change plans anytime. If you do, we'll refund/prorate the amount you didn't use. + You can cancel or change plans anytime. If you do, we'll refund or credit the amount you didn't use.
  • @@ -375,7 +375,7 @@