move date formatting from server side to javascript, so we can reuse Sugar's i18n

This commit is contained in:
Kuba Brecka 2013-03-13 13:38:41 +01:00
parent a663251bd4
commit 921a658548
3 changed files with 7 additions and 5 deletions

View File

@ -41,6 +41,11 @@ Discourse.HistoryView = Discourse.View.extend({
this.set('postLeft', null);
this.set('postRight', null);
return this.get('originalPost').loadVersions(function(result) {
result.each(function(item) {
item.description = "v" + item.number + " - " + Date.create(item.created_at).relative() + " - " +
Em.String.i18n("changed_by", { author: item.display_username });
});
_this.set('loading', false);
_this.set('versionLeft', result.first());
_this.set('versionRight', result.last());

View File

@ -1,6 +1,6 @@
class VersionSerializer < ApplicationSerializer
attributes :number, :display_username, :created_at, :description
attributes :number, :display_username, :created_at
def number
object[:number]
@ -14,8 +14,4 @@ class VersionSerializer < ApplicationSerializer
object[:created_at]
end
def description
"v#{object[:number]} - #{FreedomPatches::Rails4.time_ago_in_words(object[:created_at])} ago by #{object[:display_username]}"
end
end

View File

@ -629,6 +629,7 @@ en:
top_contributors: "Participants"
category_title: "Category"
history: "History"
changed_by: "by {{author}}"
categories_list: "Categories List"