diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 039f5d7c934..e2c4be1ad66 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -56,12 +56,17 @@ class ApplicationController < ActionController::Base SiteSetting.enable_escaped_fragments? && params.key?("_escaped_fragment_") end + def show_browser_update? + @show_browser_update ||= CrawlerDetection.show_browser_update?(request.user_agent) + end + helper_method :show_browser_update? + def use_crawler_layout? @use_crawler_layout ||= request.user_agent && (request.content_type.blank? || request.content_type.include?('html')) && !['json', 'rss'].include?(params[:format]) && - (has_escaped_fragment? || params.key?("print") || + (has_escaped_fragment? || params.key?("print") || show_browser_update? || CrawlerDetection.crawler?(request.user_agent, request.headers["HTTP_VIA"]) ) end diff --git a/app/views/layouts/crawler.html.erb b/app/views/layouts/crawler.html.erb index 8848af5cf4e..4e0a7e7bdd4 100644 --- a/app/views/layouts/crawler.html.erb +++ b/app/views/layouts/crawler.html.erb @@ -16,7 +16,9 @@ <%= theme_lookup("head_tag") %> <%= render_google_universal_analytics_code %> <%= yield :head %> - + <% if show_browser_update? %> + + <% end %> <%= build_plugin_html 'server:before-head-close-crawler' %>
@@ -67,6 +69,9 @@ <%= theme_lookup("footer") %> <%= theme_lookup("body_tag") %> + <% if show_browser_update? %> +