From f7b0c31418a6ac42187f5f710ce5b79824bb7e67 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 15 Aug 2014 12:22:06 -0400 Subject: [PATCH] Post history heatmap should use site settings for thresholds --- app/assets/javascripts/discourse/models/_post.js | 12 ------------ .../discourse/templates/post.js.handlebars | 4 ++-- .../javascripts/discourse/views/post_view.js | 15 +++++++++++++++ config/locales/server.en.yml | 12 ++++++++---- config/site_settings.yml | 11 +++++++++++ 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/discourse/models/_post.js b/app/assets/javascripts/discourse/models/_post.js index f81e3bbb2..f2afe0881 100644 --- a/app/assets/javascripts/discourse/models/_post.js +++ b/app/assets/javascripts/discourse/models/_post.js @@ -104,18 +104,6 @@ Discourse.Post = Discourse.Model.extend({ return this.get('version') - 1; }.property('version'), - historyHeat: function() { - var rightNow, updatedAt, updatedAtDate; - if (!(updatedAt = this.get('updated_at'))) return; - rightNow = new Date().getTime(); - - // Show heat on age - updatedAtDate = new Date(updatedAt).getTime(); - if (updatedAtDate > (rightNow - 60 * 60 * 1000 * 12)) return 'heatmap-high'; - if (updatedAtDate > (rightNow - 60 * 60 * 1000 * 24)) return 'heatmap-med'; - if (updatedAtDate > (rightNow - 60 * 60 * 1000 * 48)) return 'heatmap-low'; - }.property('updated_at'), - flagsAvailable: function() { var post = this; return Discourse.Site.currentProp('flagTypes').filter(function(item) { diff --git a/app/assets/javascripts/discourse/templates/post.js.handlebars b/app/assets/javascripts/discourse/templates/post.js.handlebars index 78a1e8e77..1b526e977 100644 --- a/app/assets/javascripts/discourse/templates/post.js.handlebars +++ b/app/assets/javascripts/discourse/templates/post.js.handlebars @@ -41,12 +41,12 @@ {{#if hasHistory}}
{{#if can_view_edit_history}} - + {{editCount}} {{else}} - + {{editCount}} diff --git a/app/assets/javascripts/discourse/views/post_view.js b/app/assets/javascripts/discourse/views/post_view.js index ae5ea7606..62cd2aa1a 100644 --- a/app/assets/javascripts/discourse/views/post_view.js +++ b/app/assets/javascripts/discourse/views/post_view.js @@ -1,3 +1,5 @@ +var DAY = 60 * 50 * 1000; + Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, { classNames: ['topic-post', 'clearfix'], templateName: 'post', @@ -8,6 +10,19 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, { 'groupNameClass'], postBinding: 'content', + historyHeat: function() { + var updatedAt = this.get('post.updated_at'); + if (!updatedAt) { return; } + + // Show heat on age + var rightNow = new Date().getTime(), + updatedAtDate = new Date(updatedAt).getTime(); + + if (updatedAtDate > (rightNow - DAY * Discourse.SiteSettings.history_hours_low)) return 'heatmap-high'; + if (updatedAtDate > (rightNow - DAY * Discourse.SiteSettings.history_hours_medium)) return 'heatmap-med'; + if (updatedAtDate > (rightNow - DAY * Discourse.SiteSettings.history_hours_high)) return 'heatmap-low'; + }.property('post.updated_at'), + postTypeClass: function() { return this.get('post.post_type') === Discourse.Site.currentProp('post_types.moderator_action') ? 'moderator' : 'regular'; }.property('post.post_type'), diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 43bd56d3b..9e12eff8b 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -891,12 +891,16 @@ en: topic_views_heat_high: "After this many views, the topic is strongly highlighted." cold_age_days_low: "A topic this many days old is slightly highligted." - cold_age_days_medium: "A topic this many days old is slightly highligted." - cold_age_days_high: "A topic this many days old is slightly highligted." + cold_age_days_medium: "A topic this many days old is moderately highligted." + cold_age_days_high: "A topic this many days old is strongly highligted." + + history_hours_low: "A post edited within this many hours is slightly highlighted" + history_hours_medium: "A topic with this likes:post ratio is moderately highlighted." + history_hours_high: "A topic with this likes:post ratio is strongly highlighted." topic_post_like_heat_low: "A topic with this likes:post ratio is slightly highlighted." - topic_post_like_heat_medium: "A topic with this likes:post ratio is slightly highlighted." - topic_post_like_heat_high: "A topic with this likes:post ratio is slightly highlighted." + topic_post_like_heat_medium: "A topic with this likes:post ratio is moderately highlighted." + topic_post_like_heat_high: "A topic with this likes:post ratio is strongly highlighted." faq_url: "If you have a FAQ hosted elsewhere that you want to use, provide the full URL here." tos_url: "If you have a Terms of Service document hosted elsewhere that you want to use, provide the full URL here." diff --git a/config/site_settings.yml b/config/site_settings.yml index 4e11f49bd..97f79be51 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -681,6 +681,17 @@ uncategorized: client: true default: 2.0 + # History edit heat thresholds + history_hours_low: + client: true + default: 12 + history_hours_medium: + client: true + default: 24 + history_hours_high: + client: true + default: 48 + # Cold map thresholds cold_age_days_low: client: true