From 2f4f5d56e1295cec906bc03c2150d28f68321cb9 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 15 Aug 2014 12:09:31 -0400 Subject: [PATCH] Use Site Settings for the cold date ranges --- .../discourse/components/activity-column.js.es6 | 6 +++--- .../discourse/helpers/cold-age-class.js.es6 | 7 ++++--- config/locales/server.en.yml | 10 +++++++--- config/site_settings.yml | 11 +++++++++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/discourse/components/activity-column.js.es6 b/app/assets/javascripts/discourse/components/activity-column.js.es6 index 5a7589021..3f17f5b42 100644 --- a/app/assets/javascripts/discourse/components/activity-column.js.es6 +++ b/app/assets/javascripts/discourse/components/activity-column.js.es6 @@ -26,9 +26,9 @@ export default Ember.Component.extend({ if (!bumpedAt) { return; } var delta = daysSinceEpoch(bumpedAt) - daysSinceEpoch(createdAt); - if (delta > 120) { return 'coldmap-high'; } - if (delta > 60) { return 'coldmap-med'; } - if (delta > 14) { return 'coldmap-low'; } + if (delta > Discourse.SiteSettings.cold_age_days_high) { return 'coldmap-high'; } + if (delta > Discourse.SiteSettings.cold_age_days_medium) { return 'coldmap-med'; } + if (delta > Discourse.SiteSettings.cold_age_days_low) { return 'coldmap-low'; } }.property('bumpedAt', 'createdAt'), title: function() { diff --git a/app/assets/javascripts/discourse/helpers/cold-age-class.js.es6 b/app/assets/javascripts/discourse/helpers/cold-age-class.js.es6 index a3bfaf6ea..d7d644a79 100644 --- a/app/assets/javascripts/discourse/helpers/cold-age-class.js.es6 +++ b/app/assets/javascripts/discourse/helpers/cold-age-class.js.es6 @@ -14,9 +14,10 @@ function coldAgeClass(property, options) { // Show heat on age var nowDays = daysSinceEpoch(new Date()), epochDays = daysSinceEpoch(new Date(dt)); - if (nowDays - epochDays > 60) return 'age coldmap-high'; - if (nowDays - epochDays > 30) return 'age coldmap-med'; - if (nowDays - epochDays > 14) return 'age coldmap-low'; + + if (nowDays - epochDays > Discourse.SiteSettings.cold_age_days_high) return 'age coldmap-high'; + if (nowDays - epochDays > Discourse.SiteSettings.cold_age_days_medium) return 'age coldmap-med'; + if (nowDays - epochDays > Discourse.SiteSettings.cold_age_days_low) return 'age coldmap-low'; return 'age'; } diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index d76574e95..43bd56d3b 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -890,9 +890,13 @@ en: topic_views_heat_medium: "After this many views, the topic is moderately highlighted." topic_views_heat_high: "After this many views, the topic is strongly highlighted." - topic_post_like_heat_low: "A post with this likes:post ratio is slightly highlighted." - topic_post_like_heat_medium: "A post with this likes:post ratio is slightly highlighted." - topic_post_like_heat_high: "A post with this likes:post ratio is slightly 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." + + 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." 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 ed4f22cb5..4e11f49bd 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -681,6 +681,17 @@ uncategorized: client: true default: 2.0 + # Cold map thresholds + cold_age_days_low: + client: true + default: 14 + cold_age_days_medium: + client: true + default: 60 + cold_age_days_high: + client: true + default: 120 + # Warnings educate_until_posts: 2 sequential_replies_threshold: 2