annotate app/helpers/application_helper.rb @ 119:18f1c5f989bb

Forgot the footer margin
author nanaya <me@myconan.net>
date Sun, 12 Feb 2017 17:27:17 +0900
parents 1251b3d6ec5d
children 950849c40d42
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a1c9fadc0904 Initial.
edogawaconan <me@myconan.net>
parents:
diff changeset
1 module ApplicationHelper
15
207917e41964 Add tweets~
edogawaconan <me@myconan.net>
parents: 0
diff changeset
2 include Twitter::Autolink
80
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
3
82
f91e2d00f03f Reduce title length limit
nanaya <me@myconan.net>
parents: 80
diff changeset
4 def ellipsize(text, limit = 30)
80
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
5 if text.length <= limit
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
6 text
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
7 else
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
8 "#{text.first(limit)}..."
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
9 end
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
10 end
94
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents: 82
diff changeset
11
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents: 82
diff changeset
12 def atom_id(id)
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents: 82
diff changeset
13 "tag:#{request.host_with_port},2005:#{id}"
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents: 82
diff changeset
14 end
98
c5c095f6981e Expand the urls
nanaya <me@myconan.net>
parents: 94
diff changeset
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
c5c095f6981e Expand the urls
nanaya <me@myconan.net>
parents: 94
diff changeset
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
c5c095f6981e Expand the urls
nanaya <me@myconan.net>
parents: 94
diff changeset
30 end
c5c095f6981e Expand the urls
nanaya <me@myconan.net>
parents: 94
diff changeset
31 end
0
a1c9fadc0904 Initial.
edogawaconan <me@myconan.net>
parents:
diff changeset
32 end