changeset 229:12287b32fbda

Show link to parent tweet for replies
author nanaya <me@nanaya.pro>
date Wed, 13 Apr 2022 01:49:51 +0900
parents 2a4ed5b73c73
children e6c29d47192b
files app/helpers/application_helper.rb app/views/tweets/_tweet.html.erb
diffstat 2 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/app/helpers/application_helper.rb	Wed Apr 13 01:41:50 2022 +0900
+++ b/app/helpers/application_helper.rb	Wed Apr 13 01:49:51 2022 +0900
@@ -22,6 +22,10 @@
   end
 
   def status_url(tweet)
-    "https://twitter.com/#{tweet.user.screen_name.presence || '_'}/status/#{tweet.id}"
+    status_url_base tweet.user.screen_name, tweet.id
+  end
+
+  def status_url_base(screen_name, tweet_id)
+    "https://twitter.com/#{screen_name.presence || '_'}/status/#{tweet_id}"
   end
 end
--- a/app/views/tweets/_tweet.html.erb	Wed Apr 13 01:41:50 2022 +0900
+++ b/app/views/tweets/_tweet.html.erb	Wed Apr 13 01:49:51 2022 +0900
@@ -13,6 +13,16 @@
     </p>
   <% end %>
 
+  <% if tweet.in_reply_to_status_id.present? %>
+    <p>
+      <small>
+        Replying to
+        <%= link_to 'tweet', status_url_base(tweet.in_reply_to_screen_name, tweet.in_reply_to_status_id) %>
+        by <%= link_to tweet.in_reply_to_screen_name, "https://twitter.com/#{tweet.in_reply_to_screen_name}" %>
+      </small>
+    </p>
+  <% end %>
+
   <p>
     <%# FIXME: Twitter gem doesn't support extended mode when writing this %>
     <%= auto_link(expand_url(