view app/views/tweets/_tweet.html.erb @ 254:89f6c0016bab default tip

Update to latest rails
author nanaya <me@nanaya.net>
date Tue, 03 Sep 2024 19:21:25 +0900
parents d726e8b92dd1
children
line wrap: on
line source

<% if tweet[:retweet].present? %>
  <p><em>Retweeted:</em></p>

  <%= render "tweet", :tweet => tweet[:retweet], :with_time => true %>
<% else %>
  <% if defined?(with_time) && with_time %>
    <p>
      <small>
        Originally <%= link_to 'tweeted', status_url(tweet) %> at <%= tweet[:created_at].rfc822 %>
      </small>
    </p>
  <% end %>

  <% if tweet[:reply_to_id].present? %>
    <p>
      <small>
        Replying to
        <%= link_to 'tweet', status_url_base(tweet[:reply_to_username], tweet[:reply_to_id]) %>
        by <%= link_to "@#{tweet[:reply_to_username]}", "https://twitter.com/#{tweet[:reply_to_username]}" %>
      </small>
    </p>
  <% end %>

  <p>
    <%= auto_link(expand_url(
          tweet[:message],
          { **tweet[:entity_urls], **tweet[:entity_media] }
        ))
        .gsub("\n", "<br />")
        .html_safe
      %>
  </p>

  <p>
    <%= link_to "https://twitter.com/#{tweet[:user][:username]}" do %>
      <%= image_tag tweet[:user][:avatar_url].to_s, :alt => "profile image for #{tweet[:user][:name].printable}" %>
      <%= tweet[:user][:name].printable -%>
    <% end %>
  </p>

  <p>
    <% tweet[:entity_media].each do |_short_url, media| %>
      <% case media[:type] %>
        <% when 'photo' %>
          <%= link_to "#{media[:image_url]}&name=orig" do %>
            <%= image_tag "#{media[:image_url]}&name=small", :alt => "attachment #{media[:id]}" -%>
          <% end %>
        <% when 'animated_gif', 'video' %>
          <%= video_tag media[:variants]
            .sort_by { |variant| -variant[:bitrate] }
            .map { |variant| variant[:url] }, width: '100%', controls: true
          %>
      <% end %>
    <% end %>
  </p>

  <% if tweet[:quote_id].present? %>
    <blockquote>
      <% if tweet[:quote].present? %>
        <%= render "tweet", :tweet => tweet[:quote], :with_time => true %>
      <% else %>
        <%= link_to status_url_base(nil, tweet[:quote_id]) do %>
          <em>Preview not available, view tweet directly.</em>
        <% end %>
      <% end %>
    </blockquote>
  <% end %>
<% end %>