diff --git a/Gemfile b/Gemfile index 6160f94..16ceb9d 100644 --- a/Gemfile +++ b/Gemfile @@ -16,3 +16,10 @@ group :development do end gem 'sinatra', '1.2.6' + +group :test do + gem 'aruba' + gem 'cucumber' +end + + diff --git a/Gemfile.lock b/Gemfile.lock index 6350698..7151ac5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,7 +4,15 @@ GEM RedCloth (4.2.8) albino (1.3.3) posix-spawn (>= 0.3.6) + aruba (0.4.7) + childprocess (>= 0.2.2) + cucumber (>= 1.1.1) + ffi (= 1.0.9) + rspec (>= 2.7.0) blankslate (2.1.2.4) + builder (3.0.0) + childprocess (0.3.1) + ffi (~> 1.0.6) chunky_png (1.2.1) classifier (1.3.3) fast-stemmer (>= 1.0.0) @@ -12,10 +20,19 @@ GEM chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) + cucumber (1.1.9) + builder (>= 2.1.2) + diff-lcs (>= 1.1.2) + gherkin (~> 2.9.0) + json (>= 1.4.6) + term-ansicolor (>= 1.0.6) + diff-lcs (1.1.3) directory_watcher (1.4.0) fast-stemmer (1.0.0) ffi (1.0.9) fssm (0.2.7) + gherkin (2.9.1) + json (>= 1.4.6) haml (3.1.2) jekyll (0.11.0) albino (>= 1.3.2) @@ -24,6 +41,7 @@ GEM kramdown (>= 0.13.2) liquid (>= 1.9.0) maruku (>= 0.5.9) + json (1.6.5) kramdown (0.13.3) liquid (2.2.2) maruku (0.6.0) @@ -35,6 +53,14 @@ GEM rake (0.9.2) rb-fsevent (0.4.3.1) rdiscount (1.6.8) + rspec (2.9.0) + rspec-core (~> 2.9.0) + rspec-expectations (~> 2.9.0) + rspec-mocks (~> 2.9.0) + rspec-core (2.9.0) + rspec-expectations (2.9.0) + diff-lcs (~> 1.1.3) + rspec-mocks (2.9.0) rubypants (0.2.0) rubypython (0.5.1) blankslate (>= 2.1.2.3) @@ -45,6 +71,7 @@ GEM tilt (>= 1.2.2, < 2.0) stringex (1.3.0) syntax (1.0.0) + term-ansicolor (1.0.7) tilt (1.3.2) PLATFORMS @@ -52,7 +79,9 @@ PLATFORMS DEPENDENCIES RedCloth + aruba compass (>= 0.11) + cucumber haml (>= 3.1) jekyll liquid (= 2.2.2) diff --git a/Rakefile b/Rakefile index d4dcb54..41e8f2f 100644 --- a/Rakefile +++ b/Rakefile @@ -2,6 +2,10 @@ require "rubygems" require "bundler/setup" require "stringex" +ENV['CURRENT_DIR'] ||= Dir.pwd + +current_dir = ENV['CURRENT_DIR'] + ## -- Rsync Deploy config -- ## # Be sure your public key is listed in your server's ~/.ssh/authorized_keys file ssh_user = "user@domain.com" @@ -15,16 +19,17 @@ deploy_branch = "gh-pages" ## -- Misc Configs -- ## -public_dir = "public" # compiled site directory -source_dir = "source" # source file directory -blog_index_dir = 'source' # directory for your blog's index page (if you put your index in source/blog/index.html, set this to 'source/blog') -deploy_dir = "_deploy" # deploy directory (for Github pages deployment) -stash_dir = "_stash" # directory to stash posts for speedy generation -posts_dir = "_posts" # directory for blog files -themes_dir = ".themes" # directory for blog files -new_post_ext = "markdown" # default new post file extension when using the new_post task -new_page_ext = "markdown" # default new page file extension when using the new_page task -server_port = "4000" # port for preview server eg. localhost:4000 +public_dir = File.join(current_dir, 'public') # compiled site directory +source_dir = File.join(current_dir, 'source') # source file directory +blog_index_dir = File.join(current_dir, 'source') # directory for your blog's index page (if you put your index in source/blog/index.html, set this to 'source/blog') +sass_dir = File.join(current_dir, 'sass') # sass directory +deploy_dir = "_deploy" # deploy directory (for Github pages deployment) +stash_dir = "_stash" # directory to stash posts for speedy generation +posts_dir = "_posts" # directory for blog files +themes_dir = ".themes" # directory for blog files +new_post_ext = "markdown" # default new post file extension when using the new_post task +new_page_ext = "markdown" # default new page file extension when using the new_page task +server_port = "4000" # port for preview server eg. localhost:4000 desc "Initial setup for Octopress: copies the default theme into the path of Jekyll's generator. Rake install defaults to rake install[classic] to install a different theme run rake install[some_theme_name]" @@ -37,8 +42,8 @@ task :install, :theme do |t, args| puts "## Copying "+theme+" theme into ./#{source_dir} and ./sass" mkdir_p source_dir cp_r "#{themes_dir}/#{theme}/source/.", source_dir - mkdir_p "sass" - cp_r "#{themes_dir}/#{theme}/sass/.", "sass" + mkdir_p sass_dir + cp_r "#{themes_dir}/#{theme}/sass/.", sass_dir mkdir_p "#{source_dir}/#{posts_dir}" mkdir_p public_dir end @@ -116,7 +121,7 @@ desc "Create a new page in #{source_dir}/(filename)/index.#{new_page_ext}" task :new_page, :filename do |t, args| raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir) args.with_defaults(:filename => 'new-page') - page_dir = [source_dir] + page_dir = [File.basename(source_dir)] if args.filename.downcase =~ /(^.+\/)?(.+)/ filename, dot, extension = $2.rpartition('.').reject(&:empty?) # Get filename and extension title = filename @@ -128,7 +133,7 @@ task :new_page, :filename do |t, args| extension ||= new_page_ext page_dir = page_dir.map! { |d| d = d.to_url }.join('/') # Sanitize path filename = filename.downcase.to_url - + page_dir = File.join(current_dir, page_dir) mkdir_p page_dir file = "#{page_dir}/#{filename}.#{extension}" if File.exist?(file) @@ -225,7 +230,10 @@ end desc "copy dot files for deployment" task :copydot, :source, :dest do |t, args| - FileList["#{args.source}/**/.*"].exclude("**/.", "**/..", "**/.DS_Store", "**/._*").each do |file| + jekyll_config = YAML.load(IO.read('_config.yml')) + whitelist = ['.htaccess', '**/*'] + whitelist += jekyll_config.include?(:whitelist) if jekyll_config.include?(:whitelist) + FileList["#{args.source}/**/.*"].add(*whitelist).exclude("**/.", "**/.*", "**/..", "**/.DS_Store", "**/._*").each do |file| cp_r file, file.gsub(/#{args.source}/, "#{args.dest}") unless File.directory?(file) end end diff --git a/features/jekyll.feature b/features/jekyll.feature new file mode 100644 index 0000000..a75e8f4 --- /dev/null +++ b/features/jekyll.feature @@ -0,0 +1,14 @@ +Feature: Jekyll integration + Scenario: Install octopress + When I install octopress + Then I should have created an octopress skeleton + + Scenario: Create a post + When I install octopress + And I create a new post + Then I should see that post + + Scenario: Create a page + When I install octopress + And I create a new page + Then I should see that page diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000..5c5b436 --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,16 @@ +#require 'aruba/cucumber' + +def run_command(cmd) + Dir.chdir @dir do + puts `CURRENT_DIR="#{@dir}" #{cmd}` + end +end + +def posts + posts_dir = File.join(@dir, 'source', '_posts') + Dir["#{posts_dir}/**/*"].sort +end + +def test_page + File.join(@dir, 'source', 'new-page', 'index.markdown') +end \ No newline at end of file diff --git a/features/support/step_definitions.rb b/features/support/step_definitions.rb new file mode 100644 index 0000000..9d1c2d8 --- /dev/null +++ b/features/support/step_definitions.rb @@ -0,0 +1,39 @@ +Before do + @dir = File.join(File.expand_path('../../../', __FILE__), 'tmp', 'octopress') + FileUtils.rm_rf(@dir) rescue nil + ::FileUtils.mkdir_p @dir + Dir.chdir @dir +end + +After do + FileUtils.rm_rf @dir +end + +When /^I install octopress$/ do + run_command('rake install') +end + +Then /^I should have created an octopress skeleton$/ do + %w(sass source public).each do |folder| + file = File.join(@dir, folder) + File.directory?(file).should be_true + end +end + +When /^I create a new post$/ do + posts.should be_empty + run_command('rake new_post') +end + +Then /^I should see that post$/ do + posts.should_not be_empty +end + +When /^I create a new page$/ do + File.exist?(test_page).should be_false + run_command('rake new_page') +end + +Then /^I should see that page$/ do + File.exist?(test_page).should be_true +end \ No newline at end of file