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:
parent
50c4e3707b
commit
6fa2e68742
|
@ -41,7 +41,11 @@ Discourse.ListCategoriesController = Discourse.ObjectController.extend({
|
||||||
|
|
||||||
moveCategory: function(categoryId, position){
|
moveCategory: function(categoryId, position){
|
||||||
this.get('model.categories').moveCategory(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"),
|
}.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(){
|
topicTrackingState: function(){
|
||||||
return Discourse.TopicTrackingState.current();
|
return Discourse.TopicTrackingState.current();
|
||||||
}.property(),
|
}.property(),
|
||||||
|
|
|
@ -9,7 +9,10 @@
|
||||||
Discourse.ListCategoriesRoute = Discourse.Route.extend({
|
Discourse.ListCategoriesRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
template: function() {
|
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(),
|
}.property(),
|
||||||
|
|
||||||
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
||||||
|
|
|
@ -49,8 +49,9 @@
|
||||||
</td>
|
</td>
|
||||||
<td class='num'>{{number topic_count}}</td>
|
<td class='num'>{{number topic_count}}</td>
|
||||||
<td class='num'>{{number post_count}}</td>
|
<td class='num'>{{number post_count}}</td>
|
||||||
{{#with latestTopic}}
|
|
||||||
<td {{bindAttr class="archived :latest"}}>
|
<td {{bindAttr class="archived :latest"}}>
|
||||||
|
{{#each featuredTopics}}
|
||||||
|
<div class="featured-topic">
|
||||||
{{topicStatus topic=this}}
|
{{topicStatus topic=this}}
|
||||||
<a class='title' href="{{unbound lastUnreadUrl}}">{{{unbound fancy_title}}}</a>
|
<a class='title' href="{{unbound lastUnreadUrl}}">{{{unbound fancy_title}}}</a>
|
||||||
{{#if unread}}
|
{{#if unread}}
|
||||||
|
@ -62,12 +63,19 @@
|
||||||
{{#if unseen}}
|
{{#if unseen}}
|
||||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='fa fa-asterisk'></i></a>
|
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='fa fa-asterisk'></i></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if controller.latestTopicOnly}}
|
||||||
<div class='last-user-info'>
|
<div class='last-user-info'>
|
||||||
{{i18n categories.latest_by}} <a href="{{{unbound lastPosterUrl}}}">{{unbound last_poster.username}}</a>
|
{{i18n categories.latest_by}} <a href="{{{unbound lastPosterUrl}}}">{{unbound last_poster.username}}</a>
|
||||||
<a href="{{unbound lastPostUrl}}">{{unboundAge last_posted_at}}</a>
|
<a href="{{unbound lastPostUrl}}">{{unboundAge last_posted_at}}</a>
|
||||||
</div>
|
</div>
|
||||||
|
{{else}}
|
||||||
|
|
||||||
|
<a href="{{unbound lastPostUrl}}" class="last-posted-at">{{unboundAge last_posted_at}}</a>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
</td>
|
</td>
|
||||||
{{/with}}
|
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -252,7 +252,6 @@
|
||||||
}
|
}
|
||||||
.last-user-info {
|
.last-user-info {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin-top: 3px;
|
|
||||||
}
|
}
|
||||||
tbody td {
|
tbody td {
|
||||||
padding-bottom: 20px;
|
padding-bottom: 20px;
|
||||||
|
@ -287,6 +286,13 @@
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.featured-topic {
|
||||||
|
margin: 6px 0;
|
||||||
|
a.last-posted-at, a.last-posted-at:visited {
|
||||||
|
color: #888;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,11 @@ class CategoriesController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@description = SiteSetting.site_description
|
@description = SiteSetting.site_description
|
||||||
|
|
||||||
wide_mode = SiteSetting.enable_wide_category_list
|
# TODO: remove this when we're sure about removing 2-column layout on categories page
|
||||||
|
# wide_mode = SiteSetting.enable_wide_category_list
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
options[:latest_post_only] = params[:latest_post_only] || wide_mode
|
options[:latest_posts] = params[:latest_posts] || SiteSetting.category_featured_topics
|
||||||
|
|
||||||
@list = CategoryList.new(guardian,options)
|
@list = CategoryList.new(guardian,options)
|
||||||
@list.draft_key = Draft::NEW_TOPIC
|
@list.draft_key = Draft::NEW_TOPIC
|
||||||
|
|
|
@ -22,7 +22,15 @@ class CategoryList
|
||||||
private
|
private
|
||||||
|
|
||||||
def latest_post_only?
|
def latest_post_only?
|
||||||
@options[:latest_post_only]
|
@options[:latest_posts] and latest_posts_count == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_latest_posts?
|
||||||
|
@options[:latest_posts] and latest_posts_count > 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def latest_posts_count
|
||||||
|
@options[:latest_posts].to_i > 0 ? @options[:latest_posts].to_i : SiteSetting.category_featured_topics
|
||||||
end
|
end
|
||||||
|
|
||||||
# Retrieve a list of all the topics we'll need
|
# Retrieve a list of all the topics we'll need
|
||||||
|
@ -33,6 +41,7 @@ class CategoryList
|
||||||
|
|
||||||
@all_topics = Topic.where(id: category_featured_topics.map(&:topic_id))
|
@all_topics = Topic.where(id: category_featured_topics.map(&:topic_id))
|
||||||
@all_topics.each do |t|
|
@all_topics.each do |t|
|
||||||
|
t.include_last_poster = true if include_latest_posts? # hint for serialization
|
||||||
@topics_by_id[t.id] = t
|
@topics_by_id[t.id] = t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -514,7 +514,7 @@ en:
|
||||||
delete_removed_posts_after: "Number of hours after which posts removed by the author will be deleted."
|
delete_removed_posts_after: "Number of hours after which posts removed by the author will be deleted."
|
||||||
max_image_width: "Maximum allowed width of images in a post"
|
max_image_width: "Maximum allowed width of images in a post"
|
||||||
max_image_height: "Maximum allowed height of images in a post"
|
max_image_height: "Maximum allowed height of images in a post"
|
||||||
category_featured_topics: "Number of topics displayed per category in the /categories page"
|
category_featured_topics: "Number of topics displayed per category on the /categories page. After changing this value, it takes up to 15 minutes for the categories page to update."
|
||||||
add_rel_nofollow_to_user_content: "Add rel nofollow to all submitted user content, except for internal links (including parent domains) changing this requires you update all your baked markdown with: \"rake posts:rebake\""
|
add_rel_nofollow_to_user_content: "Add rel nofollow to all submitted user content, except for internal links (including parent domains) changing this requires you update all your baked markdown with: \"rake posts:rebake\""
|
||||||
exclude_rel_nofollow_domains: "A comma delimited list of domains where nofollow is not added (tld.com will automatically allow sub.tld.com as well)"
|
exclude_rel_nofollow_domains: "A comma delimited list of domains where nofollow is not added (tld.com will automatically allow sub.tld.com as well)"
|
||||||
|
|
||||||
|
@ -681,7 +681,7 @@ en:
|
||||||
min_body_similar_length: "The minimum length of a post's body before it will be checked for similar topics"
|
min_body_similar_length: "The minimum length of a post's body before it will be checked for similar topics"
|
||||||
|
|
||||||
category_colors: "A pipe (|) separated list of hexadecimal color values allowed for categories"
|
category_colors: "A pipe (|) separated list of hexadecimal color values allowed for categories"
|
||||||
enable_wide_category_list: "Enable traditional full width, non-tiling, category list"
|
enable_wide_category_list: "Enable traditional full width, non-tiling, category list. NOTE: this setting currently does nothing and will be removed. Wide list is the only option now."
|
||||||
|
|
||||||
max_image_size_kb: "The maximum size of images we allow users to upload in kB - configure the limit in nginx (client_max_body_size) / apache or proxy as well."
|
max_image_size_kb: "The maximum size of images we allow users to upload in kB - configure the limit in nginx (client_max_body_size) / apache or proxy as well."
|
||||||
max_attachment_size_kb: "The maximum size of files we allow users to upload in kB - configure the limit in nginx (client_max_body_size) / apache or proxy as well."
|
max_attachment_size_kb: "The maximum size of files we allow users to upload in kB - configure the limit in nginx (client_max_body_size) / apache or proxy as well."
|
||||||
|
|
|
@ -32,10 +32,10 @@ basic:
|
||||||
default: ''
|
default: ''
|
||||||
enable_wide_category_list:
|
enable_wide_category_list:
|
||||||
client: true
|
client: true
|
||||||
default: false
|
default: true
|
||||||
category_featured_topics:
|
category_featured_topics:
|
||||||
client: true
|
client: true
|
||||||
default: 6
|
default: 3
|
||||||
topics_per_page: 30
|
topics_per_page: 30
|
||||||
posts_per_page:
|
posts_per_page:
|
||||||
client: true
|
client: true
|
||||||
|
|
|
@ -22,7 +22,7 @@ test("Categories List", function() {
|
||||||
expect(1);
|
expect(1);
|
||||||
|
|
||||||
visit("/categories").then(function() {
|
visit("/categories").then(function() {
|
||||||
ok(exists('.category-list-item'), "has a list of categories");
|
ok(exists('.category'), "has a list of categories");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue