Explorar o código

HUE-5135 [metadata] Add syntax highlighting with <em>

Romain Rigaux %!s(int64=9) %!d(string=hai) anos
pai
achega
1b377d09f9

+ 2 - 2
desktop/core/src/desktop/templates/assist.mako

@@ -940,9 +940,9 @@ from metadata.conf import has_navigator
       <div class="nav-autocomplete-item-link">
         <div style="padding: 8px;"><i style="color: #338bb8" class="fa fa-fw" data-bind="css: icon"></i></div>
         <div>
-          <div style="font-size: 14px; color: #338bb8" data-bind="text: label, style: { 'padding-top': description ? 0 : '8px' }"></div>
+          <div style="font-size: 14px; color: #338bb8" data-bind="html: label, style: { 'padding-top': description ? 0 : '8px' }"></div>
           <!-- ko if: description -->
-          <div style="display:inline-block; width: 170px; overflow: hidden; white-space: nowrap; text-overflow:ellipsis; font-size: 12px;" data-bind="text: description"></div>
+          <div style="display:inline-block; width: 250px; overflow: hidden; white-space: nowrap; text-overflow:ellipsis; font-size: 12px;" data-bind="html: description"></div>
           <!-- /ko -->
         </div>
       </div>

+ 4 - 0
desktop/libs/metadata/src/metadata/navigator_api.py

@@ -25,6 +25,7 @@ except ImportError:
   from ordereddict import OrderedDict # Python 2.6
 
 from django.http import Http404
+from django.utils.html import escape
 from django.utils.translation import ugettext as _
 from django.views.decorators.http import require_POST
 
@@ -241,6 +242,9 @@ def search_entities_interactive(request):
       if record.get(fname, ''):
         record['hue_description'] += ' %s:%s' % (fname, _highlight(fval, record[fname]))
 
+    record['hue_name'] = escape(record['hue_name']).replace('&lt;em&gt;', '<em>').replace('&lt;/em&gt;', '</em>')
+    record['hue_description'] = escape(record['hue_description']).replace('&lt;em&gt;', '<em>').replace('&lt;/em&gt;', '</em>')
+
   response['status'] = 0
 
   return JsonResponse(response)