mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
fix for missing following code, email fixes, start on delete site
This commit is contained in:
parent
89998e2f18
commit
08026ac235
6 changed files with 54 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -23,3 +23,4 @@ public/site_thumbnails
|
|||
public/sites
|
||||
public/site_screenshots
|
||||
*.swp
|
||||
files/map.txt
|
||||
|
|
17
app.rb
17
app.rb
|
@ -85,7 +85,7 @@ get '/site/:username.rss' do |username|
|
|||
site.to_rss.to_xml
|
||||
end
|
||||
|
||||
get '/site/:username' do |username|
|
||||
get '/site/:username/?' do |username|
|
||||
site = Site[username: username]
|
||||
not_found if site.nil?
|
||||
if current_site && (site.is_blocking?(current_site) || current_site.is_blocking?(site))
|
||||
|
@ -531,6 +531,11 @@ post '/change_email' do
|
|||
current_site.email_confirmation_token = SecureRandom.hex 3
|
||||
current_site.email_confirmed = false
|
||||
|
||||
if params[:email] == current_site.email
|
||||
current_site.errors.add :email, 'You are already using this email address for this account.'
|
||||
halt erb(:settings)
|
||||
end
|
||||
|
||||
if current_site.valid?
|
||||
current_site.save_changes
|
||||
send_confirmation_email
|
||||
|
@ -1146,6 +1151,16 @@ post '/site/:username/block' do |username|
|
|||
end
|
||||
end
|
||||
|
||||
post '/site/delete' do
|
||||
require_login
|
||||
if current_site.username != params[:username]
|
||||
errors.add :username, 'Could not delete site, site name did not match.'
|
||||
halt erb(:settings)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def require_admin
|
||||
redirect '/' unless signed_in? && current_site.is_admin
|
||||
end
|
||||
|
|
|
@ -453,9 +453,7 @@ class Site < Sequel::Model
|
|||
|
||||
# Check for existing email
|
||||
email_check = self.class.select(:id).filter(email: values[:email]).first
|
||||
if email_check && email_check.id == self.id
|
||||
errors.add :email, 'You are already using this email address for this account.'
|
||||
elsif email_check && email_check.id != self.id
|
||||
if email_check && email_check.id != self.id
|
||||
errors.add :email, 'This email address already exists on Neocities, please use your existing account instead of creating a new one.'
|
||||
end
|
||||
|
||||
|
@ -602,7 +600,7 @@ class Site < Sequel::Model
|
|||
end
|
||||
|
||||
def latest_events(current_page=1, limit=10)
|
||||
events_dataset.order(:created_at.desc).paginate(current_page, limit)
|
||||
events_dataset.exclude(site_id: self.id).order(:created_at.desc).paginate(current_page, limit)
|
||||
end
|
||||
|
||||
def news_feed(current_page=1, limit=10)
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
</p>
|
||||
|
||||
<% if request.referer %>
|
||||
<a class="btn-Action" href="#{request.referer}">Go Back</a>
|
||||
<div class="txt-Center">
|
||||
<a class="btn-Action" href="<%= request.referer %>">Go Back</a>
|
||||
</div>
|
||||
<% end %>
|
||||
</article>
|
||||
</div>
|
|
@ -69,8 +69,6 @@
|
|||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
<h2>Change Site (User) Name</h2>
|
||||
<form method="POST" action="/change_name">
|
||||
<%== csrf_token_input_html %>
|
||||
|
@ -98,7 +96,6 @@
|
|||
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">
|
||||
|
@ -113,6 +110,36 @@
|
|||
|
||||
<input class="btn-Action" type="submit" value="Update">
|
||||
</form>
|
||||
|
||||
<h2>Delete Site</h2>
|
||||
<p class="tiny">
|
||||
If you want to delete your account, you can do that here. We're sorry to see you go, but we understand if Neocities isn't right for you. If there's any specific reason you're leaving, it would be great if you <a href="/contact">let us know</a> so we can try to make your experience better in the future.
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<a href="#deleteSite" data-toggle="modal" class="btn">Delete Site</a>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div class="modal hide fade" id="deleteSite" tabindex="-1" role="dialog" aria-labelledby="deleteSiteLabel" aria-hidden="true">
|
||||
<form method="POST" action="/site/delete">
|
||||
<%== csrf_token_input_html %>
|
||||
<div class="modal-header">
|
||||
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">x</button>
|
||||
<h3 id="deleteSiteLabel">Permanently Delete Site</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<strong style="color: red">WARNING: This will permanently delete your web site and Neocities account. There is no undo!</strong>
|
||||
|
||||
<p>Delete Site Name: <strong><%= current_site.username %></strong></p>
|
||||
<p>Confirm your site name by typing it here:</p>
|
||||
<input class="input-Area" name="username" type="text">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
||||
<button type="submit" class="btn btn-Action">Permanently Delete Site</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
<% if current_site && current_site != site %>
|
||||
<% is_following = current_site.is_following?(site) %>
|
||||
<a id="followLink" href="#" onclick="Site.toggleFollow(<%= site.id %>, '<%= csrf_token %>')" class="btn-Action <%= is_following ? '' : 'follow' %>">
|
||||
<a id="followLink" href="#" onclick="Site.toggleFollow(<%= site.id %>, '<%= csrf_token %>'); return false" class="btn-Action <%= is_following ? '' : 'follow' %>">
|
||||
<span><%= is_following ? 'Unfollow' : 'Follow' %></span>
|
||||
</a>
|
||||
<!-- <a href="#" class="btn-Action tip"><span>Tip</span></a> -->
|
||||
|
@ -83,6 +83,7 @@
|
|||
<p>
|
||||
You should <a href="/dashboard">update your site</a>!
|
||||
</p>
|
||||
<%== erb :'_news', layout: false, locals: {site: @site, events: @latest_events} %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
|
|
Loading…
Add table
Reference in a new issue