Mercurial > rsstweet
annotate app/helpers/application_helper.rb @ 171:90db232f39e7
Remove unused variable
author | nanaya <me@nanaya.pro> |
---|---|
date | Wed, 08 Aug 2018 20:19:51 +0900 |
parents | 05ce14af003a |
children | df4be896ab8b |
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) | |
170 | 13 "tag:#{request.host},2005:#{id}" |
94 | 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 end |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
23 |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
24 result |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
25 end |
1251b3d6ec5d
Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents:
98
diff
changeset
|
26 |
98 | 27 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
|
28 urls[url] || url |
98 | 29 end |
30 end | |
0 | 31 end |