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 @@ + + + + + <%= render_topic_title(@topic_view.topic) %> + + +<% @topic_view.posts.each do |post| %> + <% if post.user %> +
+ #<%=post.post_number%> <%= t 'by'%>: <%= post.user.name %>, <%= post.created_at.to_formatted_s(:long_ordinal) %> +
+
+ <%= post.cooked.html_safe %> +
+
+ <% end %> +<% end %> + diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 17b2630eedf..85efbd0345d 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -500,6 +500,7 @@ en: must_approve_users: "Admins must approve all users before they gain access" ga_tracking_code: "Google analytics tracking code code, eg: UA-12345678-9; see http://google.com/analytics" ga_domain_name: "Google analytics domain name, eg: mysite.com; see http://google.com/analytics" + yandex_workaround: "Enable workaround solution to help Yandex crawler (http://www.yandex.com) index your site. WARNING: enable it only if you are really have to do it." top_menu: "Determine which items appear in the homepage navigation, and in what order. Example latest|hot|read|favorited|unread|new|posted|categories" post_menu: "Determine which items appear on the post menu, and in what order. Example like|edit|flag|delete|share|bookmark|reply" share_links: "Determine which items appear on the share dialog, and in what order. Example twitter|facebook|google+|email"