summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorJade Dominguez <plusjade@gmail.com>2011-12-30 14:17:44 -0800
committerJade Dominguez <plusjade@gmail.com>2012-01-11 15:13:40 -0800
commit4c18e3c136bea49e3335ab594ae22d999892cf27 (patch)
tree6ee24ea94d767bc6c69081531350a6776a5f9fcb /Rakefile
version 0.0.1
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile29
1 files changed, 29 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..bea3fd9
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,29 @@
+require "rubygems"
+require 'rake'
+
+desc "Switch between Jekyll-bootstrap themes."
+task :switch_theme, :theme do |t, args|
+ theme_path = File.join(File.dirname(__FILE__), "_includes", "themes", args.theme)
+ layouts_path = File.join(File.dirname(__FILE__), "_layouts")
+
+ abort("rake aborted: './_includes/themes/#{args.theme}' directory not found.") unless Dir.exists?(theme_path)
+ abort("rake aborted: './_layouts' directory not found.") unless Dir.exists?(layouts_path)
+
+ Dir.glob("#{theme_path}/*") do |filename|
+ puts "Generating '#{args.theme}' layout: #{File.basename(filename)}"
+
+ open("#{layouts_path}/#{File.basename(filename)}", 'w') do |page|
+ if File.basename(filename, ".html").downcase == "default"
+ page.puts "---"
+ page.puts "---"
+ page.puts "{% assign theme_asset_path = \"/assets/themes/#{args.theme}\" %}"
+ else
+ page.puts "---"
+ page.puts "layout: default"
+ page.puts "---"
+ end
+ page.puts "{% include themes/#{args.theme}/#{File.basename(filename)} %}"
+ end
+ end
+end # task :switch_theme
+