mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
FEATURE: Add dark mode option for category backgrounds (#24003)
Adds a new upload field for a dark mode category background that will be used as an alternative when Discourse is using a dark mode theme.
This commit is contained in:
@ -29,6 +29,7 @@ class Category < ActiveRecord::Base
|
||||
belongs_to :uploaded_logo, class_name: "Upload"
|
||||
belongs_to :uploaded_logo_dark, class_name: "Upload"
|
||||
belongs_to :uploaded_background, class_name: "Upload"
|
||||
belongs_to :uploaded_background_dark, class_name: "Upload"
|
||||
|
||||
has_many :topics
|
||||
has_many :category_users
|
||||
@ -115,8 +116,13 @@ class Category < ActiveRecord::Base
|
||||
|
||||
after_save do
|
||||
if saved_change_to_uploaded_logo_id? || saved_change_to_uploaded_logo_dark_id? ||
|
||||
saved_change_to_uploaded_background_id?
|
||||
upload_ids = [self.uploaded_logo_id, self.uploaded_logo_dark_id, self.uploaded_background_id]
|
||||
saved_change_to_uploaded_background_id? || saved_change_to_uploaded_background_dark_id?
|
||||
upload_ids = [
|
||||
self.uploaded_logo_id,
|
||||
self.uploaded_logo_dark_id,
|
||||
self.uploaded_background_id,
|
||||
self.uploaded_background_dark_id,
|
||||
]
|
||||
UploadReference.ensure_exist!(upload_ids: upload_ids, target: self)
|
||||
end
|
||||
end
|
||||
@ -1185,6 +1191,7 @@ end
|
||||
# allow_unlimited_owner_edits_on_first_post :boolean default(FALSE), not null
|
||||
# default_slow_mode_seconds :integer
|
||||
# uploaded_logo_dark_id :integer
|
||||
# uploaded_background_dark_id :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
@ -16,6 +16,7 @@ class CategoryList
|
||||
def self.included_associations
|
||||
[
|
||||
:uploaded_background,
|
||||
:uploaded_background_dark,
|
||||
:uploaded_logo,
|
||||
:uploaded_logo_dark,
|
||||
:topic_only_relative_url,
|
||||
|
@ -81,6 +81,7 @@ class Site
|
||||
:uploaded_logo,
|
||||
:uploaded_logo_dark,
|
||||
:uploaded_background,
|
||||
:uploaded_background_dark,
|
||||
:tags,
|
||||
:tag_groups,
|
||||
:form_templates,
|
||||
|
Reference in New Issue
Block a user