mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Update topic/comment embedding parameters (#20181)
This commit implements many changes to topic and comments embedding. It deprecates the class_name field from EmbeddableHost and suggests using the className parameter. discourse_username parameter has been deprecated and it will fetch it from embedded site from the author or discourse-username meta. See the updated code sample from Admin > Customize > Embedding page. * FEATURE: Add className parameter for Discourse embed * DEV: Hide class_name from EmbeddableHost * DEV: Deprecate class_name field of EmbeddableHost * FEATURE: Use either author or discourse-username meta tag * DEV: Deprecate discourse_username parameter * DEV: Improve embed code sample
This commit is contained in:
@@ -4,7 +4,6 @@ class TopicRetriever
|
||||
def initialize(embed_url, opts = nil)
|
||||
@embed_url = embed_url
|
||||
@opts = opts || {}
|
||||
@author_username = @opts[:author_username]
|
||||
end
|
||||
|
||||
def retrieve
|
||||
@@ -35,21 +34,18 @@ class TopicRetriever
|
||||
# It's possible another process or job found the embed already. So if that happened bail out.
|
||||
return if TopicEmbed.where(embed_url: @embed_url).exists?
|
||||
|
||||
fetch_http
|
||||
end
|
||||
|
||||
def fetch_http
|
||||
if @author_username.nil?
|
||||
username =
|
||||
SiteSetting.embed_by_username.presence || SiteSetting.site_contact_username.presence ||
|
||||
Discourse.system_user.username
|
||||
else
|
||||
username = @author_username
|
||||
if @opts[:author_username].present?
|
||||
Discourse.deprecate(
|
||||
"discourse_username parameter has been deprecated. Prefer passing author name using a <meta> tag.",
|
||||
since: "3.1.0.beta1",
|
||||
drop_from: "3.2",
|
||||
)
|
||||
end
|
||||
|
||||
user = User.where(username_lower: username.downcase).first
|
||||
return if user.blank?
|
||||
username =
|
||||
@opts[:author_username].present || SiteSetting.embed_by_username.presence ||
|
||||
SiteSetting.site_contact_username.presence || Discourse.system_user.username
|
||||
|
||||
TopicEmbed.import_remote(user, @embed_url)
|
||||
TopicEmbed.import_remote(@embed_url, user: User.find_by(username_lower: username.downcase))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user