FEATURE: new category setting for whether to show latest topics or top topics by default

This commit is contained in:
Neil Lalonde
2017-03-02 10:56:04 -05:00
parent bcf634ca85
commit 6aab8cb331
12 changed files with 74 additions and 13 deletions

View File

@ -6,6 +6,7 @@ class ListController < ApplicationController
skip_before_filter :check_xhr
before_filter :set_category, only: [
:category_default,
# filtered topics lists
Discourse.filters.map { |f| :"category_#{f}" },
Discourse.filters.map { |f| :"category_none_#{f}" },
@ -29,6 +30,7 @@ class ListController < ApplicationController
Discourse.anonymous_filters,
Discourse.anonymous_filters.map { |f| "#{f}_feed" },
# anonymous categorized filters
:category_default,
Discourse.anonymous_filters.map { |f| :"category_#{f}" },
Discourse.anonymous_filters.map { |f| :"category_none_#{f}" },
Discourse.anonymous_filters.map { |f| :"parent_category_category_#{f}" },
@ -106,6 +108,14 @@ class ListController < ApplicationController
end
end
def category_default
if @category.default_view == 'top'
top(category: @category.id)
else
self.send(@category.default_view || 'latest')
end
end
def topics_by
list_opts = build_topic_list_options
target_user = fetch_user_from_params({ include_inactive: current_user.try(:staff?) }, [:user_stat, :user_option])