mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Switch to new plan features model
This commit is contained in:
parent
cbd4b1bf0b
commit
b112db7e62
6 changed files with 16 additions and 18 deletions
5
app.rb
5
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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<% if current_site.updated_at %>
|
||||
<li>Last updated <%= current_site.updated_at.ago.downcase %></li>
|
||||
<% end %>
|
||||
<li>Using <strong><%= current_site.space_percentage_used %>% (<%= current_site.total_used_space.to_space_pretty %>) of your <%= current_site.maximum_space.to_space_pretty %></strong>.
|
||||
<li>Using <strong><%= current_site.space_percentage_used %>% (<%= current_site.total_space_used.to_space_pretty %>) of your <%= current_site.maximum_space.to_space_pretty %></strong>.
|
||||
<br>
|
||||
<% if !current_site.supporter? %>Need more space? <a href="/plan">Become a Supporter!</a><% end %></li>
|
||||
<li><strong><%= current_site.hits.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse %></strong> hits</li>
|
||||
|
|
|
@ -332,7 +332,7 @@
|
|||
<strong>It's affordable.</strong> As low as <strong>$<%= Site::PLAN_FEATURES[:supporter][:price] %>/month</strong> (billed once every year). Higher tiers are optional (and appreciated!)
|
||||
</li>
|
||||
<li>
|
||||
<strong>You can cancel or change plans anytime.</strong> If you do, we'll refund/prorate the amount you didn't use.
|
||||
<strong>You can cancel or change plans anytime.</strong> If you do, we'll refund or credit the amount you didn't use.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -375,7 +375,7 @@
|
|||
</div>
|
||||
<div class="modal-body">
|
||||
<div>
|
||||
You are <% if current_site && parent_site.plan_type == 'free' %>upgrading<%else%>changing<%end%> to the <strong><span id="upgradeFormPlanName"></span> Plan</strong>. You will be charged <span id="upgradeFormPlanPrice"></span>.
|
||||
You are <% if current_site && parent_site.plan_type == 'free' %>upgrading<%else%>changing<%end%> to the <strong><span id="upgradeFormPlanName"></span> Plan</strong>. You will be charged <span id="upgradeFormPlanPrice"></span>. <% 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 %>
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
<article>
|
||||
<div class="txt-Center"><img src="/img/heartcat.png"></div>
|
||||
|
||||
<h1 class="txt-Center">Thank you for your support.</h1>
|
||||
<h1 class="txt-Center">You now have the <%= Site::PLAN_FEATURES[parent_site.plan_type.to_sym][:name] %> plan.<br>Thank you for your support!</h1>
|
||||
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
|
|
Loading…
Add table
Reference in a new issue