2013-02-10 19:02:57 -05:00
|
|
|
class RobotsTxtController < ApplicationController
|
|
|
|
layout false
|
2017-08-31 00:06:56 -04:00
|
|
|
skip_before_action :preload_json, :check_xhr, :redirect_to_login_if_required
|
2013-02-10 19:02:57 -05:00
|
|
|
|
2018-04-11 16:05:02 -04:00
|
|
|
# NOTE: order is important!
|
|
|
|
DISALLOWED_PATHS ||= %w{
|
|
|
|
/auth/cas
|
|
|
|
/auth/facebook/callback
|
|
|
|
/auth/twitter/callback
|
|
|
|
/auth/google/callback
|
|
|
|
/auth/yahoo/callback
|
|
|
|
/auth/github/callback
|
|
|
|
/auth/cas/callback
|
|
|
|
/assets/browser-update*.js
|
|
|
|
/users/
|
|
|
|
/u/
|
|
|
|
/badges/
|
|
|
|
/search
|
|
|
|
/search/
|
|
|
|
/tags
|
|
|
|
/tags/
|
|
|
|
/email/
|
|
|
|
/session
|
|
|
|
/session/
|
|
|
|
/admin
|
|
|
|
/admin/
|
|
|
|
/user-api-key
|
|
|
|
/user-api-key/
|
|
|
|
/*?api_key*
|
|
|
|
/*?*api_key*
|
|
|
|
/groups
|
|
|
|
/groups/
|
|
|
|
/t/*/*.rss
|
|
|
|
/tags/*.rss
|
|
|
|
/c/*.rss
|
|
|
|
}
|
|
|
|
|
2013-02-10 19:02:57 -05:00
|
|
|
def index
|
2018-03-15 17:10:45 -04:00
|
|
|
if SiteSetting.allow_index_in_robots_txt
|
|
|
|
path = :index
|
2018-04-05 20:15:23 -04:00
|
|
|
|
2018-04-11 16:05:02 -04:00
|
|
|
@crawler_delayed_agents = SiteSetting.slow_down_crawler_user_agents.split('|').map { |agent|
|
|
|
|
[agent, SiteSetting.slow_down_crawler_rate]
|
|
|
|
}
|
2018-04-05 20:15:23 -04:00
|
|
|
|
2018-03-15 17:10:45 -04:00
|
|
|
if SiteSetting.whitelisted_crawler_user_agents.present?
|
|
|
|
@allowed_user_agents = SiteSetting.whitelisted_crawler_user_agents.split('|')
|
|
|
|
@disallowed_user_agents = ['*']
|
|
|
|
elsif SiteSetting.blacklisted_crawler_user_agents.present?
|
|
|
|
@allowed_user_agents = ['*']
|
|
|
|
@disallowed_user_agents = SiteSetting.blacklisted_crawler_user_agents.split('|')
|
|
|
|
else
|
|
|
|
@allowed_user_agents = ['*']
|
|
|
|
end
|
|
|
|
else
|
|
|
|
path = :no_index
|
|
|
|
end
|
|
|
|
|
2013-02-10 19:02:57 -05:00
|
|
|
render path, content_type: 'text/plain'
|
|
|
|
end
|
|
|
|
end
|