FIX: Bad page title for categories view by google crawler

This commit is contained in:
Robin Ward 2015-06-08 12:07:35 -04:00
parent ce0830b23f
commit ccaf525e8d
4 changed files with 10 additions and 3 deletions

View File

@ -212,6 +212,10 @@ class ApplicationController < ActionController::Base
@guardian ||= Guardian.new(current_user)
end
def current_homepage
current_user ? SiteSetting.homepage : SiteSetting.anonymous_homepage
end
def serialize_data(obj, serializer, opts=nil)
# If it's an array, apply the serializer as an each_serializer to the elements
serializer_opts = {scope: guardian}.merge!(opts || {})

View File

@ -24,6 +24,10 @@ class CategoriesController < ApplicationController
discourse_expires_in 1.minute
unless current_homepage == 'categories'
@title = I18n.t('js.filters.categories.title')
end
store_preloaded("categories_list", MultiJson.dump(CategoryListSerializer.new(@list, scope: guardian)))
respond_to do |format|
format.html { render }

View File

@ -60,7 +60,6 @@ class ListController < ApplicationController
list_opts[:no_definitions] = true
end
list = TopicQuery.new(user, list_opts).public_send("list_#{filter}")
list.more_topics_url = construct_url_with(:next, list_opts)
list.prev_topics_url = construct_url_with(:prev, list_opts)
@ -69,7 +68,7 @@ class ListController < ApplicationController
@rss = filter
# Note the first is the default and we don't add a title
if idx > 0 && use_crawler_layout?
if (filter.to_s != current_homepage) && use_crawler_layout?
filter_title = I18n.t("js.filters.#{filter.to_s}.title")
if list_opts[:category]
@title = I18n.t('js.filters.with_category', filter: filter_title, category: Category.find(list_opts[:category]).name)

View File

@ -23,4 +23,4 @@
<% end %>
</div>
<% content_for :title do %><%= I18n.t('js.filters.categories.title') %><% end %>
<% content_for :title do %><%= @title %><% end %>