Show the host for the iframe link

Instead of showing only: Click to visit embedded content

An embedded link now displays with the domain it's linking to: Embedded
content at example.com

This hopefully breaks up the links a bit so it'e easier to distinguish
between a bunch of them in a row (as long as they are on different
domains).
This commit is contained in:
Edward Loveall 2021-07-05 15:36:38 -04:00
parent d863cc27a5
commit 7cda16cef1
No known key found for this signature in database
GPG key ID: 789A4AE983AC8901
4 changed files with 20 additions and 2 deletions

View file

@ -156,7 +156,13 @@ describe PageContent do
html = PageContent.new(page: page).render_to_string
html.should eq %(<p><div class="embedded"><a href="https://example.com">Click to visit embedded content</a></div></p>)
html.should eq stripped_html <<-HTML
<p>
<div class="embedded">
<a href="https://example.com">Embedded content at example.com</a>
</div>
</p>
HTML
end
it "renders an ordered list" do

View file

@ -1,6 +1,14 @@
require "../spec_helper"
module Nodes
describe IFrame do
it "returns embedded url with subdomains" do
iframe = IFrame.new(href: "https://dev.example.com/page")
iframe.domain.should eq("dev.example.com")
end
end
describe Image do
it "adjusts the width and height proportionally" do
image = Image.new(src: "image.png", originalWidth: 1000, originalHeight: 603)

View file

@ -57,7 +57,7 @@ class PageContent < BaseComponent
def render_child(child : IFrame)
div class: "embedded" do
a href: child.href do
text "Click to visit embedded content"
text "Embedded content at #{child.domain}"
end
end
end

View file

@ -123,6 +123,10 @@ module Nodes
def initialize(@href : String)
end
def domain
URI.parse(href).host
end
def ==(other : IFrame)
other.href == href
end