From 363147b96d6742e67e22158d22b967a59c1dbb90 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Fri, 1 Aug 2014 11:56:51 -0700 Subject: [PATCH] port settings to erb --- app.rb | 17 ++++--- views/custom_domain.erb | 55 ++++++++++++++++++++ views/custom_domain.slim | 27 ---------- views/settings.erb | 105 +++++++++++++++++++++++++++++++++++++++ views/settings.slim | 77 ---------------------------- 5 files changed, 171 insertions(+), 110 deletions(-) create mode 100644 views/custom_domain.erb delete mode 100644 views/custom_domain.slim create mode 100644 views/settings.erb delete mode 100644 views/settings.slim diff --git a/app.rb b/app.rb index 39041cdc..2b781b19 100644 --- a/app.rb +++ b/app.rb @@ -17,6 +17,10 @@ helpers do return 'image' if filename.match(Site::IMAGE_REGEX) 'misc' end + + def csrf_token_input_html + %{} + end end before do @@ -423,7 +427,7 @@ end get '/settings' do require_login - slim :'settings' + erb :'settings' end post '/signin' do @@ -467,7 +471,7 @@ post '/change_password' do if !Site.valid_login?(current_site.username, params[:current_password]) current_site.errors.add :password, 'Your provided password does not match the current one.' - halt slim(:'settings') + halt erb(:'settings') end current_site.password = params[:new_password] @@ -482,7 +486,7 @@ post '/change_password' do flash[:success] = 'Successfully changed password.' redirect '/settings' else - halt slim(:'settings') + halt erb(:'settings') 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, don't forget it." redirect '/settings' else - halt slim(:'settings') + halt erb(:'settings') end end post '/change_nsfw' do require_login current_site.update is_nsfw: params[:is_nsfw] + flash[:success] = current_site.is_nsfw ? 'Marked 18+' : 'Unmarked 18+' redirect '/settings' end @@ -814,7 +819,7 @@ end get '/custom_domain' do require_login - slim :custom_domain + erb :custom_domain end post '/custom_domain' do @@ -826,7 +831,7 @@ post '/custom_domain' do flash[:success] = 'The domain has been successfully updated.' redirect '/custom_domain' else - slim :custom_domain + erb :custom_domain end end diff --git a/views/custom_domain.erb b/views/custom_domain.erb new file mode 100644 index 00000000..cc6e34e5 --- /dev/null +++ b/views/custom_domain.erb @@ -0,0 +1,55 @@ +
+
+

Custom Domain

+

Add your own domain name to your Neocities site!

+
+
+ +
+

+
+ + <% if !current_site.errors.empty? %> +
+ <% current_site.errors.each do |error| %> +

<%= error.last.first %>

+ <% end %> +
+ <% end %> + + <% if flash[:success] %> +
+ <%== flash[:success] %> +
+ <% end %> + +

+ Adding a custom domain allows you to have a domain name attached to your web site. So if you had a domain like catsknitting.com, you could have it point to your Neocities site! +

+ +

+ You will have to purchase a domain name from a registrar like Namecheap, and then add an A record to point your domain (catsknitting.com) to the following IP address: +

+ +

198.27.81.179

+ +

+ If you want to add a www subdomain, or use a wildcard that will answer to everything (*), you will have to make a CNAME pointing to catsknitting.com for www and/or *. +

+ +

+ After that, you can add the domain to the box below (just the catsknitting.com, don't add any subdomains), and your domain should come online within 5 minutes: +

+ +
+ <%== csrf_token_input_html %> + +
+ +
+ +

+ NOTE: This is for advanced users, we cannot provide technical support for this feature. If you cannot make this work, please contact your domain registrar. +

+
+
\ No newline at end of file diff --git a/views/custom_domain.slim b/views/custom_domain.slim deleted file mode 100644 index 7861b6a9..00000000 --- a/views/custom_domain.slim +++ /dev/null @@ -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 catsknitting.com, you could have it point to your Neocities site! - p You will have to purchase a domain name from a registrar like Namecheap, and then add an A record to point your domain (catsknitting.com) to the following IP address: - p 198.27.81.179 - p If you want to add a www subdomain, or use a wildcard that will answer to everything (*), you will have to make a CNAME pointing to catsknitting.com for www and/or *. - p After that, you can add the domain to the box below (just the catsknitting.com, 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 NOTE: This is for advanced users, we cannot provide technical support for this feature. If you cannot make this work, please contact your domain registrar. diff --git a/views/settings.erb b/views/settings.erb new file mode 100644 index 00000000..6a7a48ae --- /dev/null +++ b/views/settings.erb @@ -0,0 +1,105 @@ +
+
+

Settings

+

Manage your account

+
+
+ +
+
+
+
+ <% if !current_site.errors.empty? %> +
+ <% current_site.errors.each do |error| %> +

<%== error.last.first %>

+ <% end %> +
+ <% end %> + <% if flash[:success] %> +
+ <%== flash[:success] %> +
+ <% end %> +
+ +

Neocities Plan

+ <% if current_site.supporter? && !current_site.plan_ended %> +

You currently have the Supporter Plan (<%= current_site.maximum_space_in_megabytes %>MB). Thank you! We love you. +

+ Manage Plan + <% else %> +

+ You currently have the Free Plan (<%= current_site.maximum_space_in_megabytes %>MB).
Want to get more space and help Neocities? Become a supporter! +

+ Supporter Info + <% end %> + +

Custom Domain

+

+ You can configure a custom domain for your Neocities site! Click Here for more information. +

+ +

Change Password

+
+ <%== csrf_token_input_html %> + +

Current Password:

+ + +

New Password:

+ + +

Confirm New Password:

+ + + +
+ + + +

Change Site (User) Name

+
+ <%== csrf_token_input_html %> +

+ It cannot contain spaces, and can only use the following characters: a-z A-Z 0-9 _ - +

+ +

+ Current Name: + <%= current_site.username %> +

+ +

+ New name: + +

+ + +
+ + +

18+ Content

+ +

+ 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. +

+ + +
+ <%== csrf_token_input_html %> + +

+ + My page has 18+ content:    + checked<% end %> + > + +

+ + +
+
+
+
\ No newline at end of file diff --git a/views/settings.slim b/views/settings.slim deleted file mode 100644 index dbb1e889..00000000 --- a/views/settings.slim +++ /dev/null @@ -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 Supporter Plan (#{current_site.maximum_space_in_megabytes}MB). Thank you! We love you. - a.btn-Action href="/plan" Manage Plan - - else - p.tiny You currently have the Free Plan (#{current_site.maximum_space_in_megabytes}MB).
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: #{current_site.username} - - 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.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. Click Here for more information.