From 92fcee0aea6d831f6970a7b8122157da54031386 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sun, 31 Aug 2014 20:25:59 -0700 Subject: [PATCH] allow site to disable comments on profile --- app.rb | 15 ++++++++++++++- environment.rb | 3 +-- migrations/039_privacy.rb | 9 +++++++++ views/_news_actions.erb | 2 +- views/settings.erb | 15 +++++++++++++++ views/site.erb | 2 +- 6 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 migrations/039_privacy.rb diff --git a/app.rb b/app.rb index 26a69e2f..dae4afed 100644 --- a/app.rb +++ b/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 diff --git a/environment.rb b/environment.rb index d9e3f21d..5e3a904d 100644 --- a/environment.rb +++ b/environment.rb @@ -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. diff --git a/migrations/039_privacy.rb b/migrations/039_privacy.rb new file mode 100644 index 00000000..4e19c837 --- /dev/null +++ b/migrations/039_privacy.rb @@ -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 diff --git a/views/_news_actions.erb b/views/_news_actions.erb index e13d7109..412cc876 100644 --- a/views/_news_actions.erb +++ b/views/_news_actions.erb @@ -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 %> <% if event.profile_comment_id %> Reply diff --git a/views/settings.erb b/views/settings.erb index 7cc57838..deaa5499 100644 --- a/views/settings.erb +++ b/views/settings.erb @@ -35,6 +35,21 @@ Supporter Info <% end %> +

Site Profile

+
+
+ <%== csrf_token_input_html %> +

+ + checked<% end %> + > Turn off profile comments +

+ + +
+
+

Custom Domain

You can configure a custom domain for your Neocities site! Click Here for more information. diff --git a/views/site.erb b/views/site.erb index a3f5d78b..23b5b79c 100644 --- a/views/site.erb +++ b/views/site.erb @@ -66,7 +66,7 @@

- <% if current_site %> + <% if current_site && site.profile_comments_enabled %>