Example #1
0
 def __unicode__(self):
     result = [htmltag('div', {'class':'pony-tabs clearfix'}, **self.attrs), Html('\n<ul>\n') ]
     for name, markup, attrs in self._tabs:
         result.append(Html('<li><a href="#%s"><span>%s</span></a>\n') % (attrs['id'], name))
     result.append(Html('</ul>\n'))
     for name, markup, attrs in self._tabs:
         result.extend([htmltag('div', {'class': 'pony-tab clearfix'}, **attrs), markup, Html('</div>\n')])
     result.append(Html('</div>'))
     return Html('').join(result)
 def __unicode__(self):
     result = [htmltag('div', {'class':'pony-tabs clearfix'}, **self.attrs), Html('\n<ul>\n') ]
     for name, markup, attrs in self._tabs:
         result.append(Html('<li><a href="#%s"><span>%s</span></a>\n') % (attrs['id'], name))
     result.append(Html('</ul>\n'))
     for name, markup, attrs in self._tabs:
         result.extend([htmltag('div', {'class': 'pony-tab clearfix'}, **attrs), markup, Html('</div>\n')])
     result.append(Html('</div>'))
     return Html('').join(result)
Example #3
0
 def tag(field):
     result = [ htmltag('div', field.attrs, _class='checkboxes') ]
     selection = field.value
     for value, description, key in field.options:
         result.append(Html('<div class="checkboxgroup-item">'))
         result.append(htmltag('input', name=field.name, type='checkbox',
                               value=value, checked=(value in selection)))
         result.append(Html('<span class="value">%s</span></div>') % description)
     result.append(Html('</div>'))
     result.append(htmltag('input', name='.'+field.name, type='hidden', value=''))
     return htmljoin(result)
Example #4
0
 def tag(field):
     result = [ htmltag('div', field.attrs, _class='radiobuttons') ]
     selected = field.value
     for value, description, key in field.options:
         result.append(Html('<div class="radiobutton">'))
         result.append(htmltag('input', type='radio', name=field.name,
                               value=key, checked=(value==selected)))
         result.append(Html('<span class="value">%s</span></div>') % description)
     result.append(Html('</div>'))
     result.append(htmltag('input', name='.'+field.name, type='hidden', value=''))
     return htmljoin(result)
Example #5
0
 def tag(field): # for Select and MultiSelect
     result = [ htmltag('select', field.attrs, name=field.name, multiple=isinstance(field, MultiSelect)) ]
     value = field.value
     if isinstance(field, MultiSelect): selection = value
     elif value is None: selection = set()
     else: selection = set((value,))
     for value, description, key in field.options:
         if key == description: key = None
         result.append(htmltag('option', selected=(value in selection), value=key))
         result.append(description)
         result.append(Html('</option>'))
     result.append(Html('</select>'))
     return htmljoin(result)
Example #6
0
 def hidden(grid):
     result = [ htmltag('input', name='.'+grid.name, type='hidden', value='') ]
     for row in grid._rows:
         for field in row:
             hidden = getattr(field, 'hidden', None)
             if hidden: result.append(hidden)
     return Html('\n').join(result)
Example #7
0
 def buttons(form):
     if not form.submit_fields: return ''
     result = [htmltag('div', _class='buttons', align=form.buttons_align)]
     buttons = [f.html for f in form.submit_fields]
     result.extend(buttons)
     result.append(Html('\n</div>'))
     return htmljoin(result)
Example #8
0
 def buttons(form):
     if not form.submit_fields: return ''
     result = [ htmltag('div', _class='buttons', align=form.buttons_align) ]
     buttons = [ f.html for f in form.submit_fields ]
     result.extend(buttons)
     result.append(Html('\n</div>'))
     return htmljoin(result)
Example #9
0
 def tag(field):
     result = [htmltag('div', field.attrs, _class='radiobuttons')]
     selected = field.value
     for value, description, key in field.options:
         result.append(Html('<div class="radiobutton">'))
         result.append(
             htmltag('input',
                     type='radio',
                     name=field.name,
                     value=key,
                     checked=(value == selected)))
         result.append(
             Html('<span class="value">%s</span></div>') % description)
     result.append(Html('</div>'))
     result.append(
         htmltag('input', name='.' + field.name, type='hidden', value=''))
     return htmljoin(result)
Example #10
0
 def tag(field):
     result = [htmltag('div', field.attrs, _class='checkboxes')]
     selection = field.value
     for value, description, key in field.options:
         result.append(Html('<div class="checkboxgroup-item">'))
         result.append(
             htmltag('input',
                     name=field.name,
                     type='checkbox',
                     value=value,
                     checked=(value in selection)))
         result.append(
             Html('<span class="value">%s</span></div>') % description)
     result.append(Html('</div>'))
     result.append(
         htmltag('input', name='.' + field.name, type='hidden', value=''))
     return htmljoin(result)
Example #11
0
 def __unicode__(field):
     value = field.html_value
     if value is None: value = ''
     return htmltag('input',
                    field.attrs,
                    name=field.name,
                    value=value,
                    type=field.HTML_TYPE,
                    _class_='%s-field' % field.__class__.__name__.lower())
Example #12
0
 def tag(form):
     attrs = form.attrs
     for f in form.fields:
         if isinstance(f, File):
             attrs['enctype'] = 'multipart/form-data'
             break
     error_class = 'has-error' if form.error_text else ''
     return htmltag('form', attrs, method=form.method, accept_charset='UTF-8',
                    _class=('pony ' + error_class).strip())
Example #13
0
def button(link, markup, **attrs):
    result = [
        htmltag('a', {
            'class': 'button',
            'href': link
        }, **attrs),
        Html('<span>%s</span></a>') % markup
    ]
    return Html('').join(result)
Example #14
0
 def hidden(grid):
     result = [
         htmltag('input', name='.' + grid.name, type='hidden', value='')
     ]
     for row in grid._rows:
         for field in row:
             hidden = getattr(field, 'hidden', None)
             if hidden: result.append(hidden)
     return Html('\n').join(result)
def rounded(markup, **attrs):
    tagname = attrs.pop('tagname', 'div')
    radius = attrs.pop('radius', 10)
    result = [ htmltag(tagname, {'class': 'rounded'}, **attrs), markup,
               Html('<div class="top-left radius-%s"></div>\n'
                    '<div class="top-right radius-%s"></div>\n'
                    '<div class="bottom-left radius-%s"></div>\n'
                    '<div class="bottom-right radius-%s"></div>\n'
                    '</%s>') % (radius, radius, radius, radius, tagname)]
    return Html('\n').join(result)
Example #16
0
def rounded(markup, **attrs):
    tagname = attrs.pop('tagname', 'div')
    radius = attrs.pop('radius', 10)
    result = [ htmltag(tagname, {'class': 'rounded'}, **attrs), markup,
               Html('<div class="top-left radius-%s"></div>\n'
                    '<div class="top-right radius-%s"></div>\n'
                    '<div class="bottom-left radius-%s"></div>\n'
                    '<div class="bottom-right radius-%s"></div>\n'
                    '</%s>') % (radius, radius, radius, radius, tagname)]
    return Html('\n').join(result)
Example #17
0
 def tag(field):  # for Select and MultiSelect
     result = [
         htmltag('select',
                 field.attrs,
                 name=field.name,
                 multiple=isinstance(field, MultiSelect))
     ]
     value = field.value
     if isinstance(field, MultiSelect): selection = value
     elif value is None: selection = set()
     else: selection = set((value, ))
     for value, description, key in field.options:
         if key == description: key = None
         result.append(
             htmltag('option', selected=(value in selection), value=key))
         result.append(description)
         result.append(Html('</option>'))
     result.append(Html('</select>'))
     return htmljoin(result)
Example #18
0
 def tag(field):
     result = []
     result.append(
         htmltag('input',
                 field.attrs,
                 name=field.name,
                 value='yes',
                 checked=bool(field.value),
                 type=field.HTML_TYPE))
     return htmljoin(result)
Example #19
0
 def tag(form):
     attrs = form.attrs
     for f in form.fields:
         if isinstance(f, File):
             attrs['enctype'] = 'multipart/form-data'
             break
     error_class = 'has-error' if form.error_text else ''
     return htmltag('form',
                    attrs,
                    method=form.method,
                    accept_charset='UTF-8',
                    _class=('pony ' + error_class).strip())
Example #20
0
def link(*args, **kwargs):
    if not args:
        raise TypeError(
            'link() function requires at least one positional argument')
    attrs = None

    last = args[-1]
    if isinstance(last, BoundMarkup):
        description = last()
        args = (description, ) + args[:-1]

    first = args[0]
    if hasattr(first, 'routes'):
        func = first
        args = args[1:]
        if func.__doc__ is None: description = func.__name__
        else: description = Html(func.__doc__.split('\n', 1)[0])
    elif len(args) > 1 and hasattr(args[1], 'routes'):
        description = tostring(first)
        func = args[1]
        args = args[2:]
    elif len(args) > 2 and hasattr(args[2], 'routes'):
        attrs = args[1]
        if isinstance(attrs, basestring): attrs = {'class': attrs}
        elif not hasattr(attrs, 'items'):
            raise TypeError('Invalid second argument of link() function: %r' %
                            second)
        description = tostring(first)
        func = args[2]
        args = args[3:]
    elif isinstance(first, basestring):
        func = link_funcs.get(first)
        if func is not None: return func(*args[1:], **kwargs)
        if first.endswith('.css'):
            if kwargs: raise TypeError('Unexpected key arguments')
            return css_link(args)
        if first.endswith('.js'):
            if len(args) > 1:
                raise TypeError('Unexpected positional arguments')
            if kwargs: raise TypeError('Unexpected key arguments')
            return script_link(first)
        raise TypeError('Invalid arguments of link() function')

    href = url(func, *args, **kwargs)
    return htmljoin(
        [htmltag('a', attrs, href=href), description,
         Html('</a>')])
Example #21
0
def link(*args, **kwargs):
    if not args: raise TypeError('link() function requires at least one positional argument')
    attrs = None

    last = args[-1]
    if isinstance(last, BoundMarkup):
        description = last()
        args = (description,) + args[:-1]

    first = args[0]
    if hasattr(first, 'routes'):
        func = first
        args = args[1:]
        if func.__doc__ is None: description = func.__name__
        else: description = Html(func.__doc__.split('\n', 1)[0])
    elif len(args) > 1 and hasattr(args[1], 'routes'):
        description = tostring(first)
        func = args[1]
        args = args[2:]
    elif len(args) > 2 and hasattr(args[2], 'routes'):
        attrs = args[1]
        if isinstance(attrs, basestring): attrs = {'class': attrs}
        elif not hasattr(attrs, 'items'):
            raise TypeError('Invalid second argument of link() function: %r' % second)
        description = tostring(first)
        func = args[2]
        args = args[3:]
    elif isinstance(first, basestring):
        func = link_funcs.get(first)
        if func is not None: return func(*args[1:], **kwargs)
        if first.endswith('.css'):
            if kwargs: raise TypeError('Unexpected key arguments')
            return css_link(args)
        if first.endswith('.js'):
            if len(args) > 1: raise TypeError('Unexpected positional arguments')
            if kwargs: raise TypeError('Unexpected key arguments')
            return script_link(first)
        raise TypeError('Invalid arguments of link() function')

    href = url(func, *args, **kwargs)
    return htmljoin([htmltag('a', attrs, href=href), description, Html('</a>')])
Example #22
0
def button(link, markup, **attrs):
    result = [htmltag('a', {'class' : 'button', 'href' : link}, **attrs), Html('<span>%s</span></a>') % markup]
    return Html('').join(result)
Example #23
0
 def hidden(field):
     if field.__class__ == Select and str(field.attrs.get('size', '')) == '1': return ''
     return htmltag('input', name='.'+field.name, type='hidden', value='')
Example #24
0
 def tag(field):
     result = [ htmltag('textarea', field.attrs, name=field.name) ]
     if field.value is not None: result.append(field.value)
     result.append(Html('</textarea>'))
     return htmljoin(result)
Example #25
0
 def tag(field):
     result = []
     result.append(htmltag('input', field.attrs, name=field.name,
                           value='yes', checked=bool(field.value),
                           type = field.HTML_TYPE))
     return htmljoin(result)
Example #26
0
 def hidden(field):
     if not field.attrs.get('disabled'): return ''
     value = field.html_value
     if value is None: value = ''
     return htmltag('input', type='hidden', name=field.name, value=value)
Example #27
0
 def __unicode__(field):
     value = field.html_value
     if value is None: value = ''
     return htmltag('input', field.attrs, name=field.name, value=value, type=field.HTML_TYPE,
                    _class_='%s-field' % field.__class__.__name__.lower())
Example #28
0
 def tag(field):
     return htmltag('input', field.attrs, name=field.name, type=field.HTML_TYPE)
Example #29
0
 def hidden(field):
     if field.__class__ == Select and str(field.attrs.get('size',
                                                          '')) == '1':
         return ''
     return htmltag('input', name='.' + field.name, type='hidden', value='')
Example #30
0
 def hidden(field):
     return htmltag('input', name='.' + field.name, type='hidden', value='')
Example #31
0
 def hidden(field):
     return htmltag('input', name='.'+field.name, type='hidden', value='')
Example #32
0
 def tag(field):
     result = [htmltag('textarea', field.attrs, name=field.name)]
     if field.value is not None: result.append(field.value)
     result.append(Html('</textarea>'))
     return htmljoin(result)
Example #33
0
 def tag(field):
     return htmltag('input',
                    field.attrs,
                    name=field.name,
                    type=field.HTML_TYPE)
Example #34
0
 def hidden(field):
     if not field.attrs.get('disabled'): return ''
     value = field.html_value
     if value is None: value = ''
     return htmltag('input', type='hidden', name=field.name, value=value)