lib/onebox/engine/github_commit_onebox.rb in onebox-1.9.15 vs lib/onebox/engine/github_commit_onebox.rb in onebox-1.9.16

- old
+ new

@@ -5,11 +5,11 @@ class GithubCommitOnebox include Engine include LayoutSupport include JSON - matches_regexp Regexp.new("^https?://(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:/)?(?:.)*/commits?/") + matches_regexp Regexp.new("^https?://(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:/)?(?:.)*/commit/") always_https def url "https://api.github.com/repos/#{match[:owner]}/#{match[:repository]}/commits/#{match[:sha]}" end @@ -17,13 +17,13 @@ private def match return @match if @match - @match = @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/commits?/(?<sha>[^/]+)}) + @match = @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/commit/(?<sha>[^/]+)}) - @match = @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/pull/(?<pr>[^/]+)/commits?/(?<sha>[^/]+)}) if @match.nil? + @match = @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/pull/(?<pr>[^/]+)/commit/(?<sha>[^/]+)}) if @match.nil? @match end def data @@ -40,10 +40,13 @@ result['message'] += "..." if message_words.length > max_words result['message'] = result['message'].gsub("<br>", "\n") end ulink = URI(link) - result['commit_date'] = Time.parse(result['commit']['author']['date']).strftime("%I:%M%p - %d %b %y %Z") + 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['domain'] = "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}" result end end end