diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 5b34b1c08b9..4dc05c2780e 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -40,6 +40,11 @@ class TopicsController < ApplicationController anonymous_etag(@topic_view.topic) do redirect_to_correct_topic && return if slugs_do_not_match + + # render workaround pseudo-static HTML page for Yandex crawler (if enabled) + # (see http://meta.discourse.org/t/noscript-tag-and-some-search-engines/8078) + return render 'topics/plain', layout: false if (SiteSetting.yandex_workaround && params.has_key?('_escaped_fragment_')) + View.create_for(@topic_view.topic, request.remote_ip, current_user) track_visit_to_topic perform_show_response diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 66bc001dc7d..a902e0f74b9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -78,6 +78,10 @@ module ApplicationHelper end end + # Add workaround tag for Yandex crawler + # (see http://help.yandex.ru/webmaster/?id=1125296) + result << tag('meta', name: "fragment", content: "!") if SiteSetting.yandex_workaround + result end diff --git a/app/models/site_setting.rb b/app/models/site_setting.rb index 971629455f8..6dc25428d57 100644 --- a/app/models/site_setting.rb +++ b/app/models/site_setting.rb @@ -26,6 +26,7 @@ class SiteSetting < ActiveRecord::Base client_setting(:must_approve_users, false) client_setting(:ga_tracking_code, "") client_setting(:ga_domain_name, "") + client_setting(:yandex_workaround, false) client_setting(:enable_long_polling, true) client_setting(:polling_interval, 3000) client_setting(:anon_polling_interval, 30000) diff --git a/app/views/topics/plain.html.erb b/app/views/topics/plain.html.erb new file mode 100644 index 00000000000..79e02f2c987 --- /dev/null +++ b/app/views/topics/plain.html.erb @@ -0,0 +1,19 @@ + + +
+ +