UX: makes github body full width (#472)

UX: makes github body full width (#472)

Note that this commit also applies new github’s body to commits.

diff --git a/lib/onebox/engine/github_commit_onebox.rb b/lib/onebox/engine/github_commit_onebox.rb
index 6da72a6..3bd06b2 100644
--- a/lib/onebox/engine/github_commit_onebox.rb
+++ b/lib/onebox/engine/github_commit_onebox.rb
@@ -1,11 +1,14 @@
 # frozen_string_literal: true
 
+require_relative '../mixins/github_body'
+
 module Onebox
   module Engine
     class GithubCommitOnebox
       include Engine
       include LayoutSupport
       include JSON
+      include Onebox::Mixins::GithubBody
 
       matches_regexp Regexp.new("^https?://(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:/)?(?:.)*/commit/")
       always_https
@@ -27,25 +30,20 @@ module Onebox
 
       def data
         result = raw.clone
-        result['link'] = link
-        result['title'] = result['commit']['message'].split("\n").first
 
-        if result['commit']['message'].lines.count > 1
-          message = result['commit']['message'].split("\n", 2).last.strip
+        lines = result['commit']['message'].split("\n")
+        result['title'] = lines.first
+        result['body'], result['excerpt'] = compute_body(lines[1..lines.length].join("\n"))
 
-          message_words = message.gsub("\n\n", "\n").gsub("\n", "<br>").split(" ")
-          max_words = 20
-          result['message'] =  message_words[0..max_words].join(" ")
-          result['message'] += "..." if message_words.length > max_words
-          result['message'] = result['message'].gsub("<br>", "\n")
-        end
-
-        ulink = URI(link)
         committed_at = Time.parse(result['commit']['author']['date'])
         result['committed_at'] = committed_at.strftime("%I:%M%p - %d %b %y %Z")
         result['committed_at_date'] = committed_at.strftime("%F")
         result['committed_at_time'] = committed_at.strftime("%T")
+
+        result['link'] = link
+        ulink = URI(link)
         result['domain'] = "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}"
+
         result
       end
     end
diff --git a/lib/onebox/version.rb b/lib/onebox/version.rb
index c9125a6..0347545 100644
--- a/lib/onebox/version.rb
+++ b/lib/onebox/version.rb
@@ -1,5 +1,5 @@
 # frozen_string_literal: true
 
 module Onebox
-  VERSION = "2.2.13"
+  VERSION = "2.2.14"
 end
diff --git a/templates/github/github_body.mustache b/templates/github/github_body.mustache
index 24c1ba6..dae9ba1 100644
--- a/templates/github/github_body.mustache
+++ b/templates/github/github_body.mustache
@@ -1,3 +1,5 @@
 {{#body}}
-  <p class="github-body-container">{{body}}{{#excerpt}}<span class="show-more-container"><a href="{{html_url}}" target="_blank" rel="noopener" class="show-more">…</a>{{/excerpt}}</span>{{#excerpt}}<span class="excerpt hidden">{{excerpt}}</span>{{/excerpt}}</p>
+  <div class="github-row">
+    <p class="github-body-container">{{body}}{{#excerpt}}<span class="show-more-container"><a href="{{html_url}}" target="_blank" rel="noopener" class="show-more">…</a>{{/excerpt}}</span>{{#excerpt}}<span class="excerpt hidden">{{excerpt}}</span>{{/excerpt}}</p>
+  </div>
 {{/body}}
diff --git a/templates/githubcommit.mustache b/templates/githubcommit.mustache
index 43ded46..5b28e22 100644
--- a/templates/githubcommit.mustache
+++ b/templates/githubcommit.mustache
@@ -18,7 +18,7 @@
           <img alt="{{author.login}}" src="{{author.avatar_url}}" class="onebox-avatar-inline" width="20" height="20">
           {{author.login}}
         </a>
-        
+
       </div>
 
       <div class="lines" title="changed {{files.length}} files with {{stats.additions}} additions and {{stats.deletions}} deletions">
@@ -32,10 +32,4 @@
   </div>
 </div>
 
-
-{{#message}}
-  <div class="github-row">
-    <pre class="github-content" style="white-space: normal;">{{message}}</pre>
-  </div>
-{{/message}}
-
+{{> github/github_body}}
diff --git a/templates/githubissue.mustache b/templates/githubissue.mustache
index 091669f..7804c45 100644
--- a/templates/githubissue.mustache
+++ b/templates/githubissue.mustache
@@ -27,8 +27,6 @@
       </div>
     </div>
 
-    {{> github/github_body}}
-
     <div class='labels'>
       {{#labels}}
         <span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">{{name}}</span>
@@ -36,3 +34,5 @@
     </div>
   </div>
 </div>
+
+{{> github/github_body}}
diff --git a/templates/githubpullrequest.mustache b/templates/githubpullrequest.mustache
index a4d731f..17a0bbf 100644
--- a/templates/githubpullrequest.mustache
+++ b/templates/githubpullrequest.mustache
@@ -31,7 +31,7 @@
         </a>
       </div>
     </div>
-
-    {{> github/github_body}}
   </div>
 </div>
+
+{{> github/github_body}}

GitHub sha: efae3faf

This commit appears in #472 which was approved by ZogStriP. It was merged by jjaffeux.