# HG changeset patch # User Jeff Hammel # Date 1294005349 28800 # Node ID 61038b4e7425ba84ed833216de1f10cd5c5c2169 # Parent 2916206a68072b1eff50957139b4317b9907a859 initial version with acceptable formatting diff -r 2916206a6807 -r 61038b4e7425 setup.py --- 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, diff -r 2916206a6807 -r 61038b4e7425 svgsitemap/middleware.py --- 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: