mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Post history heatmap should use site settings for thresholds
This commit is contained in:
parent
2f4f5d56e1
commit
f7b0c31418
5 changed files with 36 additions and 18 deletions
|
@ -104,18 +104,6 @@ Discourse.Post = Discourse.Model.extend({
|
||||||
return this.get('version') - 1;
|
return this.get('version') - 1;
|
||||||
}.property('version'),
|
}.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() {
|
flagsAvailable: function() {
|
||||||
var post = this;
|
var post = this;
|
||||||
return Discourse.Site.currentProp('flagTypes').filter(function(item) {
|
return Discourse.Site.currentProp('flagTypes').filter(function(item) {
|
||||||
|
|
|
@ -41,12 +41,12 @@
|
||||||
{{#if hasHistory}}
|
{{#if hasHistory}}
|
||||||
<div class='post-info edits'>
|
<div class='post-info edits'>
|
||||||
{{#if can_view_edit_history}}
|
{{#if can_view_edit_history}}
|
||||||
<a href='#' class="{{unbound historyHeat}}" {{action showHistory this}} title="{{i18n post.last_edited_on}} {{raw-date updated_at}}">
|
<a href='#' class="{{unbound view.historyHeat}}" {{action showHistory this}} title="{{i18n post.last_edited_on}} {{raw-date updated_at}}">
|
||||||
{{editCount}}
|
{{editCount}}
|
||||||
<i class='fa fa-pencil'></i>
|
<i class='fa fa-pencil'></i>
|
||||||
</a>
|
</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span class="{{unbound historyHeat}}" title="{{i18n post.last_edited_on}} {{raw-date updated_at}}">
|
<span class="{{unbound view.historyHeat}}" title="{{i18n post.last_edited_on}} {{raw-date updated_at}}">
|
||||||
{{editCount}}
|
{{editCount}}
|
||||||
<i class='fa fa-pencil'></i>
|
<i class='fa fa-pencil'></i>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
var DAY = 60 * 50 * 1000;
|
||||||
|
|
||||||
Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
||||||
classNames: ['topic-post', 'clearfix'],
|
classNames: ['topic-post', 'clearfix'],
|
||||||
templateName: 'post',
|
templateName: 'post',
|
||||||
|
@ -8,6 +10,19 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
||||||
'groupNameClass'],
|
'groupNameClass'],
|
||||||
postBinding: 'content',
|
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() {
|
postTypeClass: function() {
|
||||||
return this.get('post.post_type') === Discourse.Site.currentProp('post_types.moderator_action') ? 'moderator' : 'regular';
|
return this.get('post.post_type') === Discourse.Site.currentProp('post_types.moderator_action') ? 'moderator' : 'regular';
|
||||||
}.property('post.post_type'),
|
}.property('post.post_type'),
|
||||||
|
|
|
@ -891,12 +891,16 @@ en:
|
||||||
topic_views_heat_high: "After this many views, the topic is strongly highlighted."
|
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_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_medium: "A topic this many days old is moderately highligted."
|
||||||
cold_age_days_high: "A topic this many days old is slightly 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_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_medium: "A topic with this likes:post ratio is moderately highlighted."
|
||||||
topic_post_like_heat_high: "A topic with this likes:post ratio is slightly 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."
|
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."
|
tos_url: "If you have a Terms of Service document hosted elsewhere that you want to use, provide the full URL here."
|
||||||
|
|
|
@ -681,6 +681,17 @@ uncategorized:
|
||||||
client: true
|
client: true
|
||||||
default: 2.0
|
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 map thresholds
|
||||||
cold_age_days_low:
|
cold_age_days_low:
|
||||||
client: true
|
client: true
|
||||||
|
|
Loading…
Reference in a new issue