mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
Merge branch 'master' of github.com:neocities/neocities
This commit is contained in:
commit
49df4a4d21
10 changed files with 143 additions and 7 deletions
37
Rakefile
37
Rakefile
|
@ -216,6 +216,43 @@ task :hash_ips => [:environment] do
|
|||
end
|
||||
end
|
||||
|
||||
desc 'prime_site_files'
|
||||
task :prime_site_files => [:environment] do
|
||||
Site.where(is_banned: false).select(:id, :username).all.each do |site|
|
||||
Dir.glob(File.join(site.files_path, '**/*')).each do |file|
|
||||
next unless site.username == 'kyledrake'
|
||||
path = file.gsub(site.base_files_path, '').sub(/^\//, '')
|
||||
|
||||
site_file = site.site_files_dataset[path: path]
|
||||
|
||||
if site_file.nil?
|
||||
next if File.directory? file
|
||||
mtime = File.mtime file
|
||||
site.add_site_file(
|
||||
path: path,
|
||||
size: File.size(file),
|
||||
sha1_hash: Digest::SHA1.file(file).hexdigest,
|
||||
updated_at: mtime,
|
||||
created_at: mtime
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc 'dedupe_follows'
|
||||
task :dedupe_follows => [:environment] do
|
||||
follows = Follow.all
|
||||
deduped_follows = Follow.all.uniq {|f| "#{f.site_id}_#{f.actioning_site_id}"}
|
||||
|
||||
follows.each do |follow|
|
||||
unless deduped_follows.include?(follow)
|
||||
puts "deleting dedupe: #{follow.inspect}"
|
||||
follow.delete
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
=begin
|
||||
desc 'Update screenshots'
|
||||
task :update_screenshots => [:environment] do
|
||||
|
|
|
@ -334,3 +334,29 @@ get '/settings/unsubscribe_email/?' do
|
|||
end
|
||||
erb :'settings/account/unsubscribe'
|
||||
end
|
||||
|
||||
post '/settings/update_card' do
|
||||
require_login
|
||||
|
||||
customer = Stripe::Customer.retrieve current_site.stripe_customer_id
|
||||
|
||||
old_card_ids = customer.sources.collect {|s| s.id}
|
||||
|
||||
begin
|
||||
customer.sources.create source: params[:stripe_token]
|
||||
rescue Stripe::InvalidRequestError => e
|
||||
if e.message.match /cannot use a.+token more than once/
|
||||
flash[:error] = 'Card is already being used.'
|
||||
redirect '/settings#billing'
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
old_card_ids.each do |card_id|
|
||||
customer.sources.retrieve(card_id).delete
|
||||
end
|
||||
|
||||
flash[:success] = 'Card information updated.'
|
||||
redirect '/settings#billing'
|
||||
end
|
||||
|
|
9
migrations/073_add_follow_uniqueness.rb
Normal file
9
migrations/073_add_follow_uniqueness.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
Sequel.migration do
|
||||
up {
|
||||
DB['alter table follows add constraint one_follow_per_site unique (site_id, actioning_site_id)'].first
|
||||
}
|
||||
|
||||
down {
|
||||
DB['alter table follows drop constraint one_follow_per_site'].first
|
||||
}
|
||||
end
|
|
@ -591,7 +591,11 @@ class Site < Sequel::Model
|
|||
# We gotta flush the dirname too if it's an index file.
|
||||
if relative_path != '' && relative_path.match(/\/$|index\.html?$/i)
|
||||
PurgeCacheOrderWorker.perform_async username, relative_path
|
||||
PurgeCacheOrderWorker.perform_async username, Pathname(relative_path).dirname.to_s
|
||||
|
||||
purge_file_path = Pathname(relative_path).dirname.to_s
|
||||
|
||||
PurgeCacheOrderWorker.perform_async username, '/?surf=1' if purge_file_path == '/'
|
||||
PurgeCacheOrderWorker.perform_async username, purge_file_path
|
||||
else
|
||||
PurgeCacheOrderWorker.perform_async username, relative_path
|
||||
end
|
||||
|
@ -976,6 +980,10 @@ class Site < Sequel::Model
|
|||
PLAN_FEATURES[plan_type.to_sym][:name]
|
||||
end
|
||||
|
||||
def stripe_paying_supporter?
|
||||
stripe_customer_id && !plan_ended && values[:plan_type].match(/free|special/).nil?
|
||||
end
|
||||
|
||||
def unconverted_legacy_supporter?
|
||||
stripe_customer_id && !plan_ended && values[:plan_type].nil? && stripe_subscription_id.nil?
|
||||
end
|
||||
|
|
|
@ -107,13 +107,17 @@ describe 'site_files' do
|
|||
@site.title.must_equal 'Hello?'
|
||||
|
||||
# Purge cache needs to flush / and index.html for either scenario.
|
||||
PurgeCacheOrderWorker.jobs.length.must_equal 2
|
||||
PurgeCacheOrderWorker.jobs.length.must_equal 3
|
||||
first_purge = PurgeCacheOrderWorker.jobs.first
|
||||
surf_purge = PurgeCacheOrderWorker.jobs[1]
|
||||
dirname_purge = PurgeCacheOrderWorker.jobs.last
|
||||
|
||||
username, pathname = first_purge['args']
|
||||
username.must_equal @site.username
|
||||
pathname.must_equal '/index.html'
|
||||
|
||||
surf_purge['args'].last.must_equal '/?surf=1'
|
||||
|
||||
username, pathame = nil
|
||||
username, pathname = dirname_purge['args']
|
||||
username.must_equal @site.username
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
<div class="content" style="background: white">
|
||||
<form method="POST" action="/admin/report">
|
||||
<%== csrf_token_input_html %>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>Site</th>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
var signupform = $(event.target)
|
||||
|
||||
<% if current_site && parent_site.stripe_subscription_id %>
|
||||
<% if current_site && parent_site.stripe_subscription_id && !request.path.match(/\/settings/) %>
|
||||
return true
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
<li><a href="#sites" data-toggle="tab">Sites</a></li>
|
||||
<li><a href="#password" data-toggle="tab">Password</a></li>
|
||||
<li><a href="#email" data-toggle="tab">Email</a></li>
|
||||
<% if current_site.stripe_paying_supporter? %>
|
||||
<li><a href="#billing" data-toggle="tab">Billing</a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="plan">
|
||||
|
@ -41,6 +44,11 @@
|
|||
<div class="tab-pane" id="email">
|
||||
<%== erb :'settings/account/email' %>
|
||||
</div>
|
||||
<% if current_site.stripe_paying_supporter? %>
|
||||
<div class="tab-pane" id="billing">
|
||||
<%== erb :'settings/account/billing' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
45
views/settings/account/billing.erb
Normal file
45
views/settings/account/billing.erb
Normal file
|
@ -0,0 +1,45 @@
|
|||
<h2>Change Credit Card</h2>
|
||||
<p>This allows you to change your currently stored credit card. You will be charged at the regular monthly cycle.</p>
|
||||
|
||||
<div>
|
||||
<div id="plan_error" class="alert alert-block alert-error" style="display:none"></div>
|
||||
<form id="upgradeForm" method="POST" action="/settings/update_card">
|
||||
<input type="hidden" value="<%= csrf_token %>" name="csrf_token">
|
||||
<input type="hidden" value="supporter" name="plan_type">
|
||||
<input id="stripe_token" name="stripe_token" type="hidden" value="<%= params[:stripe_token] %>">
|
||||
|
||||
<div class="credit-card-input no-js" id="skeuocard" style="margin-left: auto; margin-right: auto; margin-bottom: 20px">
|
||||
<p class="no-support-warning"></p>
|
||||
<label for="cc_type">Card Type</label>
|
||||
<select name="cc_type">
|
||||
<option value="">...</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="discover">Discover</option>
|
||||
<option value="mastercard">MasterCard</option>
|
||||
<option value="maestro">Maestro</option>
|
||||
<option value="jcb">JCB</option>
|
||||
<option value="unionpay">China UnionPay</option>
|
||||
<option value="amex">American Express</option>
|
||||
<option value="dinersclubintl">Diners Club</option>
|
||||
</select>
|
||||
<label for="cc_number">Card Number</label>
|
||||
<input type="text" name="cc_number" id="cc_number" placeholder="XXXX XXXX XXXX XXXX" maxlength="19" size="19">
|
||||
<label for="cc_exp_month">Expiration Month</label>
|
||||
<input type="text" name="cc_exp_month" id="cc_exp_month" placeholder="00">
|
||||
<label for="cc_exp_year">Expiration Year</label>
|
||||
<input type="text" name="cc_exp_year" id="cc_exp_year" placeholder="00">
|
||||
<label for="cc_name">Cardholder's Name</label>
|
||||
<input type="text" name="cc_name" id="cc_name" placeholder="John Doe">
|
||||
<label for="cc_cvc">Card Validation Code</label>
|
||||
<input type="text" name="cc_cvc" id="cc_cvc" placeholder="123" maxlength="3" size="3">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<a href="/" class="btn-Action" onclick="$('#upgradeForm').submit(); return false">Update Card</a>
|
||||
</div>
|
||||
|
||||
<%== erb :'plan/_signupcode', layout: false %>
|
||||
|
||||
<script>
|
||||
card = new Skeuocard($('#skeuocard'))
|
||||
</script>
|
|
@ -1,8 +1,6 @@
|
|||
Hi there!
|
||||
|
||||
A Neocities administrator has upgraded your account to supporter! Someone at Neocities must really like you (or your site). :)
|
||||
|
||||
We won't charge you for the upgrade, so no worries on that. You can see some of the new features you can use by visiting our supporter page at https://neocities.org/plan
|
||||
A Neocities administrator has upgraded your account to supporter! You can see some of the new features you can use by visiting our supporter page at https://neocities.org/plan
|
||||
|
||||
We're looking forward to seeing the awesome things you will do with it.
|
||||
|
||||
|
@ -12,4 +10,4 @@ If you have any questions or comments, or just want to say hi, feel free to cont
|
|||
|
||||
From Penelope (the Neocities' cat/sysadmin), everyone that's helped work on Neocities, and on behalf of all our sites, our very best wishes for you (and your awesome web site).
|
||||
|
||||
- The Neocities Team
|
||||
- The Neocities Team
|
||||
|
|
Loading…
Add table
Reference in a new issue