Ticket #10169 (assigned enhancement)

Opened 10 months ago

Last modified 7 months ago

[PATCH] improve compatibility with Trac 0.12 / 1.0

Reported by: Genie Assigned to: rjollos (accepted)
Priority: high Component: TracMetrixPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description

Hi~, This is patch for Trac 0.12 / 1.0 compatibility.

Index: tracmetrixplugin/web_ui.py
===================================================================
--- tracmetrixplugin/web_ui.py	(revision 11745)
+++ tracmetrixplugin/web_ui.py	(working copy)
@@ -28,6 +28,7 @@
 from trac.util.datefmt import to_datetime, utc
 from trac.web import IRequestFilter, IRequestHandler, ITemplateStreamFilter
 from trac.web.chrome import add_stylesheet, INavigationContributor, ITemplateProvider
+from trac import __version__
 
 from tracmetrixplugin.model import ChangesetsStats, TicketGroupMetrics
 
@@ -86,8 +87,9 @@
         milestoneName = u"".join(e[1] for e in self.buffer.events)
         title = "Go to TracMetrix for %s" % milestoneName
         href = self.baseHref.mdashboard(milestoneName)
+        func = ( __version__ < '1.0') and tag.dd or tag.span # Trac >= 1.0dev
 
-        return iter(tag.dd('[', tag.a('TracMetrix', href=href, title=title), ']'))
+        return iter( func('[', tag.a('TracMetrix', href=href, title=title), ']'))
 
 
 
@@ -104,10 +106,14 @@
 
         if filename in ('roadmap.html', ):
 
+            tag = ( __version__ < '0.12.1') and 'li' or 'div' # Trac >= 0.12.1
+            cls = ( __version__ < '1.0') and ''   or ' trac-progress'     # Trac >= 1.0dev
+            obj = ( __version__ < '1.0') and 'dl' or 'p[@class="legend"]' # Trac >= 1.0dev
+
             buffer = StreamBuffer()
-            t = Transformer('//li[@class="milestone"]/div[@class="info"]/h2/a/em/text()')
+            t = Transformer('//'+ tag +'[@class="milestone"]/div[@class="info'+ cls +'"]/h2/a/em/text()')
             t = t.copy(buffer).end()
-            t = t.select('//li[@class="milestone"]/div[@class="info"]/dl')
+            t = t.select('//'+ tag +'[@class="milestone"]/div[@class="info'+ cls +'"]/'+ obj)
             t = t.append(GenerateMetrixLink(buffer, req.href))
             stream |= t
 
@@ -125,10 +131,13 @@
 
         if filename in ('milestone_view.html', ):
 
+            cls = ( __version__ < '1.0') and ''   or ' trac-progress'     # Trac >= 1.0dev
+            obj = ( __version__ < '1.0') and 'dl' or 'p[@class="legend"]' # Trac >= 1.0dev
+
             buffer = StreamBuffer()
             t = Transformer('//div[@class="milestone"]/h1/text()[2]')
             t = t.copy(buffer).end()
-            t = t.select('//div[@class="milestone"]/div[@class="info"]/dl')
+            t = t.select('//div[@class="milestone"]/div[@class="info'+ cls +'"]/'+ obj)
             t = t.append(GenerateMetrixLink(buffer, req.href))
             stream |= t

Attachments

Change History

07/22/12 01:05:56 changed by rjollos

Thanks for the patch! Could you give a brief explanation of what the patch accomplishes or the changes in 0.12/1.0 that you are trying to address?

07/22/12 12:23:51 changed by Genie

Roadmap(Milestone) view Layout has changed.

Trac >= 0.12.1:

. roadmap.html ( li[@class="milestone"] -> div[@class="milestone"] )

r9662

07/22/12 12:24:20 changed by Genie

Trac >= 1.0dev (0.13dev):

. roadmap.html ( div[@class="info" -> div[@class="info trac-progress" )

. milestone_view.html ( div[@class="info" -> div[@class="info trac-progress" )

r10751

. progress_bar.html ( dl -> p[@class="legend"] )

r10662

10/19/12 10:33:18 changed by rjollos

  • status changed from new to assigned.
  • priority changed from normal to high.

Add/Change #10169 ([PATCH] improve compatibility with Trac 0.12 / 1.0)




Change Properties
Action