diff options
author | Jade Dominguez <plusjade@gmail.com> | 2012-01-24 02:11:01 -0800 |
---|---|---|
committer | Jade Dominguez <plusjade@gmail.com> | 2012-01-24 02:11:01 -0800 |
commit | 9bd0deabd4d1dba78194b68e0d4e2c3f3853eddb (patch) | |
tree | 5f859a3cf877f39158daaab361e1ca85dec5a90e /Rakefile | |
parent | 240271634da68308d52790e24376f6cc95515ce5 (diff) |
Use ENV variables for switch_theme
Diffstat (limited to 'Rakefile')
-rw-r--r-- | Rakefile | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -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 |