Skip to content

Commit

Permalink
add admin setting for default search engine indexing (fix mastodon#11750
Browse files Browse the repository at this point in the history
  • Loading branch information
Tao Bror Bojlén authored and hiyuki2578 committed Oct 2, 2019
1 parent 85c3516 commit 05cdfc1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/lib/settings/scoped_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Settings
class ScopedSettings
DEFAULTING_TO_UNSCOPED = %w(
theme
noindex
).freeze

def initialize(object)
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 @@ -32,6 +32,7 @@ class Form::AdminSettings
trends
show_domain_blocks
show_domain_blocks_rationale
noindex
).freeze

BOOLEAN_KEYS = %i(
Expand All @@ -45,6 +46,7 @@ class Form::AdminSettings
profile_directory
spam_check_enabled
trends
noindex
).freeze

UPLOAD_KEYS = %i(
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 @@ -71,6 +71,9 @@
.fields-group
= f.input :trends, as: :boolean, wrapper: :with_label, label: t('admin.settings.trends.title'), hint: t('admin.settings.trends.desc_html')

.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 :spam_check_enabled, as: :boolean, wrapper: :with_label, label: t('admin.settings.spam_check_enabled.title'), hint: t('admin.settings.spam_check_enabled.desc_html')

Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ en:
custom_css:
desc_html: Modify the look with CSS loaded on every page
title: Custom CSS
default_noindex:
desc_html: Affects all users who have not changed this setting themselves
title: Opt users out of search engine indexing by default
domain_blocks:
all: To everyone
disabled: To no one
Expand Down
1 change: 1 addition & 0 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def invalid_authenticity_token
sign_in current_user

allow(Setting).to receive(:[]).with('theme').and_return 'contrast'
allow(Setting).to receive(:[]).with('noindex').and_return false

expect(controller.view_context.current_theme).to eq 'contrast'
end
Expand Down

0 comments on commit 05cdfc1

Please sign in to comment.