mirror of
https://github.com/discourse/discourse.git
synced 2025-06-09 06:18:14 +08:00
Option to supress replies button below a post, when its reply is directly following.
This commit is contained in:
@ -173,6 +173,27 @@ window.Discourse.Post = Ember.Object.extend Discourse.Presence,
|
|||||||
loadVersions: (callback) ->
|
loadVersions: (callback) ->
|
||||||
$.get "/posts/#{@get('id')}/versions.json", (result) -> callback(result)
|
$.get "/posts/#{@get('id')}/versions.json", (result) -> callback(result)
|
||||||
|
|
||||||
|
|
||||||
|
# Whether to show replies directly below
|
||||||
|
showRepliesBelow: (->
|
||||||
|
reply_count = @get('reply_count')
|
||||||
|
|
||||||
|
# We don't show replies if there aren't any
|
||||||
|
return false if reply_count is 0
|
||||||
|
|
||||||
|
# Always show replies if the setting `supress_reply_directly_below` is false.
|
||||||
|
return true unless Discourse.SiteSettings.supress_reply_directly_below
|
||||||
|
|
||||||
|
# Always show replies if there's more than one
|
||||||
|
return true if reply_count > 1
|
||||||
|
|
||||||
|
# If we have *exactly* one reply, we have to consider if it's directly below us
|
||||||
|
return false if @get('topic')?.isReplyDirectlyBelow(@)
|
||||||
|
|
||||||
|
true
|
||||||
|
|
||||||
|
).property('reply_count')
|
||||||
|
|
||||||
window.Discourse.Post.reopenClass
|
window.Discourse.Post.reopenClass
|
||||||
|
|
||||||
REGULAR_TYPE: <%= Post::REGULAR %>
|
REGULAR_TYPE: <%= Post::REGULAR %>
|
||||||
|
@ -243,6 +243,18 @@ Discourse.Topic = Discourse.Model.extend Discourse.Presence,
|
|||||||
newPosts.each (p)->
|
newPosts.each (p)->
|
||||||
posts.pushObject(p) unless map[p.get('post_number')]
|
posts.pushObject(p) unless map[p.get('post_number')]
|
||||||
|
|
||||||
|
# Is the reply to a post directly below it?
|
||||||
|
isReplyDirectlyBelow: (post) ->
|
||||||
|
posts = @get('posts')
|
||||||
|
return unless posts
|
||||||
|
|
||||||
|
postBelow = posts[posts.indexOf(post) + 1]
|
||||||
|
|
||||||
|
# If the post directly below's reply_to_post_number is our post number, it's
|
||||||
|
# considered directly below.
|
||||||
|
return postBelow?.get('reply_to_post_number') is post.get('post_number')
|
||||||
|
|
||||||
|
|
||||||
window.Discourse.Topic.reopenClass
|
window.Discourse.Topic.reopenClass
|
||||||
|
|
||||||
NotificationLevel:
|
NotificationLevel:
|
||||||
|
@ -26,15 +26,13 @@ window.Discourse.PostMenuView = Ember.View.extend Discourse.Presence,
|
|||||||
# Trigger re rendering
|
# Trigger re rendering
|
||||||
needsToRender: (->
|
needsToRender: (->
|
||||||
@rerender()
|
@rerender()
|
||||||
).observes('post.deleted_at', 'post.flagsAvailable.@each', 'post.url', 'post.bookmarked', 'post.reply_count', 'post.can_delete')
|
).observes('post.deleted_at', 'post.flagsAvailable.@each', 'post.url', 'post.bookmarked', 'post.reply_count', 'post.showRepliesBelow', 'post.can_delete')
|
||||||
|
|
||||||
# Replies Button
|
# Replies Button
|
||||||
renderReplies: (post, buffer) ->
|
renderReplies: (post, buffer) ->
|
||||||
|
|
||||||
return if @get('post.replyFollowing')
|
return unless post.get('showRepliesBelow')
|
||||||
|
|
||||||
reply_count = post.get('reply_count')
|
reply_count = post.get('reply_count')
|
||||||
return if reply_count == 0
|
|
||||||
|
|
||||||
buffer.push("<button class='show-replies' data-action='replies'>")
|
buffer.push("<button class='show-replies' data-action='replies'>")
|
||||||
buffer.push("<span class='badge-posts'>#{reply_count}</span>")
|
buffer.push("<span class='badge-posts'>#{reply_count}</span>")
|
||||||
@ -97,7 +95,6 @@ window.Discourse.PostMenuView = Ember.View.extend Discourse.Presence,
|
|||||||
|
|
||||||
clickReply: -> @get('controller').replyToPost(@get('post'))
|
clickReply: -> @get('controller').replyToPost(@get('post'))
|
||||||
|
|
||||||
|
|
||||||
# Bookmark button
|
# Bookmark button
|
||||||
renderBookmark: (post, buffer) ->
|
renderBookmark: (post, buffer) ->
|
||||||
return unless Discourse.get('currentUser')
|
return unless Discourse.get('currentUser')
|
||||||
|
@ -29,6 +29,7 @@ class SiteSetting < ActiveRecord::Base
|
|||||||
client_setting(:min_topic_title_length, 5)
|
client_setting(:min_topic_title_length, 5)
|
||||||
client_setting(:max_topic_title_length, 255)
|
client_setting(:max_topic_title_length, 255)
|
||||||
client_setting(:flush_timings_secs, 5)
|
client_setting(:flush_timings_secs, 5)
|
||||||
|
client_setting(:supress_reply_directly_below, true)
|
||||||
|
|
||||||
# settings only available server side
|
# settings only available server side
|
||||||
setting(:auto_track_topics_after, 60000)
|
setting(:auto_track_topics_after, 60000)
|
||||||
@ -136,6 +137,8 @@ class SiteSetting < ActiveRecord::Base
|
|||||||
# Ways to catch griefers and other nasties
|
# Ways to catch griefers and other nasties
|
||||||
setting(:email_blacklist_regexp, '')
|
setting(:email_blacklist_regexp, '')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def self.call_mothership?
|
def self.call_mothership?
|
||||||
self.enforce_global_nicknames? and self.discourse_org_access_key.present?
|
self.enforce_global_nicknames? and self.discourse_org_access_key.present?
|
||||||
end
|
end
|
||||||
|
@ -259,7 +259,7 @@ en:
|
|||||||
posts_per_page: "How many posts are returned on a topic page"
|
posts_per_page: "How many posts are returned on a topic page"
|
||||||
system_username: "Username that sends system messages"
|
system_username: "Username that sends system messages"
|
||||||
send_welcome_message: "Do new users get a welcome private message?"
|
send_welcome_message: "Do new users get a welcome private message?"
|
||||||
|
supress_reply_directly_below: "Don't show replies button below a post when the reply is directly below"
|
||||||
allow_index_in_robots_txt: "Site should be indexed by search engines (update robots.txt)"
|
allow_index_in_robots_txt: "Site should be indexed by search engines (update robots.txt)"
|
||||||
|
|
||||||
port: "If you'd like to specify a port in the URL. Useful in development mode. Leave blank for none."
|
port: "If you'd like to specify a port in the URL. Useful in development mode. Leave blank for none."
|
||||||
|
Reference in New Issue
Block a user