Add MIXTAPE_EMBED paragraph type
This commit is contained in:
parent
0cab1a11ed
commit
9770ff5c7a
6 changed files with 68 additions and 0 deletions
|
@ -277,6 +277,25 @@ describe ParagraphConverter do
|
||||||
},
|
},
|
||||||
"layout": null,
|
"layout": null,
|
||||||
"metadata": null
|
"metadata": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "Mixtape",
|
||||||
|
"type": "MIXTAPE_EMBED",
|
||||||
|
"href": null,
|
||||||
|
"layout": null,
|
||||||
|
"markups": [
|
||||||
|
{
|
||||||
|
"title": "https://example.com",
|
||||||
|
"type": "A",
|
||||||
|
"href": "https://example.com",
|
||||||
|
"userId": null,
|
||||||
|
"start": 0,
|
||||||
|
"end": 7,
|
||||||
|
"anchorType": "LINK"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"iframe": null,
|
||||||
|
"metadata": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
JSON
|
JSON
|
||||||
|
@ -294,6 +313,12 @@ describe ParagraphConverter do
|
||||||
FigureCaption.new(children: [Text.new("text")] of Child),
|
FigureCaption.new(children: [Text.new("text")] of Child),
|
||||||
] of Child),
|
] of Child),
|
||||||
IFrame.new(href: "https://example.com"),
|
IFrame.new(href: "https://example.com"),
|
||||||
|
MixtapeEmbed.new(children: [
|
||||||
|
Anchor.new(
|
||||||
|
children: [Text.new("Mixtape")] of Child,
|
||||||
|
href: "https://example.com"
|
||||||
|
),
|
||||||
|
] of Child),
|
||||||
]
|
]
|
||||||
|
|
||||||
result = ParagraphConverter.new.convert(paragraphs)
|
result = ParagraphConverter.new.convert(paragraphs)
|
||||||
|
|
|
@ -234,6 +234,35 @@ describe PageContent do
|
||||||
HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "renders an mixtape embed container" do
|
||||||
|
page = Page.new(
|
||||||
|
title: "Title",
|
||||||
|
subtitle: nil,
|
||||||
|
author: "Author",
|
||||||
|
created_at: Time.local,
|
||||||
|
nodes: [
|
||||||
|
Paragraph.new(children: [
|
||||||
|
MixtapeEmbed.new(children: [
|
||||||
|
Anchor.new(
|
||||||
|
children: [Text.new("Mixtape")] of Child,
|
||||||
|
href: "https://example.com"
|
||||||
|
),
|
||||||
|
] of Child),
|
||||||
|
] of Child),
|
||||||
|
] of Child
|
||||||
|
)
|
||||||
|
|
||||||
|
html = PageContent.new(page: page).render_to_string
|
||||||
|
|
||||||
|
html.should eq stripped_html <<-HTML
|
||||||
|
<p>
|
||||||
|
<div class="embedded">
|
||||||
|
<a href="https://example.com">Mixtape</a>
|
||||||
|
</div>
|
||||||
|
</p>
|
||||||
|
HTML
|
||||||
|
end
|
||||||
|
|
||||||
it "renders an ordered list" do
|
it "renders an ordered list" do
|
||||||
page = Page.new(
|
page = Page.new(
|
||||||
title: "Title",
|
title: "Title",
|
||||||
|
|
|
@ -28,6 +28,10 @@ class ParagraphConverter
|
||||||
when PostResponse::ParagraphType::IMG
|
when PostResponse::ParagraphType::IMG
|
||||||
paragraph = paragraphs.shift
|
paragraph = paragraphs.shift
|
||||||
node = convert_img(paragraph)
|
node = convert_img(paragraph)
|
||||||
|
when PostResponse::ParagraphType::MIXTAPE_EMBED
|
||||||
|
paragraph = paragraphs.shift
|
||||||
|
children = MarkupConverter.convert(paragraph.text, paragraph.markups)
|
||||||
|
node = MixtapeEmbed.new(children: children)
|
||||||
when PostResponse::ParagraphType::OLI
|
when PostResponse::ParagraphType::OLI
|
||||||
list_items = convert_oli(paragraphs)
|
list_items = convert_oli(paragraphs)
|
||||||
node = OrderedList.new(children: list_items)
|
node = OrderedList.new(children: list_items)
|
||||||
|
|
|
@ -79,6 +79,12 @@ class PageContent < BaseComponent
|
||||||
li { render_children(node.children) }
|
li { render_children(node.children) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render_child(node : MixtapeEmbed)
|
||||||
|
div class: "embedded" do
|
||||||
|
render_children(node.children)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def render_child(node : OrderedList)
|
def render_child(node : OrderedList)
|
||||||
ol { render_children(node.children) }
|
ol { render_children(node.children) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,6 +48,9 @@ module Nodes
|
||||||
class ListItem < Container
|
class ListItem < Container
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class MixtapeEmbed < Container
|
||||||
|
end
|
||||||
|
|
||||||
class OrderedList < Container
|
class OrderedList < Container
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ class PostResponse
|
||||||
H4
|
H4
|
||||||
IFRAME
|
IFRAME
|
||||||
IMG
|
IMG
|
||||||
|
MIXTAPE_EMBED
|
||||||
OLI
|
OLI
|
||||||
P
|
P
|
||||||
PQ
|
PQ
|
||||||
|
|
Loading…
Reference in a new issue