summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorJade Dominguez <plusjade@gmail.com>2012-01-24 02:11:01 -0800
committerJade Dominguez <plusjade@gmail.com>2012-01-24 02:11:01 -0800
commit9bd0deabd4d1dba78194b68e0d4e2c3f3853eddb (patch)
tree5f859a3cf877f39158daaab361e1ca85dec5a90e /Rakefile
parent240271634da68308d52790e24376f6cc95515ce5 (diff)
Use ENV variables for switch_theme
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile12
1 files changed, 7 insertions, 5 deletions
diff --git a/Rakefile b/Rakefile
index 4acbf09..1b0faad 100644
--- a/Rakefile
+++ b/Rakefile
@@ -57,17 +57,19 @@ task :page do
end # task :page
desc "Switch between Jekyll-bootstrap themes."
-task :switch_theme, :theme do |t, args|
- theme_path = File.join(CONFIG['themes'], args.theme)
+task :switch_theme do
+ theme_name = ENV["name"].to_s
+ theme_path = File.join(CONFIG['themes'], theme_name)
settings_file = File.join(theme_path, "settings.yml")
non_layout_files = ["settings.yml"]
- abort("rake aborted: '#{CONFIG['themes']}/#{args.theme}' directory not found.") unless FileTest.directory?(theme_path)
+ abort("rake aborted: name cannot be blank") if theme_name.empty?
+ abort("rake aborted: '#{theme_path}' directory not found.") unless FileTest.directory?(theme_path)
abort("rake aborted: '#{CONFIG['layouts']}' directory not found.") unless FileTest.directory?(CONFIG['layouts'])
Dir.glob("#{theme_path}/*") do |filename|
next if non_layout_files.include?(File.basename(filename).downcase)
- puts "Generating '#{args.theme}' layout: #{File.basename(filename)}"
+ puts "Generating '#{theme_name}' layout: #{File.basename(filename)}"
open(File.join(CONFIG['layouts'], File.basename(filename)), 'w') do |page|
if File.basename(filename, ".html").downcase == "default"
@@ -80,7 +82,7 @@ task :switch_theme, :theme do |t, args|
page.puts "---"
end
page.puts "{% include JB/setup %}"
- page.puts "{% include themes/#{args.theme}/#{File.basename(filename)} %}"
+ page.puts "{% include themes/#{theme_name}/#{File.basename(filename)} %}"
end
end
end # task :switch_theme