view app/views/tweets/_tweet.html.erb @ 236:498043313523 legit-client

Support multiple headers
author nanaya <me@nanaya.net>
date Sat, 15 Jul 2023 01:40:31 +0900
parents 7a773720d81f
children 961d362e42c7
line wrap: on
line source

<% if tweet[:retweet].present? %>
  <p>
    <%= link_to status_url(tweet[:retweet]) do %>
      <em>Retweeted:</em>
    <% end %>
  </p>

  <%= render "tweet", :tweet => tweet[:retweet], :with_time => true %>
<% else %>
  <% if defined?(with_time) && with_time %>
    <p>
      <small>Originally tweeted 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| %>
      <% if media[:type] == 'photo' %>
        <%= link_to "#{media[:url]}?name=orig" do %>
          <%= image_tag "#{media[:url]}?name=small", :alt => "attachment #{media[:id]}" -%>
        <% end %>
      <% elsif media[:type] == '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 %>