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 %>
- You are <% if current_site && parent_site.plan_type == 'free' %>upgrading<%else%>changing<%end%> to the
Plan. You will be charged
.
+ You are <% if current_site && parent_site.plan_type == 'free' %>upgrading<%else%>changing<%end%> to the
Plan. You will be charged
. <% if current_site && parent_site.plan_type != 'free' %>We'll credit or refund the remaining amount you didn't use on your previous plan.<% end %>
<% unless current_site && parent_site.stripe_customer_id %>
Please enter your Credit Card number:
<% end %>
diff --git a/views/plan/thanks.erb b/views/plan/thanks.erb
index e33bdcaa..e96a5db7 100644
--- a/views/plan/thanks.erb
+++ b/views/plan/thanks.erb
@@ -10,7 +10,8 @@
- Thank you for your support.
+ You now have the <%= Site::PLAN_FEATURES[parent_site.plan_type.to_sym][:name] %> plan.
Thank you for your support!
+
Your support allows Neocities to continue our project to bring back the web. We will do our best to ensure that the site remains a great place for people to express themselves - one web page at a time.