Merge pull request #193 from tms/timing-is-everything

Make topic lists show last activity more intuitively
This commit is contained in:
Sam 2013-03-27 22:57:44 -07:00
commit 0bcd142a81
6 changed files with 28 additions and 31 deletions

View File

@ -127,11 +127,6 @@ Discourse.Topic = Discourse.Model.extend({
return this.get('archetype') === 'private_message';
}).property('archetype'),
// Does this topic only have a single post?
singlePost: (function() {
return this.get('posts_count') === 1;
}).property('posts_count'),
toggleStatus: function(property) {
this.toggleProperty(property);
return $.post("" + (this.get('url')) + "/status", {

View File

@ -38,16 +38,16 @@
<td class='num'>{{number views numberKey="views_long"}}</td>
{{#if singlePost}}
<td class='num activity'>
<a href="{{url}}" class='age' title='{{i18n first_post}}: {{{unboundDate created_at}}}'>{{{age}}}</a>
</td>
<td></td>
{{else}}
{{#if bumped}}
<td class='num activity'>
<a href="{{url}}" {{{bindAttr class=":age ageCold"}}} title='{{i18n first_post}}: {{{unboundDate created_at}}}' >{{{age}}}</a>
</td>
<td class='num activity last'>
<a href="{{lastPostUrl}}" class='age' title='{{i18n last_post}}: {{{unboundDate last_posted_at}}}'>{{{last_post_age}}}</a>
<a href="{{lastPostUrl}}" class='age' title='{{i18n last_post}}: {{{unboundDate bumped_at}}}'>{{{bumped_age}}}</a>
</td>
{{else}}
<td class='num activity'>
<a href="{{url}}" class='age' title='{{i18n first_post}}: {{{unboundDate created_at}}}'>{{{age}}}</a>
</td>
<td></td>
{{/if}}

View File

@ -25,18 +25,18 @@
<td class='num'>{{number views numberKey="views_long"}}</td>
{{#if singlePost}}
<td class='num activity'>
<a href="{{url}}" class='age' title='{{i18n first_post}}: {{{unboundDate created_at}}}'>{{{age}}}</a>
</td>
<td></td>
{{else}}
{{#if bumped}}
<td class='num activity'>
<a href="{{url}}" {{{bindAttr class=":age ageCold"}}} title='{{i18n first_post}}: {{{unboundDate created_at}}}' >{{{age}}}</a>
</td>
<td class='num activity last'>
<a href="{{lastPostUrl}}" class='age' title='{{i18n last_post}}: {{{unboundDate last_posted_at}}}'>{{{last_post_age}}}</a>
<a href="{{lastPostUrl}}" class='age' title='{{i18n last_post}}: {{{unboundDate bumped_at}}}'>{{{bumped_age}}}</a>
</td>
{{else}}
<td class='num activity'>
<a href="{{url}}" class='age' title='{{i18n first_post}}: {{{unboundDate created_at}}}'>{{{age}}}</a>
</td>
<td></td>
{{/if}}
{{/group}}

View File

@ -8,6 +8,9 @@ class ListableTopicSerializer < BasicTopicSerializer
:image_url,
:created_at,
:last_posted_at,
:bumped,
:bumped_at,
:bumped_age,
:age,
:unseen,
:last_read_post_number,
@ -18,6 +21,16 @@ class ListableTopicSerializer < BasicTopicSerializer
def age
AgeWords.age_words(Time.now - (object.created_at || Time.now))
end
def bumped
object.created_at < object.bumped_at
end
def bumped_age
return nil if object.bumped_at.blank?
AgeWords.age_words(Time.now - object.bumped_at)
end
alias include_bumped_age? :bumped
def seen
object.user_data.present?

View File

@ -1,11 +1,6 @@
class SuggestedTopicSerializer < ListableTopicSerializer
attributes :archetype, :like_count, :views, :last_post_age
attributes :archetype, :like_count, :views
has_one :category, embed: :objects
def last_post_age
return nil if object.last_posted_at.blank?
AgeWords.age_words(Time.now - object.last_posted_at)
end
end

View File

@ -8,7 +8,6 @@ class TopicListItemSerializer < ListableTopicSerializer
:pinned,
:closed,
:archived,
:last_post_age,
:starred,
:has_best_of,
:archetype
@ -16,11 +15,6 @@ class TopicListItemSerializer < ListableTopicSerializer
has_one :category
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
def last_post_age
return nil if object.last_posted_at.blank?
AgeWords.age_words(Time.now - object.last_posted_at)
end
def starred
object.user_data.starred?
end