mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
port settings to erb
This commit is contained in:
parent
35298346d6
commit
363147b96d
5 changed files with 171 additions and 110 deletions
17
app.rb
17
app.rb
|
@ -17,6 +17,10 @@ helpers do
|
||||||
return 'image' if filename.match(Site::IMAGE_REGEX)
|
return 'image' if filename.match(Site::IMAGE_REGEX)
|
||||||
'misc'
|
'misc'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def csrf_token_input_html
|
||||||
|
%{<input name="csrf_token" type="hidden" value="#{csrf_token}">}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -423,7 +427,7 @@ end
|
||||||
|
|
||||||
get '/settings' do
|
get '/settings' do
|
||||||
require_login
|
require_login
|
||||||
slim :'settings'
|
erb :'settings'
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/signin' do
|
post '/signin' do
|
||||||
|
@ -467,7 +471,7 @@ post '/change_password' do
|
||||||
|
|
||||||
if !Site.valid_login?(current_site.username, params[:current_password])
|
if !Site.valid_login?(current_site.username, params[:current_password])
|
||||||
current_site.errors.add :password, 'Your provided password does not match the current one.'
|
current_site.errors.add :password, 'Your provided password does not match the current one.'
|
||||||
halt slim(:'settings')
|
halt erb(:'settings')
|
||||||
end
|
end
|
||||||
|
|
||||||
current_site.password = params[:new_password]
|
current_site.password = params[:new_password]
|
||||||
|
@ -482,7 +486,7 @@ post '/change_password' do
|
||||||
flash[:success] = 'Successfully changed password.'
|
flash[:success] = 'Successfully changed password.'
|
||||||
redirect '/settings'
|
redirect '/settings'
|
||||||
else
|
else
|
||||||
halt slim(:'settings')
|
halt erb(:'settings')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -511,13 +515,14 @@ post '/change_name' do
|
||||||
flash[:success] = "Site/user name has been changed. You will need to use this name to login, <b>don't forget it</b>."
|
flash[:success] = "Site/user name has been changed. You will need to use this name to login, <b>don't forget it</b>."
|
||||||
redirect '/settings'
|
redirect '/settings'
|
||||||
else
|
else
|
||||||
halt slim(:'settings')
|
halt erb(:'settings')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/change_nsfw' do
|
post '/change_nsfw' do
|
||||||
require_login
|
require_login
|
||||||
current_site.update is_nsfw: params[:is_nsfw]
|
current_site.update is_nsfw: params[:is_nsfw]
|
||||||
|
flash[:success] = current_site.is_nsfw ? 'Marked 18+' : 'Unmarked 18+'
|
||||||
redirect '/settings'
|
redirect '/settings'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -814,7 +819,7 @@ end
|
||||||
|
|
||||||
get '/custom_domain' do
|
get '/custom_domain' do
|
||||||
require_login
|
require_login
|
||||||
slim :custom_domain
|
erb :custom_domain
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/custom_domain' do
|
post '/custom_domain' do
|
||||||
|
@ -826,7 +831,7 @@ post '/custom_domain' do
|
||||||
flash[:success] = 'The domain has been successfully updated.'
|
flash[:success] = 'The domain has been successfully updated.'
|
||||||
redirect '/custom_domain'
|
redirect '/custom_domain'
|
||||||
else
|
else
|
||||||
slim :custom_domain
|
erb :custom_domain
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
55
views/custom_domain.erb
Normal file
55
views/custom_domain.erb
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<div class="header-Outro">
|
||||||
|
<div class="row content single-Col">
|
||||||
|
<h1>Custom Domain</h1>
|
||||||
|
<h3 class="subtitle">Add your own domain name to your Neocities site!</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content single-Col misc-page">
|
||||||
|
<h3></h3>
|
||||||
|
<article>
|
||||||
|
|
||||||
|
<% if !current_site.errors.empty? %>
|
||||||
|
<div class="alert alert-block alert-error">
|
||||||
|
<% current_site.errors.each do |error| %>
|
||||||
|
<p><%= error.last.first %></p>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if flash[:success] %>
|
||||||
|
<div class="alert alert-block alert-success" style="margin-top: 20px">
|
||||||
|
<%== flash[:success] %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Adding a custom domain allows you to have a domain name attached to your web site. So if you had a domain like <strong>catsknitting.com</strong>, you could have it point to your Neocities site!
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
You will have to purchase a domain name from a registrar like <a href="https://www.namecheap.com/?aff=53678" target="_blank">Namecheap</a>, and then add an A record to point your domain (catsknitting.com) to the following IP address:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p><code>198.27.81.179</code></p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you want to add a <strong>www</strong> subdomain, or use a wildcard that will answer to everything (<strong>*</strong>), you will have to make a CNAME pointing to <strong>catsknitting.com</strong> for <strong>www</strong> and/or <strong>*</strong>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
After that, you can add the domain to the box below (just the <strong>catsknitting.com</strong>, don't add any subdomains), and your domain should come online within 5 minutes:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form method="POST" action="/custom_domain">
|
||||||
|
<%== csrf_token_input_html %>
|
||||||
|
<input name="domain" type="text" placeholder="catsknitting.com" value="<%= current_site.domain %>">
|
||||||
|
<br>
|
||||||
|
<input class="btn-Action" type="submit" value="Update Domain">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<strong>NOTE: This is for advanced users, we cannot provide technical support for this feature.</strong> If you cannot make this work, please contact your domain registrar.
|
||||||
|
</p>
|
||||||
|
</article>
|
||||||
|
</div>
|
|
@ -1,27 +0,0 @@
|
||||||
.page
|
|
||||||
.content
|
|
||||||
|
|
||||||
h1.txt-Center Custom Domain
|
|
||||||
h3.txt-Center (advanced)
|
|
||||||
|
|
||||||
.txt-Center
|
|
||||||
- if !current_site.errors.empty?
|
|
||||||
.alert.alert-block.alert-error
|
|
||||||
- current_site.errors.each do |error|
|
|
||||||
p = error.last.first
|
|
||||||
|
|
||||||
.row.c-Row
|
|
||||||
.col.col-66
|
|
||||||
.content
|
|
||||||
|
|
||||||
p Adding a custom domain allows you to have a domain name attached to your web site. So if you had a domain like <strong>catsknitting.com</strong>, you could have it point to your Neocities site!
|
|
||||||
p You will have to purchase a domain name from a registrar like <a href="https://www.namecheap.com/?aff=53678" target="_blank">Namecheap</a>, and then add an A record to point your domain (catsknitting.com) to the following IP address:
|
|
||||||
p <code>198.27.81.179</code>
|
|
||||||
p If you want to add a <strong>www</strong> subdomain, or use a wildcard that will answer to everything (<strong>*</strong>), you will have to make a CNAME pointing to <strong>catsknitting.com</strong> for <strong>www</strong> and/or <strong>*</strong>.
|
|
||||||
p After that, you can add the domain to the box below (just the <strong>catsknitting.com</strong>, don't add any subdomains), and your domain should come online within 5 minutes:
|
|
||||||
form method="POST" action="/custom_domain"
|
|
||||||
input name="csrf_token" type="hidden" value="#{csrf_token}"
|
|
||||||
input name="domain" type="text" placeholder="catsknitting.com" value="#{current_site.domain}"
|
|
||||||
br
|
|
||||||
input.btn-Action type="submit" value="Update Domain"
|
|
||||||
p <strong>NOTE: This is for advanced users, we cannot provide technical support for this feature.</strong> If you cannot make this work, please contact your domain registrar.
|
|
105
views/settings.erb
Normal file
105
views/settings.erb
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
<div class="header-Outro">
|
||||||
|
<div class="row content single-Col">
|
||||||
|
<h1>Settings</h1>
|
||||||
|
<h3 class="subtitle">Manage your account</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content single-Col misc-page txt-Center">
|
||||||
|
<article>
|
||||||
|
<section>
|
||||||
|
<div class="txt-Center">
|
||||||
|
<% if !current_site.errors.empty? %>
|
||||||
|
<div class="alert alert-block alert-error" style="margin-top: 20px">
|
||||||
|
<% current_site.errors.each do |error| %>
|
||||||
|
<p><%== error.last.first %></p>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% if flash[:success] %>
|
||||||
|
<div class="alert alert-block alert-success" style="margin-top: 20px">
|
||||||
|
<%== flash[:success] %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2>Neocities Plan</h2>
|
||||||
|
<% if current_site.supporter? && !current_site.plan_ended %>
|
||||||
|
<p class="tiny">You currently have the <strong>Supporter Plan (<%= current_site.maximum_space_in_megabytes %>MB)</strong>. Thank you! We love you.
|
||||||
|
</p>
|
||||||
|
<a class="btn-Action" href="/plan">Manage Plan</a>
|
||||||
|
<% else %>
|
||||||
|
<p class="tiny">
|
||||||
|
You currently have the <strong>Free Plan (<%= current_site.maximum_space_in_megabytes %>MB)</strong>.<br>Want to get more space and help Neocities? Become a supporter!
|
||||||
|
</p>
|
||||||
|
<a class="btn-Action" href="/plan">Supporter Info</a>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<h2>Custom Domain</h2>
|
||||||
|
<p>
|
||||||
|
You can configure a custom domain for your Neocities site! <strong><a href="/custom_domain">Click Here</a></strong> for more information.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2>Change Password</h2>
|
||||||
|
<form method="POST" action="/change_password">
|
||||||
|
<%== csrf_token_input_html %>
|
||||||
|
|
||||||
|
<p>Current Password:</p>
|
||||||
|
<input class="input-Area" name="current_password" type="password">
|
||||||
|
|
||||||
|
<p>New Password:</p>
|
||||||
|
<input class="input-Area" name="new_password" type="password">
|
||||||
|
|
||||||
|
<p>Confirm New Password:</p>
|
||||||
|
<input class="input-Area" name="new_password_confirm" type="password">
|
||||||
|
|
||||||
|
<input class="btn-Action" type="submit" value="Change Password">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Change Site (User) Name</h2>
|
||||||
|
<form method="POST" action="/change_name">
|
||||||
|
<%== csrf_token_input_html %>
|
||||||
|
<p class="tiny">
|
||||||
|
It cannot contain spaces, and can only use the following characters: a-z A-Z 0-9 _ -
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Current Name:
|
||||||
|
<span style="color: green"><strong><%= current_site.username %></strong></span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
New name:
|
||||||
|
<input name="name" class="input-Area" type="text" placeholder="newname" style="width: 200px">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<input class="btn-Action" type="submit" value="Change Name">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>18+ Content</h2>
|
||||||
|
|
||||||
|
<p class="tiny">
|
||||||
|
If your site contains objectionable (18+) content, check this box. Your site will not be removed, but it will be listed on a special browse page. We don't have an official policy on what defines 18+ content yet, but basically it's just pornography and lewd/sick/gross images. Thanks for your patience and understanding as we try to find a way to balance out the needs of everyone.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<form method="POST" action="/change_nsfw">
|
||||||
|
<%== csrf_token_input_html %>
|
||||||
|
<input name="is_nsfw" type="hidden" value="false">
|
||||||
|
<p>
|
||||||
|
<strong>
|
||||||
|
My page has 18+ content:
|
||||||
|
<input name="is_nsfw" type="checkbox" value="true" style="margin-top: 0px"
|
||||||
|
<% if current_site.is_nsfw %>checked<% end %>
|
||||||
|
>
|
||||||
|
</strong>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<input class="btn-Action" type="submit" value="Update">
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
</div>
|
|
@ -1,77 +0,0 @@
|
||||||
.page
|
|
||||||
.content
|
|
||||||
|
|
||||||
h1.txt-Center Account Settings
|
|
||||||
|
|
||||||
.txt-Center
|
|
||||||
- if !current_site.errors.empty?
|
|
||||||
.alert.alert-block.alert-error
|
|
||||||
- current_site.errors.each do |error|
|
|
||||||
p = error.last.first
|
|
||||||
|
|
||||||
.row
|
|
||||||
.col.col-100.txt-Center
|
|
||||||
.content
|
|
||||||
h2.zeta Neocities Plan
|
|
||||||
- if current_site.supporter? && !current_site.plan_ended
|
|
||||||
p.tiny You currently have the <strong>Supporter Plan (#{current_site.maximum_space_in_megabytes}MB)</strong>. Thank you! We love you.
|
|
||||||
a.btn-Action href="/plan" Manage Plan
|
|
||||||
- else
|
|
||||||
p.tiny You currently have the <strong>Free Plan (#{current_site.maximum_space_in_megabytes}MB)</strong>.<br>Want to get more space and help Neocities? Become a supporter!
|
|
||||||
a.btn-Action href="/plan" Supporter Info
|
|
||||||
|
|
||||||
.row
|
|
||||||
.col.col-33
|
|
||||||
.content
|
|
||||||
h2.zeta Change Password
|
|
||||||
form method="POST" action="/change_password"
|
|
||||||
input name="csrf_token" type="hidden" value="#{csrf_token}"
|
|
||||||
|
|
||||||
div
|
|
||||||
p Current Password:
|
|
||||||
input class="input-Area" name="current_password" type="password"
|
|
||||||
|
|
||||||
div
|
|
||||||
p New Password:
|
|
||||||
input class="input-Area" name="new_password" type="password"
|
|
||||||
|
|
||||||
div
|
|
||||||
p Confirm New Password:
|
|
||||||
input class="input-Area" name="new_password_confirm" type="password"
|
|
||||||
|
|
||||||
input.btn-Action type="submit" value="Change Password"
|
|
||||||
|
|
||||||
.col.col-33
|
|
||||||
.content
|
|
||||||
h2.zeta Change Site (User) Name
|
|
||||||
|
|
||||||
form method="POST" action="/change_name"
|
|
||||||
input name="csrf_token" type="hidden" value="#{csrf_token}"
|
|
||||||
|
|
||||||
p.tiny It cannot contain spaces, and can only use the following characters: a-z A-Z 0-9 _ -
|
|
||||||
|
|
||||||
p Current name: <span style="color: green"><strong>#{current_site.username}</strong></span>
|
|
||||||
|
|
||||||
p New name:
|
|
||||||
input name="name" class="input-Area" type="text" placeholder="newname"
|
|
||||||
|
|
||||||
input.btn-Action type="submit" value="Change Name"
|
|
||||||
|
|
||||||
.col.col-33
|
|
||||||
.content
|
|
||||||
h2.zeta 18+ Content
|
|
||||||
p.tiny If your site contains objectionable (18+) content, check this box. Your site will not be removed, but it will be listed on a special browse page. We don't have an official policy on what defines 18+ content yet, but basically it's just pornography and lewd/sick/gross images. Thanks for your patience and understanding as we try to find a way to balance out the needs of everyone.
|
|
||||||
|
|
||||||
form method="POST" action="/change_nsfw"
|
|
||||||
input name="csrf_token" type="hidden" value="#{csrf_token}"
|
|
||||||
input name="is_nsfw" type="hidden" value="false"
|
|
||||||
p: strong My page has 18+ content: <input name="is_nsfw" type="checkbox" value="true" style="margin-top: 0px" #{"checked" if current_site.is_nsfw}>
|
|
||||||
|
|
||||||
input.btn-Action type="submit" value="Update"
|
|
||||||
|
|
||||||
.row
|
|
||||||
.col.col-33
|
|
||||||
.content
|
|
||||||
h2.eps.txt-Center Custom Domain
|
|
||||||
p.txt-Center: strong (advanced)
|
|
||||||
p You can configure a custom domain for your Neocities site. <strong><a href="/custom_domain">Click Here</a></strong> for more information.
|
|
Loading…
Add table
Reference in a new issue