Add option to opt out of search engines on public profile/status pages (#4199)

This commit is contained in:
Eugen Rochko 2017-07-14 16:41:02 +02:00 committed by GitHub
parent 999170d898
commit c42092ba7a
11 changed files with 30 additions and 0 deletions

View File

@ -39,6 +39,7 @@ class Settings::PreferencesController < ApplicationController
:setting_delete_modal, :setting_delete_modal,
:setting_auto_play_gif, :setting_auto_play_gif,
:setting_system_font_ui, :setting_system_font_ui,
:setting_noindex,
notification_emails: %i(follow follow_request reblog favourite mention digest), notification_emails: %i(follow follow_request reblog favourite mention digest),
interactions: %i(must_be_follower must_be_following) interactions: %i(must_be_follower must_be_following)
) )

View File

@ -23,6 +23,7 @@ class UserSettingsDecorator
user.settings['delete_modal'] = delete_modal_preference user.settings['delete_modal'] = delete_modal_preference
user.settings['auto_play_gif'] = auto_play_gif_preference user.settings['auto_play_gif'] = auto_play_gif_preference
user.settings['system_font_ui'] = system_font_ui_preference user.settings['system_font_ui'] = system_font_ui_preference
user.settings['noindex'] = noindex_preference
end end
def merged_notification_emails def merged_notification_emails
@ -57,6 +58,10 @@ class UserSettingsDecorator
boolean_cast_setting 'setting_auto_play_gif' boolean_cast_setting 'setting_auto_play_gif'
end end
def noindex_preference
boolean_cast_setting 'setting_noindex'
end
def boolean_cast_setting(key) def boolean_cast_setting(key)
settings[key] == '1' settings[key] == '1'
end end

View File

@ -99,6 +99,10 @@ class User < ApplicationRecord
settings.system_font_ui settings.system_font_ui
end end
def setting_noindex
settings.noindex
end
def activate_session(request) def activate_session(request)
session_activations.activate(session_id: SecureRandom.hex, session_activations.activate(session_id: SecureRandom.hex,
user_agent: request.user_agent, user_agent: request.user_agent,

View File

@ -2,6 +2,9 @@
= display_name(@account) = display_name(@account)
- content_for :header_tags do - content_for :header_tags do
- if @account.user&.setting_noindex
%meta{ name: 'robots', content: 'noindex' }/
%link{ rel: 'salmon', href: api_salmon_url(@account.id) }/ %link{ rel: 'salmon', href: api_salmon_url(@account.id) }/
%link{ rel: 'alternate', type: 'application/atom+xml', href: account_url(@account, format: 'atom') }/ %link{ rel: 'alternate', type: 'application/atom+xml', href: account_url(@account, format: 'atom') }/

View File

@ -2,6 +2,9 @@
= t('accounts.people_who_follow', name: display_name(@account)) = t('accounts.people_who_follow', name: display_name(@account))
- content_for :header_tags do - content_for :header_tags do
- if @account.user&.setting_noindex
%meta{ name: 'robots', content: 'noindex' }/
= render 'accounts/og', account: @account, url: account_followers_url(@account, only_path: false) = render 'accounts/og', account: @account, url: account_followers_url(@account, only_path: false)
= render 'accounts/header', account: @account = render 'accounts/header', account: @account

View File

@ -2,6 +2,9 @@
= t('accounts.people_followed_by', name: display_name(@account)) = t('accounts.people_followed_by', name: display_name(@account))
- content_for :header_tags do - content_for :header_tags do
- if @account.user&.setting_noindex
%meta{ name: 'robots', content: 'noindex' }/
= render 'accounts/og', account: @account, url: account_followers_url(@account, only_path: false) = render 'accounts/og', account: @account, url: account_followers_url(@account, only_path: false)
= render 'accounts/header', account: @account = render 'accounts/header', account: @account

View File

@ -2,6 +2,8 @@
%html{ lang: I18n.locale } %html{ lang: I18n.locale }
%head %head
%meta{ charset: 'utf-8' }/ %meta{ charset: 'utf-8' }/
%meta{ name: 'robots', content: 'noindex' }/
= stylesheet_pack_tag 'common', media: 'all' = stylesheet_pack_tag 'common', media: 'all'
= javascript_pack_tag 'common', integrity: true, crossorigin: 'anonymous' = javascript_pack_tag 'common', integrity: true, crossorigin: 'anonymous'
= javascript_pack_tag "locale_#{I18n.locale}", integrity: true, crossorigin: 'anonymous' = javascript_pack_tag "locale_#{I18n.locale}", integrity: true, crossorigin: 'anonymous'

View File

@ -40,6 +40,9 @@
= ff.input :must_be_follower, as: :boolean, wrapper: :with_label = ff.input :must_be_follower, as: :boolean, wrapper: :with_label
= ff.input :must_be_following, as: :boolean, wrapper: :with_label = ff.input :must_be_following, as: :boolean, wrapper: :with_label
.fields-group
= f.input :setting_noindex, as: :boolean, wrapper: :with_label
.fields-group .fields-group
= f.input :setting_boost_modal, as: :boolean, wrapper: :with_label = f.input :setting_boost_modal, as: :boolean, wrapper: :with_label
= f.input :setting_delete_modal, as: :boolean, wrapper: :with_label = f.input :setting_delete_modal, as: :boolean, wrapper: :with_label

View File

@ -1,4 +1,7 @@
- content_for :header_tags do - content_for :header_tags do
- if @account.user&.setting_noindex
%meta{ name: 'robots', content: 'noindex' }/
%link{ rel: 'alternate', type: 'application/atom+xml', href: account_stream_entry_url(@account, @stream_entry, format: 'atom') }/ %link{ rel: 'alternate', type: 'application/atom+xml', href: account_stream_entry_url(@account, @stream_entry, format: 'atom') }/
%link{ rel: 'alternate', type: 'application/json+oembed', href: api_oembed_url(url: account_stream_entry_url(@account, @stream_entry), format: 'json') }/ %link{ rel: 'alternate', type: 'application/json+oembed', href: api_oembed_url(url: account_stream_entry_url(@account, @stream_entry), format: 'json') }/

View File

@ -12,6 +12,7 @@ en:
note: note:
one: <span class="note-counter">1</span> character left one: <span class="note-counter">1</span> character left
other: <span class="note-counter">%{count}</span> characters left other: <span class="note-counter">%{count}</span> characters left
setting_noindex: Affects your public profile and status pages
imports: imports:
data: CSV file exported from another Mastodon instance data: CSV file exported from another Mastodon instance
sessions: sessions:
@ -41,6 +42,7 @@ en:
setting_default_sensitive: Always mark media as sensitive setting_default_sensitive: Always mark media as sensitive
setting_delete_modal: Show confirmation dialog before deleting a toot setting_delete_modal: Show confirmation dialog before deleting a toot
setting_system_font_ui: Use system's default font setting_system_font_ui: Use system's default font
setting_noindex: Opt-out of search engine indexing
severity: Severity severity: Severity
type: Import type type: Import type
username: Username username: Username

View File

@ -21,6 +21,7 @@ defaults: &defaults
auto_play_gif: false auto_play_gif: false
delete_modal: true delete_modal: true
system_font_ui: false system_font_ui: false
noindex: false
notification_emails: notification_emails:
follow: false follow: false
reblog: false reblog: false