jekyll-serve 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0cbbadbc2dc19464faded18343b4025680af8843
4
+ data.tar.gz: 418ebeb2c3ba8cc0a1c2c7c454cc6a31ba5e32c6
5
+ SHA512:
6
+ metadata.gz: 6606038aa7b5009a09eb8c4097177687f9c7598645165a01ca59a3c9a0978170cf884a89963f19e6735a95ea17ac83bcf54d6ef33a9b6647ff46fe2d5544fc3f
7
+ data.tar.gz: 13132424928a7ccad9c4bab7ef9b387b73b8fbfc884b8dd919bb256c2d9ab5f49bd1ac91337077168fb1d501f519612465ab6289523295cd5c02619c2c9e2d3d
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Parker Moore
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ # `jekyll serve`
2
+
3
+ The `jekyll serve` command.
4
+
5
+ ## Installation
6
+
7
+ **`jekyll-serve` comes pre-installed with Jekyll 2.1 and higher**
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'jekyll-serve'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install jekyll-serve
20
+
21
+ ## Usage
22
+
23
+ ```bash
24
+ $ jekyll serve # boot up a server
25
+ $ jekyll serve --help # help for jekyll-serve
26
+ $ jekyll serve --watch # boot up a server which watches
27
+ $ jekyll serve --detach # boot up a server in the background
28
+ $ jekyll serve --port 3000 # change the port
29
+ $ jekyll serve --host parkermoo.re # change the host
30
+ $ jekyll serve --baseurl # change the baseurl (e.g. `/hi` of `http://localhost:4000/hi`) to which WEBrick mounts
31
+ $ jekyll serve --skip-initial-build # skips the site build, starts the server immediately. Useful with `--watch`.
32
+ ```
33
+
34
+ With the exception of `--detach/-B` and `--watch/-w`, any of these commands can be used together.
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it ( https://github.com/jekyll/jekyll-serve/fork )
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll-serve/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-serve"
8
+ spec.version = JekyllServe::VERSION
9
+ spec.authors = ["Parker Moore"]
10
+ spec.email = ["parkrmoore@gmail.com"]
11
+ spec.summary = %q{The `jekyll serve` command.}
12
+ spec.homepage = "https://github.com/jekyll/jekyll-serve"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "jekyll", "~> 2.0"
23
+ end
@@ -0,0 +1,5 @@
1
+ require "jekyll-serve/version"
2
+ require "jekyll/commands/serve"
3
+
4
+ module JekyllServe
5
+ end
@@ -0,0 +1,3 @@
1
+ module JekyllServe
2
+ VERSION = "1.0.0.rc1"
3
+ end
@@ -0,0 +1,129 @@
1
+ # -*- encoding: utf-8 -*-
2
+ module Jekyll
3
+ module Commands
4
+ class Serve < Command
5
+
6
+ class << self
7
+
8
+ def init_with_program(prog)
9
+ prog.command(:serve) do |c|
10
+ c.syntax 'serve [options]'
11
+ c.description 'Serve your site locally'
12
+ c.alias :server
13
+
14
+ add_build_options(c)
15
+
16
+ c.option 'detach', '-B', '--detach', 'Run the server in the background (detach)'
17
+ c.option 'port', '-P', '--port [PORT]', 'Port to listen on'
18
+ c.option 'host', '-H', '--host [HOST]', 'Host to bind to'
19
+ c.option 'baseurl', '-b', '--baseurl [URL]', 'Base URL'
20
+ c.option 'skip_initial_build', '--skip-initial-build', 'Skips the initial site build which occurs before the server is started.'
21
+
22
+ c.action do |args, options|
23
+ options["serving"] ||= true
24
+ Jekyll::Commands::Build.process(options)
25
+ Jekyll::Commands::Serve.process(options)
26
+ end
27
+ end
28
+ end
29
+
30
+ # Boot up a WEBrick server which points to the compiled site's root.
31
+ def process(options)
32
+ options = configuration_from_options(options)
33
+ destination = options['destination']
34
+ setup(destination)
35
+
36
+ s = WEBrick::HTTPServer.new(webrick_options(options))
37
+ s.unmount("")
38
+
39
+ s.mount(
40
+ options['baseurl'],
41
+ WEBrick::HTTPServlet::FileHandler,
42
+ destination,
43
+ file_handler_options
44
+ )
45
+
46
+ Jekyll.logger.info "Server address:", server_address(s, options)
47
+
48
+ if options['detach'] # detach the server
49
+ pid = Process.fork { s.start }
50
+ Process.detach(pid)
51
+ Jekyll.logger.info "Server detached with pid '#{pid}'.", "Run `kill -9 #{pid}' to stop the server."
52
+ else # create a new server thread, then join it with current terminal
53
+ t = Thread.new { s.start }
54
+ trap("INT") { s.shutdown }
55
+ t.join
56
+ end
57
+ end
58
+
59
+ def setup(destination)
60
+ require 'webrick'
61
+
62
+ FileUtils.mkdir_p(destination)
63
+
64
+ # monkey patch WEBrick using custom 404 page (/404.html)
65
+ if File.exist?(File.join(destination, '404.html'))
66
+ WEBrick::HTTPResponse.class_eval do
67
+ def create_error_page
68
+ @header['content-type'] = "text/html; charset=UTF-8"
69
+ @body = IO.read(File.join(@config[:DocumentRoot], '404.html'))
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ def webrick_options(config)
76
+ opts = {
77
+ :DocumentRoot => config['destination'],
78
+ :Port => config['port'],
79
+ :BindAddress => config['host'],
80
+ :MimeTypes => mime_types,
81
+ :DoNotReverseLookup => true,
82
+ :StartCallback => start_callback(config['detach']),
83
+ :DirectoryIndex => %w(index.html index.htm index.cgi index.rhtml index.xml)
84
+ }
85
+
86
+ if !config['verbose']
87
+ opts.merge!({
88
+ :AccessLog => [],
89
+ :Logger => WEBrick::Log.new([], WEBrick::Log::WARN)
90
+ })
91
+ end
92
+
93
+ opts
94
+ end
95
+
96
+ def start_callback(detached)
97
+ unless detached
98
+ Proc.new { Jekyll.logger.info "Server running...", "press ctrl-c to stop." }
99
+ end
100
+ end
101
+
102
+ def mime_types
103
+ mime_types_file = File.expand_path('../mime.types', File.dirname(__FILE__))
104
+ WEBrick::HTTPUtils::load_mime_types(mime_types_file)
105
+ end
106
+
107
+ def server_address(server, options)
108
+ baseurl = "#{options['baseurl']}/" if options['baseurl']
109
+ [
110
+ "http://",
111
+ server.config[:BindAddress],
112
+ ":",
113
+ server.config[:Port],
114
+ baseurl || ""
115
+ ].map(&:to_s).join("")
116
+ end
117
+
118
+ # recreate NondisclosureName under utf-8 circumstance
119
+ def file_handler_options
120
+ fh_option = WEBrick::Config::FileHandler
121
+ fh_option[:NondisclosureName] = ['.ht*','~*']
122
+ fh_option
123
+ end
124
+
125
+ end
126
+
127
+ end
128
+ end
129
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-serve
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.rc1
5
+ platform: ruby
6
+ authors:
7
+ - Parker Moore
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jekyll
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ description:
56
+ email:
57
+ - parkrmoore@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - jekyll-serve.gemspec
68
+ - lib/jekyll-serve.rb
69
+ - lib/jekyll-serve/version.rb
70
+ - lib/jekyll/commands/serve.rb
71
+ homepage: https://github.com/jekyll/jekyll-serve
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">"
87
+ - !ruby/object:Gem::Version
88
+ version: 1.3.1
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.2.2
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: The `jekyll serve` command.
95
+ test_files: []