<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -31,9 +31,10 @@ various data about my site. A reverse chronological list of all my blog posts
 can be found in &lt;code&gt;site.posts&lt;/code&gt;. Each post, in turn, contains various
 fields such as &lt;code&gt;title&lt;/code&gt; and &lt;code&gt;date&lt;/code&gt;.
 
-Jekyll gets the list of blog posts by parsing the files in the
-&quot;_posts&quot;:http://github.com/mojombo/tpw/tree/master/_posts directory. Each
-post's filename contains the publishing date and slug (what shows up in the
+Jekyll gets the list of blog posts by parsing the files in any
+&quot;_posts&quot;:http://github.com/mojombo/tpw/tree/master/_posts directory found in
+subdirectories below the root. 
+Each post's filename contains the publishing date and slug (what shows up in the
 URL) that the final HTML file should have. Open up the file corresponding to a
 blog post:
 &quot;2008-11-17-blogging-like-a-hacker.textile&quot;:http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile.
@@ -52,6 +53,13 @@ filename is used to construct the URL in the generated site. The example post,
 for instance, ends up at
 &lt;code&gt;http://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker.html&lt;/code&gt;.
 
+Categories for posts are derived from the directory structure the posts were 
+found within.
+A post that appears in the directory foo/bar/_posts is placed in the categories
+'foo' and 'bar'.
+By selecting posts from particular categories in your Liquid templates, you will
+be able to host multiple blogs within a site.
+
 Files that do not reside in directories prefixed with an underscore are
 mirrored into a corresponding directory structure in the generated site. If a
 file does not have a YAML preface, it is not run through the Liquid
@@ -158,6 +166,9 @@ h3. Site
     high quality but slow to compute results, run the jekyll command with the 
     --lsi (latent semantic indexing) option.
 
+  site.categories.CATEGORY
+    The list of all posts in category CATEGORY.
+
 h3. Post
 
   post.title
@@ -177,6 +188,9 @@ h3. Post
   post.content
     The content of the Post.
 
+  post.categories
+    The list of categories to which this post belongs.
+
 h2. YAML Front Matter
 
 Any files that contain a YAML front matter block will be processed by Jekyll
@@ -289,6 +303,22 @@ highlighting stylesheet. For an example stylesheet you can look at
 are the same styles as used by GitHub and you are free to use them for your
 own site.
 
+h2. Categories
+
+Posts are placed into categories based on the directory structure they are found
+within (see above for an example). The categories can be accessed from within
+a Liquid template as follows:
+
+&lt;pre&gt;
+{% for post in site.categories.foo %}
+	&lt;li&gt;&lt;span&gt;{{ post.date | date_to_string }}&lt;/span&gt; - {{ post.title }}&lt;/li&gt;
+{% endfor %}
+&lt;/pre&gt;
+
+This would list all the posts in the category 'foo' by date and title.
+
+The posts within each category are sorted in reverse chronological order.
+
 h2. Contribute
 
 If you'd like to hack on Jekyll, grab the source from GitHub. To get</diff>
      <filename>README.textile</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,7 @@ require 'rubygems'
 # core
 require 'fileutils'
 require 'time'
+require 'yaml'
 
 # stdlib
 </diff>
      <filename>lib/jekyll.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,7 +15,6 @@ module Jekyll
     
     def number_of_words(input)
       input.split.length
-    end
-  end
-  
+    end    
+  end  
 end
\ No newline at end of file</diff>
      <filename>lib/jekyll/filters.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@ module Jekyll
   class Post
     include Comparable
     include Convertible
-    
+        
     class &lt;&lt; self
       attr_accessor :lsi
     end
@@ -18,17 +18,19 @@ module Jekyll
       name =~ MATCHER
     end
     
-    attr_accessor :date, :slug, :ext
+    attr_accessor :date, :slug, :ext, :categories
     attr_accessor :data, :content, :output
     
     # Initialize this Post instance.
     #   +base+ is the String path to the dir containing the post file
     #   +name+ is the String filename of the post file
+    #   +categories+ is an Array of Strings for the categories for this post
     #
     # Returns &lt;Post&gt;
     def initialize(base, name)
       @base = base
       @name = name
+      @categories = base.split('/').reject { |p| ['.', '_posts'].include? p }
       
       self.process(name)
       self.read_yaml(base, name)
@@ -61,9 +63,10 @@ module Jekyll
     #
     # Returns &lt;String&gt;
     def dir
+      path = @categories ? '/' + @categories.join('/') : ''
       permalink ?
         permalink.to_s.split(&quot;/&quot;)[0..-2].join(&quot;/&quot;) :
-        date.strftime(&quot;/%Y/%m/%d/&quot;)
+        &quot;#{path}&quot; + date.strftime(&quot;/%Y/%m/%d/&quot;)
     end
     
     # The full path and filename of the post.
@@ -90,7 +93,7 @@ module Jekyll
     def id
       self.dir + self.slug
     end
-    
+        
     # Calculate related posts.
     #
     # Returns [&lt;Post&gt;]</diff>
      <filename>lib/jekyll/post.rb</filename>
    </modified>
    <modified>
      <diff>@@ -24,9 +24,8 @@ module Jekyll
     # Returns nothing
     def process
       self.read_layouts
-      self.read_posts
-      self.write_posts
       self.transform_pages
+      self.write_posts
     end
     
     # Read all the files in &lt;source&gt;/_layouts into memory for
@@ -46,12 +45,11 @@ module Jekyll
       # ignore missing layout dir
     end
     
-    # Read all the files in &lt;source&gt;/posts and create a new Post
+    # Read all the files in &lt;base&gt;/_posts and create a new Post
     # object with each one.
     #
     # Returns nothing
-    def read_posts
-      base = File.join(self.source, &quot;_posts&quot;)
+    def read_posts(base)
       entries = Dir.entries(base)
       entries = entries.reject { |e| File.directory?(e) }
 
@@ -76,7 +74,7 @@ module Jekyll
     
     # Copy all regular files from &lt;source&gt; to &lt;dest&gt;/ ignoring
     # any files/directories that are hidden (start with &quot;.&quot;) or contain
-    # site content (start with &quot;_&quot;)
+    # site content (start with &quot;_&quot;) unless they are &quot;_posts&quot; directories
     #   The +dir+ String is a relative path used to call this method
     #            recursively as it descends through directories
     #
@@ -84,10 +82,14 @@ module Jekyll
     def transform_pages(dir = '')
       base = File.join(self.source, dir)
       entries = Dir.entries(base)
-      entries = entries.reject { |e| ['.', '_'].include?(e[0..0]) }
+      entries = entries.reject { |e| 
+        (e != '_posts') and ['.', '_'].include?(e[0..0]) 
+      }
 
       entries.each do |f|
-        if File.directory?(File.join(base, f))
+        if f == '_posts'
+          read_posts(File.join(base, f))
+        elsif File.directory?(File.join(base, f))
           next if self.dest.sub(/\/$/, '') == File.join(base, f)
           transform_pages(File.join(dir, f))
         else
@@ -111,7 +113,17 @@ module Jekyll
     #
     # Returns {&quot;site&quot; =&gt; {&quot;time&quot; =&gt; &lt;Time&gt;, &quot;posts&quot; =&gt; [&lt;Post&gt;]}}
     def site_payload
-      {&quot;site&quot; =&gt; {&quot;time&quot; =&gt; Time.now, &quot;posts&quot; =&gt; self.posts.sort.reverse}}
+      # Build the category hash map of category ( names =&gt; arrays of posts )
+      # then sort each array in reverse order
+      categories = Hash.new { |hash,key| hash[key] = Array.new } 
+      self.posts.each { |p| p.categories.each { |c| categories[c] &lt;&lt; p } }
+      categories.values.map { |cats| cats.sort! { |a,b| b &lt;=&gt; a} } 
+      
+      {&quot;site&quot; =&gt; {
+        &quot;time&quot; =&gt; Time.now, 
+        &quot;posts&quot; =&gt; self.posts.sort { |a,b| b &lt;=&gt; a },
+        &quot;categories&quot; =&gt; categories
+      }}
     end
   end
 </diff>
      <filename>lib/jekyll/site.rb</filename>
    </modified>
    <modified>
      <diff>@@ -81,7 +81,7 @@ class TestPost &lt; Test::Unit::TestCase
     layouts = {&quot;default&quot; =&gt; Layout.new(File.join(File.dirname(__FILE__), *%w[source _layouts]), &quot;simple.html&quot;)}
     p.add_layout(layouts, {&quot;site&quot; =&gt; {&quot;posts&quot; =&gt; []}})
     
-    assert_equal &quot;&lt;&lt;&lt; &lt;p&gt;url: /2008/11/21/complex.html&lt;br /&gt;\ndate: #{Time.parse(&quot;2008-11-21&quot;)}&lt;br /&gt;\nid: /2008/11/21/complex&lt;/p&gt; &gt;&gt;&gt;&quot;, p.output
+    assert_equal &quot;&lt;&lt;&lt; &lt;p&gt;url: /test/source/2008/11/21/complex.html&lt;br /&gt;\ndate: #{Time.parse(&quot;2008-11-21&quot;)}&lt;br /&gt;\nid: /test/source/2008/11/21/complex&lt;/p&gt; &gt;&gt;&gt;&quot;, p.output
   end
   
   def test_include</diff>
      <filename>test/test_post.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,9 +15,9 @@ class TestSite &lt; Test::Unit::TestCase
     
     assert_equal [&quot;default&quot;, &quot;simple&quot;].sort, @s.layouts.keys.sort
   end
-  
+ 
   def test_read_posts
-    @s.read_posts
+    @s.read_posts(File.join(@s.source, '_posts'))
     
     assert_equal 3, @s.posts.size
   end</diff>
      <filename>test/test_site.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b094b933011e314ac24bd62d5563d5286783918c</id>
    </parent>
  </parents>
  <author>
    <name>Mark Reid</name>
    <email>mark@threewordslong.com</email>
  </author>
  <url>http://github.com/mojombo/jekyll/commit/3a8f7a8e3a20778573e782514e535e9a2ddcad49</url>
  <id>3a8f7a8e3a20778573e782514e535e9a2ddcad49</id>
  <committed-date>2008-12-15T22:52:00-08:00</committed-date>
  <authored-date>2008-12-15T22:52:00-08:00</authored-date>
  <message>Added post categories based on directories containing _posts</message>
  <tree>d68b35ad21b14c5276b47b350f01fb9d913d2cd8</tree>
  <committer>
    <name>Mark Reid</name>
    <email>mark@threewordslong.com</email>
  </committer>
</commit>
