FEATURE: add a message explaining the user why they're being redirected to the top page

This commit is contained in:
Régis Hanol 2014-01-03 19:20:40 +01:00
parent 59ea1c3c2c
commit 584a9f310b
3 changed files with 47 additions and 2 deletions

View File

@ -0,0 +1,35 @@
/**
Controller of the top page
@class TopController
@extends Discourse.ObjectController
@namespace Discourse
@module Discourse
**/
Discourse.TopController = Discourse.ObjectController.extend({
redirectedToTopPageReason: function() {
// no need for a reason if the default homepage is "top"
if (Discourse.Utilities.defaultHomepage() === "top") { return null; }
// check if the user is authenticated
if (Discourse.User.current()) {
if (Discourse.User.currentProp("trust_level") === 0) {
return I18n.t("filters.top.redirect_reasons.new_user");
} else if (!Discourse.User.currentProp("hasBeenSeenInTheLastMonth")) {
return I18n.t("filters.top.redirect_reasons.not_seen_in_a_month");
}
}
// no reason detected
return null;
}.property(),
showThisYear: function() {
if (Discourse.User.current()) {
return !Discourse.User.currentProp("hasBeenSeenInTheLastMonth");
} else {
return true;
}
}.property(),
});

View File

@ -1,5 +1,12 @@
<h2>{{i18n filters.top.this_year}}</h2>
{{basic-topic-list topicList=content.yearly}}
{{#if redirectedToTopPageReason}}
<div class="alert alert-info">
{{redirectedToTopPageReason}}
</div>
{{/if}}
{{#if showThisYear}}
<h2>{{i18n filters.top.this_year}}</h2>
{{basic-topic-list topicList=content.yearly}}
{{/if}}
<h2>{{i18n filters.top.this_month}}</h2>
{{basic-topic-list topicList=content.monthly}}
<h2>{{i18n filters.top.this_week}}</h2>

View File

@ -1117,6 +1117,9 @@ en:
this_month: "This month"
this_week: "This week"
today: "Today"
redirect_reasons:
new_user: "You are a new user. This will be your homepage for a while. If you don't know where to start, here's a summary of the best topics."
not_seen_in_a_month: "We have not seen you in more than a month. Here's a summary of the best topics since you were away."
browser_update: 'Unfortunately, <a href="http://www.discourse.org/faq/#browser">your browser is too old to work on this Discourse forum</a>. Please <a href="http://browsehappy.com">upgrade your browser</a>.'