mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-23 05:11:53 +01:00
Add instance-wide setting to disable profile directory (#9497)
* Add instance-wide setting to disable profile directory Fixes #9496 When the profile directory is disabled: - The “discoverable” setting is hidden from users - The “profile directory” link is not shown on public pages - /explore returns 404 * Move Setting.profile_directory check to a before_action filter
This commit is contained in:
parent
a48fe52375
commit
720daa8143
10 changed files with 29 additions and 3 deletions
|
@ -28,6 +28,7 @@ module Admin
|
||||||
@pam_enabled = ENV['PAM_ENABLED'] == 'true'
|
@pam_enabled = ENV['PAM_ENABLED'] == 'true'
|
||||||
@hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true'
|
@hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true'
|
||||||
@trending_hashtags = TrendingTags.get(7)
|
@trending_hashtags = TrendingTags.get(7)
|
||||||
|
@profile_directory = Setting.profile_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -26,6 +26,7 @@ module Admin
|
||||||
show_known_fediverse_at_about_page
|
show_known_fediverse_at_about_page
|
||||||
preview_sensitive_media
|
preview_sensitive_media
|
||||||
custom_css
|
custom_css
|
||||||
|
profile_directory
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
BOOLEAN_SETTINGS = %w(
|
BOOLEAN_SETTINGS = %w(
|
||||||
|
@ -37,6 +38,7 @@ module Admin
|
||||||
peers_api_enabled
|
peers_api_enabled
|
||||||
show_known_fediverse_at_about_page
|
show_known_fediverse_at_about_page
|
||||||
preview_sensitive_media
|
preview_sensitive_media
|
||||||
|
profile_directory
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
UPLOAD_SETTINGS = %w(
|
UPLOAD_SETTINGS = %w(
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
class DirectoriesController < ApplicationController
|
class DirectoriesController < ApplicationController
|
||||||
layout 'public'
|
layout 'public'
|
||||||
|
|
||||||
|
before_action :check_enabled
|
||||||
before_action :set_instance_presenter
|
before_action :set_instance_presenter
|
||||||
before_action :set_tag, only: :show
|
before_action :set_tag, only: :show
|
||||||
before_action :set_tags
|
before_action :set_tags
|
||||||
|
@ -18,6 +19,10 @@ class DirectoriesController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def check_enabled
|
||||||
|
return not_found unless Setting.profile_directory
|
||||||
|
end
|
||||||
|
|
||||||
def set_tag
|
def set_tag
|
||||||
@tag = Tag.discoverable.find_by!(name: params[:id].downcase)
|
@tag = Tag.discoverable.find_by!(name: params[:id].downcase)
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,6 +44,8 @@ class Form::AdminSettings
|
||||||
:preview_sensitive_media=,
|
:preview_sensitive_media=,
|
||||||
:custom_css,
|
:custom_css,
|
||||||
:custom_css=,
|
:custom_css=,
|
||||||
|
:profile_directory,
|
||||||
|
:profile_directory=,
|
||||||
to: Setting
|
to: Setting
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -57,6 +57,12 @@
|
||||||
%span.pull-right.positive-hint= fa_icon 'check fw'
|
%span.pull-right.positive-hint= fa_icon 'check fw'
|
||||||
- else
|
- else
|
||||||
%span.pull-right.negative-hint= fa_icon 'times fw'
|
%span.pull-right.negative-hint= fa_icon 'times fw'
|
||||||
|
%li
|
||||||
|
= link_to t('admin.dashboard.feature_profile_directory'), edit_admin_settings_path
|
||||||
|
- if @profile_directory
|
||||||
|
%span.pull-right.positive-hint= fa_icon 'check fw'
|
||||||
|
- else
|
||||||
|
%span.pull-right.negative-hint= fa_icon 'times fw'
|
||||||
%li
|
%li
|
||||||
= link_to t('admin.dashboard.feature_relay'), admin_relays_path
|
= link_to t('admin.dashboard.feature_relay'), admin_relays_path
|
||||||
- if @relay_enabled
|
- if @relay_enabled
|
||||||
|
|
|
@ -62,6 +62,9 @@
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :preview_sensitive_media, as: :boolean, wrapper: :with_label, label: t('admin.settings.preview_sensitive_media.title'), hint: t('admin.settings.preview_sensitive_media.desc_html')
|
= f.input :preview_sensitive_media, as: :boolean, wrapper: :with_label, label: t('admin.settings.preview_sensitive_media.title'), hint: t('admin.settings.preview_sensitive_media.desc_html')
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= f.input :profile_directory, as: :boolean, wrapper: :with_label, label: t('admin.settings.profile_directory.title'), hint: t('admin.settings.profile_directory.desc_html')
|
||||||
|
|
||||||
%hr.spacer/
|
%hr.spacer/
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
= link_to root_url, class: 'brand' do
|
= link_to root_url, class: 'brand' do
|
||||||
= image_tag asset_pack_path('logo_full.svg'), alt: 'Mastodon'
|
= image_tag asset_pack_path('logo_full.svg'), alt: 'Mastodon'
|
||||||
|
|
||||||
|
- if Setting.profile_directory
|
||||||
= link_to t('directories.directory'), explore_path, class: 'nav-link'
|
= link_to t('directories.directory'), explore_path, class: 'nav-link'
|
||||||
= link_to t('about.about_this'), about_more_path, class: 'nav-link'
|
= link_to t('about.about_this'), about_more_path, class: 'nav-link'
|
||||||
= link_to t('about.apps'), 'https://joinmastodon.org/apps', class: 'nav-link'
|
= link_to t('about.apps'), 'https://joinmastodon.org/apps', class: 'nav-link'
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :bot, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.bot')
|
= f.input :bot, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.bot')
|
||||||
|
|
||||||
|
- if Setting.profile_directory
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :discoverable, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.discoverable_html', min_followers: Account::MIN_FOLLOWERS_DISCOVERY, path: explore_path)
|
= f.input :discoverable, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.discoverable_html', min_followers: Account::MIN_FOLLOWERS_DISCOVERY, path: explore_path)
|
||||||
|
|
||||||
|
|
|
@ -229,6 +229,7 @@ en:
|
||||||
config: Configuration
|
config: Configuration
|
||||||
feature_deletions: Account deletions
|
feature_deletions: Account deletions
|
||||||
feature_invites: Invite links
|
feature_invites: Invite links
|
||||||
|
feature_profile_directory: Profile directory
|
||||||
feature_registrations: Registrations
|
feature_registrations: Registrations
|
||||||
feature_relay: Federation relay
|
feature_relay: Federation relay
|
||||||
features: Features
|
features: Features
|
||||||
|
@ -376,6 +377,9 @@ en:
|
||||||
preview_sensitive_media:
|
preview_sensitive_media:
|
||||||
desc_html: Link previews on other websites will display a thumbnail even if the media is marked as sensitive
|
desc_html: Link previews on other websites will display a thumbnail even if the media is marked as sensitive
|
||||||
title: Show sensitive media in OpenGraph previews
|
title: Show sensitive media in OpenGraph previews
|
||||||
|
profile_directory:
|
||||||
|
desc_html: Allow users to be discoverable
|
||||||
|
title: Enable profile directory
|
||||||
registrations:
|
registrations:
|
||||||
closed_message:
|
closed_message:
|
||||||
desc_html: Displayed on frontpage when registrations are closed. You can use HTML tags
|
desc_html: Displayed on frontpage when registrations are closed. You can use HTML tags
|
||||||
|
|
|
@ -15,6 +15,7 @@ defaults: &defaults
|
||||||
site_contact_username: ''
|
site_contact_username: ''
|
||||||
site_contact_email: ''
|
site_contact_email: ''
|
||||||
open_registrations: true
|
open_registrations: true
|
||||||
|
profile_directory: true
|
||||||
closed_registrations_message: ''
|
closed_registrations_message: ''
|
||||||
open_deletion: true
|
open_deletion: true
|
||||||
min_invite_role: 'admin'
|
min_invite_role: 'admin'
|
||||||
|
|
Loading…
Reference in a new issue