FEATURE: Allow embedding topics without creating them, by id

This commit is contained in:
Robin Ward
2015-06-09 16:24:04 -04:00
parent 49ca248186
commit ae277e28a6
3 changed files with 61 additions and 25 deletions

View File

@ -1,13 +1,18 @@
class EmbedController < ApplicationController
skip_before_filter :check_xhr, :preload_json, :verify_authenticity_token
before_filter :ensure_embeddable
layout 'embed'
def comments
embed_url = params.require(:embed_url)
topic_id = TopicEmbed.topic_id_for_embed(embed_url)
embed_url = params[:embed_url]
topic_id = nil
if embed_url.present?
topic_id = TopicEmbed.topic_id_for_embed(embed_url)
else
topic_id = params[:topic_id].to_i
end
if topic_id
@topic_view = TopicView.new(topic_id,
@ -21,7 +26,8 @@ class EmbedController < ApplicationController
if @topic_view && @topic_view.posts.size == SiteSetting.embed_post_limit
@posts_left = @topic_view.topic.posts_count - SiteSetting.embed_post_limit - 1
end
else
elsif embed_url.present?
Jobs.enqueue(:retrieve_topic, user_id: current_user.try(:id), embed_url: embed_url)
render 'loading'
end
@ -30,7 +36,6 @@ class EmbedController < ApplicationController
end
def count
embed_urls = params[:embed_url]
by_url = {}