<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/shinmun/handlers.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,6 +2,8 @@
 
 require 'shinmun'
 
+ENV['RACK_ENV'] = 'production'
+
 case ARGV[0]
 when 'init'
   Shinmun::Blog.init ARGV[1]
@@ -11,7 +13,7 @@ when 'post'
   post = blog.create_post(:title =&gt; ARGV[1], :date =&gt; Date.today)
   path = blog.post_file(post)
   
-  `git checkout #{path}`
+  `git checkout master posts`
   
   exec &quot;#{ENV['EDITOR']} #{path}&quot;
 
@@ -20,7 +22,7 @@ when 'page'
   post = blog.create_page(:title =&gt; ARGV[1])
   path = blog.post_file(post)
 
-  `git checkout #{path}`
+  `git checkout master pages`
 
   exec &quot;#{ENV['EDITOR']} #{path}&quot;
 </diff>
      <filename>bin/shinmun</filename>
    </modified>
    <modified>
      <diff>@@ -10,11 +10,11 @@ begin; require 'redcloth'; rescue LoadError; end
 
 require 'shinmun/bluecloth_coderay'
 require 'shinmun/helpers'
+require 'shinmun/handlers'
 require 'shinmun/blog'
 require 'shinmun/routes'
 require 'shinmun/post'
 require 'shinmun/comment'
-require 'shinmun/post_handler'
 
 require 'shinmun/aggregations/delicious'
 require 'shinmun/aggregations/flickr'</diff>
      <filename>lib/shinmun.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,16 +14,11 @@ module Shinmun
     def initialize(path)
       super
 
-      if ENV['RACK_ENV'] == 'production'
-        @store = GitStore.new(path)
-      else
-        @store = GitStore::FileStore.new(path)
-      end
-
-      @store.handler['md'] = PostHandler.new      
-      @store.load
-
       @config = {}
+      @store = GitStore.new(path)
+      @store.handler['md'] = PostHandler.new
+      @store.handler['rhtml'] = ERBHandler.new
+      @store.handler['rxml'] = ERBHandler.new
     end
 
     def self.init(path)
@@ -48,19 +43,24 @@ module Shinmun
       end
     end
 
+    def load_template(file)
+      store['templates/' + file]
+    end
+
     def render(name, vars = {})
       super(name, vars.merge(:blog =&gt; self))
     end
 
     def load
-      store.load
-      @pages = store['pages'].values
-      @posts = store['posts'].values.sort_by { |post| post.date.to_s }.reverse
+      store.load(ENV['RACK_ENV'] != 'production')
+      
+      @pages = store.tree('pages').values
+      @posts = store.tree('posts').values.sort_by { |post| post.date.to_s }.reverse
     end
 
     def call(env)
-      load if store.changed?
-      
+      load if store.changed? or ENV['RACK_ENV'] != 'production'
+        
       super
     end
     
@@ -94,8 +94,8 @@ module Shinmun
     def create_post(attr)
       post = Post.new(attr)
       path = post_file(post)
-      
-      transaction &quot;create post '#{post.title}'&quot; do
+
+      transaction &quot;create post `#{post.title}'&quot; do
         store[path] = post
       end
 
@@ -106,7 +106,7 @@ module Shinmun
       post = Post.new(attr)
       path = page_file(post)
 
-      transaction &quot;create page '#{post.title}'&quot; do
+      transaction &quot;create page `#{post.title}'&quot; do
         store[path] = post
       end
 
@@ -122,7 +122,7 @@ module Shinmun
       comments = comments_for(post)
       comment = Comment.new(params)
       
-      transaction &quot;new comment for '#{post.title}'&quot; do
+      transaction &quot;new comment for `#{post.title}'&quot; do
         store[path] = comments + [comment]
       end
       </diff>
      <filename>lib/shinmun/blog.rb</filename>
    </modified>
    <modified>
      <diff>@@ -48,8 +48,8 @@ Shinmun::Blog.map do
     if page
       render 'page.rhtml', :page =&gt; page
       
-    elsif File.exist?(path)
-      text File.read(&quot;#{self.path}/public/#{path}&quot;)
+    elsif file = store[path]
+      text file
     else
       render '404.rhtml', :path =&gt; path
     end</diff>
      <filename>lib/shinmun/routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,16 +8,18 @@ describe Shinmun::Blog do
 
   DIR = '/tmp/shinmun-test'
 
+  attr_reader :blog
+
   before do
-    FileUtils.rm_rf DIR
+    ENV['RACK_ENV'] = 'production'
     
+    FileUtils.rm_rf DIR
+
     Shinmun::Blog.init(DIR)
     
-    ENV['RACK_ENV'] = 'production'
-    
     @blog = Shinmun::Blog.new(DIR)
     
-    @blog.config = {
+    blog.config = {
       :title =&gt; 'Title',
       :description =&gt; 'Description',
       :language =&gt; 'en',
@@ -25,18 +27,18 @@ describe Shinmun::Blog do
       :categories =&gt; ['Ruby', 'Javascript']
     }
     
-    @posts = [@blog.create_post(:title =&gt; 'New post', :date =&gt; '2008-10-10', :category =&gt; 'Ruby', :body =&gt; 'Body1'),
-              @blog.create_post(:title =&gt; 'And this', :date =&gt; '2008-10-11', :category =&gt; 'Ruby', :body =&gt; 'Body2'),
-              @blog.create_post(:title =&gt; 'Again',    :date =&gt; '2008-11-10', :category =&gt; 'Javascript', :body =&gt; 'Body3')]
+    @posts = [blog.create_post(:title =&gt; 'New post', :date =&gt; '2008-10-10', :category =&gt; 'Ruby', :body =&gt; 'Body1'),
+              blog.create_post(:title =&gt; 'And this', :date =&gt; '2008-10-11', :category =&gt; 'Ruby', :body =&gt; 'Body2'),
+              blog.create_post(:title =&gt; 'Again',    :date =&gt; '2008-11-10', :category =&gt; 'Javascript', :body =&gt; 'Body3')]
 
-    @pages = [@blog.create_page(:title =&gt; 'Page 1', :body =&gt; 'Body1'),
-              @blog.create_page(:title =&gt; 'Page 2', :body =&gt; 'Body2')]
+    @pages = [blog.create_page(:title =&gt; 'Page 1', :body =&gt; 'Body1'),
+              blog.create_page(:title =&gt; 'Page 2', :body =&gt; 'Body2')]
 
-    @blog.load
+    blog.load
   end
 
   def request(method, uri, options={})
-    @request = Rack::MockRequest.new(@blog)    
+    @request = Rack::MockRequest.new(blog)    
     @response = @request.request(method, uri, options)
   end
 
@@ -64,25 +66,29 @@ describe Shinmun::Blog do
       titles[i].text.should == title
       summaries[i].text.to_s.strip.should == summary
     end
-  end 
+  end
+
+  it &quot;should load templates&quot; do
+    blog.load_template(&quot;index.rhtml&quot;).should be_kind_of(ERB)
+  end
 
   it &quot;should find posts for a category&quot; do    
-    category = @blog.find_category('ruby')
+    category = blog.find_category('ruby')
     category[:name].should == 'Ruby'
     
     category[:posts].should include(@posts[0])
     category[:posts].should include(@posts[1])
 
-    category = @blog.find_category('javascript')
+    category = blog.find_category('javascript')
     category[:name].should == 'Javascript'
     category[:posts].should include(@posts[2])
   end
 
   it &quot;should create a post&quot; do
-    post = @blog.create_post(:title =&gt; 'New post', :date =&gt; '2008-10-10')
-    @blog.load
+    post = blog.create_post(:title =&gt; 'New post', :date =&gt; '2008-10-10')
+    blog.load
 
-    post = @blog.find_post(2008, 10, 'new-post')
+    post = blog.find_post(2008, 10, 'new-post')
     post.should_not be_nil
     post.title.should == 'New post'
     post.date.should == Date.new(2008, 10, 10)
@@ -113,8 +119,8 @@ describe Shinmun::Blog do
   end
 
   it &quot;should render index and archives&quot; do
-    @blog.posts_for_month(2008, 10).should_not be_empty
-    @blog.posts_for_month(2008, 11).should_not be_empty
+    blog.posts_for_month(2008, 10).should_not be_empty
+    blog.posts_for_month(2008, 11).should_not be_empty
     
     assert_listing(get('/2008/10').body, [['And this', 'Body2'], ['New post', 'Body1']])
     assert_listing(get('/').body, [['Again', 'Body3'], ['And this', 'Body2'], ['New post', 'Body1']])
@@ -134,7 +140,7 @@ describe Shinmun::Blog do
     post &quot;/2008/10/new-post/comments?name=Hans&amp;text=Hallo&quot;
     post &quot;/2008/10/new-post/comments?name=Peter&amp;text=Servus&quot;
     
-    comments = @blog.comments_for(@posts[0])
+    comments = blog.comments_for(@posts[0])
 
     comments[0].should_not be_nil
     comments[0].name.should == 'Hans'</diff>
      <filename>test/blog_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/shinmun/post_handler.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>f9304707fe84188f607cfbc45c76b5d19d75c174</id>
    </parent>
  </parents>
  <author>
    <name>Matthias Georgi</name>
    <email>matti.georgi@gmail.com</email>
  </author>
  <url>http://github.com/georgi/shinmun/commit/a1c1fec34cecbb12a41cda66508a9e3bc53420a5</url>
  <id>a1c1fec34cecbb12a41cda66508a9e3bc53420a5</id>
  <committed-date>2009-04-27T11:07:19-07:00</committed-date>
  <authored-date>2009-04-27T11:07:19-07:00</authored-date>
  <message>adjusted handlers. reloading in dev mode.</message>
  <tree>2ba5eeb9b9d50754ff3f7481956c662a810e093b</tree>
  <committer>
    <name>Matthias Georgi</name>
    <email>matti.georgi@gmail.com</email>
  </committer>
</commit>
