barebones 'show me the pix of my peeps'
authorDavid Ascher <david@mozillamessaging.com>
Thu, 26 Feb 2009 16:58:28 -0800
changeset 62 64a5d3f3d321814f5a615091c05d38d115d20019
parent 61 a5c4bee21a3ab1686dd7a638169d47bb3d15b44a
child 64 1b32b4c00eeb6094549cb9a601dbdf52eaf8df65
push id1
push userroot
push dateWed, 08 Apr 2009 01:46:05 +0000
barebones 'show me the pix of my peeps'
client/addressbook.xhtml
server/python/junius/model.py
new file mode 100644
--- /dev/null
+++ b/client/addressbook.xhtml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+  <title>Raindrop Contacts</title>
+  <script type="text/javascript" charset="utf-8"><![CDATA[
+    if (window.console === undefined)
+      console = {log: function() {}};
+  ]]></script>
+  <script src="/_utils/script/json2.js"></script>
+  <script src="/_utils/script/jquery.js?1.2.6"></script>
+  <script src="jquery.couch.js"></script>
+  <script src="utils.js"></script>
+  <script type="text/javascript" charset="utf-8"><![CDATA[
+    function funkyInit() {
+      var dbMessages = $.couch.db("contacts");
+      dbMessages.view("contacts/with_pictures", {
+        include_docs: true,
+        group : false,
+        success: function(json) {
+          var parent = $("#middle");
+          json.rows.forEach(function(row) {
+            //alert(row);
+            console.log("row = ", row);
+            try {
+              var src = dbMessages.uri + row['id'] + '/default/';
+              console.log("src = ", src);
+              var img = $(document.createElement("img")).attr("src", src).attr("width", "64").attr("height", "64");
+              parent.append(img)
+            } catch (e) {
+              console.error(e);
+            }
+          })
+        }
+      })
+    }
+    $(function() {
+      window.setTimeout(funkyInit, 1000);
+    });
+  ]]></script>  
+</head>
+<body>
+
+  <div id="middle">
+  </div>
+  <div class="section" id="footer"></div>
+
+</body>
+</html>
--- a/server/python/junius/model.py
+++ b/server/python/junius/model.py
@@ -53,16 +53,22 @@ class Contact(schema.Document):
             var i;
             for (i = 0; i < doc.name.length; i++)
                 emit(doc.name.substring(i), null);
             for each (var identity in doc.identities) {
                 for (i = 0; i < identity.value.length; i++)
                     emit(identity.value.substring(i), null);
             }
         }''', include_docs=True)
+    #: expose contacts with pictures
+    with_pictures = schema.View('contacts', '''\
+        function(doc) {
+            if (doc._attachments['default'])
+                emit(doc._id, null);
+        }''')
 
 class Message(schema.Document):
     account_id = schema.TextField()
     storage_path = schema.TextField()
     storage_id = schema.IntegerField()
     
     conversation_id = schema.TextField()
     header_message_id = schema.TextField()