docbrown/app/views/users/_comments_section.html.erb
rhymes 4e591fea1c Show localized date/time on hover for articles/comments (#2722)
* Add article decorator published_timestamp

* Use time HTML5 element and refactor date in partial

* Add published_timestamp to Article

Adding `published_timestamp` to the homepage we can then use JS to render the full timestamp localized for the user.

We've also added the timestamp to the index and the API

* Display article published timestamp on hover

* Use time also in the article show page

* Add timestamp to bottom articles as well

* Remove published_timestamp from index because it is not used

* Fix broken specs

* Add more article dates specs

* Refactor date initializers
2019-05-09 11:05:17 -04:00

47 lines
1.9 KiB
Text

<% cache("user-profile-comments-#{@user.last_comment_at}-#{@user.id}-#{@comments.size}", expires_in: 2.days) do %>
<style>
.index-comments header {
color: <%= HexComparer.new([user_colors(@user)[:bg], user_colors(@user)[:text]]).brightness(0.88) %>;
}
.night-theme .index-comments header {
color: #cedae2;
}
</style>
<div class="index-comments">
<% if @comments.any? %>
<% if params[:view] == "comments" %>
<div class="breadcrumb"><a href="<%= @user.path %>">View All Activity</a></div>
<header>
<% if @user.comments_count > 250 %>
<h4>Last 250 Comments</h4>
<% else %>
<h4>All <%= @user.comments_count %> Comments</h4>
<% end %>
</header>
<% else %>
<header>
<h4>Recent Comments</h4>
</header>
<% end %>
<% end %>
<% @comments.each do |comment| %>
<% if comment.commentable.present? && comment.commentable.published && !comment.deleted %>
<a href="<%= comment.path %>">
<div class="single-comment <%= "strong-comment" if comment.ancestry.nil? %>">
<span class="comment-title">re: <%= comment.commentable.title %></span>
<span class="comment-date">
<time datetime="<%= comment.decorate.published_timestamp %>"><%= comment.readable_publish_date %></time>
</span>
<div class="comment-preview"><%= truncate(strip_tags(comment.processed_html), length: 64).html_safe %></div>
</div>
</a>
<% end %>
<% end %>
<% if params[:view] != "comments" && @user.comments_count > 250 %>
<div class="breadcrumb"><a href="<%= @user.path %>/comments">Last 250 Comments</a></div>
<% elsif params[:view] != "comments" && @user.comments_count > 8 %>
<div class="breadcrumb"><a href="<%= @user.path %>/comments">View All <%= @user.comments_count %> Comments</a>
</div>
<% end %>
</div>
<% end %>