Mercurial > rsstweet
annotate app/helpers/application_helper.rb @ 153:cd76c83d6d24
Update rails to 5.2.0 and other gems to their latest version
author | nanaya <me@nanaya.pro> |
---|---|
date | Sat, 14 Apr 2018 04:06:04 +0900 |
parents | 950849c40d42 |
children | 05ce14af003a |
rev | line source |
---|---|
0 | 1 module ApplicationHelper |
150
950849c40d42
Update all the things, including rails 5.2
nanaya <me@nanaya.pro>
parents:
103
diff
changeset
|
2 include Twitter::TwitterText::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 |
103
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
16 def expand_url(text, *urls) |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
17 urls.flatten! |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
18 |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
19 urls = urls.reduce({}) do |result, u| |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
20 if u.try(:[], :url) |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
21 result[u[:url]] = u[:expanded_url] |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
22 @any = 1 |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
23 end |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
24 |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
25 result |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
26 end |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
27 |
98 | 28 text.gsub /https?:\/\/t\.co\/[A-Za-z0-9]+/ do |url| |
103
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
29 urls[url] || url |
98 | 30 end |
31 end | |
0 | 32 end |