From 2ce39bc20a0a310c3773deeea73a7e369ce0ff85 Mon Sep 17 00:00:00 2001 From: Casey Lang Date: Wed, 15 May 2013 17:29:27 -0500 Subject: [PATCH 1/4] Add '--force' to 'new' command. Implements #1104 --- bin/jekyll | 4 +++- lib/jekyll/commands/new.rb | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) mode change 100755 => 100644 bin/jekyll diff --git a/bin/jekyll b/bin/jekyll old mode 100755 new mode 100644 index 2e631bbb..b2c6fab9 --- a/bin/jekyll +++ b/bin/jekyll @@ -37,8 +37,10 @@ command :new do |c| c.syntax = 'jekyll new PATH' c.description = 'Creates a new Jekyll site scaffold in PATH' + c.option '--force', 'Force creation even if PATH already exists' + c.action do |args, options| - Jekyll::Commands::New.process(args) + Jekyll::Commands::New.process(args, options.__hash__) end end diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index f6c38fc7..fc8a96f7 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -3,12 +3,12 @@ require 'erb' module Jekyll module Commands class New < Command - def self.process(args) + def self.process(args, options = {}) raise ArgumentError.new('You must specify a path.') if args.empty? new_blog_path = File.expand_path(args.join(" "), Dir.pwd) FileUtils.mkdir_p new_blog_path - unless Dir["#{new_blog_path}/**/*"].empty? + if !options[:force] && !Dir["#{new_blog_path}/**/*"].empty? Jekyll::Stevenson.error "Conflict:", "#{new_blog_path} exists and is not empty." exit(1) end From 294437fbf10160b321aa56867ed257789b8807b9 Mon Sep 17 00:00:00 2001 From: Casey Lang Date: Wed, 15 May 2013 17:36:48 -0500 Subject: [PATCH 2/4] Merge latest commits from mojombo/jekyll --- History.markdown | 1 + jekyll.gemspec | 4 +++- site/docs/plugins.md | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.markdown b/History.markdown index 7af92a8d..e96952cc 100644 --- a/History.markdown +++ b/History.markdown @@ -8,6 +8,7 @@ * Rename Jekyll::Logger to Jekyll::Stevenson to fix inheritance issue (#1106) ### Site Enhancements + * Add link to jekyll-minibundle in the doc's plugins list (#1035) * Quick patch for importers documentation * Fix prefix for WordpressDotCom importer in docs (#1107) * Add jekyll-contentblocks plugin to docs (#1068) diff --git a/jekyll.gemspec b/jekyll.gemspec index 516bc700..2d1a3af4 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -92,13 +92,14 @@ Gem::Specification.new do |s| lib/jekyll/generator.rb lib/jekyll/generators/pagination.rb lib/jekyll/layout.rb - lib/jekyll/logger.rb lib/jekyll/mime.types lib/jekyll/page.rb lib/jekyll/plugin.rb lib/jekyll/post.rb + lib/jekyll/related_posts.rb lib/jekyll/site.rb lib/jekyll/static_file.rb + lib/jekyll/stevenson.rb lib/jekyll/tags/gist.rb lib/jekyll/tags/highlight.rb lib/jekyll/tags/include.rb @@ -235,6 +236,7 @@ Gem::Specification.new do |s| test/test_rdiscount.rb test/test_redcarpet.rb test/test_redcloth.rb + test/test_related_posts.rb test/test_site.rb test/test_tags.rb ] diff --git a/site/docs/plugins.md b/site/docs/plugins.md index e8e7075d..36d932eb 100644 --- a/site/docs/plugins.md +++ b/site/docs/plugins.md @@ -427,6 +427,7 @@ There are a few useful, prebuilt plugins at the following locations: - [File compressor](https://gist.github.com/2758691) by [mytharcher](https://github.com/mytharcher): Compress HTML (\*.html) and JavaScript(\*.js) files when output. - [smilify](https://github.com/SaswatPadhi/jekyll_smilify) by [SaswatPadhi](https://github.com/SaswatPadhi): Convert text emoticons in your content to themeable smiley pics. [Demo](http://saswatpadhi.github.com/) - [excerpts](http://blog.darkrefraction.com/2012/jekyll-excerpt-plugin.html) by [drawoc](https://github.com/drawoc): provides a nice way to implement page excerpts. +- [jekyll-minibundle](https://github.com/tkareine/jekyll-minibundle): Asset bundling and cache busting using external minification tool of your choice, no gem dependencies.
Jekyll Plugins Wanted
From 00dd37d2e41f3cd0b9196b8b28073ba10c9eaae8 Mon Sep 17 00:00:00 2001 From: Casey Lang Date: Thu, 16 May 2013 16:13:13 -0500 Subject: [PATCH 3/4] Extract check for force to improve readability --- lib/jekyll/commands/new.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index fc8a96f7..7021e7d2 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -8,7 +8,7 @@ module Jekyll new_blog_path = File.expand_path(args.join(" "), Dir.pwd) FileUtils.mkdir_p new_blog_path - if !options[:force] && !Dir["#{new_blog_path}/**/*"].empty? + if preserve_source_location(new_blog_path, options) Jekyll::Stevenson.error "Conflict:", "#{new_blog_path} exists and is not empty." exit(1) end @@ -33,6 +33,11 @@ module Jekyll end private + + def self.preserve_source_location(path, options) + !options[:force] && !Dir["#{path}/**/*"].empty? + end + def self.create_sample_files(path) FileUtils.cp_r site_template + '/.', path FileUtils.rm File.expand_path(scaffold_path, path) From fafacc43ca69dd6d57bd1d3ad2100c3fb47a81b3 Mon Sep 17 00:00:00 2001 From: Casey Lang Date: Thu, 16 May 2013 16:15:21 -0500 Subject: [PATCH 4/4] Add ? to preserve_source_location --- lib/jekyll/commands/new.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index 7021e7d2..ea35ef40 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -8,7 +8,7 @@ module Jekyll new_blog_path = File.expand_path(args.join(" "), Dir.pwd) FileUtils.mkdir_p new_blog_path - if preserve_source_location(new_blog_path, options) + if preserve_source_location?(new_blog_path, options) Jekyll::Stevenson.error "Conflict:", "#{new_blog_path} exists and is not empty." exit(1) end @@ -33,8 +33,8 @@ module Jekyll end private - - def self.preserve_source_location(path, options) + + def self.preserve_source_location?(path, options) !options[:force] && !Dir["#{path}/**/*"].empty? end