diff --git a/app/assets/javascripts/discourse/controllers/list_categories_controller.js b/app/assets/javascripts/discourse/controllers/list_categories_controller.js
index 29821a1a6fd..079c480fcae 100644
--- a/app/assets/javascripts/discourse/controllers/list_categories_controller.js
+++ b/app/assets/javascripts/discourse/controllers/list_categories_controller.js
@@ -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')
});
diff --git a/app/assets/javascripts/discourse/models/category.js b/app/assets/javascripts/discourse/models/category.js
index 81f2c5ac632..7ce772e6195 100644
--- a/app/assets/javascripts/discourse/models/category.js
+++ b/app/assets/javascripts/discourse/models/category.js
@@ -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(),
diff --git a/app/assets/javascripts/discourse/routes/list_categories_route.js b/app/assets/javascripts/discourse/routes/list_categories_route.js
index 43b1bfdd881..b5c96de0ec7 100644
--- a/app/assets/javascripts/discourse/routes/list_categories_route.js
+++ b/app/assets/javascripts/discourse/routes/list_categories_route.js
@@ -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); },
diff --git a/app/assets/javascripts/discourse/templates/list/wide_categories.js.handlebars b/app/assets/javascripts/discourse/templates/list/wide_categories.js.handlebars
index 1ed05c38986..89e68590a19 100644
--- a/app/assets/javascripts/discourse/templates/list/wide_categories.js.handlebars
+++ b/app/assets/javascripts/discourse/templates/list/wide_categories.js.handlebars
@@ -49,25 +49,33 @@
{{number topic_count}} |
{{number post_count}} |
- {{#with latestTopic}}
-
- {{topicStatus topic=this}}
- {{{unbound fancy_title}}}
- {{#if unread}}
- {{unread}}
- {{/if}}
- {{#if new_posts}}
- {{new_posts}}
- {{/if}}
- {{#if unseen}}
-
- {{/if}}
- |
{{/each}}
diff --git a/app/assets/stylesheets/desktop/topic-list.scss b/app/assets/stylesheets/desktop/topic-list.scss
index c5162e05ab4..fa1f41940fb 100644
--- a/app/assets/stylesheets/desktop/topic-list.scss
+++ b/app/assets/stylesheets/desktop/topic-list.scss
@@ -252,7 +252,6 @@
}
.last-user-info {
font-size: 12px;
- margin-top: 3px;
}
tbody td {
padding-bottom: 20px;
@@ -287,6 +286,13 @@
font-size: 14px;
}
}
+
+ .featured-topic {
+ margin: 6px 0;
+ a.last-posted-at, a.last-posted-at:visited {
+ color: #888;
+ }
+ }
}
diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb
index b62e7744cf9..4a8fc6539ca 100644
--- a/app/controllers/categories_controller.rb
+++ b/app/controllers/categories_controller.rb
@@ -9,10 +9,11 @@ class CategoriesController < ApplicationController
def index
@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[: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.draft_key = Draft::NEW_TOPIC
diff --git a/app/models/category_list.rb b/app/models/category_list.rb
index 6bd84ea725e..bc580ccdcd8 100644
--- a/app/models/category_list.rb
+++ b/app/models/category_list.rb
@@ -22,7 +22,15 @@ class CategoryList
private
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
# 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.each do |t|
+ t.include_last_poster = true if include_latest_posts? # hint for serialization
@topics_by_id[t.id] = t
end
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 7b909a9e42b..cdc212383f7 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -514,7 +514,7 @@ en:
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_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\""
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"
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_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."
diff --git a/config/site_settings.yml b/config/site_settings.yml
index fa4fdb68307..b8915bd933e 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -32,10 +32,10 @@ basic:
default: ''
enable_wide_category_list:
client: true
- default: false
+ default: true
category_featured_topics:
client: true
- default: 6
+ default: 3
topics_per_page: 30
posts_per_page:
client: true
diff --git a/test/javascripts/integration/list_topics_test.js b/test/javascripts/integration/list_topics_test.js
index ac5d7122696..de5c6159294 100644
--- a/test/javascripts/integration/list_topics_test.js
+++ b/test/javascripts/integration/list_topics_test.js
@@ -22,7 +22,7 @@ test("Categories List", function() {
expect(1);
visit("/categories").then(function() {
- ok(exists('.category-list-item'), "has a list of categories");
+ ok(exists('.category'), "has a list of categories");
});
});