mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 13:43:36 +08:00
truncate gist titles at 120
This commit is contained in:
parent
134af233ad
commit
7abdd61354
|
@ -13,7 +13,12 @@ module Oneboxer
|
||||||
|
|
||||||
def parse(data)
|
def parse(data)
|
||||||
parsed = JSON.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|
|
parsed['files'].each do |filename, attrs|
|
||||||
result[:files] << {filename: filename}.merge!(attrs)
|
result[:files] << {filename: filename}.merge!(attrs)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user