Commits

Dominik Ruf committed 477b990

show svg if supported

  • Participants
  • Parent commits 1247bcd

Comments (0)

Files changed (4)

 	</buildSpec>
 	<natures>
 		<nature>org.python.pydev.pythonNature</nature>
+		<nature>com.aptana.ide.project.nature.web</nature>
 	</natures>
 </projectDescription>

File collective.editablesvg.egg-info/PKG-INFO

         copyright 2011 by Dominik Ruf, licensed under the GPL. See docs/LICENSE.txt for details.
         
         
+        Changelog
+        =========
+        
+        0.1adev (unreleased)
+        --------------------
+        
+        - Initial release
+        
 Platform: UNKNOWN
 Classifier: Framework :: Plone
 Classifier: Programming Language :: Python

File collective/editablesvg/svgimage.py

     grok.context(ISvgImage)
     grok.require('zope2.View')
     
+    def svg_supported(self):
+        if("MSIE" in self.request['HTTP_USER_AGENT']):
+            return False
+        else:
+            return True
+    
 def generatePng(contentobject):
     svgrenerer = SvgRenderer()
     svgxml = xml.dom.minidom.parseString(contentobject.svg)

File collective/editablesvg/svgimage_templates/view.pt

                 <div tal:replace="structure provider:plone.abovecontentbody"/>
                 
                 <div tal:define="bitmap nocall:context/bitmap"
-                     tal:condition="nocall:bitmap">
-                    <img tal:attributes="src string:${context/absolute_url}/@@download/bitmap/${bitmap/filename};
+                     tal:condition="not:view/svg_supported">
+                    <img tal:condition="nocall:bitmap"
+                         tal:attributes="src string:${context/absolute_url}/@@download/bitmap/${bitmap/filename};
                          height bitmap/_height | nothing;
                          width bitmap/_width | nothing;"
                     />
                 </div>
                 
+                <div tal:condition="view/svg_supported"
+                     tal:content="structure context/svg"/>
+                     
                 <div tal:replace="structure provider:plone.belowcontentbody"/>
                 
             </tal:main-macro>