mirror of
https://github.com/discourse/discourse.git
synced 2026-03-04 01:15:08 +08:00
This feature allow admins to personalize their communities by associating emojis or icons with their site categories. There are now 3 style types for categories: - Square (the default) - Emoji - Icon ### How it looks 🎨 Adding an icon: <img width="502" alt="Category with an icon" src="https://github.com/user-attachments/assets/8f711340-166e-4781-a7b7-7267469dbabd" /> Adding an emoji: <img width="651" alt="Category with an emoji" src="https://github.com/user-attachments/assets/588c38ce-c719-4ed5-83f9-f1e1cb52c929" /> Sidebar: <img width="248" alt="Sidebar with emojis" src="https://github.com/user-attachments/assets/cd03d591-6170-4515-998c-0cec20118568" /> Category menus: <img width="621" alt="Screenshot 2025-03-13 at 10 32 30 AM" src="https://github.com/user-attachments/assets/7d89797a-f69f-45e5-bf64-a92d4cff8753" /> Within posts/topics: <img width="382" alt="Screenshot 2025-03-13 at 10 33 41 AM" src="https://github.com/user-attachments/assets/b7b1a951-44c6-4a4f-82ad-8ee31ddd6061" /> Chat messages: <img width="392" alt="Screenshot 2025-03-13 at 10 30 20 AM" src="https://github.com/user-attachments/assets/126f8076-0ea3-4f19-8452-1041fd2af29f" /> Autocomplete: <img width="390" alt="Screenshot 2025-03-13 at 10 29 53 AM" src="https://github.com/user-attachments/assets/cad75669-225f-4b8e-a7b5-ae5aa8f1bcad" /> --------- Co-authored-by: Martin Brennan <martin@discourse.org> Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
162 lines
3.7 KiB
Ruby
162 lines
3.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class UserSummarySerializer < ApplicationSerializer
|
|
class TopicSerializer < BasicTopicSerializer
|
|
attributes :category_id, :like_count, :created_at
|
|
end
|
|
|
|
class ReplySerializer < ApplicationSerializer
|
|
attributes :post_number, :like_count, :created_at
|
|
has_one :topic, serializer: TopicSerializer
|
|
end
|
|
|
|
class LinkSerializer < ApplicationSerializer
|
|
attributes :url, :title, :clicks, :post_number
|
|
has_one :topic, serializer: TopicSerializer
|
|
|
|
def post_number
|
|
object.post.post_number
|
|
end
|
|
end
|
|
|
|
class UserWithCountSerializer < ApplicationSerializer
|
|
attributes :id,
|
|
:username,
|
|
:name,
|
|
:count,
|
|
:avatar_template,
|
|
:admin,
|
|
:moderator,
|
|
:trust_level,
|
|
:flair_name,
|
|
:flair_url,
|
|
:flair_bg_color,
|
|
:flair_color,
|
|
:primary_group_name
|
|
|
|
def include_name?
|
|
SiteSetting.enable_names?
|
|
end
|
|
|
|
def avatar_template
|
|
User.avatar_template(object[:username], object[:uploaded_avatar_id])
|
|
end
|
|
|
|
def flair_name
|
|
object.flair_group&.name
|
|
end
|
|
|
|
def flair_url
|
|
object.flair_group&.flair_url
|
|
end
|
|
|
|
def flair_bg_color
|
|
object.flair_group&.flair_bg_color
|
|
end
|
|
|
|
def flair_color
|
|
object.flair_group&.flair_color
|
|
end
|
|
|
|
def primary_group_name
|
|
object.primary_group&.name
|
|
end
|
|
end
|
|
|
|
class CategoryWithCountsSerializer < ApplicationSerializer
|
|
attributes :topic_count,
|
|
:post_count,
|
|
:id,
|
|
:name,
|
|
:color,
|
|
:text_color,
|
|
:style_type,
|
|
:icon,
|
|
:emoji,
|
|
:slug,
|
|
:read_restricted,
|
|
:parent_category_id
|
|
end
|
|
|
|
has_many :topics, serializer: TopicSerializer
|
|
has_many :replies, serializer: ReplySerializer, embed: :object
|
|
has_many :links, serializer: LinkSerializer, embed: :object
|
|
has_many :most_liked_by_users, serializer: UserWithCountSerializer, embed: :object
|
|
has_many :most_liked_users, serializer: UserWithCountSerializer, embed: :object
|
|
has_many :most_replied_to_users, serializer: UserWithCountSerializer, embed: :object
|
|
has_many :badges, serializer: UserBadgeSerializer, embed: :object
|
|
has_many :top_categories, serializer: CategoryWithCountsSerializer, embed: :object
|
|
|
|
attributes :likes_given,
|
|
:likes_received,
|
|
:topics_entered,
|
|
:posts_read_count,
|
|
:days_visited,
|
|
:topic_count,
|
|
:post_count,
|
|
:time_read,
|
|
:recent_time_read,
|
|
:bookmark_count,
|
|
:can_see_summary_stats,
|
|
:can_see_user_actions
|
|
|
|
def can_see_summary_stats
|
|
scope.can_see_summary_stats?(object.user)
|
|
end
|
|
|
|
def can_see_user_actions
|
|
scope.can_see_user_actions?(object.user, [])
|
|
end
|
|
|
|
def include_badges?
|
|
SiteSetting.enable_badges
|
|
end
|
|
|
|
def include_bookmark_count?
|
|
scope.authenticated? && object.user_id == scope.user.id
|
|
end
|
|
|
|
def time_read
|
|
object.time_read
|
|
end
|
|
|
|
def recent_time_read
|
|
object.recent_time_read
|
|
end
|
|
|
|
def include_likes_given?
|
|
can_see_summary_stats
|
|
end
|
|
|
|
def include_likes_received?
|
|
can_see_summary_stats
|
|
end
|
|
|
|
def include_topics_entered?
|
|
can_see_summary_stats
|
|
end
|
|
|
|
def include_posts_read_count?
|
|
can_see_summary_stats
|
|
end
|
|
|
|
def include_days_visited?
|
|
can_see_summary_stats
|
|
end
|
|
|
|
def include_topic_count?
|
|
can_see_summary_stats
|
|
end
|
|
|
|
def include_post_count?
|
|
can_see_summary_stats
|
|
end
|
|
|
|
def include_time_read?
|
|
can_see_summary_stats
|
|
end
|
|
|
|
def include_recent_time_read?
|
|
can_see_summary_stats
|
|
end
|
|
end
|