diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 6aee47d3a..27edc5037 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -50,10 +50,10 @@ module ApplicationHelper
end
end
- def time_tag(content, time)
+ def time_tag(content, time, **options)
datetime = time.strftime("%Y-%m-%dT%H:%M%:z")
- content_tag(:time, content || datetime, :datetime => datetime, :title => time.to_formatted_s)
+ tag.time content || datetime, datetime: datetime, title: time.to_formatted_s, **options
end
def humanized_duration(from, to)
@@ -71,11 +71,24 @@ module ApplicationHelper
def time_ago_in_words_tagged(time, compact: false)
if time.past?
- text = time_ago_in_words(time) + " ago"
- text = text.gsub(/almost|about|over/, "").strip if compact
- raw time_tag(text, time)
+ if compact
+ text = time_ago_in_words(time)
+ text = text.gsub(/almost|about|over/, "").strip
+ text = text.gsub(/less than a/, "<1")
+ text = text.gsub(/ minutes?/, "m")
+ text = text.gsub(/ hours?/, "h")
+ text = text.gsub(/ days?/, "d")
+ text = text.gsub(/ months?/, "mo")
+ text = text.gsub(/ years?/, "y")
+ klass = "compact-timestamp"
+ else
+ text = time_ago_in_words(time) + " ago"
+ klass = ""
+ end
+
+ time_tag(text, time, class: klass)
else
- raw time_tag("in " + distance_of_time_in_words(Time.now, time), time)
+ time_tag("in " + distance_of_time_in_words(Time.now, time), time)
end
end
diff --git a/app/views/posts/show.html+tooltip.erb b/app/views/posts/show.html+tooltip.erb
index 402f53d31..520662ad5 100644
--- a/app/views/posts/show.html+tooltip.erb
+++ b/app/views/posts/show.html+tooltip.erb
@@ -4,11 +4,9 @@
<%= link_to_user @post.uploader %>
<% end %>
- <%= link_to time_ago_in_words_tagged(@post.created_at, compact: true), posts_path(tags: "date:#{@post.created_at.strftime("%Y-%m-%d")}"), class: "post-tooltip-date post-tooltip-info" %>
-
<%= @post.fav_count %>
-
+
@@ -22,6 +20,10 @@
<% end %>
+
+ <%= link_to posts_path(tags: "date:#{@post.created_at.strftime("%Y-%m-%d")}"), class: "post-tooltip-date post-tooltip-info" do %>
+ <%= time_ago_in_words_tagged(@post.created_at, compact: true) %> ago
+ <% end %>