capcode-render-static 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,3 +1,14 @@
1
1
  = capcode-render-static
2
2
 
3
3
  Capcode plugin to render static file
4
+
5
+ = History
6
+
7
+ * 0.3.0 :
8
+ ** Add mime/type detection
9
+
10
+ * 0.2.0 :
11
+ ** Bug correction
12
+
13
+ * 0.1.0 :
14
+ ** Initial release
data/Rakefile CHANGED
@@ -10,6 +10,8 @@ begin
10
10
  gem.email = "gregoire.lejeune@free.fr"
11
11
  gem.homepage = "http://github.com/glejeune/Capcode.more/tree/master/%s" % gem.name
12
12
  gem.authors = ["Gregoire Lejeune"]
13
+
14
+ gem.add_dependency('mime-types')
13
15
  end
14
16
  Jeweler::GemcutterTasks.new
15
17
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{capcode-render-static}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gregoire Lejeune"]
12
- s.date = %q{2010-01-07}
12
+ s.date = %q{2010-02-08}
13
13
  s.description = %q{Capcode plugin to render static file}
14
14
  s.email = %q{gregoire.lejeune@free.fr}
15
15
  s.extra_rdoc_files = [
@@ -39,9 +39,12 @@ Gem::Specification.new do |s|
39
39
  s.specification_version = 3
40
40
 
41
41
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
42
+ s.add_runtime_dependency(%q<mime-types>, [">= 0"])
42
43
  else
44
+ s.add_dependency(%q<mime-types>, [">= 0"])
43
45
  end
44
46
  else
47
+ s.add_dependency(%q<mime-types>, [">= 0"])
45
48
  end
46
49
  end
47
50
 
@@ -1,3 +1,6 @@
1
+ require 'rubygems'
2
+ require 'mime/types'
3
+
1
4
  module Capcode
2
5
  module Helpers
3
6
  def render_static( f, opts = {} ) #:nodoc:
@@ -5,14 +8,17 @@ module Capcode
5
8
  opts = { :exact_path => true }.merge(opts)
6
9
  opts = (Capcode::Configuration.options[:static] || {}).merge(opts)
7
10
 
8
- # Update Content-Type
9
- @response['Content-Type'] = opts[:content_type] if opts.keys.include?(:content_type)
10
-
11
11
  # Path with ".." not allowed
12
12
  if Capcode.static.nil? or f.include? '..'
13
13
  return [403, {}, '403 - Invalid path']
14
14
  end
15
15
 
16
+ # Update Content-Type
17
+ if opts.keys.include?(:content_type)
18
+ @response['Content-Type'] = opts[:content_type]
19
+ else
20
+ @response['Content-Type'] = MIME::Types.type_for(File.join( static[:path], f ))[0].content_type
21
+ end
16
22
 
17
23
  if !opts.keys.include?(:exact_path) or opts[:exact_path] == true
18
24
  redirect File.join( static[:uri], f )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capcode-render-static
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregoire Lejeune
@@ -9,10 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-07 00:00:00 +01:00
12
+ date: 2010-02-08 00:00:00 +01:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mime-types
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
16
25
  description: Capcode plugin to render static file
17
26
  email: gregoire.lejeune@free.fr
18
27
  executables: []