<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>views/index.builder</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,7 @@
 require 'rubygems'
 require 'sinatra'
+require 'builder'
+require 'json'
 
 $cheats_list = (`cheat sheets`).split(&quot;\n&quot;)
 
@@ -26,10 +28,10 @@ end
 
 get &quot;/query/:cheat&quot; do
 
-  current_cheat = params[:cheat]
+  current_cheat = params[:cheat].split(&quot;.&quot;)[0]
   @cookie = request.cookies[&quot;last_cheat&quot;]
 
-  if current_cheat == @cookie
+  if (current_cheat == @cookie) and (current_cheat.nil? or current_cheat == &quot;&quot;)
     redirect &quot;/&quot;
   end
 
@@ -37,11 +39,28 @@ get &quot;/query/:cheat&quot; do
 
   # Reset the cookie
   set_cookie(&quot;last_cheat&quot;, current_cheat)
-  erb :index
+  if params[:cheat].match(/(.xml)$/)
+    @cheat_name, @cheat_info = get_cheat_data(@cheats)
+    builder :index
+  elsif params[:cheat].match(/(.json)$/)
+    content_type 'application/json', :charset =&gt; 'utf-8'
+    @cheat_name, @cheat_info = get_cheat_data(@cheats)
+    response_json = {:cheat_name =&gt; @cheat_name, :cheat_info =&gt; @cheat_info}
+    response_json.to_json
+  else
+    erb :index
+  end
 
 end
 
 
+def get_cheat_data(cheats)
+  cheat_name = @cheats[0].gsub(&quot;:&quot;, &quot;&quot;)
+  cheats.shift
+  cheat_info = cheats.join(&quot;&lt;br /&gt;&quot;)
+  return cheat_name, cheat_info
+end
+
 #Exception handing for production environment
 configure :production do
 </diff>
      <filename>app.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d9cb93fa73fd128dd23a0a7b14d4c604a5a2d20a</id>
    </parent>
  </parents>
  <author>
    <name>Anil</name>
    <email>Anil@anils-macbook.local</email>
  </author>
  <url>http://github.com/anildigital/cheatsweets/commit/98ef30c864000617d087730be9c4c89da68105fd</url>
  <id>98ef30c864000617d087730be9c4c89da68105fd</id>
  <committed-date>2009-07-11T11:11:44-07:00</committed-date>
  <authored-date>2009-07-11T11:11:44-07:00</authored-date>
  <message>Added xml, json api</message>
  <tree>094ba256843cf6e25747d0716c00bfbe6183199d</tree>
  <committer>
    <name>Anil</name>
    <email>Anil@anils-macbook.local</email>
  </committer>
</commit>
