Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 715

Show
Ignore:
Timestamp:
02/20/05 17:18:59 (4 years ago)
Author:
david
Message:

Made caching work for WEBrick and lighttpd by appending .html for all URLs not already containing a dot

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/caching.rb

    r525 r715  
    9191        private 
    9292          def page_cache_path(path) 
    93             if path[-1,1] == '/' 
    94               page_cache_directory + path + '/index' 
    95             else 
    96               page_cache_directory + path 
    97             end 
     93            page_cache_directory + path + ".html" 
    9894          end 
    9995      end 
     
    116112      #   cache_page "I'm the cached content", :controller => "lists", :action => "show" 
    117113      def cache_page(content = nil, options = {}) 
     114        logger.info "Cached page: #{options.inspect} || #{caching_allowed}" 
    118115        return unless perform_caching && caching_allowed 
    119116        self.class.cache_page(content || @response.body, url_for(options.merge({ :only_path => true }))) 
     
    122119      private 
    123120        def caching_allowed 
    124           !@request.post? && (@request.parameters.reject { |k, v| %w( id action controller ).include?(k) }).empty? 
     121          !@request.post? 
    125122        end 
    126123    end 
  • trunk/actionpack/lib/action_controller/components.rb

    r713 r715  
    66        def render_component(options)  
    77          @controller.logger.info("Start rendering component (#{options.inspect}): ") 
    8           @controller.send(:component_response, options).body 
     8          result = @controller.send(:component_response, options).body 
    99          @controller.logger.info("\n\nEnd of component rendering") 
     10          return result 
    1011        end 
    1112      end 
     
    1617        response = component_response(options) 
    1718        logger.info "Rendering component (#{options.inspect}): " 
    18         render_text(response.body, response.headers["Status"]) 
     19        result = render_text(response.body, response.headers["Status"]) 
    1920        logger.info("\n\nEnd of component rendering") 
     21        return result 
    2022      end 
    2123   
  • trunk/railties/lib/webrick_server.rb

    r617 r715  
    66 
    77include WEBrick 
     8 
    89 
    910class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet 
     
    4344  def handle_file(req, res) 
    4445    begin 
     46      add_dot_html(req) 
    4547      @file_handler.send(:do_GET, req, res) 
     48      remove_dot_html(req) 
    4649      return true 
    4750    rescue HTTPStatus::PartialContent, HTTPStatus::NotModified => err 
     
    5053    rescue => err 
    5154      return false 
     55    ensure 
     56      remove_dot_html(req) 
    5257    end 
     58  end 
     59 
     60  def add_dot_html(req) 
     61    if /^([^.]+)$/ =~ req.path then req.instance_variable_set(:@path_info, "#{$1}.html") end 
     62  end 
     63   
     64  def remove_dot_html(req) 
     65    if /^([^.]+).html$/ =~ req.path then req.instance_variable_set(:@path_info, $1) end 
    5366  end 
    5467