Well we could convert the menu on client side but I found several ugly 
rendering issues.
And why we should avoid server-side dom? I think that it is an interesting 
web2py feature. 

However since your opinion is important for me, do you think the following 
function might have a bad impact server-side?

def menu():
    # get the current menu
    current_menu = current.response.menu
    # set the new menu
    menu = MENU(current_menu,
                   _class='nav navbar-nav',
                   li_class='dropdown',
                   ul_class='dropdown-menu')
    # add here any menu customization
    menu = menu.serialize(menu.data)
    dropdowns = menu.elements('ul.dropdown-menu')
    for dropdown in dropdowns:
        toggle = dropdown.parent
        if toggle.parent['_class'] == 'nav navbar-nav':
            toggle['_data-w2pmenulevel'] = "l0"
            toggle.element('a',
                           replace=lambda t: A(t[0], ' ',
                                               SPAN('', _class="caret"),
                                               _href=t['_href'],
                                               _class='dropdown-toggle',
                                               **{'_data-toggle': 'dropdown'
}))
        else:
            toggle['_class'] = toggle['_class'].replace('dropdown',
                                                        'dropdown-submenu')


    return menu

And in the layout.html:

            {{if response.menu:}}
            {{=bs3.menu()}}
            {{pass}}

Thank you in advance for your feedback.




Il giorno venerdì 13 dicembre 2013 17:22:35 UTC+1, Niphlod ha scritto:
>
> is the endgame really let response.menu generate a structure than is 
> converted every time server-side ?
> Shouldn't we avoid server-side dom at all costs ?
>
> On Friday, December 13, 2013 3:21:28 PM UTC+1, Paolo Caruccio wrote:
>>
>> Thank you LightDot.
>> In the next few days I'll send to your private email the files for 
>> bootstrap3 and foundation5 so you will able to check my code and yours.
>> My bootstrap 3 code supports multilevel (2, 3 and so on) menu also. Both 
>> bs3 and f5 manage the errors in form (see attached image) and the auth 
>> navbar is easily customizable by the user. There are other small features 
>> too. Of course they are responsive and should work also in mobile machines. 
>> But more important thing is that by making small changes to it,  the code 
>> can be applied also to other framework and therefore we will isolate this 
>> matters from web2py core. The package for each framework  is constitued by 
>> a python module, custom css file and a custom js file  in addition to the 
>> framework files obviously.
>> I hope this will be the first step to the web2py theming.
>>
>>
>> Il giorno venerdì 13 dicembre 2013 11:54:21 UTC+1, LightDot ha scritto:
>>>
>>> That's excellent! I just started converting the welcome app to bs3 
>>> yesterday and got as far as converting and tweaking the html and adding 2nd 
>>> level submenu support. Foundation 5 was the next on my list.
>>>
>>> It seems that you've gotten further along so I'll wait for your code and 
>>> help out once it's published. Drop me a note directly if you could use any 
>>> help before that.
>>>
>>> Regards
>>>
>>>
>>> On Thursday, December 12, 2013 11:25:34 PM UTC+1, Paolo Caruccio wrote:
>>>>
>>>> In this days I'm finishing an external module (based on DOM server-side 
>>>> manipulation) that converts web2py elements (at the moment: the auth 
>>>> navbar, the menu and SQLform) to bootstrap3. It is my intention make this 
>>>> module easy to extend to other frameworks also. Bootstrap3 and Foundation5 
>>>> are almost ready and I'm working on "ink sapo framework" just to try if 
>>>> it's possible the porting to something different. 
>>>> I'm posting the code and examples on this group before xmas for testing 
>>>> and feedback purposes. Some screenshots here attached.
>>>>
>>>>
>>>> Il giorno giovedì 12 dicembre 2013 22:32:32 UTC+1, Massimo Di Pierro ha 
>>>> scritto:
>>>>>
>>>>> Can you please open a ticket about this so it does not get lost? We 
>>>>> need to port welcome to bootstrap 3 asap.
>>>>>
>>>>> On Thursday, 12 December 2013 12:08:15 UTC-6, Annet wrote:
>>>>>>
>>>>>> Some field definitions in my models have comments, which in a 
>>>>>> Bootstrap form are
>>>>>> being displayed in a help-block.
>>>>>>
>>>>>> The problem is that this help-block
>>>>>>
>>>>>> <span class="help-block">my comment</span>
>>>>>>
>>>>>> is added to every form field, resulting in 20 px of extra padding 
>>>>>> between form fields, margin-bottom: 10px
>>>>>> and margin-bottom: 5px. Is there a way to make adding a help-block 
>>>>>> conditional?
>>>>>>
>>>>>> So far I made the following adjustments to a custom formstyle 
>>>>>> function:
>>>>>>
>>>>>> def bootstrap3(form, fields):
>>>>>>     form.add_class('form-horizontal')
>>>>>>     parent = FIELDSET()
>>>>>>     for id, label, controls, help in fields:
>>>>>>         # wrappers
>>>>>>         _help = SPAN(help, _class='help-block')
>>>>>>         # embed _help into _controls
>>>>>>         _controls = DIV(controls, _help, _class='controls col-sm-8')
>>>>>>         # submit unflag by default
>>>>>>         _submit = False
>>>>>>
>>>>>>         if isinstance(controls, INPUT):
>>>>>>             controls.add_class('form-control')
>>>>>>             if controls['_type'] == 'submit':
>>>>>>                 # flag submit button
>>>>>>                 _submit = True
>>>>>>                 controls['_class'] = 'btn btn-primary'
>>>>>>             if controls['_type'] == 'file':
>>>>>>                 controls['_class'] = 'input-file'
>>>>>>
>>>>>>         # For password fields, which are wrapped in a CAT object.
>>>>>>         if isinstance(controls, CAT) and isinstance(controls[0], 
>>>>>> INPUT):
>>>>>>             controls[0].add_class('form-control')
>>>>>>
>>>>>>         if isinstance(controls, SELECT):
>>>>>>             controls.add_class('form-control')
>>>>>>
>>>>>>         if isinstance(controls, TEXTAREA):
>>>>>>             controls.add_class('form-control')
>>>>>>
>>>>>>         if isinstance(label, LABEL):
>>>>>>             label['_class'] = 'col-sm-4 control-label'
>>>>>>
>>>>>>         if _submit:
>>>>>>             # submit button has unwrapped label and controls, 
>>>>>> different class
>>>>>>             parent.append(DIV(label, controls, 
>>>>>> _class='col-sm-offset-4 col-sm-8 form-actions', _id=id))
>>>>>>             # unflag submit (possible side effect)
>>>>>>             _submit = False
>>>>>>         else:
>>>>>>             # unwrapped label
>>>>>>             parent.append(DIV(label, _controls, _class='form-group', 
>>>>>> _id=id))
>>>>>>     return parent
>>>>>>
>>>>>>
>>>>>>
>>>>>> Kind regards,
>>>>>>
>>>>>> Annet
>>>>>>
>>>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to