mirror of
https://github.com/discourse/discourse.git
synced 2026-08-27 05:37:29 -05:00
Show more than one topic per category on the wide categories page. Disable support for the 2-column categories page. The category_featured_topics site setting controls how many topics to show.
This commit is contained in:
@@ -41,7 +41,11 @@ Discourse.ListCategoriesController = Discourse.ObjectController.extend({
|
||||
|
||||
moveCategory: function(categoryId, position){
|
||||
this.get('model.categories').moveCategory(categoryId, position);
|
||||
}
|
||||
},
|
||||
|
||||
latestTopicOnly: function() {
|
||||
return this.get('categories').find(function(c) { return c.get('featuredTopics.length') > 1; }) === undefined;
|
||||
}.property('categories.featuredTopics.length')
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -117,6 +117,13 @@ Discourse.Category = Discourse.Model.extend({
|
||||
}
|
||||
}.property("topics"),
|
||||
|
||||
featuredTopics: function() {
|
||||
var topics = this.get('topics');
|
||||
if (topics && topics.length) {
|
||||
return topics.slice(0, Discourse.SiteSettings.category_featured_topics || 2);
|
||||
}
|
||||
}.property('topics'),
|
||||
|
||||
topicTrackingState: function(){
|
||||
return Discourse.TopicTrackingState.current();
|
||||
}.property(),
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
Discourse.ListCategoriesRoute = Discourse.Route.extend({
|
||||
|
||||
template: function() {
|
||||
return Discourse.SiteSettings.enable_wide_category_list ? 'listWideCategories' : 'listCategories';
|
||||
// Remove the option to have 2-column layout on categories page.
|
||||
// TODO: remove this old code when we're sure about it.
|
||||
// return Discourse.SiteSettings.enable_wide_category_list ? 'listWideCategories' : 'listCategories';
|
||||
return 'listWideCategories';
|
||||
}.property(),
|
||||
|
||||
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
||||
|
||||
@@ -49,25 +49,33 @@
|
||||
</td>
|
||||
<td class='num'>{{number topic_count}}</td>
|
||||
<td class='num'>{{number post_count}}</td>
|
||||
{{#with latestTopic}}
|
||||
<td {{bindAttr class="archived :latest"}}>
|
||||
{{topicStatus topic=this}}
|
||||
<a class='title' href="{{unbound lastUnreadUrl}}">{{{unbound fancy_title}}}</a>
|
||||
{{#if unread}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unread}}</a>
|
||||
{{/if}}
|
||||
{{#if new_posts}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="new_posts"}}'>{{new_posts}}</a>
|
||||
{{/if}}
|
||||
{{#if unseen}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='fa fa-asterisk'></i></a>
|
||||
{{/if}}
|
||||
<div class='last-user-info'>
|
||||
{{i18n categories.latest_by}} <a href="{{{unbound lastPosterUrl}}}">{{unbound last_poster.username}}</a>
|
||||
<a href="{{unbound lastPostUrl}}">{{unboundAge last_posted_at}}</a>
|
||||
<td {{bindAttr class="archived :latest"}}>
|
||||
{{#each featuredTopics}}
|
||||
<div class="featured-topic">
|
||||
{{topicStatus topic=this}}
|
||||
<a class='title' href="{{unbound lastUnreadUrl}}">{{{unbound fancy_title}}}</a>
|
||||
{{#if unread}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unread}}</a>
|
||||
{{/if}}
|
||||
{{#if new_posts}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="new_posts"}}'>{{new_posts}}</a>
|
||||
{{/if}}
|
||||
{{#if unseen}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='fa fa-asterisk'></i></a>
|
||||
{{/if}}
|
||||
|
||||
{{#if controller.latestTopicOnly}}
|
||||
<div class='last-user-info'>
|
||||
{{i18n categories.latest_by}} <a href="{{{unbound lastPosterUrl}}}">{{unbound last_poster.username}}</a>
|
||||
<a href="{{unbound lastPostUrl}}">{{unboundAge last_posted_at}}</a>
|
||||
</div>
|
||||
{{else}}
|
||||
|
||||
<a href="{{unbound lastPostUrl}}" class="last-posted-at">{{unboundAge last_posted_at}}</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
</td>
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user