Commit e1f96ca4 authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Replaces the obsolete robots.txt with a cached action (#2491).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2319 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 6c93b8d5
......@@ -29,6 +29,12 @@ class ProjectsController < ApplicationController
before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ]
accept_key_auth :activity
after_filter :only => [:add, :edit, :archive, :unarchive, :destroy] do |controller|
if controller.request.post?
controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt'
end
end
helper :sort
include SortHelper
helper :custom_fields
......
......@@ -16,9 +16,15 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class WelcomeController < ApplicationController
caches_action :robots
def index
@news = News.latest User.current
@projects = Project.latest User.current
end
def robots
@projects = Project.public.active
render :layout => false, :content_type => 'text/plain'
end
end
......@@ -67,6 +67,7 @@ class Project < ActiveRecord::Base
named_scope :has_module, lambda { |mod| { :conditions => ["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s] } }
named_scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"}
named_scope :public, { :conditions => { :is_public => true } }
named_scope :visible, lambda { { :conditions => Project.visible_by(User.current) } }
def identifier=(identifier)
......
User-agent: *
<% @projects.each do |p| -%>
Disallow: /projects/<%= p.to_param %>/repository
Disallow: /projects/<%= p.to_param %>/issues
Disallow: /projects/<%= p.to_param %>/activity
<% end -%>
Disallow: /issues/gantt
Disallow: /issues/calendar
Disallow: /activity
......@@ -250,4 +250,5 @@ ActionController::Routing::Routes.draw do |map|
# Install the default route as the lowest priority.
map.connect ':controller/:action/:id'
map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
end
User-agent: *
Disallow: /projects/gantt
Disallow: /projects/calendar
Disallow: /repositories/diff
......@@ -60,4 +60,11 @@ class WelcomeControllerTest < Test::Unit::TestCase
get :index
assert_equal :fr, @controller.current_language
end
def test_robots
get :robots
assert_response :success
assert_equal 'text/plain', @response.content_type
assert @response.body.match(%r{^Disallow: /projects/ecookbook/issues$})
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment