Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use ENV variables for switch_theme
  • Loading branch information
plusjade committed Jan 24, 2012
1 parent 2402716 commit 9bd0dea
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Rakefile
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 9bd0dea

Please sign in to comment.