Changeset 1911

Show
Ignore:
Timestamp:
01/28/07 16:58:17 (2 years ago)
Author:
eblot
Message:

RevtreePlugin:

  • Generated XML code are now fully compliant w/ XHTML+SVG DTD
    • Documents are not fully compliant yet (see Trac issue 4614)
    • Fix up ids for SVG markers (issue w/ color-based naming)
    • Fix up invalid form action
  • Use SVG 1.1 DTD
  • Use direct links (w/o Javascript) from changeset to Trac changeset pages
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • revtreeplugin/0.11/revtree/htdocs/js/svgtip.js

    r1909 r1911  
    66 * 
    77 * Badly hacked & tweaked to support XHTML/XML and SVG for the RevtreePlugin 
    8  *   <emmanuel.blot@free.fr> 
     8 * by Emmanuel Blot <emmanuel.blot@free.fr> 2006-2007 
    99 */ 
    1010 
    1111function JT_init(){ 
    12     $('a[@id^=rev]') 
    13     .hover(function(){JT_show(this)},function(){JT_hide(this)}) 
    14       .click(function(){return false});      
     12  $('a[@id^=rev]').hover(function(){JT_show(this)},function(){JT_hide(this)}); 
    1513} 
    1614 
    1715function JT_hide(object) { 
    18   $('#JT').remove() 
     16  $('#JT').remove() 
    1917} 
    2018 
     
    2321  if (! jQuery.browser.opera) { href = 'xlink:' + href; } 
    2422  var url = object.getAttribute(href); 
     23  var logurl = url.replace(/\/changeset\//, '/revtree_log/'); 
    2524  var id = object.getAttribute('id'); 
    2625  var title = id.replace(/^rev/, 'Changeset '); 
     
    3433  var params = parseQuery( queryString ); 
    3534  if(params['width'] === undefined){params['width'] = 250}; 
    36   if(params['link'] !== undefined){      
    37   $(object).bind('click',function(){window.location = params['link']}); 
    38   //$(object).css('cursor','pointer'); 
    39   } 
    4035     
    4136  if(hasArea>((params['width']*1)+box.w)){ 
     
    7368  document.getElementsByTagName('body')[0].appendChild(d0); 
    7469 
    75   // netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); 
    7670  $('#JT').show(); 
    77   $('#JT_copy').load(url); 
     71  $('#JT_copy').load(logurl); 
    7872} 
    7973 
    8074function getSvgPosition(objectId) { 
     75   // The following loop could be simplified to use JQuery 
     76   // JQuery has some trouble with XML documents for now 
    8177   var svg = document.getElementsByTagName('svg')[0]; 
    8278   var anodes = svg.getElementsByTagName('a'); 
     
    9187   var elem; 
    9288        for ( var n = 0; n < cnodes.length; n++ ) { 
    93       if ( cnodes[n].tagName == "g" ) { 
     89      if ( cnodes[n].tagName == "svg:g" ) { 
    9490         elem = cnodes[n] 
    9591         break; 
  • revtreeplugin/0.11/revtree/SVGdraw.py

    r1633 r1911  
    5757is available from www.adobe.com""" 
    5858 
    59 __version__="1.0" 
     59# Note: Emmanuel Blot, 2007: 
     60# The version has been updated to reflect the small changes made to 
     61# support SVG 1.1 and the hack to support inline SVG (in XHTML host document) 
     62__version__="1.0a" 
    6063 
    6164# there are two possibilities to generate svg: 
     
    253256        self.elements.append(SVGelement) 
    254257 
    255     def toXml(self,level,f): 
     258    def toXml(self,level,f,prefix=''): 
    256259        f.write('\t'*level) 
    257         f.write('<'+self.type) 
     260        f.write('<'+prefix+self.type) 
    258261        for attkey in self.attributes.keys(): 
    259262            f.write(' '+_escape(str(attkey))+'='+_quoteattr(str(self.attributes[attkey]))) 
     
    269272            f.write('\n') 
    270273        for element in self.elements: 
    271             element.toXml(level+1,f
     274            element.toXml(level+1,f,prefix
    272275        if self.cdata: 
    273276            f.write('\n'+'\t'*(level+1)+'<![CDATA[') 
     
    281284                f.write(str(self.text)) 
    282285        if self.elements: 
    283             f.write('\t'*level+'</'+self.type+'>\n') 
     286            f.write('\t'*level+'</'+prefix+self.type+'>\n') 
    284287        elif self.text:  
    285             f.write('</'+self.type+'>\n') 
     288            f.write('</'+prefix+self.type+'>\n') 
    286289        elif self.cdata: 
    287             f.write('\t'*level+'</'+self.type+'>\n') 
     290            f.write('\t'*level+'</'+prefix+self.type+'>\n') 
    288291        else: 
    289292            f.write('/>\n') 
     
    871874    d.toXml() 
    872875    """ 
    873     def __init__(self,viewBox=None, width=None, height=None,**args): 
     876    def __init__(self,viewBox=None, width=None, height=None, 
     877                 svgns=None,**args): 
    874878        SVGelement.__init__(self,'svg',**args) 
     879        self._svgns = svgns 
    875880        if viewBox<>None: 
    876881            self.attributes['viewBox']=_viewboxlist(viewBox) 
     
    879884        if height<>None: 
    880885            self.attributes['height']=height 
    881         #self.namespace="http://www.w3.org/2000/svg" 
    882         self.namespace = { 'xmlns': "http://www.w3.org/2000/svg", 
     886        ns = svgns and 'xmlns:svg' or 'xmlns' 
     887        self.namespace = { ns: "http://www.w3.org/2000/svg", 
    883888                           'xmlns:xlink': "http://www.w3.org/1999/xlink" } 
     889                            
     890    def toXml(self,level,f): 
     891        SVGelement.toXml(self,level,f,self._svgns and 'svg:' or '') 
    884892         
    885893class drawing: 
  • revtreeplugin/0.11/revtree/svgview.py

    r1908 r1911  
    280280                                    self._textcolor.rgb() 
    281281        widgets.append(title) 
    282  
    283282        g = SVG.group('grp%d' % self._revision, elements=widgets) 
    284          
    285         link = "%s/revtree_log/?rev=%d&link=%s/changeset/%d" \ 
    286             % (self._parent.urlbase(), self._revision,  
    287                self._parent.urlbase(), self._revision) 
     283        link = "%s/changeset/%d" % (self._parent.urlbase(), self._revision) 
    288284        self._link = SVG.link(link, elements=[g]) 
    289285        if self._revision: 
     
    762758         
    763759    def _get_name(self, color, head): 
    764         return 'arrow_%s_%s' % (head and 'head' or 'tail', color) 
     760        fcolor = str(color) 
     761        if fcolor.startswith('#'): 
     762            fcolor = fcolor[1:] 
     763        return 'arrow_%s_%s' % (head and 'head' or 'tail', fcolor) 
    765764         
    766765    def create(self, color, head): 
     
    967966        """Render the revision tree""" 
    968967        self._svg = SVG.svg((0,0,self._extent[0],self._extent[1]), 
    969                             scale*self._extent[0], scale*self._extent[1]) 
     968                            scale*self._extent[0], scale*self._extent[1], 
     969                            True) 
    970970        self._arrows.render() 
    971971        # FIXME: only two levels for enhancers (background, foreground) 
  • revtreeplugin/0.11/revtree/templates/revtree.html

    r1909 r1911  
    11<!DOCTYPE html  
    2     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  
    3     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
     2    PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" 
     3    "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> 
    44<html xmlns="http://www.w3.org/1999/xhtml"  
    55      xmlns:xi="http://www.w3.org/2001/XInclude"  
     
    88  <xi:include href="macros.html" /> 
    99  <head> 
     10    <!-- This document conforms to XHTML + SVG + MathML  
     11         However, a tiny issue in Trac (#4614) prevents the validation of 
     12         the RevtreePlugin documents. 
     13      --> 
    1014    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    1115    <title>${rt.title}</title> 
     
    3034      <h1>${rt.title}</h1> 
    3135      <div id="settings"> 
    32         <form id="prefs" method="GET" action=""> 
     36        <form id="prefs" method="get" action=""> 
    3337          <div class="revprops"> 
    3438            <fieldset id="properties"> 
     
    130134        </div> 
    131135        <div py:otherwise="" class="svg"> 
    132           <!-- Inline SVG breaks the XHTML 1.0 strict conformance 
    133              XHTML + SVG + MathML document type does not help ... --> 
    134136          ${rt.svg} 
    135137        </div> 
  • revtreeplugin/0.11/revtree/web_ui.py

    r1908 r1911  
    151151 
    152152    def match_request(self, req): 
    153         match = re.match(r'/revtree(_log)?/?', req.path_info) 
     153        match = re.match(r'/revtree(_log)?(?:/([^/]+))?', req.path_info) 
    154154        if match: 
    155155            if match.group(1): 
    156                 req.args['log'] = True 
     156                req.args['logrev'] = match.group(2) 
    157157            return True 
    158158 
     
    160160        req.perm.assert_permission('REVTREE_VIEW') 
    161161             
    162         if req.args.has_key('log'): 
     162        if req.args.has_key('logrev'): 
    163163            return self._process_log(req) 
    164164        else: 
     
    206206        """Handle AJAX log requests""" 
    207207        try: 
    208             rev = int(req.args['rev']) 
     208            rev = int(req.args['logrev']) 
    209209            repos = self.env.get_repository(req.authname) 
    210210            chgset = repos.get_changeset(rev)