annotate app/helpers/application_helper.rb @ 257:c6a50441a58d

It's now X
author nanaya <me@nanaya.net>
date Sun, 15 Dec 2024 22:48:25 +0900
parents 3ac13a9e593d
children e2150dce4e90
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)
175
52252ae4b580 Static tag because it's supposed to be the same across rsstweet installs
nanaya <me@nanaya.pro>
parents: 172
diff changeset
5 "tag:rsstweet@nanaya.pro,2014:#{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
234
7a773720d81f Totally legit client
nanaya <me@nanaya.net>
parents: 229
diff changeset
8 def expand_url(text, urls)
98
c5c095f6981e Expand the urls
nanaya <me@myconan.net>
parents: 94
diff changeset
9 text.gsub /https?:\/\/t\.co\/[A-Za-z0-9]+/ do |url|
242
3ac13a9e593d Fix wrong expanded media url
nanaya <me@nanaya.net>
parents: 234
diff changeset
10 expanded = urls[url]
3ac13a9e593d Fix wrong expanded media url
nanaya <me@nanaya.net>
parents: 234
diff changeset
11
3ac13a9e593d Fix wrong expanded media url
nanaya <me@nanaya.net>
parents: 234
diff changeset
12 case expanded
3ac13a9e593d Fix wrong expanded media url
nanaya <me@nanaya.net>
parents: 234
diff changeset
13 when nil then url
3ac13a9e593d Fix wrong expanded media url
nanaya <me@nanaya.net>
parents: 234
diff changeset
14 when Hash then expanded[:url]
3ac13a9e593d Fix wrong expanded media url
nanaya <me@nanaya.net>
parents: 234
diff changeset
15 else expanded
3ac13a9e593d Fix wrong expanded media url
nanaya <me@nanaya.net>
parents: 234
diff changeset
16 end
98
c5c095f6981e Expand the urls
nanaya <me@myconan.net>
parents: 94
diff changeset
17 end
c5c095f6981e Expand the urls
nanaya <me@myconan.net>
parents: 94
diff changeset
18 end
204
70e90ea4b870 Fix uri for nil user
nanaya <me@nanaya.pro>
parents: 175
diff changeset
19
70e90ea4b870 Fix uri for nil user
nanaya <me@nanaya.pro>
parents: 175
diff changeset
20 def status_url(tweet)
234
7a773720d81f Totally legit client
nanaya <me@nanaya.net>
parents: 229
diff changeset
21 status_url_base tweet[:user][:username], tweet[:id]
229
12287b32fbda Show link to parent tweet for replies
nanaya <me@nanaya.pro>
parents: 204
diff changeset
22 end
12287b32fbda Show link to parent tweet for replies
nanaya <me@nanaya.pro>
parents: 204
diff changeset
23
234
7a773720d81f Totally legit client
nanaya <me@nanaya.net>
parents: 229
diff changeset
24 def status_url_base(username, id)
257
c6a50441a58d It's now X
nanaya <me@nanaya.net>
parents: 242
diff changeset
25 "https://x.com/#{username.presence || '_'}/status/#{id}"
204
70e90ea4b870 Fix uri for nil user
nanaya <me@nanaya.pro>
parents: 175
diff changeset
26 end
0
a1c9fadc0904 Initial.
edogawaconan <me@myconan.net>
parents:
diff changeset
27 end