From 9ecbfb2253e11f5cb0364e24d4f13595efdd20b6 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 19 Dec 2008 17:49:57 -0600 Subject: [PATCH 1/2] Added --server option to start a simple WEBrick server on destination directory --- bin/jekyll | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bin/jekyll b/bin/jekyll index acf8d56f..307e4936 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -25,6 +25,10 @@ opts = OptionParser.new do |opts| options[:auto] = true end + opts.on("--server", "Run a WEBrick server on destination directory") do + options[:server] = true + end + opts.on("--lsi", "Use LSI for better related posts") do Jekyll.lsi = true end @@ -78,6 +82,24 @@ case ARGV.size exit(1) end +if options[:server] + require 'webrick' + include WEBrick + + s = HTTPServer.new( + :Port => 4000, + :DocumentRoot => destination + ) + t = Thread.new { + s.start + } + + unless options[:auto] + trap("INT") { s.shutdown } + t.join() + end +end + if options[:auto] require 'directory_watcher' From 6bfaa6bac05cf734b9cb9d850998f2f4a0a8b987 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 19 Dec 2008 18:16:11 -0600 Subject: [PATCH 2/2] updated readme to include --server option --- README.textile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.textile b/README.textile index 2352dd88..0f68f0e5 100644 --- a/README.textile +++ b/README.textile @@ -129,6 +129,13 @@ compilation), you must install it (gem install rdiscount) and then you can have it used instead: $ jekyll --rdiscount + +When previewing complex sites locally, simply opening the site in a web +browser (using file://) can cause problems with links that are relative to +the site root (e.g., "/stylesheets/style.css"). To get around this, Jekyll +can launch a simple WEBrick server (works well in conjunction with --auto): + + $ jekyll --server h2. Data