From ca20cb9941cd5474f1377a3f82e6bf53f1960cbb Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 2 Mar 2017 15:06:47 -0500 Subject: [PATCH] FEATURE: subcategories can be discovered by web crawlers on page 1 of the parent category topics list --- app/controllers/list_controller.rb | 4 ++++ app/views/list/list.erb | 28 +++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb index a3ae278b3e9..f2a4aabac77 100644 --- a/app/controllers/list_controller.rb +++ b/app/controllers/list_controller.rb @@ -294,6 +294,10 @@ class ListController < ApplicationController @description_meta = @category.description_text raise Discourse::NotFound unless guardian.can_see?(@category) + + if use_crawler_layout? + @subcategories = @category.subcategories.select { |c| guardian.can_see?(c) } + end end def build_topic_list_options diff --git a/app/views/list/list.erb b/app/views/list/list.erb index 92d76d635eb..ba4b1dff319 100644 --- a/app/views/list/list.erb +++ b/app/views/list/list.erb @@ -13,16 +13,34 @@ <% if @category %>

<% if @category.parent_category %> - <%= link_to @category.parent_category.url, itemprop: 'item' do %> - <%= @category.parent_category.name %> - <% end %> -   + <%= link_to @category.parent_category.url, itemprop: 'item' do %> + <%= @category.parent_category.name %> + <% end %> +   <% end %> + <%= link_to @category.url, itemprop: 'item' do %> <%= @category.name %> <% end %>


+ + <% if params[:page].to_i == 0 && @subcategories.present? %> +
+ <% @subcategories.each do |subcategory| %> +
+ + + <%= subcategory.name %> + + <% if subcategory.description.present? %> + <%= subcategory.description %> + <% end %> +
+ <% end %> +
+
+ <% end %> <% end %>
@@ -58,7 +76,7 @@ <% end %> <% end %> -<%- end %> +<%- end %> <% if @rss %> <% content_for :head do %>