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
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
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
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