Mercurial > rsstweet
annotate app/helpers/application_helper.rb @ 100:c1d5d8be92c6
Add support for extended tweets
| author | nanaya <me@myconan.net> | 
|---|---|
| date | Fri, 23 Sep 2016 23:02:16 +0900 | 
| parents | c5c095f6981e | 
| children | 1251b3d6ec5d | 
| rev | line source | 
|---|---|
| 0 | 1 module ApplicationHelper | 
| 15 | 2 include Twitter::Autolink | 
| 80 | 3 | 
| 82 | 4 def ellipsize(text, limit = 30) | 
| 80 | 5 if text.length <= limit | 
| 6 text | |
| 7 else | |
| 8 "#{text.first(limit)}..." | |
| 9 end | |
| 10 end | |
| 94 | 11 | 
| 12 def atom_id(id) | |
| 13 "tag:#{request.host_with_port},2005:#{id}" | |
| 14 end | |
| 98 | 15 | 
| 16 def expand_url(text) | |
| 17 text.gsub /https?:\/\/t\.co\/[A-Za-z0-9]+/ do |url| | |
| 18 Rails.cache.fetch url, :expires_in => 1.hour do | |
| 19 " #{Embiggen::URI(url).expand} " | |
| 20 end | |
| 21 end | |
| 22 end | |
| 0 | 23 end | 
