コード例 #1
0
ファイル: _workflow.py プロジェクト: silky/floof
def new_json_response(request):
    ret = {
        'status': 'unknown',
        'flash': [],
    }
    for flash in request.session.pop_flash():
        message = flash['message']
        # XXX we may want to move this escaping to JS-land or else we're
        # bound to miss something one day
        if flash['html_escape']:
            message = escape(message)
        ret['flash'].append({
            'level':
            flash['level'],
            'icon':
            flash['icon'],
            'icon_url':
            request.static_url('floof:assets/icons/{0}.png'.format(
                flash['icon'])),
            'message':
            message,
            # XXX we shouldn't need this at all; should always go through markupsafe
            'html':
            not flash['html_escape'],
        })
    return ret
コード例 #2
0
ファイル: __init__.py プロジェクト: lmamsen/rhodecode
 def highlight(self, content, top=5):
     if self.search_type != 'content':
         return ''
     hl = highlight(escape(content),
              self.highlight_items,
              analyzer=ANALYZER,
              fragmenter=FRAGMENTER,
              formatter=FORMATTER,
              top=top)
     return hl
コード例 #3
0
 def highlight(self, content, top=5):
     if self.search_type != 'content':
         return ''
     hl = highlight(text=escape(content),
                    terms=self.highlight_items,
                    analyzer=ANALYZER,
                    fragmenter=FRAGMENTER,
                    formatter=FORMATTER,
                    top=top)
     return hl
コード例 #4
0
ファイル: _workflow.py プロジェクト: eevee/floof
def new_json_response(request):
    ret = {
        'status': 'unknown',
        'flash': [],
    }
    for flash in request.session.pop_flash():
        message = flash['message']
        # XXX we may want to move this escaping to JS-land or else we're
        # bound to miss something one day
        if flash['html_escape']:
            message = escape(message)
        ret['flash'].append({
            'level': flash['level'],
            'icon': flash['icon'],
            'icon_url': request.static_url(
                'floof:assets/icons/{0}.png'.format(flash['icon'])),
            'message': message,
            # XXX we shouldn't need this at all; should always go through markupsafe
            'html': not flash['html_escape'],
        })
    return ret