<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>run.ru</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -26,7 +26,8 @@ The fellowing [gems][] are required to run git-wiki:
 - BlueCloth
 - rubypants
 
-Run `rake bootstrap &amp;&amp; ruby git-wiki.rb` and point your browser at &lt;http://0.0.0.0:4567/&gt;. Enjoy!
+Run with `mkdir ~/wiki &amp;&amp; ./run.ru -sthin -p4567` and point your
+browser at &lt;http://0.0.0.0:4567/&gt;. Enjoy!
 
 ## Licence
                DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@@ -42,41 +43,47 @@ Run `rake bootstrap &amp;&amp; ruby git-wiki.rb` and point your browser at &lt;http://0.0.0
 
      0. You just DO WHAT THE FUCK YOU WANT TO.
 
+## See also
+
+- [WiGit](http://el-tramo.be/software/wigit) &#8211; git-wiki in PHP
+- [ikiwiki](http://ikiwiki.info/) &#8211; a wiki compiler supporting git
+
 ## Quotes
 
 &lt;blockquote&gt;
 &lt;p&gt;[...] the first wiki engine I'd consider worth using for my own projects.&lt;/p&gt;
-&lt;p&gt;&lt;cite&gt;&lt;a href=&quot;http://www.dekorte.com/blog/blog.cgi?do=item&amp;amp;id=3319&quot;&gt;Steve Dekorte&lt;/a&gt;&lt;/cite&gt;&lt;/p&gt;
+&lt;p&gt;&lt;cite&gt;
+&lt;a href=&quot;http://www.dekorte.com/blog/blog.cgi?do=item&amp;amp;id=3319&quot;&gt;
+Steve Dekorte&lt;/a&gt;
+&lt;/cite&gt;&lt;/p&gt;
 &lt;/blockquote&gt;
 
 &lt;blockquote&gt;
-&lt;p&gt;Oh, it looks like &lt;a href=&quot;http://atonie.org/2008/02/git-wiki&quot;&gt;Git Wiki&lt;/a&gt; may be the
-starting point for what I need...&lt;/p&gt;
+&lt;p&gt;Oh, it looks like &lt;a href=&quot;http://atonie.org/2008/02/git-wiki&quot;&gt;Git Wiki&lt;/a&gt;
+may be the starting point for what I need...&lt;/p&gt;
 &lt;p&gt;&lt;cite&gt;&lt;a href=&quot;http://tommorris.org/blog/2008/03/09#pid2761430&quot;&gt;
 Tom Morris on &quot;How to build the perfect wiki&quot;&lt;/a&gt;&lt;/cite&gt;&lt;/p&gt;
 &lt;/blockquote&gt;
 
 &lt;blockquote&gt;
-&lt;p&gt;What makes git-wiki so cool is because it is backed by a git store, you can clone your
-wiki just like you could any other git repository. I&#8217;ve always wanted a wiki that I could
-a.) pull offline when I didn&#8217;t have access to the Internets and b.) edit (perhaps in bulk)
+&lt;p&gt;What makes git-wiki so cool is because it is backed by a git store,
+you can clone your wiki just like you could any other git repository.
+I&#8217;ve always wanted a wiki that I could a.) pull offline when I didn&#8217;t
+have access to the Internets and b.) edit (perhaps in bulk)
 in my favorite text editor. git-wiki allows both.&lt;/p&gt;
-&lt;p&gt;&lt;cite&gt;&lt;a href=&quot;http://github.com/willcodeforfoo/git-wiki/wikis&quot;&gt;Cloning your wiki&lt;/a&gt;&lt;/cite&gt;&lt;/p&gt;
+&lt;p&gt;&lt;cite&gt;&lt;a href=&quot;http://github.com/willcodeforfoo/git-wiki/wikis&quot;&gt;
+Cloning your wiki&lt;/a&gt;&lt;/cite&gt;&lt;/p&gt;
 &lt;/blockquote&gt;
 
 &lt;blockquote&gt;
-&lt;p&gt;Numerous people have written diff and merge systems for wikis; TWiki even uses RCS.
-If they used git instead, the repository would be tiny, and you could make a personal
-copy of the entire wiki to take on the plane with you, then sync your changes back when you're done.&lt;/p&gt; 
-&lt;p&gt;&lt;cite&gt;&lt;a href=&quot;http://www.advogato.org/person/apenwarr/diary/371.html&quot;&gt;Git is the next Unix&lt;/a&gt;&lt;/cite&gt;&lt;/p&gt;
+&lt;p&gt;Numerous people have written diff and merge systems for wikis;
+TWiki even uses RCS. If they used git instead, the repository would be tiny, and
+you could make a personal copy of the entire wiki to take on the plane with you,
+then sync your changes back when you're done.&lt;/p&gt;
+&lt;p&gt;&lt;cite&gt;&lt;a href=&quot;http://www.advogato.org/person/apenwarr/diary/371.html&quot;&gt;
+Git is the next Unix&lt;/a&gt;&lt;/cite&gt;&lt;/p&gt;
 &lt;/blockquote&gt;
 
-## See also
-
-- [WiGit](http://el-tramo.be/software/wigit) &#8211; git-wiki in PHP
-- [ikiwiki](http://ikiwiki.info/) &#8211; a wiki compiler supporting git
-
-
   [Sinatra]: http://sinatrarb.com
   [GitHub]: http://github.com/sr/git-wiki
   [forks]: http://github.com/sr/git-wiki/network</diff>
      <filename>README.markdown</filename>
    </modified>
    <modified>
      <diff>@@ -2,17 +2,9 @@
 require &quot;rubygems&quot;
 gem &quot;mojombo-grit&quot;
 
-%w(sinatra
-grit
-haml
-sass
-redcloth).each { |dependency| require dependency }
-
-begin
-  require &quot;thin&quot;
-rescue LoadError
-  puts &quot;# May I suggest you to use Thin?&quot;
-end
+require &quot;sinatra/base&quot;
+require &quot;grit&quot;
+require &quot;redcloth&quot;
 
 class String
   def titleize
@@ -20,168 +12,188 @@ class String
   end
 end
 
-class PageNotFound &lt; Sinatra::NotFound
-  attr_reader :name
+module GitWiki
+  class &lt;&lt; self
+    attr_accessor :homepage, :extension, :repository
+  end
+
+  def self.new(repository, extension, homepage)
+    self.homepage   = homepage
+    self.extension  = extension
+    self.repository = Grit::Repo.new(repository)
 
-  def initialize(name)
-    @name = name
+    App
   end
-end
 
-class Page
-  class &lt;&lt; self
-    attr_accessor :repository
-    attr_accessor :extension
+  class PageNotFound &lt; Sinatra::NotFound
+    attr_reader :name
+
+    def initialize(name)
+      @name = name
+    end
+  end
 
-    def find_all
+  class Page
+    def self.find_all
       return [] if repository.tree.contents.empty?
       repository.tree.contents.collect { |blob| new(blob) }
     end
 
-    def find(name)
+    def self.find(name)
       page_blob = find_blob(name)
       raise PageNotFound.new(name) unless page_blob
       new(page_blob)
     end
 
-    def find_or_create(name)
+    def self.find_or_create(name)
       find(name)
     rescue PageNotFound
       new(create_blob_for(name))
     end
 
-    def css_class_for(name)
+    def self.css_class_for(name)
       find(name)
       &quot;exists&quot;
     rescue PageNotFound
       &quot;unknown&quot;
     end
 
-    private
-      def find_blob(page_name)
-        repository.tree/(page_name + extension)
-      end
-
-      def create_blob_for(page_name)
-        Grit::Blob.create(repository, :name =&gt; page_name + extension, :data =&gt; &quot;&quot;)
-      end
-  end
-
-  def initialize(blob)
-    @blob = blob
-  end
-
-  def to_html
-    linked = auto_link(wiki_link(content))
-    RedCloth.new(linked).to_html
-  end
+    def self.repository
+      GitWiki.repository || raise
+    end
 
-  def to_s
-    name
-  end
+    def self.extension
+      GitWiki.extension || raise
+    end
 
-  def new?
-    @blob.id.nil?
-  end
+    def self.find_blob(page_name)
+      repository.tree/(page_name + extension)
+    end
+    private_class_method :find_blob
 
-  def name
-    @blob.name.delete(File.extname(@blob.name))
-  end
+    def self.create_blob_for(page_name)
+      Grit::Blob.create(repository, {
+        :name =&gt; page_name + extension,
+        :data =&gt; &quot;&quot;
+      })
+    end
+    private_class_method :create_blob_for
 
-  def content
-    @blob.data
-  end
+    def initialize(blob)
+      @blob = blob
+    end
 
-  def update_content(new_content)
-    return if new_content == content
-    File.open(file_name, &quot;w&quot;) { |f| f &lt;&lt; new_content }
-    add_to_index_and_commit!
-  end
+    def to_html
+      linked = auto_link(wiki_link(content))
+      RedCloth.new(linked).to_html
+    end
 
-  private
-    def add_to_index_and_commit!
-      Dir.chdir(self.class.repository.path) { self.class.repository.add(@blob.name) }
-      self.class.repository.commit_index(commit_message)
+    def to_s
+      name
     end
 
-    def file_name
-      File.join(self.class.repository.path, name + self.class.extension)
+    def new?
+      @blob.id.nil?
     end
 
-    def commit_message
-      new? ? &quot;Created #{name}&quot; : &quot;Updated #{name}&quot;
+    def name
+      @blob.name.gsub(/#{File.extname(@blob.name)}$/, '')
     end
 
-    def auto_link(string)
-      string.gsub(/&lt;((https?|ftp|irc):[^'&quot;&gt;\s]+)&gt;/xi, %Q{&lt;a href=&quot;\\1&quot;&gt;\\1&lt;/a&gt;})
+    def content
+      @blob.data
     end
 
-    def wiki_link(string)
-      string.gsub(/([A-Z][a-z]+[A-Z][A-Za-z0-9]+)/) { |page|
-        %Q{&lt;a class=&quot;#{self.class.css_class_for(page)}&quot; href=&quot;/#{page}&quot;&gt;#{page.titleize}&lt;/a&gt;}
-      }
+    def update_content(new_content)
+      return if new_content == content
+      File.open(file_name, &quot;w&quot;) { |f| f &lt;&lt; new_content }
+      add_to_index_and_commit!
     end
-end
 
-use_in_file_templates!
+    private
+      def add_to_index_and_commit!
+        Dir.chdir(self.class.repository.working_dir) {
+          self.class.repository.add(@blob.name)
+        }
+        self.class.repository.commit_index(commit_message)
+      end
 
-configure do
-  GitRepository = ENV[&quot;GIT_WIKI_REPO&quot;] || File.join(ENV[&quot;HOME&quot;], &quot;wiki&quot;)
-  Homepage = &quot;Home&quot;
-  set_option :haml,  :format =&gt; :html5, :attr_wrapper  =&gt; '&quot;'
+      def file_name
+        File.join(self.class.repository.working_dir, name + self.class.extension)
+      end
 
-  Page.repository = Grit::Repo.new(GitRepository)
-  Page.extension  = &quot;.textile&quot;
-end
+      def commit_message
+        new? ? &quot;Created #{name}&quot; : &quot;Updated #{name}&quot;
+      end
 
-error PageNotFound do
-  page = request.env[&quot;sinatra.error&quot;].name
-  redirect &quot;/e/#{page}&quot;
-end
+      def auto_link(str)
+        str.gsub(/&lt;((https?|ftp|irc):[^'&quot;&gt;\s]+)&gt;/xi, %Q{&lt;a href=&quot;\\1&quot;&gt;\\1&lt;/a&gt;})
+      end
 
-helpers do
-  def title(title=nil)
-    @title = title.to_s unless title.nil?
-    @title
+      def wiki_link(str)
+        str.gsub(/([A-Z][a-z]+[A-Z][A-Za-z0-9]+)/) { |page|
+          %Q{&lt;a class=&quot;#{self.class.css_class_for(page)}&quot;} +
+            %Q{href=&quot;/#{page}&quot;&gt;#{page.titleize}&lt;/a&gt;}
+        }
+      end
   end
 
-  def list_item(page)
-    %Q{&lt;a class=&quot;page_name&quot; href=&quot;/#{page}&quot;&gt;#{page.name.titleize}&lt;/a&gt;}
-  end
-end
+  class App &lt; Sinatra::Base
+    set :app_file, __FILE__
+    set :haml, { :format        =&gt; :html5,
+                 :attr_wrapper  =&gt; '&quot;'     }
+    enable :static
+    use_in_file_templates!
 
-before do
-  content_type &quot;text/html&quot;, :charset =&gt; &quot;utf-8&quot;
-end
+    error PageNotFound do
+      page = request.env[&quot;sinatra.error&quot;].name
+      redirect &quot;/#{page}/edit&quot;
+    end
 
-get &quot;/&quot; do
-  redirect &quot;/&quot; + Homepage
-end
+    before do
+      content_type &quot;text/html&quot;, :charset =&gt; &quot;utf-8&quot;
+    end
 
-get &quot;/_stylesheet.css&quot; do
-  content_type &quot;text/css&quot;, :charset =&gt; &quot;utf-8&quot;
-  sass :stylesheet
-end
+    get &quot;/&quot; do
+      redirect &quot;/&quot; + GitWiki.homepage
+    end
 
-get &quot;/_list&quot; do
-  @pages = Page.find_all
-  haml :list
-end
+    get &quot;/_stylesheet.css&quot; do
+      content_type &quot;text/css&quot;, :charset =&gt; &quot;utf-8&quot;
+      sass :stylesheet
+    end
 
-get &quot;/:page&quot; do
-  @page = Page.find(params[:page])
-  haml :show
-end
+    get &quot;/_list&quot; do
+      @pages = Page.find_all
+      haml :list
+    end
 
-get &quot;/e/:page&quot; do
-  @page = Page.find_or_create(params[:page])
-  haml :edit
-end
+    get &quot;/:page&quot; do
+      @page = Page.find(params[:page])
+      haml :show
+    end
+
+    get &quot;/e/:page&quot; do
+      @page = Page.find_or_create(params[:page])
+      haml :edit
+    end
 
-post &quot;/e/:page&quot; do
-  @page = Page.find_or_create(params[:page])
-  @page.update_content(params[:body])
-  redirect &quot;/#{@page}&quot;
+    post &quot;/e/:page&quot; do
+      @page = Page.find_or_create(params[:page])
+      @page.update_content(params[:body])
+      redirect &quot;/#{@page}&quot;
+    end
+
+    private
+      def title(title=nil)
+        @title = title.to_s unless title.nil?
+        @title
+      end
+
+      def list_item(page)
+        %Q{&lt;a class=&quot;page_name&quot; href=&quot;/#{page}&quot;&gt;#{page.name.titleize}&lt;/a&gt;}
+      end
+  end
 end
 
 __END__
@@ -196,8 +208,8 @@ __END__
     %script{:src =&gt; '/to-title-case.js', :type =&gt; 'text/javascript'}
     :javascript
       $(document).ready(function() {
-        $.hotkeys.add('Ctrl+h', function() { document.location = '/#{Homepage}' })
-        $.hotkeys.add('Ctrl+l', function() { document.location = '/_list' })
+        $.hotkeys.add('Ctrl+h', function(){document.location = '/#{GitWiki.homepage}'})
+        $.hotkeys.add('Ctrl+l', function(){document.location = '/_list'})
 
         /* title-case-ification */
         document.title = document.title.toTitleCase();
@@ -214,7 +226,7 @@ __END__
 - title @page.name.titleize
 :javascript
   $(document).ready(function() {
-    $.hotkeys.add('Ctrl+e', function() { document.location = '/e/#{@page}' })
+    $.hotkeys.add('Ctrl+e', function(){document.location = '/e/#{@page}'})
   })
 %h1#page_title= title
 #page_content</diff>
      <filename>git-wiki.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>config.ru</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>d8e708df67144a91020fd338f2dfefd6a2c4de9a</id>
    </parent>
  </parents>
  <author>
    <name>Simon Rozet</name>
    <email>simon@rozet.name</email>
  </author>
  <url>http://github.com/sr/git-wiki/commit/b50336ac2b93b65bfcaedd1ee90108c9ffbb1018</url>
  <id>b50336ac2b93b65bfcaedd1ee90108c9ffbb1018</id>
  <committed-date>2009-02-01T13:01:02-08:00</committed-date>
  <authored-date>2009-01-21T16:39:56-08:00</authored-date>
  <message>Upgrade to Sinatra 0.9

See &lt;http://www.sinatrarb.com/2009/01/18/sinatra-0.9.0.html&gt;
for more information on 0.9

* Use a Sinatra::Base subclass
* config.ru takes the wiki directory as argument and launch
  git-wiki on it
* Update the README to reflects changes</message>
  <tree>a35cbf94699f2bf978b2ead9ed2115d1cbdb71ae</tree>
  <committer>
    <name>Simon Rozet</name>
    <email>simon@rozet.name</email>
  </committer>
</commit>
