From 3eedfd8fe08a2e7a9cc44c89acb60de0f2c7d2f7 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Thu, 6 Oct 2016 14:41:23 -0400 Subject: [PATCH] abstract site directory to variable --- Rakefile | 6 +++++- rake/site.rake | 14 +++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index 4e9a1057..de2aa441 100644 --- a/Rakefile +++ b/Rakefile @@ -27,6 +27,10 @@ def docs_name "#{name}-docs" end +def docs_folder + "site" +end + def gemspec_file "#{name}.gemspec" end @@ -102,7 +106,7 @@ def siteify_file(file, overrides_front_matter = {}) "note" => "This file is autogenerated. Edit /#{file} instead." }.merge(overrides_front_matter) contents = "#{front_matter.to_yaml}---\n\n#{content_for(file)}" - File.write("site/_docs/#{slug}.md", contents) + File.write("#{docs_folder}/_docs/#{slug}.md", contents) end def content_for(file) diff --git a/rake/site.rake b/rake/site.rake index 8dd283fb..283b4a9c 100644 --- a/rake/site.rake +++ b/rake/site.rake @@ -23,8 +23,8 @@ namespace :site do # Generate the site in server mode. puts "Running Jekyll..." options = { - "source" => File.expand_path("site"), - "destination" => File.expand_path("site/_site"), + "source" => File.expand_path(docs_folder), + "destination" => File.expand_path("#{docs_folder}/_site"), "watch" => true, "serving" => true } @@ -37,15 +37,15 @@ namespace :site do require "jekyll" Jekyll::Commands::Build.process({ "profile" => true, - "source" => File.expand_path("site"), - "destination" => File.expand_path("site/_site") + "source" => File.expand_path(docs_folder), + "destination" => File.expand_path("#{docs_folder}/_site") }) end task :build => :generate desc "Update normalize.css library to the latest version and minify" task :update_normalize_css do - Dir.chdir("site/_sass") do + Dir.chdir("#{docs_folder}/_sass") do sh 'curl "http://necolas.github.io/normalize.css/latest/normalize.css" -o "normalize.scss"' sh 'sass "normalize.scss":"_normalize.scss" --style compressed' rm ['normalize.scss', Dir.glob('*.map')].flatten @@ -84,7 +84,7 @@ namespace :site do ENV['JEKYLL_ENV'] = 'production' require "jekyll" Jekyll::Commands::Build.process({ - "source" => File.expand_path("site"), + "source" => File.expand_path(docs_folder), "destination" => File.expand_path("gh-pages"), "sass" => { "style" => "compressed" } }) @@ -132,7 +132,7 @@ namespace :site do raise "Specify a version: rake site:releases:new['1.2.3']" unless args.version today = Time.new.strftime('%Y-%m-%d') release = args.version.to_s - filename = "site/_posts/#{today}-jekyll-#{release.split('.').join('-')}-released.markdown" + filename = "#{docs_folder}/_posts/#{today}-jekyll-#{release.split('.').join('-')}-released.markdown" File.open(filename, "wb") do |post| post.puts("---")