##// END OF EJS Templates
Replaces the obsolete robots.txt with a cached action (#2491)....
Jean-Philippe Lang -
r2317:e1f96ca4db64
parent child
Show More
@@ -0,0 +1,9
1 User-agent: *
2 <% @projects.each do |p| -%>
3 Disallow: /projects/<%= p.to_param %>/repository
4 Disallow: /projects/<%= p.to_param %>/issues
5 Disallow: /projects/<%= p.to_param %>/activity
6 <% end -%>
7 Disallow: /issues/gantt
8 Disallow: /issues/calendar
9 Disallow: /activity
@@ -29,6 +29,12 class ProjectsController < ApplicationController
29 before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ]
29 before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ]
30 accept_key_auth :activity
30 accept_key_auth :activity
31
31
32 after_filter :only => [:add, :edit, :archive, :unarchive, :destroy] do |controller|
33 if controller.request.post?
34 controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt'
35 end
36 end
37
32 helper :sort
38 helper :sort
33 include SortHelper
39 include SortHelper
34 helper :custom_fields
40 helper :custom_fields
@@ -16,9 +16,15
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class WelcomeController < ApplicationController
18 class WelcomeController < ApplicationController
19 caches_action :robots
19
20
20 def index
21 def index
21 @news = News.latest User.current
22 @news = News.latest User.current
22 @projects = Project.latest User.current
23 @projects = Project.latest User.current
23 end
24 end
25
26 def robots
27 @projects = Project.public.active
28 render :layout => false, :content_type => 'text/plain'
29 end
24 end
30 end
@@ -67,6 +67,7 class Project < ActiveRecord::Base
67
67
68 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] } }
68 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] } }
69 named_scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"}
69 named_scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"}
70 named_scope :public, { :conditions => { :is_public => true } }
70 named_scope :visible, lambda { { :conditions => Project.visible_by(User.current) } }
71 named_scope :visible, lambda { { :conditions => Project.visible_by(User.current) } }
71
72
72 def identifier=(identifier)
73 def identifier=(identifier)
@@ -250,4 +250,5 ActionController::Routing::Routes.draw do |map|
250
250
251 # Install the default route as the lowest priority.
251 # Install the default route as the lowest priority.
252 map.connect ':controller/:action/:id'
252 map.connect ':controller/:action/:id'
253 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
253 end
254 end
@@ -60,4 +60,11 class WelcomeControllerTest < Test::Unit::TestCase
60 get :index
60 get :index
61 assert_equal :fr, @controller.current_language
61 assert_equal :fr, @controller.current_language
62 end
62 end
63
64 def test_robots
65 get :robots
66 assert_response :success
67 assert_equal 'text/plain', @response.content_type
68 assert @response.body.match(%r{^Disallow: /projects/ecookbook/issues$})
69 end
63 end
70 end
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now