From 7abdd61354fe05700c20b2599165cdaaa6dd34ee Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 25 Apr 2013 18:00:02 +1000 Subject: [PATCH] truncate gist titles at 120 --- lib/oneboxer/gist_onebox.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/oneboxer/gist_onebox.rb b/lib/oneboxer/gist_onebox.rb index 35ca2e1f6..42ffe052d 100644 --- a/lib/oneboxer/gist_onebox.rb +++ b/lib/oneboxer/gist_onebox.rb @@ -13,7 +13,12 @@ module Oneboxer def parse(data) parsed = JSON.parse(data) - result = {files: [], title: parsed['description']} + desc = parsed['description'] + if desc.length > 120 + desc = desc[0..120] + desc << "..." + end + result = {files: [], title: desc} parsed['files'].each do |filename, attrs| result[:files] << {filename: filename}.merge!(attrs) end