mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Site creation is back online
This commit is contained in:
parent
6c4cacbd3e
commit
1aac62923d
2 changed files with 33 additions and 59 deletions
72
app.rb
72
app.rb
|
@ -507,70 +507,36 @@ post '/create_validate' do
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/create' do
|
post '/create' do
|
||||||
|
content_type :json
|
||||||
require_unbanned_ip
|
require_unbanned_ip
|
||||||
dashboard_if_signed_in
|
dashboard_if_signed_in
|
||||||
|
|
||||||
@site = Site.new(
|
@site = Site.new(
|
||||||
username: params[:username],
|
username: params[:username],
|
||||||
password: params[:password],
|
password: params[:password],
|
||||||
email: params[:email],
|
email: params[:email],
|
||||||
new_tags_string: params[:tags],
|
new_tags_string: params[:tags],
|
||||||
is_nsfw: params[:is_nsfw],
|
|
||||||
ip: request.ip
|
ip: request.ip
|
||||||
)
|
)
|
||||||
|
|
||||||
recaptcha_is_valid = ENV['RACK_ENV'] == 'test' || recaptcha_valid?
|
if !@site.valid?
|
||||||
|
return {result: 'error'}.to_json
|
||||||
if @site.valid? && recaptcha_is_valid
|
|
||||||
DB.transaction do
|
|
||||||
if !params[:stripe_token].nil? && params[:stripe_token] != ''
|
|
||||||
customer = Stripe::Customer.create(
|
|
||||||
card: params[:stripe_token],
|
|
||||||
description: @site.username,
|
|
||||||
email: @site.email,
|
|
||||||
plan: params[:selected_plan]
|
|
||||||
)
|
|
||||||
@site.stripe_customer_id = customer.id
|
|
||||||
|
|
||||||
plan_name = customer.subscriptions.first['plan']['name']
|
|
||||||
|
|
||||||
EmailWorker.perform_async({
|
|
||||||
from: 'web@neocities.org',
|
|
||||||
reply_to: 'contact@neocities.org',
|
|
||||||
to: @site.email,
|
|
||||||
subject: "[Neocities] You've become a supporter!",
|
|
||||||
body: Tilt.new('./views/templates/email_subscription.erb', pretty: true).render(self, plan_name: plan_name)
|
|
||||||
})
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
@site.save
|
|
||||||
end
|
|
||||||
|
|
||||||
EmailWorker.perform_async({
|
|
||||||
from: 'web@neocities.org',
|
|
||||||
reply_to: 'contact@neocities.org',
|
|
||||||
to: @site.email,
|
|
||||||
subject: "[Neocities] Welcome to Neocities!",
|
|
||||||
body: Tilt.new('./views/templates/email_welcome.erb', pretty: true).render(self)
|
|
||||||
})
|
|
||||||
|
|
||||||
EmailWorker.perform_async({
|
|
||||||
from: 'web@neocities.org',
|
|
||||||
reply_to: 'contact@neocities.org',
|
|
||||||
to: @site.email,
|
|
||||||
subject: "[Neocities] Welcome to Neocities!",
|
|
||||||
body: Tilt.new('./views/templates/email_welcome.erb', pretty: true).render(self)
|
|
||||||
})
|
|
||||||
|
|
||||||
send_confirmation_email @site
|
|
||||||
|
|
||||||
session[:id] = @site.id
|
|
||||||
redirect '/'
|
|
||||||
else
|
|
||||||
@site.errors.add :captcha, 'You must type in the captcha correctly! Try again.' if !recaptcha_is_valid
|
|
||||||
|
|
||||||
erb :'/new'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@site.save
|
||||||
|
|
||||||
|
EmailWorker.perform_async({
|
||||||
|
from: 'web@neocities.org',
|
||||||
|
reply_to: 'contact@neocities.org',
|
||||||
|
to: @site.email,
|
||||||
|
subject: "[Neocities] Welcome to Neocities!",
|
||||||
|
body: Tilt.new('./views/templates/email_welcome.erb', pretty: true).render(self)
|
||||||
|
})
|
||||||
|
|
||||||
|
send_confirmation_email @site
|
||||||
|
|
||||||
|
session[:id] = @site.id
|
||||||
|
{result: 'ok'}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/dashboard' do
|
get '/dashboard' do
|
||||||
|
|
|
@ -154,25 +154,26 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<form action="/new" method="get" class="signup-Form">
|
<form id="createSiteForm" action="/new" method="POST" class="signup-Form" onsubmit="createSite(); return false">
|
||||||
|
<input type="hidden" name="csrf_token" value="<%= csrf_token %>">
|
||||||
<fieldset class="content">
|
<fieldset class="content">
|
||||||
<h2 class="gamma">Sign up for free</h2>
|
<h2 class="gamma">Sign up for free</h2>
|
||||||
<hr />
|
<hr />
|
||||||
<label for="create-Input">Username</label>
|
<label for="create-Input">Username</label>
|
||||||
<input type="text" class="input-Area" id="create-Input" name="username" placeholder="my-site-name" data-placement="left" data-trigger="manual" />
|
<input type="text" class="input-Area" id="create-Input" name="username" placeholder="my-site-name" data-placement="left" data-trigger="manual" autocapitalize="off" autocorrect="off" autocomplete="off" />
|
||||||
<label for="create-Input" id="domain-name">.neocities.org</label>
|
<label for="create-Input" id="domain-name">.neocities.org</label>
|
||||||
|
|
||||||
<label for="tags-input">Tags (your interests, site topics)</label>
|
<label for="tags-input">Tags (your interests, site topics)</label>
|
||||||
<input type="text" class="input-Area" id="tags-input" name="new_tags_string" placeholder="art, videogames, food, music, programming, gardening, cats" data-placement="left" data-trigger="manual" />
|
<input type="text" class="input-Area" id="tags-input" name="new_tags_string" placeholder="art, videogames, food, music, programming, gardening, cats" data-placement="left" data-trigger="manual" autocapitalize="off" autocorrect="off" autocomplete="off" />
|
||||||
|
|
||||||
<div class="col col-50" style="padding-left:0;">
|
<div class="col col-50" style="padding-left:0;">
|
||||||
<label for="password-input">Password</label>
|
<label for="password-input">Password</label>
|
||||||
<input type="text" class="input-Area" id="password-input" name="password" placeholder="password" data-placement="left" data-trigger="manual" />
|
<input type="password" class="input-Area" id="password-input" name="password" placeholder="password" data-placement="left" data-trigger="manual" autocapitalize="off" autocorrect="off" autocomplete="off" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col col-50">
|
<div class="col col-50">
|
||||||
<label for="email-input">Email</label>
|
<label for="email-input">Email</label>
|
||||||
<input type="text" class="input-Area" id="email-input" name="email" placeholder="me@example.com" data-placement="left" data-trigger="manual" />
|
<input type="text" class="input-Area" id="email-input" name="email" placeholder="me@example.com" data-placement="left" data-trigger="manual" autocapitalize="off" autocorrect="off" autocomplete="off" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="submit" value="Create My Site" class="btn-Action float-Right" />
|
<input type="submit" value="Create My Site" class="btn-Action float-Right" />
|
||||||
|
@ -336,7 +337,14 @@
|
||||||
<script src="/js/app.min.js"></script>
|
<script src="/js/app.min.js"></script>
|
||||||
<script src="/js/bootstrap.min.js"></script>
|
<script src="/js/bootstrap.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$('input[type=text]').change(function(obj) {
|
function createSite() {
|
||||||
|
$.post('/create', $('#createSiteForm').serialize(), function(res) {
|
||||||
|
if(res.result == 'ok')
|
||||||
|
location.reload()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$('input[type=text]').on('change focusout', function(obj) {
|
||||||
$.post('/create_validate', {field: obj.target.name, value: obj.target.value, csrf_token: '<%= csrf_token %>'}, function(res) {
|
$.post('/create_validate', {field: obj.target.name, value: obj.target.value, csrf_token: '<%= csrf_token %>'}, function(res) {
|
||||||
if(res.result == 'ok') {
|
if(res.result == 'ok') {
|
||||||
return $(obj.target).tooltip('hide')
|
return $(obj.target).tooltip('hide')
|
||||||
|
|
Loading…
Add table
Reference in a new issue