rack-jekyll 0.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +29 -6
- data/lib/rack/jekyll.rb +21 -6
- data/lib/rack/jekyll/test.rb +12 -11
- data/lib/rack/jekyll/version.rb +7 -0
- metadata +3 -2
data/README.markdown
CHANGED
@@ -3,7 +3,12 @@ Rack-Jekyll
|
|
3
3
|
|
4
4
|
Transform your [Jekyll](http://github.com/mojombo/jekyll) app into [Rack](http://github.com/rack/rack) application
|
5
5
|
|
6
|
-
|
6
|
+
- Can run it with rackup and [shotgun](http://github.com/rtomakyo/shotgun), [unicorn](http://github.com/defunkt/unicorn), and more.
|
7
|
+
|
8
|
+
- Can run rack-jekyll with any modified jekyll
|
9
|
+
|
10
|
+
- Can deploy rack-jekyll on Heroku, EC2, Slicehost, Rackspace Cloud, Dedicated server, VPS, etc..
|
11
|
+
|
7
12
|
|
8
13
|
Heroku Demo: [http://bry4n.heroku.com/](http://bry4n.heroku.com/)
|
9
14
|
|
@@ -24,7 +29,7 @@ config.ru:
|
|
24
29
|
That's it.
|
25
30
|
|
26
31
|
|
27
|
-
Heroku:
|
32
|
+
Heroku is a [read-only filesystem](http://docs.heroku.com/constraints#read-only-filesystem):
|
28
33
|
|
29
34
|
You need to generate pages and git-add pages and git-commit before you deploy your jekyll to Heroku
|
30
35
|
|
@@ -34,13 +39,31 @@ You need to generate pages and git-add pages and git-commit before you deploy yo
|
|
34
39
|
|
35
40
|
3) build pages, type: jekyll
|
36
41
|
|
37
|
-
4)
|
42
|
+
4) echo "rack-jekyll" > .gems
|
43
|
+
|
44
|
+
5) git init && git add config.ru .gems _site/*
|
38
45
|
|
39
|
-
|
46
|
+
6) git commit -m "first heroku app"
|
40
47
|
|
41
|
-
|
48
|
+
7) heroku create
|
42
49
|
|
43
|
-
|
50
|
+
8) git push heroku master
|
51
|
+
|
52
|
+
|
53
|
+
## Initialization Options
|
54
|
+
|
55
|
+
:destination - use the desintation path (default: _site)
|
56
|
+
|
57
|
+
|
58
|
+
*Example:*
|
59
|
+
|
60
|
+
run Rack::Jekyll.new(:destination => "mysite")
|
61
|
+
|
62
|
+
|
63
|
+
## YAML Config
|
64
|
+
|
65
|
+
It now can read the `_config.yml` file for destination path. Read [Jekyll Configuration](http://wiki.github.com/mojombo/jekyll/configuration)
|
66
|
+
|
44
67
|
|
45
68
|
## 404 page
|
46
69
|
|
data/lib/rack/jekyll.rb
CHANGED
@@ -6,25 +6,36 @@ module Rack
|
|
6
6
|
class Jekyll
|
7
7
|
|
8
8
|
def initialize(opts = {})
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
if ::File.exist?("_config.yml")
|
10
|
+
@config = ::YAML.load(::File.read("_config.yml"))
|
11
|
+
if @config[:desination].nil?
|
12
|
+
@path = opts[:desination].nil? ? "_site" : opts[:desination]
|
13
|
+
else
|
14
|
+
opts.merge!(@config)
|
15
|
+
@path = @config[:desination].nil? ? "_site" : @config[:desination]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
@files = ::Dir[@path + "/**/*"].inspect
|
19
|
+
@mimes = Rack::Mime::MIME_TYPES.reject{|k,v|k=~%r{html?}}.map{|k,v|%r{#{k.gsub('.','\.')}$}i}
|
20
|
+
@compiling = false
|
21
|
+
if ::Dir[@path + "/**/*"].empty?
|
12
22
|
begin
|
13
23
|
require "jekyll"
|
14
24
|
options = ::Jekyll.configuration(opts)
|
15
25
|
site = ::Jekyll::Site.new(options)
|
26
|
+
@compiling = true
|
16
27
|
site.process
|
17
28
|
rescue LoadError => boom
|
29
|
+
@compiling = false
|
18
30
|
end
|
19
31
|
end
|
20
32
|
end
|
21
|
-
|
22
33
|
def call(env)
|
23
34
|
request = Request.new(env)
|
24
35
|
path_info = request.path_info
|
25
36
|
if @files.include?(path_info)
|
26
37
|
if path_info =~ /(\/?)$/
|
27
|
-
if path_info
|
38
|
+
if @mimes.collect {|regex| path_info =~ regex }.compact.empty?
|
28
39
|
path_info += $1.nil? ? "/index.html" : "index.html"
|
29
40
|
end
|
30
41
|
end
|
@@ -34,7 +45,11 @@ module Rack
|
|
34
45
|
else
|
35
46
|
status, body, path_info = ::File.exist?(@path+"/404.html") ? [200,content(@path+"/404.html"),"404.html"] : [404,"Not found","404.html"]
|
36
47
|
mime = mime(path_info)
|
37
|
-
|
48
|
+
if !@compiling
|
49
|
+
[status, {"Content-Type" => mime, "Content-Type" => body.length.to_s}, [body]]
|
50
|
+
else
|
51
|
+
[200, {"Content-Type" => "text/plain"}, ["This site is currently generating pages. Please reload this page after 10 secs."]]
|
52
|
+
end
|
38
53
|
end
|
39
54
|
end
|
40
55
|
def content(file)
|
data/lib/rack/jekyll/test.rb
CHANGED
@@ -7,6 +7,7 @@ module Rack
|
|
7
7
|
class Test
|
8
8
|
def initialize
|
9
9
|
@files = %w{_fake/ _fake/index.html _fake/3/2/1/helloworld/index.html _fake/css/test.css _fake/js/test.js}
|
10
|
+
@mimes = Rack::Mime::MIME_TYPES.reject{|k,v|k=~%r{html?}}.map{|k,v|%r{#{k.gsub('.','\.')}$}i}
|
10
11
|
end
|
11
12
|
|
12
13
|
def call(env)
|
@@ -14,22 +15,22 @@ module Rack
|
|
14
15
|
path_info = "_fake" + request.path_info
|
15
16
|
if @files.include?(path_info)
|
16
17
|
if path_info =~ /(\/?)$/
|
17
|
-
|
18
|
+
if @mimes.collect {|regex| path_info =~ regex }.compact.empty?
|
18
19
|
path_info += $1.nil? ? "/index.html" : "index.html"
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
end
|
21
|
+
end
|
22
|
+
mime = mime(path_info)
|
23
|
+
body = "Jekyll/Rack"
|
24
|
+
[200, {"Content-Type" => mime, "Content-length" => body.length.to_s}, [body]]
|
24
25
|
else
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
status, body, path_info = [404,"Not found","404.html"]
|
27
|
+
mime = mime(path_info)
|
28
|
+
[status, {"Content-Type" => mime, "Content-Type" => body.length.to_s}, [body]]
|
28
29
|
end
|
29
30
|
end
|
30
31
|
def mime(path_info)
|
31
|
-
|
32
|
-
|
32
|
+
ext = $1 if path_info =~ /(\.\S+)$/
|
33
|
+
Mime.mime_type((ext.nil? ? ".html" : ext))
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-jekyll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Goines
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-25 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- LICENSE
|
56
56
|
- lib/rack/jekyll.rb
|
57
57
|
- lib/rack/jekyll/test.rb
|
58
|
+
- lib/rack/jekyll/version.rb
|
58
59
|
has_rdoc: false
|
59
60
|
homepage: http://github.com/bry4n/rack-jekyll
|
60
61
|
licenses: []
|