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))
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))
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))
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))
def wrapper(*args, **kwargs): return markup(func(*args, **kwargs))
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">×' '</button><span>%s</span></div>' % (style, msg))
def kform_inline_filter(self, form): out = [] for field in form: out.append(self.kfield_inline_filter(field)) return markup(''.join(out))
def kform_filter(self, form, **kwargs): out = [] for field in form: out.append(self.kfield_filter(field, **kwargs)) return markup(''.join(out))
def text2html_filter(self, text): return markup(text2html(text))
def line2br_filter(self, text): return markup(escape(text).replace('\n', '<br>'))
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))