mirror of
https://github.com/discourse/discourse.git
synced 2026-08-13 06:25:11 -05:00
FEATURE: Allow posting a link with topics
This commit is contained in:
@@ -193,6 +193,10 @@ class PostRevisionSerializer < ApplicationSerializer
|
||||
end
|
||||
end
|
||||
|
||||
if SiteSetting.topic_featured_link_enabled
|
||||
latest_modifications["featured_link"] = [post.topic.featured_link]
|
||||
end
|
||||
|
||||
if SiteSetting.tagging_enabled
|
||||
latest_modifications["tags"] = [post.topic.tags.map(&:name)]
|
||||
end
|
||||
|
||||
@@ -23,7 +23,8 @@ class SiteSerializer < ApplicationSerializer
|
||||
:can_tag_topics,
|
||||
:tags_filter_regexp,
|
||||
:top_tags,
|
||||
:wizard_required
|
||||
:wizard_required,
|
||||
:topic_featured_link_allowed_category_ids
|
||||
|
||||
has_many :categories, serializer: BasicCategorySerializer, embed: :objects
|
||||
has_many :trust_levels, embed: :objects
|
||||
@@ -121,4 +122,12 @@ class SiteSerializer < ApplicationSerializer
|
||||
def include_wizard_required?
|
||||
Wizard.user_requires_completion?(scope.user)
|
||||
end
|
||||
|
||||
def include_topic_featured_link_allowed_category_ids?
|
||||
SiteSetting.topic_featured_link_enabled
|
||||
end
|
||||
|
||||
def topic_featured_link_allowed_category_ids
|
||||
scope.topic_featured_link_allowed_category_ids
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ class SuggestedTopicSerializer < ListableTopicSerializer
|
||||
has_one :user, serializer: BasicUserSerializer, embed: :objects
|
||||
end
|
||||
|
||||
attributes :archetype, :like_count, :views, :category_id, :tags
|
||||
attributes :archetype, :like_count, :views, :category_id, :tags, :featured_link
|
||||
has_many :posters, serializer: SuggestedPosterSerializer, embed: :objects
|
||||
|
||||
def posters
|
||||
@@ -21,4 +21,12 @@ class SuggestedTopicSerializer < ListableTopicSerializer
|
||||
def tags
|
||||
object.tags.map(&:name)
|
||||
end
|
||||
|
||||
def include_featured_link?
|
||||
SiteSetting.topic_featured_link_enabled
|
||||
end
|
||||
|
||||
def featured_link
|
||||
object.featured_link
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,7 +10,8 @@ class TopicListItemSerializer < ListableTopicSerializer
|
||||
:pinned_globally,
|
||||
:bookmarked_post_numbers,
|
||||
:liked_post_numbers,
|
||||
:tags
|
||||
:tags,
|
||||
:featured_link
|
||||
|
||||
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
|
||||
has_many :participants, serializer: TopicPosterSerializer, embed: :objects
|
||||
@@ -72,4 +73,12 @@ class TopicListItemSerializer < ListableTopicSerializer
|
||||
object.tags.map(&:name)
|
||||
end
|
||||
|
||||
def include_featured_link?
|
||||
SiteSetting.topic_featured_link_enabled
|
||||
end
|
||||
|
||||
def featured_link
|
||||
object.featured_link
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -56,7 +56,8 @@ class TopicViewSerializer < ApplicationSerializer
|
||||
:chunk_size,
|
||||
:bookmarked,
|
||||
:message_archived,
|
||||
:tags
|
||||
:tags,
|
||||
:featured_link
|
||||
|
||||
# TODO: Split off into proper object / serializer
|
||||
def details
|
||||
@@ -243,8 +244,17 @@ class TopicViewSerializer < ApplicationSerializer
|
||||
def include_tags?
|
||||
SiteSetting.tagging_enabled
|
||||
end
|
||||
|
||||
def tags
|
||||
object.topic.tags.map(&:name)
|
||||
end
|
||||
|
||||
def include_featured_link?
|
||||
SiteSetting.topic_featured_link_enabled
|
||||
end
|
||||
|
||||
def featured_link
|
||||
object.topic.featured_link
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user