Commits

Olemis Lang committed 1b05245 Merge

TracGViz: Merge 20fe9648c84e90d07eabb232 : Incorporating enhancements to providers, testing code and documentation

Comments (0)

Files changed (8)

trac-dev/gviz/TODO

 Outstanding tasks
 -----------------
 
+X Fix GViz providers index, broken using Trac=1.0
+
+X Bloodhound web UI enhancementX Bloodhound web UI enhancementss
+
 ~ Write tests for data sources included in TracGViz 1.3.4 that are 
   not about version control.
 

trac-dev/gviz/setup.py

             'tracgviz.ig' : ('tracgviz/ig',               # Package dir
                            # Package data
                             ['templates/*', 'htdocs/*'],
+                          ),
+            'tracgviz.util' : ('tracgviz/util',     # Package dir
+                            # Package data
+                            [],
                           ), 
             }
 

trac-dev/gviz/tracgviz/templates/gviz_provdoc.html

   idx = count()
   ?>
   <py:def function="attr_desc(name, value)">
-    <tr class="${idx.next() % 2 and 'odd' or None}">
-      <th scope="row"><var>$name</var></th>
+    <tr class="${idx.next() % 2 and 'odd' or None}" py:choose="">
+      <td py:when="is_bhtheme_active">
+        <span class="label"><var>$name</var></span>
+      </td>
+      <th scope="row" py:otherwise="">
+        <var>$name</var>
+      </th>
       <td colspan="4"><small>$value</small></td>
     </tr>
   </py:def>
   <br/>
-  <strong> GViz data provider: ${p.__class__.__name__}</strong>
+  <h4> GViz data provider: ${p.__class__.__name__}</h4>
   <br/>
-  <table class="listing">
+  <table class="listing${' table table-striped' if is_bhtheme_active else None}">
     <thead>
-      <tr>
-        <th>Property</th>
-        <th colspan="4">Value</th>
-      </tr>
     </thead>
     <tbody>
       ${attr_desc('Name', p.__class__.__name__)}
     </tbody>
     <thead py:if="cols">
       <tr>
-        <th colspan="5">Columns</th>
+        <th colspan="5">
+          <h5>
+            <span class="label label-info" py:strip="not is_bhtheme_active">Columns</span>
+          </h5>
+        </th>
       </tr>
       <tr>
         <th>Index</th>
     </tbody>
     <thead>
       <tr>
-        <th colspan="5">Parameters</th>
+        <th colspan="5">
+          <h5>
+            <span class="label label-info" py:strip="not is_bhtheme_active">Parameters</span>
+          </h5>
+        </th>
       </tr>
       <tr>
         <th>Name</th>

trac-dev/gviz/tracgviz/testing/__init__.py

   def enable_component(self, clsdef):
     r"""Enable a plugin temporarily at testing time.
     """
-    if clsdef not in self.enabled_components :
-      self.enabled_components.append(clsdef)
+    self.config.set('components', clsdef, 'enabled')
   
   def disable_component(self, clsdef):
     r"""Disable a plugin temporarily at testing time.
     """
-    try:
-      self.enabled_components.remove(clsdef)
-    except ValueError :
-      self.log.warning("Component %s was not enabled", clsdef)
+    self.config.set('components', clsdef, 'disabled')
 
   def rip_component(self, cls):
     r"""Disable a plugin forever and RIP it using the super-laser beam.

trac-dev/gviz/tracgviz/testing/test_rpc.py

   l = MultiTestLoader(
         [defaultTestLoader, \
           DocTestRpcLoader(extraglobs=magic_vars, \
-                            enable=['trac.[a-uw-z]*', 'tracrpc.*', \
-                                        'tracgviz.*'], \
+                            enable=[
+                                'trac.*', 'tracrpc.*', 'tracgviz.*'
+                              ], \
                             default_data=True,
-                            optionflags=ELLIPSIS | # REPORT_UDIFF | \
+                            optionflags=ELLIPSIS | REPORT_UDIFF | \
                                         NORMALIZE_WHITESPACE) \
         ])
   

trac-dev/gviz/tracgviz/util/__init__.py

File contents unchanged.

trac-dev/gviz/tracgviz/util/bloodhound.py

+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+# Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+r"""Helper (abstract) classes for Apache(TM) Bloodhound integration.
+
+Copyright 2009-2011 Olemis Lang <olemis at gmail.com>
+Licensed under the Apache License, Version 2.0 
+"""
+__author__ = 'Olemis Lang'
+
+__all__ = 'is_bhtheme_active',
+
+def is_bhtheme_active(env):
+  r"""Determine whether Bloodhound theme is active in target environment
+  """
+  try:
+    from themeengine.api import ThemeEngineSystem
+    from bhtheme.theme import BloodhoundTheme
+  except ImportError:
+    return False
+  else:
+    tes = env[ThemeEngineSystem]
+    bht = env[BloodhoundTheme]
+    return tes is not None and bht is not None and \
+        tes.theme['name'] == bht.get_theme_names().next()
+

trac-dev/gviz/tracgviz/wiki.py

 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 
-r"""This module contains every WikiFirmatting extension being related 
+r"""This module contains every WikiFormatting extension being related 
 to Trac GViz system, as well as data sources that interact with Trac 
 Wiki module.
 
 from trac.wiki.macros import WikiMacroBase
 from trac.wiki.formatter import system_message, wiki_to_html
 
-from genshi.core import Markup
+from genshi.core import Markup, Stream
 from genshi.builder import tag
 from genshi.template import MarkupTemplate
 from pkg_resources import resource_string
 import types
 from xmlrpclib import DateTime
 
-from api import TracGVizSystem, gviz_api, ITracLinksHandler, \
+from tracgviz.api import TracGVizSystem, gviz_api, ITracLinksHandler, \
                 GVizBadRequestError, gviz_col, gviz_param
-from util import GVizXMLRPCAdapter, convert_req_date, \
+from tracgviz.util import GVizXMLRPCAdapter, convert_req_date, \
                 REQFIELDS_DESC, REQFIELDS_DEFAULTS, is_dyn_schema, \
                 dummy_request, compile_pattern
+from tracgviz.util.bloodhound import is_bhtheme_active
 
 __metaclass__ = type
 
             else:
               wikifier = lambda text : text
             stream = tmpl.generate(cols=cols, p=provider, docs=docs, \
-                                    pdocs=pdocs, dyn=dyn, fmt=wikifier)
-            return stream.render('xhtml')
+                                    pdocs=pdocs, dyn=dyn, fmt=wikifier, \
+                                    is_bhtheme_active=is_bhtheme_active(self.env))
+            return stream
         except Exception, exc:
             self.log.exception("IG: Generating provider docs ... failed")
             return str(system_message('Could not generate docs for %s' \
                                     'not found'))
             else:
                 providers = gvizsys._cache.itervalues()
-            doc = ''.join(self._provider_doc(p, formatter) \
-                                              for p in providers)
-            return Markup(doc)
+            stream = Stream(chain(self._provider_doc(p, formatter) \
+                    for p in providers))
+            result = sum(stream.serialize('xhtml'))
+            self.log.debug('GViz docs stream %s', repr(result))
+            return Markup(result.unescape())
 
 class GVizTableMacro(WikiMacroBase):
     r"""Render in TracWiki pages the result sets returned by