@@ -85,44 +85,57 @@ task :page do
8585 end
8686end # task :page
8787
88- desc "Switch between Jekyll-bootstrap themes."
89- task :switch_theme do
90- theme_name = ENV [ "name" ] . to_s
91- theme_path = File . join ( CONFIG [ 'themes' ] , theme_name )
92- settings_file = File . join ( theme_path , "settings.yml" )
93- non_layout_files = [ "settings.yml" ]
94-
95- abort ( "rake aborted: name cannot be blank" ) if theme_name . empty?
96- abort ( "rake aborted: '#{ theme_path } ' directory not found." ) unless FileTest . directory? ( theme_path )
97- abort ( "rake aborted: '#{ CONFIG [ 'layouts' ] } ' directory not found." ) unless FileTest . directory? ( CONFIG [ 'layouts' ] )
98-
99- Dir . glob ( "#{ theme_path } /*" ) do |filename |
100- next if non_layout_files . include? ( File . basename ( filename ) . downcase )
101- puts "Generating '#{ theme_name } ' layout: #{ File . basename ( filename ) } "
102-
103- open ( File . join ( CONFIG [ 'layouts' ] , File . basename ( filename ) ) , 'w' ) do |page |
104- if File . basename ( filename , ".html" ) . downcase == "default"
105- page . puts "---"
106- page . puts File . read ( settings_file ) if File . exist? ( settings_file )
107- page . puts "---"
108- else
109- page . puts "---"
110- page . puts "layout: default"
111- page . puts "---"
112- end
113- page . puts "{% include JB/setup %}"
114- page . puts "{% include themes/#{ theme_name } /#{ File . basename ( filename ) } %}"
115- end
116- end
117- end # task :switch_theme
118-
11988desc "Launch preview environment"
12089task :preview do
12190 system "jekyll --auto --server"
12291end # task :preview
12392
93+ # Public: Alias - Maintains backwards compatability for theme switching.
94+ task :switch_theme => "theme:switch"
95+
12496namespace :theme do
12597
98+ # Public: Switch from one theme to another for your blog.
99+ #
100+ # name - String, Required. name of the theme you want to switch to.
101+ # The the theme must be installed into your JB framework.
102+ #
103+ # Examples
104+ #
105+ # rake theme:switch name="the-program"
106+ #
107+ # Returns Success/failure messages.
108+ desc "Switch between Jekyll-bootstrap themes."
109+ task :switch do
110+ theme_name = ENV [ "name" ] . to_s
111+ theme_path = File . join ( CONFIG [ 'themes' ] , theme_name )
112+ settings_file = File . join ( theme_path , "settings.yml" )
113+ non_layout_files = [ "settings.yml" ]
114+
115+ abort ( "rake aborted: name cannot be blank" ) if theme_name . empty?
116+ abort ( "rake aborted: '#{ theme_path } ' directory not found." ) unless FileTest . directory? ( theme_path )
117+ abort ( "rake aborted: '#{ CONFIG [ 'layouts' ] } ' directory not found." ) unless FileTest . directory? ( CONFIG [ 'layouts' ] )
118+
119+ Dir . glob ( "#{ theme_path } /*" ) do |filename |
120+ next if non_layout_files . include? ( File . basename ( filename ) . downcase )
121+ puts "Generating '#{ theme_name } ' layout: #{ File . basename ( filename ) } "
122+
123+ open ( File . join ( CONFIG [ 'layouts' ] , File . basename ( filename ) ) , 'w' ) do |page |
124+ if File . basename ( filename , ".html" ) . downcase == "default"
125+ page . puts "---"
126+ page . puts File . read ( settings_file ) if File . exist? ( settings_file )
127+ page . puts "---"
128+ else
129+ page . puts "---"
130+ page . puts "layout: default"
131+ page . puts "---"
132+ end
133+ page . puts "{% include JB/setup %}"
134+ page . puts "{% include themes/#{ theme_name } /#{ File . basename ( filename ) } %}"
135+ end
136+ end
137+ end # task :switch
138+
126139 # Public: Install a theme using the theme packager.
127140 # Version 0.1.0 simple 1:1 file matching.
128141 #
0 commit comments