Commits

Anonymous committed 12c0117

Fixes a bug where value.txt didn't like slaves; adds index highlighting.

Comments (0)

Files changed (4)

+syntax = glob
+__/bin
+__/etc/aspen.conf
+__/include/python2.5
+__/var/aspen.log

__/etc/templates/base.html

+<html>
+    <head>
+        <style>
+            BODY {
+                font: normal 9pt/12pt Arial, sans-serif;
+                padding: 10px;
+                margin: 0;
+            }
+            TABLE {
+                border-spacing: 0;
+                margin: 0;
+                padding: 0;
+                width: 100%;
+            }
+            TH, TD {
+                vertical-align: top;
+            }
+            TH {
+                text-align: right;
+                padding: 0;
+                width: 100px;
+                font-weight: normal;
+            }
+            TD {
+                padding: 0 0 0 10px;
+            }
+            TR.big TH {
+                height: 40px;
+                border-right: 2px solid gray;
+            }
+            TR.big TD {
+                padding-top: 10px;
+                font-weight: bold;
+            }
+            TR.big.listing TD {
+                font-weight: normal;
+                padding-bottom: 10px;
+            }
+            TR.big TD,
+            TR.big TH {
+                border-top: 1px solid #CCC ! important;
+            }
+            TR.server TH { border-color: orange; }
+            TR.database TH { border-color: red; }
+            TR.collection TH { border-color: green; }
+            TR.document TH {  border-color: blue; }
+            TR.document TD { font-weight: normal; color: #999; }
+            TR.attribute TH {
+                border-right: 2px solid blue;
+            }
+            TR.attribute TH SPAN {
+                color: #999;
+                padding: 2px 10px;
+            }
+            TR.attribute TD {
+                padding: 2px 10px;
+            }
+            TH DIV {
+                position: relative;
+            }
+            TH A,
+            TH SPAN {
+                display: block;
+                padding: 10px;
+                color: black;
+                text-decoration: none;
+            }
+            TR.attribute SPAN.bytes {
+                color: #999;
+            }
+            TR.attribute A {
+                font: normal 10px/10px Verdana, sans-serif;
+            }
+            TH EM {
+                background: #FFFE98;
+                font-style: normal;
+            }
+            TH SPAN.note {
+                margin: 0;
+                padding: 0;
+                font-size: 9px;
+                line-height: 10px;
+                color: #999;
+            }
+        </style>
+        <script src="/jquery-1.4.4.min.js"></script>
+        <script>
+            $(document).ready(function() {
+                function addEss() {
+                    var a = $(this);
+                    var current = a.html();
+                    a.html(current + 's'); 
+                }
+                function removeEss() {
+                    var a = $(this);
+                    var current = a.html();
+                    a.html(current.slice(0, current.length-1));
+                }
+                $('TH A').hover(addEss, removeEss);
+            });
+        </script>
+    </head>
+    <body>
+        {% block content %}{% endblock %}
+    </body>
+</html>
 database = request.environ['urlmap.database']
 collection = request.environ['urlmap.collection']
 
-db = pymongo.Connection(server, slave_okay=True)[database][collection]
-ndocs = db.count()
-document = db.find_one()
+coll = pymongo.Connection(server, slave_okay=True)[database][collection]
+
+ndocs = coll.count()
+document = coll.find_one()
+indices = coll.index_information()
+
+indexed = [v['key'][0][0] for v in indices.values()]
+
 if document is not None:
-    _id = document['_id']
+    _id = document.get('_id', '')
     def gendoc(d):
         for k,v in sorted(d.iteritems()):
             nv = len(str(v))
             short = True 
-            if nv > 300:
+            if _id and nv > 300:
                 v = "%d bytes" % nv
                 short = False
-            yield k, short, v
+            yield k, short, v, k in indexed
     doc = gendoc(document)
 
 
 <table>
     <tr class="big server"><th><a href="/" title="Click for All Servers">Server</a></th><td>{{ server }}</td></tr>
     <tr class="big database"><th><a href="/{{ server }}/" title="Click for All Databases">Database</a></th><td>{{ database }}</td></tr>
-        <tr class="big collection"><th><a href="/{{ server }}/{{ database }}/" title="Click for All Collections">Collection</a></th><td>{{ collection }}</td></tr>
-    <tr class="big document"><th><span>Document</span></th><td>1st of {{ ndocs }}</td></tr>
-    {% for k, short, v in doc %}
+    <tr class="big collection"><th><a href="/{{ server }}/{{ database }}/" title="Click for All Collections">Collection</a></th><td>{{ collection }}</td></tr>
+    <tr class="big document">
+        <th><span>Document <span class="note"><em>indices</em> highlighted</span></th>
+        <td>1st of {{ ndocs }}</td>
+    </tr>
+    {% for k, short, v, indexed in doc %}
     <tr class="attribute">
-        <th><span>{{ k }}</span></th>
+        <th><span>{% if indexed %}<em>{{ k }}</em>{% else %}{{ k }}{% endif %}</span></th>
         <td>{% if short %}{{ v }}{% else %}<span class="bytes">{{ v }}</span> <a href="/{{ server }}/{{ database }}/{{ collection }}/{{ _id }}/{{ k }}.txt" target="_blank">view</a>{% endif %}</td>
     </tr>
     {% endfor %}
 _id = request.environ['urlmap._id']
 key = request.environ['urlmap.key']
 
-db = pymongo.Connection(server)[database][collection]
+db = pymongo.Connection(server, slave_okay=True)[database][collection]
 document = db.find_one(ObjectId(_id))
 value = document[key]