make time_ago_in_words_label actually do what was intended

This commit is contained in:
joshua stein 2015-01-06 14:08:15 -06:00
parent 6eca23a481
commit 5efe3ce6c3
6 changed files with 20 additions and 14 deletions

View file

@ -12,8 +12,14 @@ module ApplicationHelper
raw(html)
end
def time_ago_in_words_label(*args)
label_tag(nil, time_ago_in_words(*args),
:title => args.first.strftime("%F %T %z"))
def time_ago_in_words_label(time, options = {})
strip_about = options.delete(:strip_about)
ago = time_ago_in_words(time, options)
if strip_about
ago.gsub!(/^about /, "")
end
raw(label_tag(nil, ago, :title => time.strftime("%F %T %z")))
end
end

View file

@ -51,8 +51,8 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
<% elsif comment.is_from_email? %>
e-mailed
<% end %>
<%= raw(time_ago_in_words_label(comment.has_been_edited? ?
comment.updated_at : comment.created_at).gsub(/^about /, "")) %> ago
<%= time_ago_in_words_label((comment.has_been_edited? ?
comment.updated_at : comment.created_at), :strip_about => true) %> ago
<% end %>
<% if !comment.previewing %>

View file

@ -42,7 +42,7 @@
<a href="/u/<%= message.recipient.username %>"><%=
message.recipient.username %></a>
<% end %></td>
<td><%= raw(time_ago_in_words_label(message.created_at)) %> ago</td>
<td><%= time_ago_in_words_label(message.created_at) %> ago</td>
<td><a href="/messages/<%= message.short_id %>"><%= message.subject
%></a></td>
</tr>

View file

@ -21,7 +21,7 @@
to
<a href="/u/<%= @message.recipient.username %>"><%=
@message.recipient.username %></a>
<%= raw(time_ago_in_words_label(@message.created_at)) %> ago
<%= time_ago_in_words_label(@message.created_at) %> ago
</div>
</div>

View file

@ -54,8 +54,8 @@ class="story <%= story.vote == 1 ? "upvoted" : "" %> <%= story.vote == -1 ?
class="new_user"
<% end %>><%= ms.user.username %></a>
<%= raw(time_ago_in_words_label(ms.created_at).gsub(/^about /, ""))
%> ago
<%= time_ago_in_words_label(ms.created_at, :strip_about => true) %>
ago
</span>
<% end %>
<% end %>
@ -70,8 +70,8 @@ class="story <%= story.vote == 1 ? "upvoted" : "" %> <%= story.vote == -1 ?
class="new_user"
<% end %>><%= story.user.username %></a>
<%= raw(time_ago_in_words_label(story.created_at).gsub(/^about /, ""))
%> ago
<%= time_ago_in_words_label(story.created_at, :strip_about => true) %>
ago
<% if story.is_editable_by_user?(@user) %>
|

View file

@ -38,7 +38,7 @@
<label class="required">Joined:</label>
<span class="d">
<%= raw(time_ago_in_words_label(@showing_user.created_at)) %> ago
<%= time_ago_in_words_label(@showing_user.created_at) %> ago
<% if @showing_user.invited_by_user %>
by invitation from
<%= link_to @showing_user.invited_by_user.try(:username),
@ -50,7 +50,7 @@
<% if @showing_user.is_banned? %>
<label class="required">Banned:</label>
<span class="d">
<%= raw(time_ago_in_words_label(@showing_user.banned_at)) %> ago
<%= time_ago_in_words_label(@showing_user.banned_at) %> ago
<% if @showing_user.banned_by_user %>
by <%= link_to @showing_user.banned_by_user.try(:username),
@showing_user.banned_by_user %>:
@ -73,7 +73,7 @@
<% if @showing_user.deleted_at? %>
<label class="required">Left:</label>
<span class="d">
<%= raw(time_ago_in_words_label(@showing_user.deleted_at)) %> ago
<%= time_ago_in_words_label(@showing_user.deleted_at) %> ago
</span>
<br>
<% end %>