UX: displays the body of a PR in a details/summary tag (#466)

UX: displays the body of a PR in a details/summary tag (#466)

diff --git a/lib/onebox/engine/github_pullrequest_onebox.rb b/lib/onebox/engine/github_pullrequest_onebox.rb
index 982c4a1..2c32d14 100644
--- a/lib/onebox/engine/github_pullrequest_onebox.rb
+++ b/lib/onebox/engine/github_pullrequest_onebox.rb
@@ -20,6 +20,7 @@ module Onebox
         @match ||= @url.match(%r{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/pull/(?<number>[^/]+)})
       end
 
+      GITHUB_COMMENT_REGEX = /(<!--.*?-->\r\n)/
       def data
         result = raw.clone
         result['link'] = link
@@ -31,6 +32,10 @@ module Onebox
 
         ulink = URI(link)
         result['domain'] = "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}"
+
+        body = (result['body'] || '').gsub(GITHUB_COMMENT_REGEX, '')
+        result['body'] = body.length > 0 ? body : nil
+
         result
       end
     end
diff --git a/lib/onebox/sanitize_config.rb b/lib/onebox/sanitize_config.rb
index 0ba2995..59cb48e 100644
--- a/lib/onebox/sanitize_config.rb
+++ b/lib/onebox/sanitize_config.rb
@@ -6,7 +6,7 @@ class Sanitize
     HTTP_PROTOCOLS ||= ['http', 'https', :relative].freeze
 
     ONEBOX ||= freeze_config merge(RELAXED,
-      elements: RELAXED[:elements] + %w[audio embed iframe source video svg path],
+      elements: RELAXED[:elements] + %w[audio details embed iframe source video svg path],
 
       attributes: {
         'a' => RELAXED[:attributes]['a'] + %w(target),
diff --git a/spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb b/spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb
index 2ff7fc8..6a969ce 100644
--- a/spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb
+++ b/spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb
@@ -44,5 +44,9 @@ describe Onebox::Engine::GithubPullRequestOnebox do
     it "includes number of deletions" do
       expect(html).to include("1")
     end
+
+    it "includes the body" do
+      expect(html).to include("http://meta.discourse.org/t/audio-html5-tag/8168")
+    end
   end
 end
diff --git a/templates/githubpullrequest.mustache b/templates/githubpullrequest.mustache
index 66a4805..8b95b6e 100644
--- a/templates/githubpullrequest.mustache
+++ b/templates/githubpullrequest.mustache
@@ -4,9 +4,22 @@
   </div>
 
   <div class="github-info-container">
-    <h4>
-      <a href="{{html_url}}" target="_blank" rel="noopener">{{title}}</a>
-    </h4>
+    {{^body}}
+      <h4>
+        <a href="{{html_url}}" target="_blank" rel="noopener">{{title}}</a>
+      </h4>
+    {{/body}}
+
+    {{#body}}
+      <details class="onebox-details">
+        <summary class="onebox-details-summary">
+          <h4>
+            <a href="{{html_url}}" target="_blank" rel="noopener">{{title}}</a>
+          </h4>
+        </summary>
+        <p class="onebox-details-body">{{body}}</p>
+      </details>
+    {{/body}}
 
     <div class="branches">
       <code>{{base.label}}</code> ← <code>{{head.label}}</code>

GitHub sha: 0008f7a4

This commit appears in #466 which was approved by davidtaylorhq. It was merged by jjaffeux.