rack-jekyll 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -1,15 +1,15 @@
1
1
  Rack-Jekyll
2
2
  ===========
3
3
 
4
- Transform your Jekyll app into Rack application
4
+ Transform your [Jekyll](http://github.com/mojombo/jekyll) app into [Rack](http://github.com/rack/rack) application
5
5
 
6
- You can run it with rackup and shotgun.
6
+ You can run it with rackup and [shotgun](http://github.com/rtomakyo/shotgun).
7
7
 
8
- Demo: [http://bry4n.heroku.com/](http://bry4n.heroku.com/)
8
+ Heroku Demo: [http://bry4n.heroku.com/](http://bry4n.heroku.com/)
9
9
 
10
10
  ### How to use it?
11
11
 
12
- *config.ru* is required in order to run with shotgun and rackup. Even you can deploy your jekyll app to Heroku!
12
+ *config.ru* is required in order to run with shotgun and rackup. Even you can deploy your jekyll app to [Heroku!](http://www.heroku.com/)
13
13
 
14
14
  Copy this and put in config.ru in your jekyll's root directory.
15
15
 
@@ -24,6 +24,24 @@ config.ru:
24
24
  That's it.
25
25
 
26
26
 
27
- ## TODO
27
+ Heroku:
28
28
 
29
- Rails
29
+ You need to generate pages and git-add pages and git-commit before you deploy your jekyll to Heroku
30
+
31
+ 1) cd to your jekyll directory
32
+
33
+ 2) add config.ru (see example above)
34
+
35
+ 3) build pages, type: jekyll
36
+
37
+ 4) git init && git add .
38
+
39
+ 5) git commit -m "first heroku app"
40
+
41
+ 6) heroku create
42
+
43
+ 7) git push heroku master
44
+
45
+ ## 404 page
46
+
47
+ You can create a new file: `404.html` with YAML Front Matter. See my [Heroku Demo 404](http://bry4n.heroku.com/show/me/404/)
@@ -0,0 +1,37 @@
1
+ require "rack"
2
+ require "rack/request"
3
+ require "rack/response"
4
+
5
+ module Rack
6
+ class Jekyll
7
+ class Test
8
+ attr_accessor :config, :url
9
+ def initialize(config)
10
+ @url = ''
11
+ @config = config
12
+ @files = %w{_fake/ _fake/index.html _fake/3/2/1/helloworld/index.html _fake/css/test.css _fake/js/test.js}
13
+ end
14
+
15
+ def call(env)
16
+ request = Request.new(env)
17
+ path_info = "_fake" + request.path_info
18
+ ext = ''
19
+ if @files.include?(path_info)
20
+ if path_info =~ /(\/?)$/
21
+ if path_info !~ /\.(css|js|jpe?g|gif|png|mov|mp3)$/i
22
+ path_info += $1.nil? ? "/index.html" : "index.html"
23
+ end
24
+ ext = $1 if path_info =~ /(\.\S+)$/i
25
+ end
26
+ mime = Mime.mime_type(ext)
27
+ body = "Jekyll/Rack"
28
+ [200, {"Content-Type" => mime, "Content-length" => body.length.to_s}, [body]]
29
+ else
30
+ ext = $1 if path_info =~ /(\.\S+)$/i
31
+ mime = Mime.mime_type(ext)
32
+ [404, {"Content-Type" => mime}, ["Not found"]]
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
data/lib/rack/jekyll.rb CHANGED
@@ -9,7 +9,7 @@ module Rack
9
9
  @path = opts[:path].nil? ? "_site" : opts[:path]
10
10
  @files = Dir[@path + "/**/*"].inspect
11
11
  if Dir[@path + "/**/*"].empty?
12
- system("jekyll")
12
+ system("jekyll #{@path}")
13
13
  end
14
14
  end
15
15
 
@@ -30,7 +30,14 @@ module Rack
30
30
  else
31
31
  ext = $1 if path_info =~ /(\.\S+)$/i
32
32
  mime = Mime.mime_type(ext)
33
- [404, {"Content-Type" => mime}, ["Not found"]]
33
+ status = 404
34
+ body = "Not found"
35
+ if ::File.exist?(@path + "/404.html")
36
+ status = 200
37
+ body = ::File.read(@path + "/404.html")
38
+ mime = Mime.mime_type(".html")
39
+ end
40
+ [status, {"Content-Type" => mime, "Content-Type" => body.length.to_s}, [body]]
34
41
  end
35
42
  end
36
43
 
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: "0.1"
4
+ version: "0.2"
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-15 00:00:00 -06:00
12
+ date: 2009-12-17 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,6 +32,16 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: "0"
34
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: bacon
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
35
45
  description: Transform your jekyll based app into a Rack application
36
46
  email: bryan@ffiirree.com
37
47
  executables: []
@@ -44,6 +54,7 @@ files:
44
54
  - README.markdown
45
55
  - LICENSE
46
56
  - lib/rack/jekyll.rb
57
+ - lib/rack/jekyll/test.rb
47
58
  has_rdoc: false
48
59
  homepage: http://github.com/bry4n/rack-jekyll
49
60
  licenses: []