mirror of
https://github.com/discourse/discourse.git
synced 2025-03-21 20:15:43 +08:00
Merge pull request #1145 from abbat/yandex-workaround
Workaround solution to help Yandex crawler index discourse.
This commit is contained in:
commit
7335f5fb7f
@ -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 old crawlers which ignores <noscript>
|
||||
# (see http://meta.discourse.org/t/noscript-tag-and-some-search-engines/8078)
|
||||
return render 'topics/plain', layout: false if (SiteSetting.enable_escaped_fragments && params.has_key?('_escaped_fragment_'))
|
||||
|
||||
View.create_for(@topic_view.topic, request.remote_ip, current_user)
|
||||
track_visit_to_topic
|
||||
perform_show_response
|
||||
|
@ -78,6 +78,10 @@ module ApplicationHelper
|
||||
end
|
||||
end
|
||||
|
||||
# Add workaround tag for old crawlers which ignores <noscript>
|
||||
# (see https://developers.google.com/webmasters/ajax-crawling/docs/specification)
|
||||
result << tag('meta', name: "fragment", content: "!") if SiteSetting.enable_escaped_fragments
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
|
@ -26,6 +26,8 @@ class SiteSetting < ActiveRecord::Base
|
||||
client_setting(:must_approve_users, false)
|
||||
client_setting(:ga_tracking_code, "")
|
||||
client_setting(:ga_domain_name, "")
|
||||
client_setting(:enable_escaped_fragments, false)
|
||||
client_setting(:enable_noscript_support, true)
|
||||
client_setting(:enable_long_polling, true)
|
||||
client_setting(:polling_interval, 3000)
|
||||
client_setting(:anon_polling_interval, 30000)
|
||||
|
19
app/views/topics/plain.html.erb
Normal file
19
app/views/topics/plain.html.erb
Normal file
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="<%=SiteSetting.default_locale%>">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title><%= render_topic_title(@topic_view.topic) %></title>
|
||||
</head>
|
||||
<body>
|
||||
<% @topic_view.posts.each do |post| %>
|
||||
<% if post.user %>
|
||||
<div>
|
||||
#<%=post.post_number%> <%= t 'by'%>: <b><%= post.user.name %></b>, <%= post.created_at.to_formatted_s(:long_ordinal) %>
|
||||
</div>
|
||||
<div>
|
||||
<%= post.cooked.html_safe %>
|
||||
</div>
|
||||
<hr/>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</body>
|
@ -500,6 +500,8 @@ 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"
|
||||
enable_escaped_fragments: "Enable workaround solution to help old crawlers to index your site. WARNING: enable it only if you are really have to do it."
|
||||
enable_noscript_support: "Enable supporting <noscipt> tag"
|
||||
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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user