<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>static/sha1.js</filename>
    </added>
    <added>
      <filename>templates/addurl.html</filename>
    </added>
    <added>
      <filename>templates/base.html</filename>
    </added>
    <added>
      <filename>templates/checkurl.html</filename>
    </added>
    <added>
      <filename>templates/tools.html</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -5,7 +5,7 @@ import urllib, httplib2, unittest
 class WebTests(unittest.TestCase):
 
     def setUp(self):
-        self.http = httplib2.Http()
+        self._init_http()
         self.url = 'http://localhost:8080'
         self.headers = {'Content-type': 'application/x-www-form-urlencoded'}
         self.body = {
@@ -13,7 +13,16 @@ class WebTests(unittest.TestCase):
             'status': '200',
             }
 
-    
+    def _init_http(self):
+        self.http = httplib2.Http()
+        
+    def _post(self):
+        return self.http.request(
+            self.url, 'POST',
+            headers=self.headers,
+            body=urllib.urlencode(self.body)
+            )
+
     def testHome(self):
         response, content = self.http.request(self.url, 'GET')
         self.assert_( response['status'] == '200' )
@@ -24,18 +33,9 @@ class WebTests(unittest.TestCase):
         response, content = self.http.request(&quot;%s/test1234&quot; % self.url, 'GET')
         self.assert_(response['status'] == '404')
 
-    def _post(self):
-        return self.http.request(
-            self.url, 'POST',
-            headers=self.headers,
-            body=urllib.urlencode(self.body)
-            )
 
     def test303(self):
-        &quot;&quot;&quot;
-        test the direct response to a POST, without following
-        the redirect
-        &quot;&quot;&quot;
+        # test the direct response to a POST, without following the redirect
         self.http.follow_redirects = False
         response, content = self._post()
         self.assert_( response['status'] == '303' )
@@ -62,12 +62,14 @@ class WebTests(unittest.TestCase):
         self.assert_( response['status'] == '200' )
         self.assert_( self.body['uri'] in content )
         self.assert_( '[&quot;abc&quot;, &quot;xyz&quot;]' in content )
-
+    
     def testDELETE(self):
         self.body['uri'] = 'http://foobar.com/deleteme.html'
         response, content = self._post()
         self.assert_( response['status'] == '200' )
         self.assert_( self.body['uri'] in content )
+        
+        self._init_http()
         response, content = self.http.request(
             response['content-location'], 'DELETE'
             )</diff>
      <filename>dammit/webtests.py</filename>
    </modified>
    <modified>
      <diff>@@ -9,11 +9,15 @@ from dammit.lrucache import LRUCache
 from couchdb import Database
 from dammit.http import status
 from dammit.request import unpack_tags, unpack_pairs, pack_response
+import view
+from view import render
 
 urls = (
     '/', 'urldammit',
     '/_tools', 'tools',
-    '/(.*)', 'urldammit',
+    '/_tools/addurl', 'tools_addurl',
+    '/_tools/checkurl', 'tools_checkurl',
+    '/([0-9a-f]{40})', 'urldammit',
     )
 
 db = Database('http://localhost:5984/urldammit')
@@ -37,7 +41,7 @@ class urldammit:
         if not uri:
             print &quot;where's my url dammit?&quot;
             return
-        
+
         r = self._locate(uri)
         
         if not r: return
@@ -84,45 +88,55 @@ class urldammit:
         
         r = register_uri(db, uri = uri, status = int(status),\
                          tags = tags, pairs = pairs )
-        if r: known[id] = r
-        web.http.seeother(&quot;%s/%s&quot; % ( web.ctx.home, urllib2.quote(i.uri)) )
+
+        id = uri_to_id(i.uri)
+        if r:
+            known[id] = r
+            web.http.seeother(
+                &quot;%s/%s&quot; % ( web.ctx.home, id)
+                )
         self._render(r)
             
         
-    def DELETE(self):
-        i = web.input()
-        uri = self._reqd(i, 'uri')
-        if not uri: return
+    def DELETE(self, uri):
+        &quot;&quot;&quot;
+        TODO: take the uri as a param
+        currently very broken...
+        &quot;&quot;&quot;
+        logging.debug(&quot;got a delete request&quot;)
 
-        delete(db, id)
+        try:
+            delete(db, uri)
+        except Exception, e:
+            logging.error(e)
+        
         web.ctx.status = status[204]
 
     def _locate(self, uri):
         &quot;&quot;&quot;
         See what we know about this uri...
+        uri is in fact a SHA-1 hash of the uri
         &quot;&quot;&quot;
-        id = uri_to_id(uri)
-
         def ithas(key, cache):
             if key in cache:
                 return cache[key]
             return None
 
-        u = ithas(id, unknown)
+        u = ithas(uri, unknown)
         if u:
             web.notfound()
             return None
 
-        r = ithas(id, known)
+        r = ithas(uri, known)
         if not r:
-            r = URI.load(db, id)
+            r = URI.load(db, uri)
             
             if not r:
-                unknown[id] = True
+                unknown[uri] = True
                 web.notfound()
                 return None
             
-            known[id] = r
+            known[uri] = r
         
         return r
 
@@ -138,7 +152,10 @@ class urldammit:
         if 300 &lt;= r.status &lt; 400:
             if r.status in status:
                 web.ctx.status = status[r.status]
-                web.header('Location', r.location)
+                web.header(
+                    'Location',
+                    &quot;%s/%s&quot; % ( web.ctx.home, uri_to_id(r.location) )
+                    )
                 return True
         return False
 
@@ -176,13 +193,15 @@ class urldammit:
 
 class tools:
     def GET(self):
-        print '&lt;form action=&quot;/&quot; method=&quot;POST&quot;&gt;'
-        print '&lt;label for=&quot;uri&quot;&gt;uri:&lt;/label&gt;&lt;input name=&quot;uri&quot; type=&quot;text&quot;&gt;&lt;br&gt;'
-        print '&lt;label for=&quot;status&quot;&gt;status:&lt;/label&gt;&lt;input name=&quot;status&quot; type=&quot;text&quot;&gt;&lt;br&gt;'
-        print '&lt;label for=&quot;tags&quot;&gt;tags:&lt;/label&gt;&lt;input name=&quot;tags&quot; type=&quot;text&quot;&gt;&lt;br&gt;'
-        print '&lt;label for=&quot;pairs&quot;&gt;pairs:&lt;/label&gt;&lt;input name=&quot;pairs&quot; type=&quot;text&quot;&gt;&lt;br&gt;'
-        print '&lt;input type=&quot;submit&quot; value=&quot;submit&quot;&gt;'
-        print '&lt;/form&gt;'
+        print render.base(view.tools())
+
+class tools_addurl:
+    def GET(self):
+        print render.base(view.addurl())
+
+class tools_checkurl:
+    def GET(self):
+        print render.base(view.checkurl())
 
 if __name__ == '__main__':
     import logging, sys</diff>
      <filename>urldammit.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7cab6165fda30184f642acefbbb02435674f969a</id>
    </parent>
  </parents>
  <author>
    <name>Harry Fuecks</name>
    <email>hfuecks@gmail.com</email>
  </author>
  <url>http://github.com/harryf/urldammit/commit/a0580895e5c68201a3cca72f4abb1e8cb6272181</url>
  <id>a0580895e5c68201a3cca72f4abb1e8cb6272181</id>
  <committed-date>2008-06-06T14:22:22-07:00</committed-date>
  <authored-date>2008-06-06T14:22:22-07:00</authored-date>
  <message>Switch to use sha-1 hash of url as id, start on web.py templates for _tools, add javascript sha1 implementation</message>
  <tree>4e30540d85721a0b4f090b13e680ae2132cc2981</tree>
  <committer>
    <name>Harry Fuecks</name>
    <email>hfuecks@gmail.com</email>
  </committer>
</commit>
