guard-jekyll-plus 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +5 -5
- data/README.md +20 -1
- data/lib/guard/jekyll-plus/version.rb +1 -1
- data/lib/guard/jekyll-plus.rb +33 -12
- data/lib/rack/config.ru +37 -0
- data/test/404.html +12 -0
- data/test/Gemfile +1 -0
- data/test/Gemfile.lock +2 -0
- metadata +4 -2
data/CHANGELOG.md
CHANGED
@@ -42,3 +42,9 @@ New config options
|
|
42
42
|
### 1.3.0
|
43
43
|
|
44
44
|
- Changed guard name to jekyll-plus to help Guard properly init the Guardfile.
|
45
|
+
|
46
|
+
### 1.4.0
|
47
|
+
|
48
|
+
- Now allowing Rack server as an alternative to Jekyll's WEBrick server.
|
49
|
+
- Ships with an internal config for Rack, but users can override it in the guard config options.
|
50
|
+
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
guard-jekyll-plus (1.
|
4
|
+
guard-jekyll-plus (1.3.0)
|
5
5
|
guard (>= 1.1.0)
|
6
6
|
jekyll (>= 1.0.0)
|
7
7
|
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
fast-stemmer (>= 1.0.0)
|
13
13
|
coderay (1.0.9)
|
14
14
|
colorator (0.1)
|
15
|
-
commander (4.1.
|
15
|
+
commander (4.1.4)
|
16
16
|
highline (~> 1.6.11)
|
17
17
|
directory_watcher (1.4.1)
|
18
18
|
fast-stemmer (1.0.2)
|
@@ -25,19 +25,19 @@ GEM
|
|
25
25
|
pry (>= 0.9.10)
|
26
26
|
thor (>= 0.14.6)
|
27
27
|
highline (1.6.19)
|
28
|
-
jekyll (1.1.
|
28
|
+
jekyll (1.1.2)
|
29
29
|
classifier (~> 1.3)
|
30
30
|
colorator (~> 0.1)
|
31
31
|
commander (~> 4.1.3)
|
32
32
|
directory_watcher (~> 1.4.1)
|
33
33
|
kramdown (~> 1.0.2)
|
34
|
-
liquid (~> 2.
|
34
|
+
liquid (~> 2.5.1)
|
35
35
|
maruku (~> 0.5)
|
36
36
|
pygments.rb (~> 0.5.0)
|
37
37
|
redcarpet (~> 2.2.2)
|
38
38
|
safe_yaml (~> 0.7.0)
|
39
39
|
kramdown (1.0.2)
|
40
|
-
liquid (2.5.
|
40
|
+
liquid (2.5.1)
|
41
41
|
listen (1.2.2)
|
42
42
|
rb-fsevent (>= 0.9.3)
|
43
43
|
rb-inotify (>= 0.9)
|
data/README.md
CHANGED
@@ -75,15 +75,34 @@ This guard has two configurations.
|
|
75
75
|
|:--------------|:-------------------------------------------------|:-----------------------------------------------------------------------------------|
|
76
76
|
| `extensions` | Array of file extensions to trigger Jekyll build | ['md', 'mkd', 'mkdn', 'markdown', 'textile', 'html', 'haml', 'slim', 'xml', 'yml'] |
|
77
77
|
| `config` | Array of configuration files | ['_config.yml'] |
|
78
|
-
| `serve` |
|
78
|
+
| `serve` | Serve your site with Jekyll or a Rack server | false |
|
79
79
|
| `drafts` | Build your site with draft posts | false |
|
80
80
|
| `future` | Build your site with future dated posts | false |
|
81
81
|
| `config_hash` | Use a config hash instead of an array of files | nil |
|
82
82
|
| `silent` | Slience all output other than exception message | false |
|
83
83
|
| `msg_prefix` | Output messages are prefixed with with this | 'Jekyll' |
|
84
|
+
| `rack_config` | Optional configuration for using the rack server | nil |
|
84
85
|
|
85
86
|
**Note:** customizations to the `extensions` configuration are additive.
|
86
87
|
|
88
|
+
### Using Jekyll Server
|
89
|
+
|
90
|
+
To use Jekyll's built-in server, simply set `:server => true` in your rack options
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
guard "jekyll-plus", :server => true do
|
94
|
+
watch /.*/
|
95
|
+
ignore /^_site/
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
### Using Rack Server
|
100
|
+
|
101
|
+
Simply add `gem 'rack'` to your Gemfile and Jekyll Plus will use Rack instead with a [config file](lib/rack/config.ru) which redirects `404s` and auto-appends `index.html` to directory urls.
|
102
|
+
If you want to use [Thin](https://github.com/macournoyer/thin/), add `gem 'thin'` instead.
|
103
|
+
|
104
|
+
If you wish to use your own rack server configuration, simply drop a `config.ru` file into your site root, or use the option `:rack_config => 'path/to/config.ru'` to tell Jeklly Plus where to look for your rack config file.
|
105
|
+
|
87
106
|
### Configuring Jekyll watched file extensions
|
88
107
|
|
89
108
|
Here's how you would add `txt` to the list of file extensions which triggers a Jekyll build.
|
data/lib/guard/jekyll-plus.rb
CHANGED
@@ -4,6 +4,12 @@ require 'guard'
|
|
4
4
|
require 'guard/guard'
|
5
5
|
|
6
6
|
require 'jekyll'
|
7
|
+
#begin require 'thin' rescue false end
|
8
|
+
begin
|
9
|
+
require 'rack'
|
10
|
+
USE_RACK = true
|
11
|
+
rescue LoadError
|
12
|
+
end
|
7
13
|
|
8
14
|
module Guard
|
9
15
|
class Jekyllplus < Guard
|
@@ -14,14 +20,15 @@ module Guard
|
|
14
20
|
default_extensions = ['md','mkd','mkdn','markdown','textile','html','haml','slim','xml','yml']
|
15
21
|
|
16
22
|
@options = {
|
17
|
-
:extensions
|
18
|
-
:config
|
19
|
-
:serve
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
23
|
+
:extensions => [],
|
24
|
+
:config => ['_config.yml'],
|
25
|
+
:serve => false,
|
26
|
+
:rack_config => nil,
|
27
|
+
:drafts => false,
|
28
|
+
:future => false,
|
29
|
+
:config_hash => nil,
|
30
|
+
:silent => false,
|
31
|
+
:msg_prefix => 'Jekyll'
|
25
32
|
}.merge(options)
|
26
33
|
|
27
34
|
# The config_hash option should be a hash ready to be consumed by Jekyll's Site class.
|
@@ -51,6 +58,8 @@ module Guard
|
|
51
58
|
# Create a Jekyll site
|
52
59
|
#
|
53
60
|
@site = ::Jekyll::Site.new @config
|
61
|
+
@rack = ::Rack::Server.new(rack_config) if USE_RACK
|
62
|
+
puts @rack
|
54
63
|
|
55
64
|
end
|
56
65
|
|
@@ -199,13 +208,20 @@ module Guard
|
|
199
208
|
if options[:config_hash]
|
200
209
|
config = options[:config_hash]
|
201
210
|
elsif options[:config]
|
202
|
-
|
203
|
-
|
204
|
-
config = { "config" => config_files}
|
211
|
+
options[:config] = [options[:config]] unless options[:config].is_a? Array
|
212
|
+
config = options
|
205
213
|
end
|
206
214
|
::Jekyll.configuration(config)
|
207
215
|
end
|
208
216
|
|
217
|
+
def rack_config
|
218
|
+
default_config = File.expand_path("../rack/config.ru", File.dirname(__FILE__))
|
219
|
+
local_config = File.exist? 'config.ru' ? 'config.ru' : nil
|
220
|
+
config = (@config['rack_config'] || local_config || default_config)
|
221
|
+
puts config
|
222
|
+
{ :config => config, :Port => @config['port'], :Host => @config['host'] }
|
223
|
+
end
|
224
|
+
|
209
225
|
def local_path(path)
|
210
226
|
Dir.chdir('.')
|
211
227
|
current = Dir.pwd
|
@@ -231,7 +247,11 @@ module Guard
|
|
231
247
|
end
|
232
248
|
|
233
249
|
def server(config)
|
234
|
-
|
250
|
+
if @rack
|
251
|
+
proc{ Process.fork { @rack.start } }
|
252
|
+
else
|
253
|
+
proc{ Process.fork { ::Jekyll::Commands::Serve.process(config) } }
|
254
|
+
end
|
235
255
|
end
|
236
256
|
|
237
257
|
def kill
|
@@ -244,6 +264,7 @@ module Guard
|
|
244
264
|
end
|
245
265
|
|
246
266
|
def stop_server
|
267
|
+
#@rack.stop if @rack
|
247
268
|
if alive?
|
248
269
|
instance_eval do
|
249
270
|
kill.call(@pid)
|
data/lib/rack/config.ru
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Rack
|
2
|
+
|
3
|
+
class TryStatic
|
4
|
+
|
5
|
+
def initialize(app, options)
|
6
|
+
@app = app
|
7
|
+
@try = ['', *options.delete(:try)]
|
8
|
+
@static = ::Rack::Static.new(lambda { [404, {}, []] }, options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
orig_path = env['PATH_INFO']
|
13
|
+
found = nil
|
14
|
+
@try.each do |path|
|
15
|
+
resp = @static.call(env.merge!({'PATH_INFO' => orig_path + path}))
|
16
|
+
break if 404 != resp[0] && found = resp
|
17
|
+
end
|
18
|
+
found or @app.call(env.merge!('PATH_INFO' => orig_path))
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def start_rack(root, not_found)
|
26
|
+
use Rack::TryStatic, :root => root, :urls => %w[/], :try => ['.html', 'index.html', '/index.html']
|
27
|
+
|
28
|
+
# Run your own Rack app here or use this one to serve 404 messages:
|
29
|
+
run lambda{ |env|
|
30
|
+
not_found_page = File.exist?(not_found) ? [File.read(not_found)] : ['404 - page not found']
|
31
|
+
[ 404, { 'Content-Type' => 'text/html' }, not_found_page ]
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
root = ENV['RACK_ROOT'] || '_site'
|
36
|
+
|
37
|
+
start_rack root, "#{root}/404.html"
|
data/test/404.html
ADDED
data/test/Gemfile
CHANGED
data/test/Gemfile.lock
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-jekyll-plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
@@ -61,7 +61,9 @@ files:
|
|
61
61
|
- lib/guard/jekyll-plus.rb
|
62
62
|
- lib/guard/jekyll-plus/templates/Guardfile
|
63
63
|
- lib/guard/jekyll-plus/version.rb
|
64
|
+
- lib/rack/config.ru
|
64
65
|
- test/.gitignore
|
66
|
+
- test/404.html
|
65
67
|
- test/Gemfile
|
66
68
|
- test/Gemfile.lock
|
67
69
|
- test/Guardfile
|