2
0

Add a new setting to choose the server landing page (#36588)

This commit is contained in:
Renaud Chaput
2025-10-27 11:16:59 +01:00
committed by GitHub
parent e40ca321ed
commit 779a1f8448
72 changed files with 81 additions and 135 deletions

View File

@@ -27,7 +27,7 @@ import { uploadCompose, resetCompose, changeComposeSpoilerness } from '../../act
import { clearHeight } from '../../actions/height_cache';
import { fetchServer, fetchServerTranslationLanguages } from '../../actions/server';
import { expandHomeTimeline } from '../../actions/timelines';
import { initialState, me, owner, singleUserMode, trendsEnabled, trendsAsLanding, disableHoverCards, autoPlayGif } from '../../initial_state';
import { initialState, me, owner, singleUserMode, trendsEnabled, landingPage, localLiveFeedAccess, disableHoverCards, autoPlayGif } from '../../initial_state';
import BundleColumnError from './components/bundle_column_error';
import { NavigationBar } from './components/navigation_bar';
@@ -148,8 +148,10 @@ class SwitchingColumnsArea extends PureComponent {
}
} else if (singleUserMode && owner && initialState?.accounts[owner]) {
redirect = <Redirect from='/' to={`/@${initialState.accounts[owner].username}`} exact />;
} else if (trendsEnabled && trendsAsLanding) {
} else if (trendsEnabled && landingPage === 'trends') {
redirect = <Redirect from='/' to='/explore' exact />;
} else if (localLiveFeedAccess === 'public' && landingPage === 'local_feed') {
redirect = <Redirect from='/' to='/public/local' exact />;
} else {
redirect = <Redirect from='/' to='/about' exact />;
}

View File

@@ -39,7 +39,7 @@ interface InitialStateMeta {
remote_topic_feed_access: 'public' | 'authenticated' | 'disabled';
title: string;
show_trends: boolean;
trends_as_landing_page: boolean;
landing_page: 'about' | 'trends' | 'local_feed';
use_blurhash: boolean;
use_pending_items?: boolean;
version: string;
@@ -120,7 +120,7 @@ export const remoteLiveFeedAccess = getMeta('remote_live_feed_access');
export const localTopicFeedAccess = getMeta('local_topic_feed_access');
export const remoteTopicFeedAccess = getMeta('remote_topic_feed_access');
export const title = getMeta('title');
export const trendsAsLanding = getMeta('trends_as_landing_page');
export const landingPage = getMeta('landing_page');
export const useBlurhash = getMeta('use_blurhash');
export const usePendingItems = getMeta('use_pending_items');
export const version = getMeta('version');

View File

@@ -24,7 +24,6 @@ class Form::AdminSettings
thumbnail
mascot
trends
trends_as_landing_page
trendable_by_default
show_domain_blocks
show_domain_blocks_rationale
@@ -44,6 +43,7 @@ class Form::AdminSettings
remote_live_feed_access
local_topic_feed_access
remote_topic_feed_access
landing_page
).freeze
INTEGER_KEYS = %i(
@@ -61,7 +61,6 @@ class Form::AdminSettings
preview_sensitive_media
profile_directory
trends
trends_as_landing_page
trendable_by_default
noindex
require_invite_text
@@ -88,6 +87,7 @@ class Form::AdminSettings
DOMAIN_BLOCK_AUDIENCES = %w(disabled users all).freeze
REGISTRATION_MODES = %w(open approved none).freeze
FEED_ACCESS_MODES = %w(public authenticated disabled).freeze
LANDING_PAGE = %w(trends about local_feed).freeze
attr_accessor(*KEYS)
@@ -106,6 +106,7 @@ class Form::AdminSettings
validates :site_short_description, length: { maximum: DESCRIPTION_LIMIT }, if: -> { defined?(@site_short_description) }
validates :status_page_url, url: true, allow_blank: true
validate :validate_site_uploads
validates :landing_page, inclusion: { in: LANDING_PAGE }, if: -> { defined?(@landing_page) }
KEYS.each do |key|
define_method(key) do

View File

@@ -113,7 +113,7 @@ class InitialStateSerializer < ActiveModel::Serializer
status_page_url: Setting.status_page_url,
streaming_api_base_url: Rails.configuration.x.streaming_api_base_url,
title: instance_presenter.title,
trends_as_landing_page: Setting.trends_as_landing_page,
landing_page: Setting.landing_page,
trends_enabled: Setting.trends,
version: instance_presenter.version,
terms_of_service_enabled: TermsOfService.current.present?,

View File

@@ -68,5 +68,12 @@
= material_symbol 'delete'
= t('admin.site_uploads.delete')
.fields-row
= f.input :landing_page,
collection: f.object.class::LANDING_PAGE,
include_blank: false,
label_method: ->(page) { I18n.t("admin.settings.landing_page.values.#{page}") },
wrapper: :with_label
.actions
= f.button :button, t('generic.save_changes'), type: :submit

View File

@@ -17,11 +17,6 @@
as: :boolean,
wrapper: :with_label
.fields-group
= f.input :trends_as_landing_page,
as: :boolean,
wrapper: :with_label
.fields-group
= f.input :trendable_by_default,
as: :boolean,