mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
Support embedded link counts via data-*
attribute
This commit is contained in:
@ -28,11 +28,14 @@ class EmbedController < ApplicationController
|
||||
|
||||
def count
|
||||
|
||||
topic_embeds = TopicEmbed.where(embed_url: params[:embed_url]).includes(:topic).all
|
||||
urls = params[:embed_url].map {|u| u.sub(/#discourse-comments$/, '') }
|
||||
topic_embeds = TopicEmbed.where(embed_url: urls).includes(:topic).references(:topic)
|
||||
|
||||
by_url = {}
|
||||
topic_embeds.each do |te|
|
||||
by_url["#{te.embed_url}#discourse-comments"] = I18n.t('embed.replies', count: te.topic.posts_count - 1)
|
||||
url = te.embed_url
|
||||
url = "#{url}#discourse-comments" unless params[:embed_url].include?(url)
|
||||
by_url[url] = I18n.t('embed.replies', count: te.topic.posts_count - 1)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
Reference in New Issue
Block a user