From ccb345bd88024edf79fc91f90f02c5aac897a8d4 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Tue, 28 Feb 2023 14:31:59 +0200 Subject: [PATCH] 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 --- .../addon/components/embeddable-host.hbs | 15 - .../addon/controllers/admin-embedding.js | 8 +- .../admin/addon/templates/embedding.hbs | 9 +- .../admin/embeddable_hosts_controller.rb | 1 - app/controllers/embed_controller.rb | 30 +- app/models/topic_embed.rb | 6 +- config/locales/client.en.yml | 8 +- lib/topic_retriever.rb | 24 +- public/javascripts/embed.js | 4 + script/import_scripts/disqus.rb | 2 +- spec/lib/topic_retriever_spec.rb | 3 +- .../admin/embeddable_hosts_controller_spec.rb | 4 +- spec/requests/embed_controller_spec.rb | 426 ++++++++++-------- 13 files changed, 298 insertions(+), 242 deletions(-) diff --git a/app/assets/javascripts/admin/addon/components/embeddable-host.hbs b/app/assets/javascripts/admin/addon/components/embeddable-host.hbs index f37f242ba09..55e4b3df3fa 100644 --- a/app/assets/javascripts/admin/addon/components/embeddable-host.hbs +++ b/app/assets/javascripts/admin/addon/components/embeddable-host.hbs @@ -9,15 +9,6 @@ autofocus={{true}} /> - -
{{i18n "admin.embedding.class_name"}}
- -
{{i18n "admin.embedding.allowed_paths"}}
{{i18n "admin.embedding.host"}} {{this.host.host}} - -
- {{i18n "admin.embedding.class_name"}} -
- {{this.host.class_name}} -
{{i18n "admin.embedding.allowed_paths"}} diff --git a/app/assets/javascripts/admin/addon/controllers/admin-embedding.js b/app/assets/javascripts/admin/addon/controllers/admin-embedding.js index 147d4dd35a6..04579a40cd7 100644 --- a/app/assets/javascripts/admin/addon/controllers/admin-embedding.js +++ b/app/assets/javascripts/admin/addon/controllers/admin-embedding.js @@ -16,10 +16,14 @@ export default Controller.extend({ @discourseComputed("embedding.base_url") embeddingCode(baseUrl) { const html = `
+