mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
allow site to disable comments on profile
This commit is contained in:
parent
8274ac3e80
commit
92fcee0aea
6 changed files with 41 additions and 5 deletions
15
app.rb
15
app.rb
|
@ -122,6 +122,7 @@ post '/site/:username/comment' do |username|
|
|||
require_login
|
||||
|
||||
site = Site[username: username]
|
||||
redirect request.referrer if site.profile_comments_enabled == false
|
||||
|
||||
if params[:message].empty? || (site.is_blocking?(current_site) || current_site.is_blocking?(site))
|
||||
redirect "/site/#{username}"
|
||||
|
@ -476,6 +477,15 @@ get '/settings' do
|
|||
erb :'settings'
|
||||
end
|
||||
|
||||
post '/settings/profile' do
|
||||
require_login
|
||||
current_site.update(
|
||||
profile_comments_enabled: params[:site][:profile_comments_enabled]
|
||||
)
|
||||
flash[:success] = 'Profile settings changed.'
|
||||
redirect '/settings'
|
||||
end
|
||||
|
||||
post '/signin' do
|
||||
dashboard_if_signed_in
|
||||
|
||||
|
@ -1076,7 +1086,10 @@ post '/event/:event_id/comment' do |event_id|
|
|||
content_type :json
|
||||
event = Event[id: event_id]
|
||||
|
||||
return {result: 'error'}.to_json if event.site.is_blocking?(current_site)
|
||||
site = event.site
|
||||
|
||||
return {result: 'error'}.to_json if site.is_blocking?(current_site)
|
||||
return {result: 'error'}.to_json if site.profile_comments_enabled == false
|
||||
|
||||
event.add_site_comment current_site, params[:message]
|
||||
{result: 'success'}.to_json
|
||||
|
|
|
@ -77,8 +77,7 @@ Stripe.api_key = $config['stripe_api_key']
|
|||
Dir.glob('models/*.rb').each {|m| require File.join(DIR_ROOT, "#{m}") }
|
||||
Dir.glob('workers/*.rb').each {|w| require File.join(DIR_ROOT, "/#{w}") }
|
||||
|
||||
|
||||
#DB.loggers << Logger.new(STDOUT) if ENV['RACK_ENV'] == 'development'
|
||||
DB.loggers << Logger.new(STDOUT) if ENV['RACK_ENV'] == 'development'
|
||||
|
||||
if ENV['RACK_ENV'] == 'development'
|
||||
# If new, throw up a random Server for development.
|
||||
|
|
9
migrations/039_privacy.rb
Normal file
9
migrations/039_privacy.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
Sequel.migration do
|
||||
up {
|
||||
DB.add_column :sites, :profile_comments_enabled, :boolean, default: true
|
||||
}
|
||||
|
||||
down {
|
||||
DB.drop_column :sites, :profile_comments_enabled
|
||||
}
|
||||
end
|
|
@ -7,7 +7,7 @@
|
|||
<%= event_likes_count %> <%= event_likes_count == 1 ? 'like' : 'likes' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if current_site %>
|
||||
<% if current_site && event.site.profile_comments_enabled %>
|
||||
<a id="reply" href="#" onclick="Template.renderComment(<%= event.id %>); return false">
|
||||
<% if event.profile_comment_id %>
|
||||
Reply
|
||||
|
|
|
@ -35,6 +35,21 @@
|
|||
<a class="btn-Action" href="/plan">Supporter Info</a>
|
||||
<% end %>
|
||||
|
||||
<h2>Site Profile</h2>
|
||||
<div>
|
||||
<form method="POST" action="/settings/profile">
|
||||
<%== csrf_token_input_html %>
|
||||
<p>
|
||||
<input name="site[profile_comments_enabled]" type="hidden" value="true">
|
||||
<input name="site[profile_comments_enabled]" type="checkbox" value="false"
|
||||
<% if current_site.profile_comments_enabled == false %>checked<% end %>
|
||||
> Turn off profile comments
|
||||
</p>
|
||||
|
||||
<input class="btn-Action" type="submit" value="Update Site Profile Settings">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<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.
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
<div class="container">
|
||||
<div class="content misc-page columns right-col"><div class="col-left">
|
||||
<div class="col col-66">
|
||||
<% if current_site %>
|
||||
<% if current_site && site.profile_comments_enabled %>
|
||||
<div class="post-comment">
|
||||
<form method="POST" action="/site/<%= site.username %>/comment">
|
||||
<input name="csrf_token" type="hidden" value="<%= csrf_token %>">
|
||||
|
|
Loading…
Add table
Reference in a new issue