<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>features/pagination.feature</filename>
    </added>
    <added>
      <filename>lib/jekyll/pager.rb</filename>
    </added>
    <added>
      <filename>test/test_pager.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -51,6 +51,16 @@ opts = OptionParser.new do |opts|
   opts.on(&quot;--permalink [TYPE]&quot;, &quot;Use 'date' (default) for YYYY/MM/DD&quot;) do |style|
     options['permalink'] = style unless style.nil?
   end
+  
+  opts.on(&quot;--paginate [POSTS_PER_PAGE]&quot;, &quot;Paginate a blog's posts&quot;) do |per_page|
+    begin
+      options['paginate'] = per_page.to_i
+      raise ArgumentError if options['paginate'] == 0
+    rescue
+      puts 'you must specify a number of posts by page bigger than 0'
+      exit 0
+    end
+  end
 
   opts.on(&quot;--version&quot;, &quot;Display current version&quot;) do
     puts &quot;Jekyll &quot; + Jekyll.version</diff>
      <filename>bin/jekyll</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,7 @@ Feature: Site data
     And I should see &quot;Contact: email@me.com&quot; in &quot;_site/contact.html&quot;
 
   Scenario: Use site.time variable
-    Given I have an &quot;index.html&quot; page that contains &quot;Generated on: {{ site.time }}&quot;
+    Given I have an &quot;index.html&quot; page that contains &quot;{{ site.time }}&quot;
     When I run jekyll
     Then the _site directory should exist
     And I should see today's time in &quot;_site/index.html&quot;</diff>
      <filename>features/site_data.feature</filename>
    </modified>
    <modified>
      <diff>@@ -100,6 +100,10 @@ Then /^the (.*) directory should exist$/ do |dir|
   assert File.directory?(dir)
 end
 
+Then /^the (.*) file should exist$/ do |file|
+  assert File.file?(file)
+end
+
 Then /^I should see &quot;(.*)&quot; in &quot;(.*)&quot;$/ do |text, file|
   assert_match Regexp.new(text), File.open(file).readlines.join
 end
@@ -109,10 +113,9 @@ Then /^the &quot;(.*)&quot; file should not exist$/ do |file|
 end
 
 Then /^I should see today's time in &quot;(.*)&quot;$/ do |file|
-  assert_match Regexp.new(Time.now.to_s), File.open(file).readlines.join
+  assert_equal Time.now.to_s, File.open(file).readlines.join.chomp
 end
 
 Then /^I should see today's date in &quot;(.*)&quot;$/ do |file|
   assert_match Regexp.new(Date.today.to_s), File.open(file).readlines.join
-end
-
+end
\ No newline at end of file</diff>
      <filename>features/step_definitions/jekyll_steps.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,6 +16,7 @@ require 'redcloth'
 
 # internal requires
 require 'jekyll/core_ext'
+require 'jekyll/pager'
 require 'jekyll/site'
 require 'jekyll/convertible'
 require 'jekyll/layout'</diff>
      <filename>lib/jekyll.rb</filename>
    </modified>
    <modified>
      <diff>@@ -46,18 +46,21 @@ module Jekyll
     end
 
     # Write the generated page file to the destination directory.
-    #   +dest+ is the String path to the destination dir
+    #   +dest_prefix+ is the String path to the destination dir
+    #   +dest_suffix+ is a suffix path to the destination dir
     #
     # Returns nothing
-    def write(dest)
-      FileUtils.mkdir_p(File.join(dest, @dir))
+    def write(dest_prefix, dest_suffix = nil)
+      dest = File.join(dest_prefix, @dir)
+      dest = File.join(dest, dest_suffix) if dest_suffix
+      FileUtils.mkdir_p(dest)
 
       name = @name
       if self.ext != &quot;&quot;
         name = @name.split(&quot;.&quot;)[0..-2].join('.') + self.ext
       end
 
-      path = File.join(dest, @dir, name)
+      path = File.join(dest, name)
       File.open(path, 'w') do |f|
         f.write(self.output)
       end</diff>
      <filename>lib/jekyll/page.rb</filename>
    </modified>
    <modified>
      <diff>@@ -167,11 +167,14 @@ module Jekyll
         directories.delete('_posts')
         read_posts(dir)
       end
+      
       [directories, files].each do |entries|
         entries.each do |f|
           if File.directory?(File.join(base, f))
             next if self.dest.sub(/\/$/, '') == File.join(base, f)
             transform_pages(File.join(dir, f))
+          elsif Pager.pagination_enabled?(self.config, f)
+            paginate_posts(f, dir)
           else
             first3 = File.open(File.join(self.source, dir, f)) { |fd| fd.read(3) }
 
@@ -229,6 +232,31 @@ module Jekyll
         end
       end
     end
+    
+    # Paginates the blog's posts. Renders the index.html file into paginated directories, ie: page2, page3...
+    # and adds more wite-wide data
+    #
+    # {&quot;paginator&quot; =&gt; { &quot;page&quot; =&gt; &lt;Number&gt;,
+    #                   &quot;per_page&quot; =&gt; &lt;Number&gt;,
+    #                   &quot;posts&quot; =&gt; [&lt;Post&gt;],
+    #                   &quot;total_posts&quot; =&gt; &lt;Number&gt;,
+    #                   &quot;total_pages&quot; =&gt; &lt;Number&gt;,
+    #                   &quot;previous_page&quot; =&gt; &lt;Number&gt;,
+    #                   &quot;next_page&quot; =&gt; &lt;Number&gt; }}
+    def paginate_posts(file, dir)
+      all_posts = self.posts.sort { |a,b| b &lt;=&gt; a }
+      page = Page.new(self, self.source, dir, file)
+
+      pages = Pager.calculate_pages(all_posts, self.config['paginate'].to_i)
+
+      (1..pages).each do |num_page|
+        pager = Pager.new(self.config, num_page, all_posts, pages)
+
+        page.render(self.layouts, site_payload.merge({'paginator' =&gt; pager.to_hash}))
+        suffix = &quot;page#{num_page}&quot; if num_page &gt; 1
+        page.write(self.dest, suffix)
+      end
+    end
 
   end
 end</diff>
      <filename>lib/jekyll/site.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8a11c0e92a7efc1013c8af8e9be6afae68fb86c4</id>
    </parent>
    <parent>
      <id>6eb29a4808cc9cb585b6d48548d401d23a3d5875</id>
    </parent>
  </parents>
  <author>
    <name>Nick Quaranto</name>
    <email>nick@quaran.to</email>
  </author>
  <url>http://github.com/mojombo/jekyll/commit/e1dbda47edb00ae815bc8d942ece0d5684ef8088</url>
  <id>e1dbda47edb00ae815bc8d942ece0d5684ef8088</id>
  <committed-date>2009-05-09T08:44:34-07:00</committed-date>
  <authored-date>2009-05-09T08:44:34-07:00</authored-date>
  <message>Merging in calavera's pagination branch</message>
  <tree>16b44fced3e6dbbaecc13a3f0b7f98d6394c8901</tree>
  <committer>
    <name>Nick Quaranto</name>
    <email>nick@quaran.to</email>
  </committer>
</commit>
