summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorJade Dominguez <plusjade@gmail.com>2012-02-01 15:15:35 -0800
committerJade Dominguez <plusjade@gmail.com>2012-02-01 15:15:35 -0800
commit533d840a7556217ebc8250e157de843b9a9f5f04 (patch)
treedd1f3a18b50c4a1d421f1af70ce52623bcada365 /Rakefile
parentd25b40e9ea03d61be338b232c734b95a0f350e16 (diff)
Namespace 'switch_theme'
Make sure to maintain backwards compatibility
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile75
1 files changed, 44 insertions, 31 deletions
diff --git a/Rakefile b/Rakefile
index 3e04930..fe7a9d1 100644
--- a/Rakefile
+++ b/Rakefile
@@ -85,44 +85,57 @@ task :page do
end
end # task :page
-desc "Switch between Jekyll-bootstrap themes."
-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: 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 '#{theme_name}' layout: #{File.basename(filename)}"
-
- open(File.join(CONFIG['layouts'], File.basename(filename)), 'w') do |page|
- if File.basename(filename, ".html").downcase == "default"
- page.puts "---"
- page.puts File.read(settings_file) if File.exist?(settings_file)
- page.puts "---"
- else
- page.puts "---"
- page.puts "layout: default"
- page.puts "---"
- end
- page.puts "{% include JB/setup %}"
- page.puts "{% include themes/#{theme_name}/#{File.basename(filename)} %}"
- end
- end
-end # task :switch_theme
-
desc "Launch preview environment"
task :preview do
system "jekyll --auto --server"
end # task :preview
+# Public: Alias - Maintains backwards compatability for theme switching.
+task :switch_theme => "theme:switch"
+
namespace :theme do
+ # Public: Switch from one theme to another for your blog.
+ #
+ # name - String, Required. name of the theme you want to switch to.
+ # The the theme must be installed into your JB framework.
+ #
+ # Examples
+ #
+ # rake theme:switch name="the-program"
+ #
+ # Returns Success/failure messages.
+ desc "Switch between Jekyll-bootstrap themes."
+ task :switch 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: 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 '#{theme_name}' layout: #{File.basename(filename)}"
+
+ open(File.join(CONFIG['layouts'], File.basename(filename)), 'w') do |page|
+ if File.basename(filename, ".html").downcase == "default"
+ page.puts "---"
+ page.puts File.read(settings_file) if File.exist?(settings_file)
+ page.puts "---"
+ else
+ page.puts "---"
+ page.puts "layout: default"
+ page.puts "---"
+ end
+ page.puts "{% include JB/setup %}"
+ page.puts "{% include themes/#{theme_name}/#{File.basename(filename)} %}"
+ end
+ end
+ end # task :switch
+
# Public: Install a theme using the theme packager.
# Version 0.1.0 simple 1:1 file matching.
#