diff --git a/app/controllers/api/v1/timelines/public_controller.rb b/app/controllers/api/v1/timelines/public_controller.rb index 5bc8de83341d27..2c83738a2702c9 100644 --- a/app/controllers/api/v1/timelines/public_controller.rb +++ b/app/controllers/api/v1/timelines/public_controller.rb @@ -2,6 +2,8 @@ class Api::V1::Timelines::PublicController < Api::V1::Timelines::BaseController before_action :require_user!, only: [:show], if: :require_auth? + before_action :require_user!, only: [:show], if: :require_auth_local? && !truthy_param?(:local) + before_action :require_user!, only: [:show], if: :require_auth_remote? && !truthy_param?(:remote) PERMITTED_PARAMS = %i(local remote limit only_media allow_local_only).freeze @@ -17,6 +19,14 @@ def require_auth? !Setting.timeline_preview end + def require_auth_local? + !Setting.timeline_preview_local + end + + def require_auth_remote? + !Setting.timeline_preview_remote + end + def load_statuses cached_public_statuses_page end diff --git a/app/javascript/flavours/blobfox/initial_state.js b/app/javascript/flavours/blobfox/initial_state.js index 52066aac420546..e40cfa0a459782 100644 --- a/app/javascript/flavours/blobfox/initial_state.js +++ b/app/javascript/flavours/blobfox/initial_state.js @@ -38,6 +38,8 @@ * @property {string} source_url * @property {string} streaming_api_base_url * @property {boolean} timeline_preview + * @property {boolean} timeline_preview_local + * @property {boolean} timeline_preview_remote * @property {string} title * @property {boolean} show_trends * @property {boolean} trends_as_landing_page @@ -122,6 +124,8 @@ export const showTrends = getMeta('show_trends'); export const singleUserMode = getMeta('single_user_mode'); export const source_url = getMeta('source_url'); export const timelinePreview = getMeta('timeline_preview'); +export const timelinePreview_local = getMeta('timeline_preview_local'); +export const timelinePreview_remote = getMeta('timeline_preview_remote'); export const title = getMeta('title'); export const trendsAsLanding = getMeta('trends_as_landing_page'); export const unfollowModal = getMeta('unfollow_modal'); diff --git a/app/javascript/flavours/glitch/initial_state.js b/app/javascript/flavours/glitch/initial_state.js index 452f2991898686..e97794277db5c5 100644 --- a/app/javascript/flavours/glitch/initial_state.js +++ b/app/javascript/flavours/glitch/initial_state.js @@ -38,6 +38,8 @@ * @property {string} source_url * @property {string} streaming_api_base_url * @property {boolean} timeline_preview + * @property {boolean} timeline_preview_local + * @property {boolean} timeline_preview_remote * @property {string} title * @property {boolean} show_trends * @property {boolean} trends_as_landing_page @@ -123,6 +125,8 @@ export const showTrends = getMeta('show_trends'); export const singleUserMode = getMeta('single_user_mode'); export const source_url = getMeta('source_url'); export const timelinePreview = getMeta('timeline_preview'); +export const timelinePreview_local = getMeta('timeline_preview_local'); +export const timelinePreview_remote = getMeta('timeline_preview_remote'); export const title = getMeta('title'); export const trendsAsLanding = getMeta('trends_as_landing_page'); export const unfollowModal = getMeta('unfollow_modal'); diff --git a/app/javascript/mastodon/initial_state.js b/app/javascript/mastodon/initial_state.js index 58e665151632d6..52d0a22c15eaf6 100644 --- a/app/javascript/mastodon/initial_state.js +++ b/app/javascript/mastodon/initial_state.js @@ -36,6 +36,8 @@ * @property {string} source_url * @property {string} streaming_api_base_url * @property {boolean} timeline_preview + * @property {boolean} timeline_preview_local + * @property {boolean} timeline_preview_remote * @property {string} title * @property {boolean} show_trends * @property {boolean} trends_as_landing_page @@ -102,6 +104,8 @@ export const showTrends = getMeta('show_trends'); export const singleUserMode = getMeta('single_user_mode'); export const source_url = getMeta('source_url'); export const timelinePreview = getMeta('timeline_preview'); +export const timelinePreview_local = getMeta('timeline_preview_local'); +export const timelinePreview_remote = getMeta('timeline_preview_remote'); export const title = getMeta('title'); export const trendsAsLanding = getMeta('trends_as_landing_page'); export const unfollowModal = getMeta('unfollow_modal'); diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index ef55dfd65f637b..de0b7788b97ba2 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -15,6 +15,8 @@ class Form::AdminSettings registrations_mode closed_registrations_message timeline_preview + timeline_preview_local + timeline_preview_remote bootstrap_timeline_accounts flavour skin @@ -56,6 +58,8 @@ class Form::AdminSettings BOOLEAN_KEYS = %i( timeline_preview + timeline_preview_local + timeline_preview_remote activity_api_enabled peers_api_enabled preview_sensitive_media diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index c1d9f6d7002634..34c253226b1729 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -131,6 +131,8 @@ def default_meta_store status_page_url: Setting.status_page_url, streaming_api_base_url: Rails.configuration.x.streaming_api_base_url, timeline_preview: Setting.timeline_preview, + timeline_preview_local: Setting.timeline_preview_local, + timeline_preview_remote: Setting.timeline_preview_remote, title: instance_presenter.title, trends_as_landing_page: Setting.trends_as_landing_page, trends_enabled: Setting.trends, diff --git a/app/views/admin/settings/discovery/show.html.haml b/app/views/admin/settings/discovery/show.html.haml index 6655fc2acf71b2..ebab8d2a770e79 100644 --- a/app/views/admin/settings/discovery/show.html.haml +++ b/app/views/admin/settings/discovery/show.html.haml @@ -29,6 +29,16 @@ .fields-group = f.input :timeline_preview, as: :boolean, wrapper: :with_label + %h4= t('admin.settings.discovery.public_timelines_local') + + .fields-group + = f.input :timeline_preview_local, as: :boolean, wrapper: :with_label + + %h4= t('admin.settings.discovery.public_timelines_remote') + + .fields-group + = f.input :timeline_preview_remote, as: :boolean, wrapper: :with_label + .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') diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 4ba6e88f418183..638986d746edb5 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -97,6 +97,8 @@ en: theme: Theme that logged out visitors and new users see. thumbnail: A roughly 2:1 image displayed alongside your server information. timeline_preview: Logged out visitors will be able to browse the most recent public posts available on the server. + timeline_preview_local: Logged out visitors will be able to browse the most recent public local posts available on the server. + timeline_preview_remote: Logged out visitors will be able to browse the most recent public remote posts available on the server. trendable_by_default: Skip manual review of trending content. Individual items can still be removed from trends after the fact. trends: Trends show which posts, hashtags and news stories are gaining traction on your server. trends_as_landing_page: Show trending content to logged-out users and visitors instead of a description of this server. Requires trends to be enabled. @@ -263,6 +265,8 @@ en: theme: Default theme thumbnail: Server thumbnail timeline_preview: Allow unauthenticated access to public timelines + timeline_preview: Allow unauthenticated access to local timeline + timeline_preview: Allow unauthenticated access to remote timeline trendable_by_default: Allow trends without prior review trends: Enable trends trends_as_landing_page: Use trends as the landing page diff --git a/config/settings.yml b/config/settings.yml index 9bd78b5c014f30..aa4c3069e8e120 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -13,6 +13,8 @@ defaults: &defaults profile_directory: true closed_registrations_message: '' timeline_preview: false + timeline_preview_local: false + timeline_preview_remote: false show_staff_badge: true preview_sensitive_media: false noindex: false