Class: Shutterbug::Handlers::FileHandler
- Inherits:
-
Object
- Object
- Shutterbug::Handlers::FileHandler
- Defined in:
- lib/shutterbug/handlers/file_handler.rb
Class Method Summary collapse
-
.path_prefix ⇒ Object
relative url.
- .regex ⇒ Object
-
.uri_prefix ⇒ Object
absolute url.
Instance Method Summary collapse
Class Method Details
.path_prefix ⇒ Object
relative url
6 7 8 |
# File 'lib/shutterbug/handlers/file_handler.rb', line 6 def self.path_prefix "#{Configuration.instance.path_prefix}/get_file" end |
.regex ⇒ Object
15 16 17 18 |
# File 'lib/shutterbug/handlers/file_handler.rb', line 15 def self.regex filename_matcher = "(([^\/|\.]+)\.?([^\/]+))?" /#{self.path_prefix}\/#{filename_matcher}/ end |
.uri_prefix ⇒ Object
absolute url
11 12 13 |
# File 'lib/shutterbug/handlers/file_handler.rb', line 11 def self.uri_prefix "#{Configuration.instance.uri_prefix}#{self.path_prefix}" end |
Instance Method Details
#handle(helper, req, env) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/shutterbug/handlers/file_handler.rb', line 20 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 |