BUGFIX: display links to other periods at the bottom of the top/:period page
This commit is contained in:
parent
8d2e5041bc
commit
aca53aa722
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
The base controller for discoverying topics
|
||||
|
||||
@class DiscoveryController
|
||||
@extends Discourse.Controller
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.DiscoveryController = Discourse.ObjectController.extend({
|
||||
|
||||
showMoreUrl: function(period) {
|
||||
var url = '', category = this.get('category');
|
||||
if (category) {
|
||||
url = '/category/' + Discourse.Category.slugFor(category) + (this.get('noSubcategories') ? '/none' : '') + '/l';
|
||||
}
|
||||
url += '/top/' + period;
|
||||
return url;
|
||||
},
|
||||
|
||||
showMoreDailyUrl: function() { return this.showMoreUrl('daily'); }.property('category', 'noSubcategories'),
|
||||
showMoreWeeklyUrl: function() { return this.showMoreUrl('weekly'); }.property('category', 'noSubcategories'),
|
||||
showMoreMonthlyUrl: function() { return this.showMoreUrl('monthly'); }.property('category', 'noSubcategories'),
|
||||
showMoreYearlyUrl: function() { return this.showMoreUrl('yearly'); }.property('category', 'noSubcategories'),
|
||||
});
|
|
@ -6,7 +6,7 @@
|
|||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.DiscoveryCategoriesController = Discourse.ObjectController.extend({
|
||||
Discourse.DiscoveryCategoriesController = Discourse.DiscoveryController.extend({
|
||||
needs: ['modal'],
|
||||
|
||||
actions: {
|
||||
|
@ -19,11 +19,6 @@ Discourse.DiscoveryCategoriesController = Discourse.ObjectController.extend({
|
|||
return Discourse.User.currentProp('staff');
|
||||
}.property(),
|
||||
|
||||
// clear a pinned topic
|
||||
clearPin: function(topic) {
|
||||
topic.clearPin();
|
||||
},
|
||||
|
||||
moveCategory: function(categoryId, position){
|
||||
this.get('model.categories').moveCategory(categoryId, position);
|
||||
},
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.DiscoveryTopController = Discourse.ObjectController.extend({
|
||||
category: null,
|
||||
|
||||
Discourse.DiscoveryTopController = Discourse.DiscoveryController.extend({
|
||||
redirectedToTopPageReason: function() {
|
||||
// no need for a reason if the default homepage is 'top'
|
||||
if (Discourse.Utilities.defaultHomepage() === 'top') { return null; }
|
||||
|
@ -24,19 +22,5 @@ Discourse.DiscoveryTopController = Discourse.ObjectController.extend({
|
|||
return null;
|
||||
}.property(),
|
||||
|
||||
hasDisplayedAllTopLists: Em.computed.and('content.yearly', 'content.monthly', 'content.weekly', 'content.daily'),
|
||||
|
||||
showMoreUrl: function(period) {
|
||||
var url = '', category = this.get('category');
|
||||
if (category) {
|
||||
url = '/category/' + Discourse.Category.slugFor(category) + (this.get('noSubcategories') ? '/none' : '') + '/l';
|
||||
}
|
||||
url += '/top/' + period;
|
||||
return url;
|
||||
},
|
||||
|
||||
showMoreDailyUrl: function() { return this.showMoreUrl('daily'); }.property('category', 'noSubcategories'),
|
||||
showMoreWeeklyUrl: function() { return this.showMoreUrl('weekly'); }.property('category', 'noSubcategories'),
|
||||
showMoreMonthlyUrl: function() { return this.showMoreUrl('monthly'); }.property('category', 'noSubcategories'),
|
||||
showMoreYearlyUrl: function() { return this.showMoreUrl('yearly'); }.property('category', 'noSubcategories'),
|
||||
hasDisplayedAllTopLists: Em.computed.and('content.yearly', 'content.monthly', 'content.weekly', 'content.daily')
|
||||
});
|
||||
|
|
|
@ -6,18 +6,13 @@
|
|||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.DiscoveryTopicsController = Discourse.ObjectController.extend({
|
||||
Discourse.DiscoveryTopicsController = Discourse.DiscoveryController.extend({
|
||||
actions: {
|
||||
// Star a topic
|
||||
toggleStar: function(topic) {
|
||||
topic.toggleStar();
|
||||
},
|
||||
|
||||
// clear a pinned topic
|
||||
clearPin: function(topic) {
|
||||
topic.clearPin();
|
||||
},
|
||||
|
||||
// Show newly inserted topics
|
||||
showInserted: function() {
|
||||
var tracker = Discourse.TopicTrackingState.current();
|
||||
|
@ -46,8 +41,13 @@ Discourse.DiscoveryTopicsController = Discourse.ObjectController.extend({
|
|||
|
||||
hasTopics: Em.computed.gt('topics.length', 0),
|
||||
showTable: Em.computed.or('hasTopics', 'topicTrackingState.hasIncoming'),
|
||||
latest: Em.computed.equal('filter', 'latest'),
|
||||
allLoaded: Em.computed.empty('more_topics_url'),
|
||||
latest: Discourse.computed.endWith('filter', 'latest'),
|
||||
top: Em.computed.notEmpty('period'),
|
||||
yearly: Em.computed.equal('period', 'yearly'),
|
||||
monthly: Em.computed.equal('period', 'monthly'),
|
||||
weekly: Em.computed.equal('period', 'weekly'),
|
||||
daily: Em.computed.equal('period', 'daily'),
|
||||
|
||||
updateTitle: function(){
|
||||
Discourse.notifyTitle(this.get('topicTrackingState.incomingCount'));
|
||||
|
|
|
@ -7,21 +7,6 @@
|
|||
@module Discourse
|
||||
**/
|
||||
Discourse.NavigationDefaultController = Discourse.Controller.extend({
|
||||
needs: ['composer', 'discoveryTopics'],
|
||||
|
||||
actions: {
|
||||
createTopic: function() {
|
||||
var topicsController = this.get('controllers.discoveryTopics');
|
||||
this.get('controllers.composer').open({
|
||||
categoryId: this.get('category.id'),
|
||||
action: Discourse.Composer.CREATE_TOPIC,
|
||||
draft: topicsController.get('draft'),
|
||||
draftKey: topicsController.get('draft_key'),
|
||||
draftSequence: topicsController.get('draft_sequence')
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
categories: function() {
|
||||
return Discourse.Category.list();
|
||||
}.property(),
|
||||
|
|
|
@ -88,6 +88,28 @@ Discourse.computed = {
|
|||
})));
|
||||
});
|
||||
return computed.property.apply(computed, args);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Returns whether properties end with a string
|
||||
|
||||
@method i18n
|
||||
@params {String} properties* to check
|
||||
@params {String} substring the substring
|
||||
@return {Function} computedProperty function
|
||||
**/
|
||||
endWith: function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0);
|
||||
var substring = args.pop();
|
||||
var computed = Ember.computed(function() {
|
||||
var self = this;
|
||||
return _.all(args.map(function(a) { return self.get(a); }), function(s) {
|
||||
var position = s.length - substring.length,
|
||||
lastIndex = s.lastIndexOf(substring);
|
||||
return lastIndex !== -1 && lastIndex === position;
|
||||
});
|
||||
});
|
||||
return computed.property.apply(computed, args);
|
||||
},
|
||||
|
||||
};
|
||||
|
|
|
@ -19,6 +19,22 @@ Discourse.DiscoveryRoute = Discourse.Route.extend({
|
|||
|
||||
didTransition: function() {
|
||||
this.send('loadingComplete');
|
||||
},
|
||||
|
||||
// clear a pinned topic
|
||||
clearPin: function(topic) {
|
||||
topic.clearPin();
|
||||
},
|
||||
|
||||
createTopic: function() {
|
||||
var topicsController = this.controllerFor('discoveryTopics');
|
||||
this.controllerFor('composer').open({
|
||||
categoryId: topicsController.get('category.id'),
|
||||
action: Discourse.Composer.CREATE_TOPIC,
|
||||
draft: topicsController.get('draft'),
|
||||
draftKey: topicsController.get('draft_key'),
|
||||
draftSequence: topicsController.get('draft_sequence')
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -22,9 +22,12 @@ function buildTopicRoute(filter) {
|
|||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
var filterText = I18n.t('filters.' + filter.replace('/', '.') + '.title', {count: 0});
|
||||
var period = filter.indexOf('/') > 0 ? filter.split('/')[1] : '',
|
||||
filterText = I18n.t('filters.' + filter.replace('/', '.') + '.title', {count: 0});
|
||||
|
||||
Discourse.set('title', I18n.t('filters.with_topics', {filter: filterText}));
|
||||
this.controllerFor('discoveryTopics').set('model', model);
|
||||
|
||||
this.controllerFor('discoveryTopics').setProperties({ model: model, category: null, period: period });
|
||||
this.controllerFor('navigationDefault').set('canCreateTopic', model.get('can_create_topic'));
|
||||
},
|
||||
|
||||
|
@ -76,12 +79,20 @@ function buildCategoryRoute(filter, params) {
|
|||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
var topics = this.get('topics');
|
||||
var topics = this.get('topics'),
|
||||
period = filter.indexOf('/') > 0 ? filter.split('/')[1] : '',
|
||||
filterText = I18n.t('filters.' + filter.replace('/', '.') + '.title', {count: 0});
|
||||
|
||||
Discourse.set('title', I18n.t('filters.with_category', { filter: filterText, category: model.get('name').capitalize() }));
|
||||
|
||||
var filterText = I18n.t('filters.' + filter.replace('/', '.') + '.title', {count: 0});
|
||||
Discourse.set('title', I18n.t('filters.with_category', {filter: filterText, category: model.get('name').capitalize()}));
|
||||
this.controllerFor('discoveryTopics').set('model', topics);
|
||||
this.controllerFor('navigationCategory').set('canCreateTopic', topics.get('can_create_topic'));
|
||||
this.controllerFor('discoveryTopics').setProperties({
|
||||
model: topics,
|
||||
category: model,
|
||||
period: period,
|
||||
noSubcategories: params && !!params.no_subcategories
|
||||
});
|
||||
|
||||
this.set('topics', null);
|
||||
},
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend({
|
|||
|
||||
this.controllerFor('search').set('searchContext', model);
|
||||
|
||||
var opts = { category: model, filterMode: filterMode};
|
||||
var opts = { category: model, filterMode: filterMode };
|
||||
opts.noSubcategories = noSubcategories;
|
||||
opts.canEditCategory = Discourse.User.current('staff');
|
||||
this.controllerFor('navigationCategory').setProperties(opts);
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
<td {{bind-attr class=":num :views topic.viewsHeat"}}>{{number topic.views numberKey="views_long"}}</td>
|
||||
{{#if topic.bumped}}
|
||||
<td class='num activity'>
|
||||
<a href="{{unbound topic.url}}" {{{bindAttr class=":age topic.ageCold"}}} title='{{i18n first_post}}: {{{rawDate topic.created_at}}}' >{{unboundAge topic.created_at}}</a>
|
||||
<a href="{{unbound topic.url}}" {{{bind-attr class=":age topic.ageCold"}}} title='{{i18n first_post}}: {{{rawDate topic.created_at}}}' >{{unboundAge topic.created_at}}</a>
|
||||
</td>
|
||||
<td class='num activity last'>
|
||||
<a href="{{unbound topic.lastPostUrl}}" class='age' title='{{i18n last_post}}: {{{rawDate topic.bumped_at}}}'>{{unboundAge topic.bumped_at}}</a>
|
||||
|
|
|
@ -54,17 +54,23 @@
|
|||
{{#if loadingMore}}
|
||||
<div class='topics-loading'>{{i18n topic.loading_more}}</div>
|
||||
{{/if}}
|
||||
|
||||
<h3>
|
||||
{{footerMessage}}
|
||||
{{#if allLoaded}}
|
||||
{{#if allLoaded}}
|
||||
<h3>
|
||||
{{#if latest}}
|
||||
{{#if can_create_topic}}
|
||||
<a href='#' {{action createTopic}}>{{i18n topic.suggest_create_topic}}</a>
|
||||
{{footerMessage}}<a href='#' {{action createTopic}}>{{i18n topic.suggest_create_topic}}</a>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#link-to "discovery.categories"}}{{i18n topic.browse_all_categories}}{{/link-to}} {{i18n or}} {{#link-to 'discovery.latest'}}{{i18n topic.view_latest_topics}}{{/link-to}}
|
||||
{{#if top}}
|
||||
{{#link-to "discovery.categories"}}{{i18n topic.browse_all_categories}}{{/link-to}}, {{#link-to 'discovery.latest'}}{{i18n topic.view_latest_topics}}{{/link-to}} {{i18n or}} {{i18n filters.top.other_periods}}
|
||||
{{#unless yearly}}<a href="{{unbound showMoreYearlyUrl}}" class='btn'>{{i18n filters.top.this_year}}</a>{{/unless}}
|
||||
{{#unless monthly}}<a href="{{unbound showMoreMonthlyUrl}}" class='btn'>{{i18n filters.top.this_month}}</a>{{/unless}}
|
||||
{{#unless weekly}}<a href="{{unbound showMoreWeeklyUrl}}" class='btn'>{{i18n filters.top.this_week}}</a>{{/unless}}
|
||||
{{#unless daily}}<a href="{{unbound showMoreDailyUrl}}" class='btn'>{{i18n filters.top.today}}</a>{{/unless}}
|
||||
{{else}}
|
||||
{{footerMessage}}{{#link-to "discovery.categories"}}{{i18n topic.browse_all_categories}}{{/link-to}} {{i18n or}} {{#link-to 'discovery.latest'}}{{i18n topic.view_latest_topics}}{{/link-to}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</h3>
|
||||
</h3>
|
||||
{{/if}}
|
||||
</footer>
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
</div>
|
||||
</td>
|
||||
<td class='num posts'><span class='badge-posts'>{{number posts_count}}</span></td>
|
||||
<td class='num age'><span {{bindAttr class=":age ageCold"}} title='{{rawDate created_at}}'>{{{unboundAge created_at}}}</span></td>
|
||||
<td class='num age'><span {{bind-attr class=":age ageCold"}} title='{{rawDate created_at}}'>{{{unboundAge created_at}}}</span></td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
{{#if bumped}}
|
||||
<td class='num activity'>
|
||||
<a href="{{url}}" {{{bindAttr class=":age ageCold"}}} title='{{i18n first_post}}: {{{rawDate created_at}}}' >{{unboundAge created_at}}</a>
|
||||
<a href="{{url}}" {{{bind-attr class=":age ageCold"}}} title='{{i18n first_post}}: {{{rawDate created_at}}}' >{{unboundAge created_at}}</a>
|
||||
</td>
|
||||
<td class='num activity last'>
|
||||
<a href="{{lastPostUrl}}" class='age' title='{{i18n last_post}}: {{{rawDate bumped_at}}}'>{{unboundAge bumped_at}}</a>
|
||||
|
|
Loading…
Reference in New Issue