diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0dcfe5ef404..0c2b5c185f6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -46,8 +46,12 @@ class ApplicationController < ActionController::Base SiteSetting.enable_escaped_fragments? && params.key?("_escaped_fragment_") end + def use_crawler_layout? + @use_crawler_layout ||= (has_escaped_fragment? || CrawlerDetection.crawler?(request.user_agent)) + end + def set_layout - has_escaped_fragment? || CrawlerDetection.crawler?(request.user_agent) ? 'crawler' : 'application' + use_crawler_layout? ? 'crawler' : 'application' end rescue_from Exception do |exception| diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb index ce73e884237..5c7548b079b 100644 --- a/app/controllers/list_controller.rb +++ b/app/controllers/list_controller.rb @@ -57,13 +57,24 @@ class ListController < ApplicationController list_opts[:no_definitions] = true end + list = TopicQuery.new(user, list_opts).public_send("list_#{filter}") list.more_topics_url = construct_next_url_with(list_opts) list.prev_topics_url = construct_prev_url_with(list_opts) if Discourse.anonymous_filters.include?(filter) @description = SiteSetting.site_description @rss = filter + + if 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) + else + @title = I18n.t('js.filters.with_topics', filter: filter_title) + end + end end + respond(list) end @@ -158,6 +169,11 @@ class ListController < ApplicationController list.for_period = period list.more_topics_url = construct_next_url_with(top_options) list.prev_topics_url = construct_prev_url_with(top_options) + + if use_crawler_layout? + @title = I18n.t("js.filters.top.#{period}.title") + end + respond(list) end diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 41c66bd98aa..78d9c277e74 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -28,6 +28,7 @@ class StaticController < ApplicationController if map.has_key?(@page) @topic = Topic.find_by_id(SiteSetting.send(map[@page][:topic_id])) + @title = @topic.title raise Discourse::NotFound unless @topic @body = @topic.posts.first.cooked @faq_overriden = !SiteSetting.faq_url.blank? diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erb index 176da771241..1ee491eccc8 100644 --- a/app/views/categories/index.html.erb +++ b/app/views/categories/index.html.erb @@ -9,4 +9,6 @@ <%- end %> -<% end %> \ No newline at end of file +<% end %> + +<% content_for :title do %><%= I18n.t('js.filters.categories.title') %><% end %> diff --git a/app/views/list/list.erb b/app/views/list/list.erb index 58a6a599f48..4091f0b01ff 100644 --- a/app/views/list/list.erb +++ b/app/views/list/list.erb @@ -28,6 +28,11 @@ <% content_for :head do %> <%= auto_discovery_link_tag(@category, {action: :category_feed, format: :rss}, title: t('rss_topics_in_category', category: @category.name), type: 'application/rss+xml') %> <% end %> +<% end %> + +<% if @title %> + <% content_for :title do %><%= @title %><% end %> +<% elsif @category %> <% content_for :title do %><%=@category.name%> <%=t('topics')%><% end %> <% elsif params[:page] %> <% content_for :title do %><%=t 'page_num', num: params[:page].to_i + 1 %><% end %> diff --git a/app/views/static/show.html.erb b/app/views/static/show.html.erb index e2eb4fb0e2e..305b137c98a 100644 --- a/app/views/static/show.html.erb +++ b/app/views/static/show.html.erb @@ -14,3 +14,7 @@ <% end %> <%= @body.html_safe %> + +<% if @title %> + <% content_for :title do %><%= @title %><% end %> +<% end %>