mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-17 02:34:40 +08:00
This commit introduces the concept of themeable site settings,
which is a new tool for theme authors that lives alongside theme
modifiers and theme settings. Here is a quick summary:
* Theme settings - These are custom settings used to control UI and functionality within your theme or component and provide configuration options. These cannot change core Discourse functionality.
* Theme modifiers - Allows a theme or a component to modify selected server-side functionality of core Discourse as an alternative to building a plugin.
* Themeable site settings (new) - Allows a theme (not components) to override a small subset of core site settings, which generally control parts of the UI and other minor functionality. This allows themes to have a greater control over the full site experience.
Themeable site settings will be shown for all themes, whether the theme
changes
the value or not, and have a similar UI to custom theme settings.
We are also introducing a new page at
`/admin/config/theme-site-settings` that
allows admins to see all possible themeable site settings, and which
themes
are changing the value from the default.
### Configuration
Theme authors can configure initial values themeable site settings using
a section in the `about.json` file like so:
```json
"theme_site_settings": {
"search_experience": "search_field"
}
```
These values will not change when the theme updates, because we cannot
know if admins have manually changed them.
### Limitations
Themeable site settings are only really intended to control elements of
the UI, and when retrieving their value we require a theme ID, so these
limitations apply:
- Themeable site settings cannot be used in Sidekiq jobs
- Themeable site settings cannot be used in markdown rules
- Themeable site settings will be cached separately to client site
settings using theme ID as a key
- Themeable site settings will override keys on the `siteSettings`
service on the client using the application preloader
- `SiteSetting.client_settings_json` will not include themeable site
settings, instead you can call `SiteSetting.theme_site_settings_json`
with a theme ID
### Initial settings
There are only two site settings that will be themeable to begin with:
* `enable_welcome_banner`
* `search_experience`
And our new Horizon theme will take advantage of both. Over time, more
settings that control elements of the UI will be exposed this way.
|
||
|---|---|---|
| .. | ||
| admin | ||
| users | ||
| about_controller.rb | ||
| application_controller.rb | ||
| associated_groups_controller.rb | ||
| badges_controller.rb | ||
| bookmarks_controller.rb | ||
| bootstrap_controller.rb | ||
| categories_controller.rb | ||
| clicks_controller.rb | ||
| composer_controller.rb | ||
| composer_messages_controller.rb | ||
| csp_reports_controller.rb | ||
| directory_columns_controller.rb | ||
| directory_items_controller.rb | ||
| do_not_disturb_controller.rb | ||
| drafts_controller.rb | ||
| edit_directory_columns_controller.rb | ||
| email_controller.rb | ||
| embed_controller.rb | ||
| emojis_controller.rb | ||
| exceptions_controller.rb | ||
| export_csv_controller.rb | ||
| extra_locales_controller.rb | ||
| finish_installation_controller.rb | ||
| form_templates_controller.rb | ||
| forums_controller.rb | ||
| groups_controller.rb | ||
| hashtags_controller.rb | ||
| highlight_js_controller.rb | ||
| home_page_controller.rb | ||
| inline_onebox_controller.rb | ||
| invites_controller.rb | ||
| list_controller.rb | ||
| metadata_controller.rb | ||
| new_invite_controller.rb | ||
| new_topic_controller.rb | ||
| notifications_controller.rb | ||
| offline_controller.rb | ||
| onebox_controller.rb | ||
| pageview_controller.rb | ||
| permalinks_controller.rb | ||
| post_action_users_controller.rb | ||
| post_actions_controller.rb | ||
| post_localizations_controller.rb | ||
| post_readers_controller.rb | ||
| posts_controller.rb | ||
| presence_controller.rb | ||
| published_pages_controller.rb | ||
| push_notification_controller.rb | ||
| qunit_controller.rb | ||
| reviewable_claimed_topics_controller.rb | ||
| reviewable_notes_controller.rb | ||
| reviewables_controller.rb | ||
| robots_txt_controller.rb | ||
| safe_mode_controller.rb | ||
| search_controller.rb | ||
| session_controller.rb | ||
| sidebar_sections_controller.rb | ||
| similar_topics_controller.rb | ||
| site_controller.rb | ||
| sitemap_controller.rb | ||
| slugs_controller.rb | ||
| static_controller.rb | ||
| steps_controller.rb | ||
| stylesheets_controller.rb | ||
| svg_sprite_controller.rb | ||
| tag_groups_controller.rb | ||
| tags_controller.rb | ||
| test_requests_controller.rb | ||
| theme_javascripts_controller.rb | ||
| topic_localizations_controller.rb | ||
| topic_view_stats_controller.rb | ||
| topics_controller.rb | ||
| uploads_controller.rb | ||
| user_actions_controller.rb | ||
| user_api_key_clients_controller.rb | ||
| user_api_keys_controller.rb | ||
| user_avatars_controller.rb | ||
| user_badges_controller.rb | ||
| user_status_controller.rb | ||
| users_controller.rb | ||
| users_email_controller.rb | ||
| webhooks_controller.rb | ||
| wizard_controller.rb | ||