Permalink
Browse files

Added --post and --page preview options. Removed --single option.

  • Loading branch information...
1 parent 455db38 commit 0fa135a432f45154bfa10d57c3520e83be387f19 Mark Reid committed Aug 31, 2010
Showing with 32 additions and 8 deletions.
  1. +15 −6 bin/jekyll
  2. +17 −2 lib/jekyll/site.rb
View
21 bin/jekyll
@@ -78,8 +78,12 @@ opts = OptionParser.new do |opts|
end
end
- opts.on("--single [FILE]", "Render a single file") do |file|
- options['single'] = file
+ opts.on("--post [FILE]", "Render a single post") do |file|
+ options['post'] = file
+ end
+
+ opts.on("--page [FILE]", "Render a single page") do |file|
+ options['page'] = file
end
opts.on("--url [URL]", "Set custom site.url") do |url|
@@ -148,11 +152,16 @@ if options['auto']
unless options['server']
loop { sleep 1000 }
end
-elsif options['single']
- file = options['single']
- puts "Rendering #{file}"
- post = site.process_single(file)
+elsif options['post']
+ file = options['post']
+ puts "Rendering single post in #{file}"
+ post = site.process_post(file)
puts "Finished! Post at #{post.url}"
+elsif options['page']
+ file = options['page']
+ puts "Rendering single page in #{file}"
+ post = site.process_page(file)
+ puts "Finished! Page at #{post.url}"
else
puts "Building site: #{source} -> #{destination}"
begin
View
19 lib/jekyll/site.rb
@@ -74,10 +74,10 @@ def process
self.write
end
- # Process a single file using the site's configuration and layouts.
+ # Process a single post using the site's configuration and layouts.
#
# Returns the rendered post
- def process_single(filename)
+ def process_post(filename)
self.reset
self.read_layouts
dir = File.dirname(filename)
@@ -89,6 +89,21 @@ def process_single(filename)
return post
end
+ # Process a single page using the site's configuration and layouts.
+ #
+ # Returns the rendered page
+ def process_page(filename)
+ self.reset
+ self.read_layouts
+ dir = File.dirname(filename)
+ f = File.basename(filename)
+ page= Page.new(self, self.source, dir, f)
+ page.render(self.layouts, site_payload)
+ page.write(self.dest)
+
+ return page
+ end
+
def read
self.read_layouts # existing implementation did this at top level only so preserved that
self.read_directories

0 comments on commit 0fa135a

Please sign in to comment.