<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,4 @@
--record(wiki, {page, body, last_author}).
+-record(wiki, {id, page, body, author, timestamp}).
 -record(user, {name, password_hash}).
 -record(role, {name, user}).
 -record(session, {id, user_name}).</diff>
      <filename>src/erliki_records.hrl</filename>
    </modified>
    <modified>
      <diff>@@ -7,28 +7,39 @@
 
 -export([get_page/1, update_page/3, output_page/2, output/2]).
 -include(&quot;erliki_records.hrl&quot;).
+-include_lib(&quot;stdlib/include/qlc.hrl&quot;).    
 
 
 get_page(Page) -&gt; 
     mnesia:transaction(fun() -&gt;
-        mnesia:select(wiki, 
-            [{#wiki{page=Page, body='$1', last_author='$2'}, [], [{{Page, '$1', '$2'}}]}]
-        )
+        qlc:e(qlc:q(
+            [W || W &lt;- mnesia:table(wiki), 
+                W#wiki.page =:= Page]
+        ))
     end).
 
 update_page(Page, Body, User_Name) -&gt;
     TokenizedBody = wiki_tokenizer:tokenize(Body),
     {ok, Parsed} = wiki_parser:parse(TokenizedBody),
+    Timestamp = erlang:localtime(),
     
     case is_tuple(Parsed) of
         true -&gt; 
-            Record = #wiki{page=Page, 
-                           body=[Parsed],
-                           last_author=User_Name};
+            Record = #wiki{
+                        id={Page, Timestamp},
+                        page=Page, 
+                        body=[Parsed],
+                        author=User_Name,
+                        timestamp=Timestamp
+                     };
         _ -&gt;
-            Record = #wiki{page=Page, 
-                           body=lists:flatten(Parsed),
-                           last_author=User_Name}
+            Record = #wiki{
+                        id={Page, Timestamp},
+                        page=Page, 
+                        body=lists:flatten(Parsed),
+                        author=User_Name,
+                        timestamp=Timestamp
+                     }
     end,
 
     case mnesia:transaction(fun() -&gt; 
@@ -46,12 +57,19 @@ update_page(Page, Body, User_Name) -&gt;
 
 output_page(Page, F) -&gt;
     case wiki_model:get_page(Page) of
-        {atomic, [ {Page, Parsed, Last_Author} | _ ]} -&gt;
+        {atomic, []} -&gt; 
+            io:format(&quot;Could find page: ~p ~n&quot;, [Page]),
+            {not_found, {Page}};
+
+        {atomic, Result_Set} -&gt;
+            [ #wiki{id=Id, page=Page, body=Parsed, author=Last_Author, timestamp=Timestamp} | _ ] = lists:reverse(lists:keysort(2, Result_Set)),
+            
             io:format(&quot;Found record for ~p ~n&quot;, [Page]),
             
             {ok, {Page, F(Parsed), Last_Author}};
+
         Error -&gt; 
-            io:format(&quot;Error: ~p ~n&quot;, [Error]),
+            io:format(&quot;Could not get page: ~p ~n&quot;, [Error]),
             {not_found, {Page}}
     end.
     </diff>
      <filename>src/wiki_model.erl</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f13746c20c9deec93aafb5a72c188b52164cf16f</id>
    </parent>
  </parents>
  <author>
    <name>Carlo Cabanilla</name>
    <email>carlo.cabanilla@gmail.com</email>
  </author>
  <url>http://github.com/clofresh/erliki/commit/e7998f20f2530403f053d1b1b608a891a5debd84</url>
  <id>e7998f20f2530403f053d1b1b608a891a5debd84</id>
  <committed-date>2009-06-20T21:58:42-07:00</committed-date>
  <authored-date>2009-06-20T21:58:42-07:00</authored-date>
  <message>keep revision data for each wiki page</message>
  <tree>82b618e9ac33a2ec8cfe08005caae5cc9a6c9b5b</tree>
  <committer>
    <name>Carlo Cabanilla</name>
    <email>carlo.cabanilla@gmail.com</email>
  </committer>
</commit>
