Skip to content

Support blueprintUE embedding #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/qiita/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require "qiita/markdown/embed/docswell"
require "qiita/markdown/embed/figma"
require "qiita/markdown/embed/stack_blitz"
require "qiita/markdown/embed/blueprint_ue"
require "qiita/markdown/transformers/filter_attributes"
require "qiita/markdown/transformers/filter_script"
require "qiita/markdown/transformers/filter_iframe"
Expand Down
11 changes: 11 additions & 0 deletions lib/qiita/markdown/embed/blueprint_ue.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module Qiita
module Markdown
module Embed
module BlueprintUe
SCRIPT_HOST = "blueprintue.com"
end
end
end
end
1 change: 1 addition & 0 deletions lib/qiita/markdown/transformers/filter_iframe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class FilterIframe
Embed::Figma::SCRIPT_HOST,
Embed::GoogleDrive::SCRIPT_HOST,
Embed::StackBlitz::SCRIPT_HOST,
Embed::BlueprintUe::SCRIPT_HOST,
].flatten.freeze

def self.call(**args)
Expand Down
37 changes: 37 additions & 0 deletions spec/qiita/markdown/processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,43 @@
end
end

context "with HTML embed code for blueprintUE" do
shared_examples "embed code blueprintUE example" do
let(:markdown) do
<<~MARKDOWN
<iframe src="#{url}" width="800" height="600" frameborder="0" allowfullscreen="true"></iframe>
MARKDOWN
end
let(:url) { "#{scheme}//blueprintue.com/embed/example" }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The domain blueprintue.com is hardcoded here. To improve maintainability and prevent potential inconsistencies, it's better to use the Qiita::Markdown::Embed::BlueprintUe::SCRIPT_HOST constant defined for this purpose.

let(:url) { "#{scheme}//#{Qiita::Markdown::Embed::BlueprintUe::SCRIPT_HOST}/embed/example" }


if allowed
it "does not sanitize embed code" do
should eq <<~HTML
<iframe src="#{url}" width="800" height="600" frameborder="0" allowfullscreen="true"></iframe>
HTML
end
else
it "forces width attribute on iframe" do
should eq <<~HTML
<iframe src="#{url}" width="100%" height="600" frameborder="0" allowfullscreen="true"></iframe>
HTML
end
end
end

context "with scheme" do
let(:scheme) { "https:" }

include_examples "embed code blueprintUE example"
end

context "without scheme" do
let(:scheme) { "" }

include_examples "embed code blueprintUE example"
end
end

context "with embed code for Tweet" do
let(:markdown) do
<<-MARKDOWN.strip_heredoc
Expand Down
Loading