Skip to content

Commit

Permalink
Merge pull request #1233 from hometown-fork/1232-rss-opt-out
Browse files Browse the repository at this point in the history
Adding a `norss` user preference
  • Loading branch information
dariusk authored Dec 4, 2022
2 parents 4360a50 + 427596a commit 29eb83d
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def show
format.rss do
expires_in 1.minute, public: true

if @account&.user&.setting_norss == true
@statuses = []
next
end

limit = params[:limit].present? ? [params[:limit].to_i, PAGE_SIZE_MAX].min : PAGE_SIZE
@statuses = filtered_statuses.without_reblogs.without_local_only.limit(limit)
@statuses = cache_collection(@statuses, Status)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/settings/preferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def user_settings_params
:setting_disable_swiping,
:setting_system_font_ui,
:setting_noindex,
:setting_norss,
:setting_theme,
:setting_aggregate_reblogs,
:setting_show_application,
Expand Down
1 change: 1 addition & 0 deletions app/lib/settings/scoped_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class ScopedSettings
DEFAULTING_TO_UNSCOPED = %w(
theme
noindex
norss
).freeze

def initialize(object)
Expand Down
5 changes: 5 additions & 0 deletions app/lib/user_settings_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def process_update
user.settings['disable_swiping'] = disable_swiping_preference if change?('setting_disable_swiping')
user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui')
user.settings['noindex'] = noindex_preference if change?('setting_noindex')
user.settings['norss'] = norss_preference if change?('setting_norss')
user.settings['theme'] = theme_preference if change?('setting_theme')
user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs')
user.settings['show_application'] = show_application_preference if change?('setting_show_application')
Expand Down Expand Up @@ -102,6 +103,10 @@ def noindex_preference
boolean_cast_setting 'setting_noindex'
end

def norss_preference
boolean_cast_setting 'setting_norss'
end

def show_application_preference
boolean_cast_setting 'setting_show_application'
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/form/admin_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Form::AdminSettings
show_domain_blocks
show_domain_blocks_rationale
noindex
norss
require_invite_text
).freeze

Expand All @@ -48,6 +49,7 @@ class Form::AdminSettings
trends
trendable_by_default
noindex
norss
require_invite_text
).freeze

Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class User < ApplicationRecord
has_many :session_activations, dependent: :destroy

delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal,
:reduce_motion, :system_font_ui, :noindex, :theme, :display_media,
:reduce_motion, :system_font_ui, :noindex, :norss, :theme, :display_media,
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
:advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images,
:disable_swiping, :default_federation, :always_send_emails,
Expand Down
3 changes: 2 additions & 1 deletion app/views/accounts/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
- if @account.user&.setting_noindex
%meta{ name: 'robots', content: 'noindex, noarchive' }/

%link{ rel: 'alternate', type: 'application/rss+xml', href: @rss_url }/
- if [email protected]&.setting_norss
%link{ rel: 'alternate', type: 'application/rss+xml', href: @rss_url }/
%link{ rel: 'alternate', type: 'application/activity+json', href: ActivityPub::TagManager.instance.uri_for(@account) }/

- if @older_url
Expand Down
3 changes: 3 additions & 0 deletions app/views/admin/settings/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
.fields-group
= f.input :noindex, as: :boolean, wrapper: :with_label, label: t('admin.settings.default_noindex.title'), hint: t('admin.settings.default_noindex.desc_html')

.fields-group
= f.input :norss, as: :boolean, wrapper: :with_label, label: t('admin.settings.default_norss.title'), hint: t('admin.settings.default_norss.desc_html')

%hr.spacer/

.fields-group
Expand Down
3 changes: 3 additions & 0 deletions app/views/settings/preferences/other/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
.fields-group
= f.input :setting_noindex, as: :boolean, wrapper: :with_label

.fields-group
= f.input :setting_norss, as: :boolean, wrapper: :with_label

.fields-group
= f.input :setting_aggregate_reblogs, as: :boolean, wrapper: :with_label, recommended: true

Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,9 @@ en:
default_noindex:
desc_html: Affects all users who have not changed this setting themselves
title: Opt users out of search engine indexing by default
default_norss:
desc_html: Affects all users who have not changed this setting themselves
title: Opt users out of having an RSS feed of their public posts by default
domain_blocks:
all: To everyone
disabled: To no one
Expand Down
1 change: 1 addition & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ en:
setting_expand_spoilers: Always expand posts marked with content warnings
setting_hide_network: Hide your social graph
setting_noindex: Opt-out of search engine indexing
setting_norss: Opt-out of an RSS feed for your public posts
setting_reduce_motion: Reduce motion in animations
setting_show_application: Disclose application used to send posts
setting_system_font_ui: Use system's default font
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ defaults: &defaults
show_application: true
system_font_ui: false
noindex: false
norss: false
theme: 'default'
aggregate_reblogs: true
advanced_layout: false
Expand Down

0 comments on commit 29eb83d

Please sign in to comment.