incubator-bloodhound-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary <gary.mar...@wandisco.com>
Subject Re: [Apache Bloodhound] #88: Generic conversions of tables to bootstrap
Date Fri, 25 May 2012 00:52:18 GMT
Hi,

I have some more suggestions for how we might provide limited support 
for plugin templates to allow them to blend in a little easier with our 
theme.

https://issues.apache.org/bloodhound/ticket/88 contains the initial 
suggestion, including a helper function to help add classes to elements 
and applying it to tables.

https://issues.apache.org/bloodhound/ticket/36 begins to look at buttons 
with the same approach.

If this idea is seen as having merit and appears to work then further 
tickets should be raised for other predictable conversions.

Cheers,
     Gary


On 25/05/12 01:29, Apache Bloodhound wrote:
> #88: Generic conversions of tables to bootstrap
> --------------------------+-----------------
>    Reporter:  gjm          |      Owner:  gjm
>        Type:  enhancement  |     Status:  new
>    Priority:  major        |  Milestone:
>   Component:  dashboard    |    Version:
> Resolution:               |   Keywords:
> --------------------------+-----------------
>
> Comment (by gjm):
>
>   Part of the barrier to doing this is a simple way of adding the bootstrap
>   classes to objects - it is useful to make this fairly simple so that it is
>   reusable for other conversions. The following might suffice as a starting
>   point.
>
>   {{{
>   #!diff
>   Index: trunk/bloodhound_theme/bhtheme/theme.py
>   ===================================================================
>   --- trunk/bloodhound_theme/bhtheme/theme.py     (revision 1341781)
>   +++ trunk/bloodhound_theme/bhtheme/theme.py     (working copy)
>   @@ -105,6 +106,21 @@
>        def post_process_request(self, req, template, data, content_type):
>            """Post process request filter.
>            Removes all trac provided css if required"""
>   +        def add_classes(attributes,*args):
>   +            """Helper function to add classes to the existing attributes
>   found
>   +            by a select('@*') or similar. Example use:
>   +<element py:attrs="add_classes(select('@*'), 'cl1', 'cl2')"/>
>   +            """
>   +            attrib_list = list(attributes)
>   +            if attrib_list:
>   +                attrs = dict(list(attrib_list[0]))
>   +            else:
>   +                attrs = {}
>   +            if len(args):
>   +                attrs['class'] = ' '.join((attrs.get('class',''),) +
>   args)
>   +            return attrs
>   +        data['add_classes'] = add_classes
>   +
>            def is_active_theme():
>                is_active = False
>                active_theme = ThemeEngineSystem(self.env).theme
>   }}}
>
>   Using this, it is then possible to transform unconverted tables with
>   something like this:
>
>   {{{
>   #!diff
>   Index: trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
>   ===================================================================
>   --- trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
>   (revision 1341816)
>   +++ trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
>   (working copy)
>   @@ -252,4 +252,30 @@
>      </body></py:match>
>
>      <xi:include href="bh_admin.html" py:with="bh_fix_legacy = True"/>
>   +
>   +<py:match path="table[not(contains(@class,'table'))]" once="false"
>   buffer="true">
>   +<table py:attrs="add_classes(select('@*'), 'table', 'table-striped',
>   'table-bordered', 'table-condensed')">
>   +      ${select('*|text()|comment()')}
>   +</table>
>   +</py:match>
>   +
>    </html>
>   }}}
>
>   Similar conversions could be applied for buttons and other common
>   interface pieces but these should be considered in separate tickets.
>
>   Comments appreciated.
>


Mime
View raw message