mirror of
https://github.com/discourse/discourse.git
synced 2026-03-03 23:54:20 +08:00
## Summary Adds a new `fullApp` option to the embed snippet that renders the complete Discourse Ember application in the iframe instead of the simplified Rails-templated view. This allows embedded comments to have the full Discourse experience including likes, reactions, and inline replies. When `fullApp: true` is set: - `/embed/comments` redirects to the topic URL with `?embed_mode=true` - Header, sidebar, and footer are hidden - All links open in new tabs (to avoid navigating away within the iframe) - Iframe is scrollable with configurable height (default 600px) Feature is gated on a hidden site setting, default disabled, named `embed_full_app` ## Demo https://discourse-full-embed.pages.dev/embed-test ## Usage ```js DiscourseEmbed = { discourseUrl: 'https://forum.example.com/', discourseEmbedUrl: 'EMBED_URL', fullApp: true, // embedHeight: '800px', // optional, defaults to 600px }; ``` ## Security The `embed_mode` parameter only removes the X-Frame-Options header if: - `embed_any_origin` site setting is enabled, OR - The request referer matches a configured embeddable host This matches the existing security model for `/embed/comments`.
38 lines
1.1 KiB
Ruby
38 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe "Embed mode", type: :system do
|
|
fab!(:topic)
|
|
fab!(:post) { Fabricate(:post, topic: topic) }
|
|
|
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
|
|
|
before { SiteSetting.embed_full_app = true }
|
|
|
|
it "applies embed-mode class to body when embed_mode=true" do
|
|
visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
|
|
|
|
expect(page).to have_css("body.embed-mode")
|
|
end
|
|
|
|
it "does not apply embed-mode class without the param" do
|
|
visit("/t/#{topic.slug}/#{topic.id}")
|
|
|
|
expect(page).to have_no_css("body.embed-mode")
|
|
end
|
|
|
|
it "hides suggested topics in embed mode" do
|
|
Fabricate(:post) # create another topic for suggestions
|
|
visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
|
|
|
|
expect(page).to have_css("body.embed-mode")
|
|
expect(page).to have_no_css(".suggested-topics")
|
|
end
|
|
|
|
it "loads topic content without JS errors" do
|
|
visit("/t/#{topic.slug}/#{topic.id}?embed_mode=true")
|
|
|
|
expect(page).to have_css("body.embed-mode")
|
|
expect(topic_page).to have_topic_title(topic.title)
|
|
expect(page).to have_css("#post_1")
|
|
end
|
|
end
|