예제 #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
 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