rack-jekyll 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,12 @@ module Rack
21
21
  end
22
22
  mime = mime(path_info)
23
23
  body = "Jekyll/Rack"
24
- [200, {"Content-Type" => mime, "Content-length" => body.length.to_s}, [body]]
24
+ time = "Thu, 01 Apr 2010 15:27:52 GMT"
25
+ if time == request.env['HTTP_IF_MODIFIED_SINCE']
26
+ [304, {'Last-Modified' => time}, []]
27
+ else
28
+ [200, {"Content-Type" => mime, "Content-length" => body.length.to_s, "Last-Modified" => "Thu, 01 Apr 2010 15:27:52 GMT"}, [body]]
29
+ end
25
30
  else
26
31
  status, body, path_info = [404,"Not found","404.html"]
27
32
  mime = mime(path_info)
@@ -1,7 +1,7 @@
1
1
  module Rack
2
2
  class Jekyll
3
3
  def self.version
4
- '0.3.4'
4
+ '0.3.5'
5
5
  end
6
6
  end
7
7
  end
data/lib/rack/jekyll.rb CHANGED
@@ -9,14 +9,15 @@ module Rack
9
9
  if ::File.exist?(Dir.pwd + "/_config.yml")
10
10
  @config = ::YAML.load(::File.read(Dir.pwd + "/_config.yml"))
11
11
  @config = (@config.class == FalseClass ? {} : @config)
12
- if @config[:desination].nil?
13
- @path = opts[:desination].nil? ? "_site" : opts[:desination]
12
+ if @config[:destination].nil?
13
+ @path = opts[:destination].nil? ? "_site" : opts[:destination]
14
14
  else
15
15
  opts.merge!(@config)
16
- @path = @config[:desination].nil? ? "_site" : @config[:desination]
16
+ @path = @config[:destination].nil? ? "_site" : @config[:destination]
17
17
  end
18
18
  end
19
19
  @files = ::Dir[@path + "/**/*"].inspect
20
+ p @files if ENV['RACK_DEBUG'] == "true"
20
21
  @mimes = Rack::Mime::MIME_TYPES.map{|k,v| /#{k.gsub('.','\.')}$/i }
21
22
  @compiling = false
22
23
  if ::Dir[@path + "/**/*"].empty?
@@ -41,10 +42,19 @@ module Rack
41
42
  end
42
43
  end
43
44
  mime = mime(path_info)
44
- body = content(::File.expand_path(@path + path_info))
45
- [200, {"Content-Type" => mime, "Content-length" => body.length.to_s}, [body]]
45
+
46
+ file = file_info(@path + path_info)
47
+ body = file[:body]
48
+ time = file[:time]
49
+
50
+ if time == request.env['HTTP_IF_MODIFIED_SINCE']
51
+ [304, {'Last-Modified' => time}, []]
52
+ else
53
+ [200, {"Content-Type" => mime, "Content-length" => body.length.to_s, 'Last-Modified' => time}, [body]]
54
+ end
55
+
46
56
  else
47
- status, body, path_info = ::File.exist?(@path+"/404.html") ? [200,content(@path+"/404.html"),"404.html"] : [404,"Not found","404.html"]
57
+ status, body, path_info = ::File.exist?(@path+"/404.html") ? [404,file_info(@path+"/404.html")[:body],"404.html"] : [404,"Not found","404.html"]
48
58
  mime = mime(path_info)
49
59
  if !@compiling
50
60
  [status, {"Content-Type" => mime, "Content-Type" => body.length.to_s}, [body]]
@@ -53,9 +63,14 @@ module Rack
53
63
  end
54
64
  end
55
65
  end
56
- def content(file)
57
- ::File.read(file)
66
+
67
+ def file_info(path)
68
+ expand_path = ::File.expand_path(path)
69
+ ::File.open(expand_path, 'r') do |f|
70
+ {:body => f.read, :time => f.mtime.httpdate, :expand_path => expand_path}
71
+ end
58
72
  end
73
+
59
74
  def mime(path_info)
60
75
  if path_info !~ /html$/i
61
76
  ext = $1 if path_info =~ /(\.\S+)$/
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 5
9
+ version: 0.3.5
5
10
  platform: ruby
6
11
  authors:
7
12
  - Bryan Goines
@@ -9,39 +14,45 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-01 00:00:00 -06:00
17
+ date: 2010-04-01 00:00:00 -05:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: jekyll
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :runtime
31
+ version_requirements: *id001
25
32
  - !ruby/object:Gem::Dependency
26
33
  name: rack
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
33
41
  version: "0"
34
- version:
42
+ type: :runtime
43
+ version_requirements: *id002
35
44
  - !ruby/object:Gem::Dependency
36
45
  name: bacon
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
40
48
  requirements:
41
49
  - - ">="
42
50
  - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
43
53
  version: "0"
44
- version:
54
+ type: :development
55
+ version_requirements: *id003
45
56
  description: Transform your jekyll based app into a Rack application
46
57
  email: bryan@ffiirree.com
47
58
  executables: []
@@ -56,7 +67,7 @@ files:
56
67
  - lib/rack/jekyll.rb
57
68
  - lib/rack/jekyll/test.rb
58
69
  - lib/rack/jekyll/version.rb
59
- has_rdoc: false
70
+ has_rdoc: true
60
71
  homepage: http://github.com/bry4n/rack-jekyll
61
72
  licenses: []
62
73
 
@@ -69,18 +80,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
80
  requirements:
70
81
  - - ">="
71
82
  - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
72
85
  version: "0"
73
- version:
74
86
  required_rubygems_version: !ruby/object:Gem::Requirement
75
87
  requirements:
76
88
  - - ">="
77
89
  - !ruby/object:Gem::Version
90
+ segments:
91
+ - 0
78
92
  version: "0"
79
- version:
80
93
  requirements: []
81
94
 
82
95
  rubyforge_project: rack-jekyll
83
- rubygems_version: 1.3.5
96
+ rubygems_version: 1.3.6
84
97
  signing_key:
85
98
  specification_version: 1
86
99
  summary: rack-jekyll