@@ -24,7 +24,7 @@ module JB
2424 :theme_packages => "_theme_packages" ,
2525 :posts => "_posts"
2626 }
27-
27+
2828 def self . base
2929 SOURCE
3030 end
@@ -36,7 +36,7 @@ module JB
3636 path . compact!
3737 File . __send__ :join , path
3838 end
39-
39+
4040 end #Path
4141end #JB
4242
@@ -59,7 +59,7 @@ task :post do
5959 if File . exist? ( filename )
6060 abort ( "rake aborted!" ) if ask ( "#{ filename } already exists. Do you want to overwrite?" , [ 'y' , 'n' ] ) == 'n'
6161 end
62-
62+
6363 puts "Creating new post: #{ filename } "
6464 open ( filename , 'w' ) do |post |
6565 post . puts "---"
@@ -85,7 +85,7 @@ task :page do
8585 if File . exist? ( filename )
8686 abort ( "rake aborted!" ) if ask ( "#{ filename } already exists. Do you want to overwrite?" , [ 'y' , 'n' ] ) == 'n'
8787 end
88-
88+
8989 mkdir_p File . dirname ( filename )
9090 puts "Creating new page: #{ filename } "
9191 open ( filename , 'w' ) do |post |
@@ -107,7 +107,7 @@ end # task :preview
107107task :switch_theme => "theme:switch"
108108
109109namespace :theme do
110-
110+
111111 # Public: Switch from one theme to another for your blog.
112112 #
113113 # name - String, Required. name of the theme you want to switch to.
@@ -142,16 +142,16 @@ namespace :theme do
142142 page . puts "---"
143143 page . puts "layout: default"
144144 page . puts "---"
145- end
145+ end
146146 page . puts "{% include JB/setup %}"
147- page . puts "{% include themes/#{ theme_name } /#{ File . basename ( filename ) } %}"
147+ page . puts "{% include themes/#{ theme_name } /#{ File . basename ( filename ) } %}"
148148 end
149149 end
150-
150+
151151 puts "=> Theme successfully switched!"
152152 puts "=> Reload your web-page to check it out =)"
153153 end # task :switch
154-
154+
155155 # Public: Install a theme using the theme packager.
156156 # Version 0.1.0 simple 1:1 file matching.
157157 #
@@ -175,28 +175,28 @@ namespace :theme do
175175 end
176176
177177 packaged_theme_path = JB ::Path . build ( :theme_packages , :node => name )
178-
178+
179179 abort ( "rake aborted!
180180 => ERROR: 'name' cannot be blank" ) if name . empty?
181- abort ( "rake aborted!
181+ abort ( "rake aborted!
182182 => ERROR: '#{ packaged_theme_path } ' directory not found.
183183 => Installable themes can be added via git. You can find some here: http://github.com/jekyllbootstrap
184184 => To download+install run: `rake theme:install git='[PUBLIC-CLONE-URL]'`
185185 => example : rake theme:install git='[email protected] :jekyllbootstrap/theme-the-program.git' 186186 " ) unless FileTest . directory? ( packaged_theme_path )
187-
187+
188188 manifest = verify_manifest ( packaged_theme_path )
189-
189+
190190 # Get relative paths to packaged theme files
191191 # Exclude directories as they'll be recursively created. Exclude meta-data files.
192192 packaged_theme_files = [ ]
193193 FileUtils . cd ( packaged_theme_path ) {
194- Dir . glob ( "**/*.*" ) { |f |
194+ Dir . glob ( "**/*.*" ) { |f |
195195 next if ( FileTest . directory? ( f ) || f =~ /^(manifest|readme|packager)/i )
196- packaged_theme_files << f
196+ packaged_theme_files << f
197197 }
198198 }
199-
199+
200200 # Mirror each file into the framework making sure to prompt if already exists.
201201 packaged_theme_files . each do |filename |
202202 file_install_path = File . join ( JB ::Path . base , filename )
@@ -207,7 +207,7 @@ namespace :theme do
207207 cp_r File . join ( packaged_theme_path , filename ) , file_install_path
208208 end
209209 end
210-
210+
211211 puts "=> #{ name } theme has been installed!"
212212 puts "=> ---"
213213 if ask ( "=> Want to switch themes now?" , [ 'y' , 'n' ] ) == 'y'
@@ -220,7 +220,7 @@ namespace :theme do
220220 # In other words packaging is essentially the reverse of installing.
221221 #
222222 # name - String, Required name of the theme you want to package.
223- #
223+ #
224224 # Examples
225225 #
226226 # rake theme:package name="twitter"
@@ -235,12 +235,12 @@ namespace :theme do
235235 abort ( "rake aborted: name cannot be blank" ) if name . empty?
236236 abort ( "rake aborted: '#{ theme_path } ' directory not found." ) unless FileTest . directory? ( theme_path )
237237 abort ( "rake aborted: '#{ asset_path } ' directory not found." ) unless FileTest . directory? ( asset_path )
238-
238+
239239 ## Mirror theme's template directory (_includes)
240240 packaged_theme_path = JB ::Path . build ( :themes , :root => JB ::Path . build ( :theme_packages , :node => name ) )
241241 mkdir_p packaged_theme_path
242242 cp_r theme_path , packaged_theme_path
243-
243+
244244 ## Mirror theme's asset directory
245245 packaged_theme_assets_path = JB ::Path . build ( :theme_assets , :root => JB ::Path . build ( :theme_packages , :node => name ) )
246246 mkdir_p packaged_theme_assets_path
@@ -251,18 +251,18 @@ namespace :theme do
251251 open ( JB ::Path . build ( :theme_packages , :node => "#{ name } /packager.yml" ) , "w" ) do |page |
252252 page . puts packager . to_yaml
253253 end
254-
254+
255255 puts "=> '#{ name } ' theme is packaged and available at: #{ JB ::Path . build ( :theme_packages , :node => name ) } "
256256 end
257-
257+
258258end # end namespace :theme
259259
260260# Internal: Download and process a theme from a git url.
261261# Notice we don't know the name of the theme until we look it up in the manifest.
262262# So we'll have to change the folder name once we get the name.
263263#
264264# url - String, Required url to git repository.
265- #
265+ #
266266# Returns theme manifest hash
267267def theme_from_git_url ( url )
268268 tmp_path = JB ::Path . build ( :theme_packages , :node => "_tmp" )
282282# Internal: Process theme package manifest file.
283283#
284284# theme_path - String, Required. File path to theme package.
285- #
285+ #
286286# Returns theme manifest hash
287287def verify_manifest ( theme_path )
288288 manifest_path = File . join ( theme_path , "manifest.yml" )
0 commit comments