lib/onebox/engine/github_issue_onebox.rb in onebox-1.9.15 vs lib/onebox/engine/github_issue_onebox.rb in onebox-1.9.16
- old
+ new
@@ -29,18 +29,25 @@
content_words = body_text.gsub("\n\n", "\n").gsub("\n", "<br>").split(" ") #one pass of removing double newline, then we change \n to <br> and later on we revert it back to \n this is a workaround to avoid losing newlines after we join it back.
max_words = 20
short_content = content_words[0..max_words].join(" ")
short_content += "..." if content_words.length > max_words
+ created_at = Time.parse(@raw['created_at'])
+ closed_at = Time.parse(@raw['closed_at']) if @raw['closed_at']
+
ulink = URI(link)
{
link: @url,
title: @raw["title"],
content: short_content.gsub("<br>", "\n"),
labels: @raw["labels"],
user: @raw['user'],
- created_at: @raw['created_at'].split("T")[0], #get only date for now
- closed_at: (@raw['closed_at'].nil? ? "" : @raw['closed_at'].split("T")[0]),
+ created_at: created_at.strftime("%I:%M%p - %d %b %y %Z"),
+ created_at_date: created_at.strftime("%F"),
+ created_at_time: created_at.strftime("%T"),
+ closed_at: closed_at&.strftime("%I:%M%p - %d %b %y %Z"),
+ closed_at_date: closed_at&.strftime("%F"),
+ closed_at_time: closed_at&.strftime("%T"),
closed_by: @raw['closed_by'],
avatar: "https://avatars1.githubusercontent.com/u/#{@raw['user']['id']}?v=2&s=96",
domain: "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}",
}
end