<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>couchapp/_attachments/js/controllers/page_versions.js</filename>
    </added>
    <added>
      <filename>couchapp/_attachments/js/controllers/pages.js</filename>
    </added>
    <added>
      <filename>couchapp/_attachments/js/controllers/statistics.js</filename>
    </added>
    <added>
      <filename>couchapp/_attachments/js/models/page.js</filename>
    </added>
    <added>
      <filename>couchapp/_attachments/templates/page_versions/_page_version.html.erb</filename>
    </added>
    <added>
      <filename>couchapp/_attachments/templates/page_versions/index.html.erb</filename>
    </added>
    <added>
      <filename>couchapp/_attachments/templates/page_versions/show.html.erb</filename>
    </added>
    <added>
      <filename>couchapp/_attachments/templates/statistics/_stat.html.erb</filename>
    </added>
    <added>
      <filename>couchapp/_attachments/templates/statistics/index.html.erb</filename>
    </added>
    <added>
      <filename>couchapp/views/page_versions_by_page_id_and_created_at/map.js</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -18,10 +18,20 @@
     &lt;div id=&quot;notice&quot;&gt;&lt;/div&gt;
     &lt;div id=&quot;content&quot;&gt;&lt;/div&gt;
   &lt;/body&gt;
+  &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
+    Wiki = {
+      Models: {},
+      Controllers: {}
+    };
+  &lt;/script&gt;
   &lt;script src=&quot;/_utils/script/json2.js&quot;&gt;&lt;/script&gt;
   &lt;script src=&quot;./jquery.js&quot;&gt;&lt;/script&gt;
   &lt;script src=&quot;/_utils/script/jquery.couch.js&quot;&gt;&lt;/script&gt;
   &lt;script src=&quot;./vendor/couchapp/jquery.couchapp.js&quot;&gt;&lt;/script&gt;
   &lt;script src=&quot;./vendor/sammy/sammy.js&quot;&gt;&lt;/script&gt;
+  &lt;script src=&quot;./js/models/page.js&quot;&gt;&lt;/script&gt;
+  &lt;script src=&quot;./js/controllers/pages.js&quot;&gt;&lt;/script&gt;
+  &lt;script src=&quot;./js/controllers/page_versions.js&quot;&gt;&lt;/script&gt;
+  &lt;script src=&quot;./js/controllers/statistics.js&quot;&gt;&lt;/script&gt;
   &lt;script src=&quot;./js/app.js&quot;&gt;&lt;/script&gt;
 &lt;/html&gt;</diff>
      <filename>couchapp/_attachments/index.html</filename>
    </modified>
    <modified>
      <diff>@@ -4,155 +4,13 @@ $.CouchApp(function(app) {
 });
 var content = $('#content');
 
-var Wiki = {
-  Page: {
-    init: function(attributes) {
-      this.id = attributes.id;
-      this._rev = attributes._rev;
-      this.title = attributes.title;
-      this.body = attributes.body;
-      this.created_at = attributes.created_at || Date();
-      return this;
-    },
-    errors: [],
-    valid: function() {
-      this.errors = [];
-      if(this.title.length == 0) {
-        this.errors.push(&quot;Title can't be blank&quot;);
-      }
-      if(this.body.length == 0) {
-        this.errors.push(&quot;Body can't be blank&quot;);
-      }
-      return this.errors.length == 0;
-    },
-    to_json: function() {
-      return {
-        title: this.title,
-        body: this.body,
-        created_at: this.created_at,
-        type: 'Page'
-      }
-    }
-  }
-};
 
 var sammy = $.sammy(function() { with(this) {
   element_selector = '#content';
   
-  get('#/', function() { with(this) {
-    couchapp.design.view(&quot;pages_by_created_at&quot;, {
-       limit: 1,
-       success: function(json) {
-         if(json.rows[0]) {
-           redirect('#/pages/' + json.rows[0]['id']);
-           content.html();
-         } else {
-           redirect('#/new_page');
-         }
-       }
-     });
-  }});
-  
-  get('#/pages', function() { with(this) {
-    var context = this;
-    couchapp.design.view(&quot;pages_by_created_at&quot;, {
-       include_docs: true,
-       success: function(json) {
-         context.partial('./templates/pages/index.html.erb', function(html) {
-           content.html(html);
-           this.each(json['rows'], function(i, page) {
-             this.partial('./templates/pages/_page.html.erb', {page: page.doc}, function(page_html) {
-               $(page_html).appendTo('#all_pages')
-             })
-             
-           });
-         });
-       }
-     });
-  }});
-  
-  get('#/pages/:id', function() { with(this) {
-    var context = this;
-    couchapp.db.openDoc(params['id'], {
-      success: function(doc) {
-        context.page = doc;
-        context.partial('./templates/pages/show.html.erb')
-      },
-      error: function() {
-        trigger('error', {message: &quot;Page not found&quot;});
-      }
-    });
-  }});
-  
-  get('#/pages/edit/:id', function() { with(this) {
-    var context = this;
-    couchapp.db.openDoc(params['id'], {
-      success: function(doc) {
-        context.page = doc;
-        context.partial('./templates/pages/edit.html.erb')
-      },
-      error: function() {
-        trigger('error', {message: &quot;Page not found&quot;});
-      }
-    });
-  }});
-  
-  get('#/new_page', function() { with(this) {
-    partial('./templates/pages/new.html.erb');
-  }});
-  
-  post('#/pages/:id', function() { with(this) {
-    var page = Wiki.Page.init(params);
-    if(page.valid()) {
-      couchapp.db.saveDoc(page.to_json(), {
-        success: function(res) {
-          trigger('notice', {message: 'Page Saved'});
-          redirect('#/pages/' + res.id)
-        },
-        error: function(response_code, res) {
-          trigger('error', {message: 'Error saving page: ' + res});
-        }
-      });
-    } else {
-      trigger('error', {message: page.errors.join(&quot;, &quot;)});
-    };
-    return false;
-  }});
-  
-  post('#/pages', function() { with(this) {
-    var page = Wiki.Page.init(params);
-    if(page.valid()) {
-      couchapp.db.saveDoc(page.to_json(), {
-        success: function(res) {
-          trigger('notice', {message: 'Page Saved'});
-          redirect('#/pages/' + res.id)
-        },
-        error: function(response_code, res) {
-          trigger('error', {message: 'Error saving page: ' + res});
-        }
-      });
-    } else {
-      trigger('error', {message: page.errors.join(&quot;, &quot;)});
-    };
-    return false;
-  }});
-  
-  get('#/statistics', function() { with(this) {
-    var context = this;
-    couchapp.design.view('statistics', {
-      group: true,
-      success: function(json) {
-        context.partial('./templates/pages/statistics.html.erb', function(html) {
-          content.html(html);
-          this.each(json['rows'], function(i, row) {
-            this.partial('./templates/pages/_stat.html.erb', {stat: row}, function(stat_html) {
-              $(stat_html).appendTo('#statistics')
-            });
-          });
-        });
-      }
-    })
-  }});
+  Wiki.Controllers.Pages(this);
+  Wiki.Controllers.PageVersions(this);
+  Wiki.Controllers.Statistics(this);
   
   before(function() {
     $('#error').html('').hide();</diff>
      <filename>couchapp/_attachments/js/app.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,14 @@
 /* add styles here */
 
+body {
+  font-family: Verdana;
+}
+
+h2 {
+  background-color: #CCC;
+  padding: 10px;
+}
+
 #error {
   display:none;
   background-color: rgb(255, 100, 80);
@@ -16,6 +25,12 @@
   margin: 10px;
 }
 
+#nav li {
+  display: inline-block;
+  background-color: #DDD;
+  padding: 5px;
+}
+
 table.grid {
   border-collapse: collapse;
 }
@@ -23,4 +38,27 @@ table.grid {
 table.grid td, table.grid th {
   border: 1px solid gray;
   padding: 10px;
+}
+
+#page {
+  background-color: #EEE;
+  padding: 20px;
+}
+
+#subnav {
+  padding: 5px;
+  background-color: #666;
+}
+
+#subnav li {
+  display: inline-block;
+  background-color: #888;
+  color: white;
+  font-size: 1.2em;
+  padding: 10px;
+  padding-right: 20px;
+}
+
+#subnav li a {
+  color: white;
 }
\ No newline at end of file</diff>
      <filename>couchapp/_attachments/style/main.css</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
 &lt;li&gt;
-  &lt;a href=&quot;#/pages/&lt;%= page._id %&gt;&quot;&gt;&lt;%= page.title %&gt;&lt;/a&gt;
+  &lt;a href=&quot;#/pages/&lt;%= page._id %&gt;&quot;&gt;&lt;%= page._id %&gt;&lt;/a&gt;
 &lt;/li&gt;
 </diff>
      <filename>couchapp/_attachments/templates/pages/_page.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,6 @@
-&lt;h2&gt;&lt;%= page.title %&gt;&lt;/h2&gt;
+&lt;h2&gt;&lt;%= page._id %&gt;&lt;/h2&gt;
 
-&lt;form action=&quot;#/pages/&lt;%= page._id %&gt;&quot; method=&quot;post&quot;&gt;
-  &lt;input type=&quot;hidden&quot; name=&quot;_rev&quot; value=&quot;&lt;%= page._rev %&gt;&quot;/&gt;
-  &lt;label for=&quot;title&quot;&gt;Title&lt;/label&gt;
-  &lt;p&gt;&lt;input type=&quot;text&quot; name=&quot;title&quot; id=&quot;title&quot; value=&quot;&lt;%= page.title %&gt;&quot;/&gt;&lt;/p&gt;
-  &lt;label for=&quot;body&quot;&gt;Body&lt;/label&gt;
-  &lt;p&gt;&lt;textarea name=&quot;body&quot; id=&quot;body&quot;&gt;&lt;%= page.body %&gt;&lt;/textarea&gt;&lt;/p&gt;
+&lt;form action=&quot;#/pages/&lt;%= page._id %&gt;&quot; method=&quot;put&quot;&gt;
+  &lt;p&gt;&lt;textarea name=&quot;body&quot; id=&quot;body&quot; rows=&quot;20&quot; cols=&quot;80&quot;&gt;&lt;%= page.body %&gt;&lt;/textarea&gt;&lt;/p&gt;
   &lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;Update Page&quot;/&gt;&lt;/p&gt;
 &lt;/form&gt;</diff>
      <filename>couchapp/_attachments/templates/pages/edit.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 &lt;form action=&quot;#/pages&quot; method=&quot;post&quot;&gt;
   &lt;label for=&quot;title&quot;&gt;Title&lt;/label&gt;
-  &lt;p&gt;&lt;input type=&quot;text&quot; name=&quot;title&quot; id=&quot;title&quot;/&gt;&lt;/p&gt;
+  &lt;p&gt;&lt;input type=&quot;text&quot; name=&quot;_id&quot; id=&quot;title&quot; value=&quot;&lt;%= title %&gt;&quot;/&gt;&lt;/p&gt;
   &lt;label for=&quot;body&quot;&gt;Body&lt;/label&gt;
   &lt;p&gt;&lt;textarea name=&quot;body&quot; id=&quot;body&quot;&gt;&lt;/textarea&gt;&lt;/p&gt;
   &lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;Create Page&quot;/&gt;&lt;/p&gt;</diff>
      <filename>couchapp/_attachments/templates/pages/new.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,10 @@
-&lt;h2&gt;&lt;%= page.title %&gt;&lt;/h2&gt;
+&lt;h2&gt;&lt;%= page._id %&gt;&lt;/h2&gt;
 
-&lt;p&gt;&lt;a href=&quot;#/pages/edit/&lt;%= page._id %&gt;&quot;&gt;edit&lt;/a&gt;&lt;/p&gt;
+&lt;ul id=&quot;subnav&quot;&gt;
+  &lt;li&gt;&lt;a href=&quot;#/pages/&lt;%= page._id %&gt;/edit&quot;&gt;edit&lt;/a&gt;&lt;/li&gt;
+  &lt;li&gt;&lt;a href=&quot;#/pages/&lt;%= page._id %&gt;/versions&quot;&gt;versions&lt;/a&gt;&lt;/li&gt;
+&lt;/ul&gt;
 
-&lt;p&gt;&lt;%= page.body %&gt;&lt;/p&gt;
\ No newline at end of file
+&lt;div id=&quot;page&quot;&gt;
+  &lt;p&gt;&lt;%= page.body.replace(/([A-Z][a-z]+([A-Z][a-z]+)+)/g, function(match) {return &quot;&lt;a href=\&quot;#/pages/&quot; + match + &quot;\&quot;&gt;&quot; + match + &quot;&lt;/a&gt;&quot;}) %&gt;&lt;/p&gt;
+&lt;/div&gt;
\ No newline at end of file</diff>
      <filename>couchapp/_attachments/templates/pages/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,7 @@ Feature: wiki
   
   Scenario: create first page
     When I go to the start page
+    And I wait for the AJAX call to finish
     And I fill in &quot;Page One&quot; for &quot;Title&quot;
     And I fill in &quot;this is page one&quot; for &quot;Body&quot;
     And I press &quot;Create Page&quot;</diff>
      <filename>couchapp/features/create_page.feature</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,7 @@
+require 'rubygems'
+gem 'langalex-culerity'
 require 'culerity'
+require 'tempfile'
 
 Before do
   $server ||= Culerity::run_server
@@ -108,6 +111,7 @@ def assert_successful_response
     tmp &lt;&lt; $browser.html
     tmp.close
     `open -a /Applications/Safari.app #{tmp.path}`
+    sleep 1
     raise &quot;Brower returned Response Code #{$browser.page.web_response.status_code}&quot;
   end
 end
\ No newline at end of file</diff>
      <filename>couchapp/features/step_definitions/common_celerity.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 require 'rubygems'
-gem 'jchris-couchrest'
+gem 'couchrest'
 require 'couchrest'
 
 Before do</diff>
      <filename>couchapp/features/step_definitions/page_steps.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ def path_to(page_name)
   case page_name
   
   when /the start page/i
-    '/_design/couchapp/_show/new'
+    '/_design/couchapp/index.html'
   
   # Add more page name =&gt; path mappings here
   </diff>
      <filename>couchapp/features/support/paths.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>couchapp/_attachments/templates/pages/_stat.html.erb</filename>
    </removed>
    <removed>
      <filename>couchapp/_attachments/templates/pages/statistics.html.erb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>8bdeca054679e2d3478963b7ee084a2152675b70</id>
    </parent>
  </parents>
  <author>
    <name>Alexander Lang</name>
    <email>alex@upstream-berlin.com</email>
  </author>
  <url>http://github.com/langalex/couchdb_example_wiki/commit/4edff3ed2750a19bf57e74d19dc3e9153e461762</url>
  <id>4edff3ed2750a19bf57e74d19dc3e9153e461762</id>
  <committed-date>2009-05-22T12:33:39-07:00</committed-date>
  <authored-date>2009-05-22T12:33:39-07:00</authored-date>
  <message>added creating new pages via camelcase links, refactored app into multiple controllers</message>
  <tree>32cf78e9467a29367f9cfbbd73f6755a330e0441</tree>
  <committer>
    <name>Alexander Lang</name>
    <email>alex@upstream-berlin.com</email>
  </committer>
</commit>
