FEATURE: Show Reply count on blog index page when embedding

This commit is contained in:
Robin Ward
2014-01-13 12:47:24 -05:00
parent 0b58266934
commit af3edfd5eb
3 changed files with 60 additions and 0 deletions

View File

@ -24,6 +24,20 @@ class EmbedController < ApplicationController
discourse_expires_in 1.minute
end
def count
topic_embeds = TopicEmbed.where(embed_url: params[:embed_url]).includes(:topic).all
by_url = {}
topic_embeds.each do |te|
by_url["#{te.embed_url}#discourse-comments"] = I18n.t('embed.replies', count: te.topic.posts_count - 1)
end
respond_to do |format|
format.js { render json: {counts: by_url}, callback: params[:callback] }
end
end
private
def ensure_embeddable