view app/views/tweets/_tweet.html.erb @ 261:8c47a69cbfdb

Missing default 8.0 bin
author nanaya <me@nanaya.net>
date Sun, 15 Dec 2024 23:01:58 +0900
parents c6a50441a58d
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://x.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://x.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 %>