id,summary,reporter,owner,description,type,status,priority,component,severity,resolution,keywords,cc,release
10169,[PATCH]  improve compatibility with Trac 0.12 / 1.0,Genie,rjollos,Hi~_ This is patch for Trac 0.12 / 1.0 compatibility.\r\n\r\n{{{\r\n#!diff\r\nIndex: tracmetrixplugin/web_ui.py\r\n===================================================================\r\n--- tracmetrixplugin/web_ui.py	(revision 11745)\r\n+++ tracmetrixplugin/web_ui.py	(working copy)\r\n@@ -28_6 +28_7 @@\r\n from trac.util.datefmt import to_datetime_ utc\r\n from trac.web import IRequestFilter_ IRequestHandler_ ITemplateStreamFilter\r\n from trac.web.chrome import add_stylesheet_ INavigationContributor_ ITemplateProvider\r\n+from trac import __version__\r\n \r\n from tracmetrixplugin.model import ChangesetsStats_ TicketGroupMetrics\r\n \r\n@@ -86_8 +87_9 @@\r\n         milestoneName = u"".join(e[1] for e in self.buffer.events)\r\n         title = "Go to TracMetrix for %s" % milestoneName\r\n         href = self.baseHref.mdashboard(milestoneName)\r\n+        func = ( __version__ < '1.0') and tag.dd or tag.span # Trac >= 1.0dev\r\n \r\n-        return iter(tag.dd('['_ tag.a('TracMetrix'_ href=href_ title=title)_ ']'))\r\n+        return iter( func('['_ tag.a('TracMetrix'_ href=href_ title=title)_ ']'))\r\n \r\n \r\n \r\n@@ -104_10 +106_14 @@\r\n \r\n         if filename in ('roadmap.html'_ ):\r\n \r\n+            tag = ( __version__ < '0.12.1') and 'li' or 'div' # Trac >= 0.12.1\r\n+            cls = ( __version__ < '1.0') and ''   or ' trac-progress'     # Trac >= 1.0dev\r\n+            obj = ( __version__ < '1.0') and 'dl' or 'p[@class="legend"]' # Trac >= 1.0dev\r\n+\r\n             buffer = StreamBuffer()\r\n-            t = Transformer('//li[@class="milestone"]/div[@class="info"]/h2/a/em/text()')\r\n+            t = Transformer('//'+ tag +'[@class="milestone"]/div[@class="info'+ cls +'"]/h2/a/em/text()')\r\n             t = t.copy(buffer).end()\r\n-            t = t.select('//li[@class="milestone"]/div[@class="info"]/dl')\r\n+            t = t.select('//'+ tag +'[@class="milestone"]/div[@class="info'+ cls +'"]/'+ obj)\r\n             t = t.append(GenerateMetrixLink(buffer_ req.href))\r\n             stream |= t\r\n \r\n@@ -125_10 +131_13 @@\r\n \r\n         if filename in ('milestone_view.html'_ ):\r\n \r\n+            cls = ( __version__ < '1.0') and ''   or ' trac-progress'     # Trac >= 1.0dev\r\n+            obj = ( __version__ < '1.0') and 'dl' or 'p[@class="legend"]' # Trac >= 1.0dev\r\n+\r\n             buffer = StreamBuffer()\r\n             t = Transformer('//div[@class="milestone"]/h1/text()[2]')\r\n             t = t.copy(buffer).end()\r\n-            t = t.select('//div[@class="milestone"]/div[@class="info"]/dl')\r\n+            t = t.select('//div[@class="milestone"]/div[@class="info'+ cls +'"]/'+ obj)\r\n             t = t.append(GenerateMetrixLink(buffer_ req.href))\r\n             stream |= t\r\n}}},enhancement,assigned,high,TracMetrixPlugin,normal,,,,1.0
