Sha256: 88f579dd57f3a2b9f2c614aa7cc0bcc5fbc03790eda5dc4fdc7e0bd9398fd4dd

Contents?: true

Size: 755 Bytes

Versions: 11

Compression:

Stored size: 755 Bytes

Contents

module Shutterbug
  module Handlers
    class FileHandler

      # relative url
      def self.path_prefix
        "#{Configuration.instance.path_prefix}/get_file"
      end

      # absolute url
      def self.uri_prefix
        "#{Configuration.instance.uri_prefix}#{self.path_prefix}"
      end

      def self.regex
        filename_matcher = "(([^\/|\.]+)\.?([^\/]+))?"
        /#{self.path_prefix}\/#{filename_matcher}/
      end

      def handle(helper, req, env)
        filename = self.class.regex.match(req.path)[1]
        if File.extname(filename) == ''
          filename += '.html'
        end
        file = Configuration.instance.storage.new(filename)
        helper.response(file.get_content, file.mime_type)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
shutterbug-0.5.9 lib/shutterbug/handlers/file_handler.rb
shutterbug-0.5.8 lib/shutterbug/handlers/file_handler.rb
shutterbug-0.5.7 lib/shutterbug/handlers/file_handler.rb
shutterbug-0.5.6 lib/shutterbug/handlers/file_handler.rb
shutterbug-0.5.5 lib/shutterbug/handlers/file_handler.rb
shutterbug-0.5.4 lib/shutterbug/handlers/file_handler.rb
shutterbug-0.5.3 lib/shutterbug/handlers/file_handler.rb
shutterbug-0.5.2 lib/shutterbug/handlers/file_handler.rb
shutterbug-0.5.1 lib/shutterbug/handlers/file_handler.rb
shutterbug-0.5.0 lib/shutterbug/handlers/file_handler.rb
shutterbug-0.4.3 lib/shutterbug/handlers/file_handler.rb