diff --git a/README.textile b/README.textile index 7cd86729..f792c480 100644 --- a/README.textile +++ b/README.textile @@ -141,9 +141,10 @@ have it used instead: 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): +can launch a simple WEBrick server (works well in conjunction with --auto). +Default port is 4000: - $ jekyll --server + $ jekyll --server [PORT] h2. Data diff --git a/bin/jekyll b/bin/jekyll index fb4abdc8..34a70b71 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -83,24 +83,6 @@ case ARGV.size exit(1) end -if options[:server] - require 'webrick' - include WEBrick - - s = HTTPServer.new( - :Port => options[:server_port], - :DocumentRoot => destination - ) - t = Thread.new { - s.start - } - - unless options[:auto] - trap("INT") { s.shutdown } - t.join() - end -end - if options[:auto] require 'directory_watcher' @@ -118,7 +100,27 @@ if options[:auto] dw.start - loop { sleep 1000 } + unless options[:server] + loop { sleep 1000 } + end else Jekyll.process(source, destination) +end + +if options[:server] + require 'webrick' + include WEBrick + + FileUtils.mkdir_p(destination) + + s = HTTPServer.new( + :Port => options[:server_port], + :DocumentRoot => destination + ) + t = Thread.new { + s.start + } + + trap("INT") { s.shutdown } + t.join() end \ No newline at end of file