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
