changeset 15:61038b4e7425

initial version with acceptable formatting
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 02 Jan 2011 13:55:49 -0800
parents 2916206a6807
children f50b4e4ad764
files setup.py svgsitemap/middleware.py
diffstat 2 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Sun Jan 02 11:57:04 2011 -0800
+++ b/setup.py	Sun Jan 02 13:55:49 2011 -0800
@@ -6,7 +6,7 @@
 except IOError: 
     description = ''
 
-version = "0.0"
+version = "0.1"
 
 setup(name='svgsitemap',
       version=version,
--- a/svgsitemap/middleware.py	Sun Jan 02 11:57:04 2011 -0800
+++ b/svgsitemap/middleware.py	Sun Jan 02 13:55:49 2011 -0800
@@ -37,7 +37,7 @@
                  'external_referers': True,
                  'maxwidth': 5,
                  'minwidth': '0.1',
-                 'maxlength': 80,
+                 'maxlength': 60,
                  'excluded': '*.css *.js */static/* /css/* *.ico /backgrounds/* *.png *.jpg',
 
                  # input/output
@@ -48,11 +48,11 @@
                  'bgcolor': 'black',
                  'fontcolor': 'white',
                  'fontname': 'Helvetica',
-                 'fontsize': '10.0',
+                 'fontsize': '80.0',
                  'nodecolor': 'aqua',
                  'edgecolor': 'lime',
                  'shape': 'plaintext',
-                 'len': '1.3',
+                 'len': '1.0',
                  'arrowsize': '0.5',
                  }
 
@@ -87,8 +87,12 @@
                 if self.exclude(edge[0], edge[1]):
                     self.graph.remove_edge(edge[0], edge[1])
                     continue
-                label = edge.attr['label']
-                count = int(label)
+                if edge.attr['tooltip']:
+                    count = int(edge.attr['tooltip'].split(':', 1)[0].strip())
+                else:
+                    label = edge.attr['label']
+                    count = int(label)
+                    self.label(edge, count)
                 self.edges[(edge[0], edge[1])] = count
                 if count > self.max:
                     self.max = count
@@ -103,6 +107,8 @@
         self.graph.graph_attr['fontname'] = self.fontname
         self.graph.graph_attr['fontcolor'] = self.fontcolor
         self.graph.graph_attr['bgcolor'] = self.bgcolor
+        self.graph.graph_attr['overlap'] = 'compress'
+        self.graph.graph_attr['sep'] = '0.01'
         self.graph.node_attr['color'] = self.nodecolor
         self.graph.node_attr['fontcolor'] = self.fontcolor
         self.graph.node_attr['fontname'] = self.fontname
@@ -160,11 +166,12 @@
                 self.max = count
             self.edges[(from_url, to_url)] = count
             edge = self.graph.get_edge(from_url, to_url)
-            edge.attr['label'] =  str(count)
+            self.label(edge, count)
         else:
             self.edges[(from_url, to_url)] = 1
             self.max = 1
-            self.graph.add_edge(from_url, to_url, label='1')
+            labeltooltip = '1: %s -> %s' % (from_url, to_url)
+            self.graph.add_edge(from_url, to_url, label='', tooltip=labeltooltip, href='#')
 
         if self.maxwidth:
             self.set_widths()
@@ -176,6 +183,12 @@
 
         self.save()
 
+    def label(self, edge, count):
+        edge.attr['label'] = ''
+        edge.attr['tooltip'] = '%d: %s -> %s' % (count, edge[0], edge[1])
+        edge.attr['labeltooltip'] = edge.attr['tooltip']
+        edge.attr['href'] = '#'
+
     def exclude(self, *urls):
         """tell whether the edge is excluded"""
         for pattern in self.excluded: