Beispiel #1
0
 def static_footer(self, name='default'):
     instance = self.file[name]
     if self.app.debug:
         htmls = [self.static_js(x) for x in instance['jsfooterx']]
     else:
         htmls = [self.static_js(x) for x in instance['jsfooter']]
     return markup('\n'.join(htmls))
Beispiel #2
0
 def static_header(self, name='default'):
     instance = self.file[name]
     if self.app.debug:
         htmls = [self.static_css(x) for x in instance['cssx']]
         htmls.extend([self.static_js(x) for x in instance['jsx']])
     else:
         htmls = [self.static_css(x) for x in instance['css']]
         htmls.extend([self.static_js(x) for x in instance['js']])
     return markup('\n'.join(htmls))
Beispiel #3
0
 def kfield_filter(self, field, **kwargs):
     label = kwargs.pop('label', 3)
     grid = kwargs.pop('grid', 'sm')
     _class = kwargs.pop('_class', 'form-group')
     error = kwargs.pop('error', True)
     label_class = 'control-label col-%s-%d' % (grid, label)
     out = []
     if field.type == 'Label':
         out.append(field(class_='form-title'))
     elif field.type not in ['CSRFTokenField', 'HiddenField']:
         out.append('<div class="%s">' % _class)
         out.append(field.label(class_=label_class))
         if field.type == 'KRadioField':
             field_div = '<div class="col-%s-%d radio-line">' % (grid,
                                                                 (12 -
                                                                  label))
             out.append(field_div)
             out.append(field(sub_class='radio-inline',
                              class_="radio-line"))
         elif field.type == 'KCheckboxField':
             field_div = '<div class="col-%s-%d checkbox-line">' % (grid,
                                                                    (12 -
                                                                     label))
             out.append(field_div)
             out.append(
                 field(sub_class='checkbox-inline', class_="checkbox-line"))
         else:
             field_div = '<div class="col-%s-%d">' % (grid, (12 - label))
             out.append(field_div)
             if hasattr(field, 'addon'):
                 out.append('<div class="input-group">')
                 out.append(
                     field(class_='form-control',
                           data_label=field.label.text,
                           placeholder=field.description or ''))
                 out.append('<span class="input-group-addon">%s</span>' %
                            field.addon)
                 out.append('</div>')
             else:
                 out.append(
                     field(class_='form-control',
                           data_label=field.label.text,
                           placeholder=field.description or ''))
         if error and field.errors:
             out.append('<div class="error-msg">%s</div>' % field.errors[0])
         out.append('</div><div class="clearfix"></div></div>')
     else:
         out.append(field())
     return markup(''.join(out))
Beispiel #4
0
 def kfield_inline_filter(self, field, **kwargs):
     out = []
     if field.type in ['CSRFTokenField', 'HiddenField']:
         out.append(field(**kwargs))
     else:
         out.append('<div class="form-group">')
         if field.type == 'BooleanField':
             out.append('<div class="checkbox"><label>%s %s</label></div>' %
                        (field(**kwargs), field.label.text))
         else:
             kwargs.setdefault('class_', 'form-control')
             kwargs.setdefault('data_label', field.label.text)
             kwargs.setdefault('placeholder', field.label.text)
             out.append(field(**kwargs))
         out.append('</div>')
     return markup(''.join(out))
Beispiel #5
0
 def wrapper(*args, **kwargs):
     return markup(func(*args, **kwargs))
Beispiel #6
0
 def alert_msg(self, msg, style='danger'):
     return markup(
         '<div class="alert alert-%s"><button class="close" '
         'type="button" data-dismiss="alert" aria-hidden="true">&times;'
         '</button><span>%s</span></div>' % (style, msg))
Beispiel #7
0
 def kform_inline_filter(self, form):
     out = []
     for field in form:
         out.append(self.kfield_inline_filter(field))
     return markup(''.join(out))
Beispiel #8
0
 def kform_filter(self, form, **kwargs):
     out = []
     for field in form:
         out.append(self.kfield_filter(field, **kwargs))
     return markup(''.join(out))
Beispiel #9
0
 def text2html_filter(self, text):
     return markup(text2html(text))
Beispiel #10
0
 def line2br_filter(self, text):
     return markup(escape(text).replace('\n', '<br>'))
Beispiel #11
0
 def static_ie8(self):
     ie8 = self.ie8x if self.app.debug else self.ie8
     htmls = [self.static_js(x) for x in ie8]
     t = '    <!--[if lt IE 9]>\n%s\n    <![endif]-->' % '\n'
     return markup(t.join(htmls))