##// 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 29 before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ]
30 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 38 helper :sort
33 39 include SortHelper
34 40 helper :custom_fields
@@ -16,9 +16,15
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class WelcomeController < ApplicationController
19 caches_action :robots
19 20
20 21 def index
21 22 @news = News.latest User.current
22 23 @projects = Project.latest User.current
23 24 end
25
26 def robots
27 @projects = Project.public.active
28 render :layout => false, :content_type => 'text/plain'
29 end
24 30 end
@@ -67,6 +67,7 class Project < ActiveRecord::Base
67 67
68 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 69 named_scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"}
70 named_scope :public, { :conditions => { :is_public => true } }
70 71 named_scope :visible, lambda { { :conditions => Project.visible_by(User.current) } }
71 72
72 73 def identifier=(identifier)
@@ -250,4 +250,5 ActionController::Routing::Routes.draw do |map|
250 250
251 251 # Install the default route as the lowest priority.
252 252 map.connect ':controller/:action/:id'
253 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
253 254 end
@@ -60,4 +60,11 class WelcomeControllerTest < Test::Unit::TestCase
60 60 get :index
61 61 assert_equal :fr, @controller.current_language
62 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 70 end
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now