mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:01:14 +08:00
DEV: Add option to keep onebox body content in post excerpt.
This commit is contained in:
@ -34,4 +34,51 @@ describe ExcerptParser do
|
||||
expect(ExcerptParser.get_excerpt(html, 3, {})).to match_html('<details class="disabled"><summary>foo</summary></details>')
|
||||
expect(ExcerptParser.get_excerpt(html, 2, {})).to match_html('<details class="disabled"><summary>fo…</summary></details>')
|
||||
end
|
||||
|
||||
describe "keep_onebox_body parameter" do
|
||||
it "keeps the body content for external oneboxes" do
|
||||
html = <<~HTML.strip
|
||||
<aside class="onebox">
|
||||
<header class="source">
|
||||
<img src="https://github.githubassets.com/favicon.ico" class="site-icon" width="32" height="32">
|
||||
<a href="https://github.com/discourse/discourse" target="_blank">GitHub</a>
|
||||
</header>
|
||||
<article class="onebox-body">
|
||||
<img src="/uploads/default/original/1X/10c0f1565ee5b6ca3fe43f3183529bc0afd26003.jpeg" class="thumbnail">
|
||||
<h3>
|
||||
<a href="https://github.com/discourse/discourse" target="_blank">discourse/discourse</a>
|
||||
</h3>
|
||||
<p>A platform for community discussion. Free, open, simple. - discourse/discourse</p>
|
||||
</article>
|
||||
</aside>
|
||||
HTML
|
||||
expect(ExcerptParser.get_excerpt(html, 100, keep_onebox_body: true)).to eq(<<~HTML.strip)
|
||||
[image]
|
||||
|
||||
<a href="https://github.com/discourse/discourse" target="_blank">discourse/discourse</a>
|
||||
|
||||
A platform for community discussion. Free, o…
|
||||
HTML
|
||||
end
|
||||
|
||||
it "keeps the content for internal oneboxes" do
|
||||
html = <<~HTML.strip
|
||||
<aside class="quote" data-post="1" data-topic="8">
|
||||
<div class="title">
|
||||
<div class="quote-controls"></div>
|
||||
<img width="20" height="20" src="/user_avatar/localhost/system/40/2_2.png" class="avatar">
|
||||
<a href="/t/welcome-to-discourse/8/1">Welcome to Discourse</a>
|
||||
</div>
|
||||
<blockquote>The first paragraph of this pinned topic will be visible as a welcome message to all new visitors on your homepage.</blockquote>
|
||||
</aside>
|
||||
HTML
|
||||
expect(ExcerptParser.get_excerpt(html, 100, keep_onebox_body: true)).to eq(<<~HTML.strip)
|
||||
[image]
|
||||
|
||||
<a href="/t/welcome-to-discourse/8/1">Welcome to Discourse</a>
|
||||
|
||||
The first paragraph of this pinned topic will be …
|
||||
HTML
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user