Improve date displaying on embedded comments
This commit is contained in:
parent
e5cb1cac86
commit
3fbb2cd728
|
@ -0,0 +1,18 @@
|
|||
module EmbedHelper
|
||||
|
||||
def embed_post_date(dt)
|
||||
current = Time.now
|
||||
|
||||
if dt >= 1.day.ago
|
||||
distance_of_time_in_words(dt, current)
|
||||
else
|
||||
if dt.year == current.year
|
||||
dt.strftime("%e %b")
|
||||
else
|
||||
dt.strftime("%e %b %Y")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
<%- if @topic_view.posts.present? %>
|
||||
<%- @topic_view.posts.each do |post| %>
|
||||
<article class='post<%- if post.trashed? %> deleted<% end %>' id='post-<%= post.id.to_s %>'>
|
||||
<%= link_to post.created_at.strftime("%e %b %Y"), post.url, class: 'post-date', target: "_blank" %>
|
||||
<%= link_to embed_post_date(post.created_at), post.url, class: 'post-date', target: "_blank" %>
|
||||
<%- if post.reply_to_post.present? %>
|
||||
<%= link_to I18n.t('embed.in_reply_to', username: post.reply_to_post.username), post.reply_to_post.url, 'data-link-to-post' => post.reply_to_post.id.to_s, :class => 'in-reply-to' %>
|
||||
<%- end %>
|
||||
|
|
Loading…
Reference in New Issue