annotate app/helpers/application_helper.rb @ 174:d35dbc09bd83

Less double escaping for actual content Ends up rather confusing.
author nanaya <me@nanaya.pro>
date Thu, 09 Aug 2018 19:31:22 +0900
parents df4be896ab8b
children 52252ae4b580
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
150
950849c40d42 Update all the things, including rails 5.2
nanaya <me@nanaya.pro>
parents: 103
diff changeset
2 include Twitter::TwitterText::Autolink
80
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
3
94
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents: 82
diff changeset
4 def atom_id(id)
170
05ce14af003a port can't be part of the id
nanaya <me@nanaya.pro>
parents: 150
diff changeset
5 "tag:#{request.host},2005:#{id}"
94
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents: 82
diff changeset
6 end
98
c5c095f6981e Expand the urls
nanaya <me@myconan.net>
parents: 94
diff changeset
7
103
1251b3d6ec5d Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents: 98
diff changeset
8 def expand_url(text, *urls)
1251b3d6ec5d Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents: 98
diff changeset
9 urls.flatten!
1251b3d6ec5d Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents: 98
diff changeset
10
1251b3d6ec5d Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents: 98
diff changeset
11 urls = urls.reduce({}) do |result, u|
1251b3d6ec5d Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents: 98
diff changeset
12 if u.try(:[], :url)
1251b3d6ec5d Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents: 98
diff changeset
13 result[u[:url]] = u[:expanded_url]
1251b3d6ec5d Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents: 98
diff changeset
14 end
1251b3d6ec5d Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents: 98
diff changeset
15
1251b3d6ec5d Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents: 98
diff changeset
16 result
1251b3d6ec5d Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents: 98
diff changeset
17 end
1251b3d6ec5d Use included url data instead of expanding using embiggen
nanaya <me@myconan.net>
parents: 98
diff changeset
18
98
c5c095f6981e Expand the urls
nanaya <me@myconan.net>
parents: 94
diff changeset
19 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
20 urls[url] || url
98
c5c095f6981e Expand the urls
nanaya <me@myconan.net>
parents: 94
diff changeset
21 end
c5c095f6981e Expand the urls
nanaya <me@myconan.net>
parents: 94
diff changeset
22 end
0
a1c9fadc0904 Initial.
edogawaconan <me@myconan.net>
parents:
diff changeset
23 end