Browse Source

[feat] results: show source of suggested answer

Bnyro 1 year ago
parent
commit
13d801b75d

+ 12 - 0
searx/static/themes/simple/src/less/style.less

@@ -633,6 +633,18 @@ summary.title {
   span {
     overflow-wrap: anywhere;
   }
+
+  .answer {
+    display: flex;
+    flex-direction: column;
+  }
+
+  .answer-url {
+    margin-left: auto;
+    margin-top: 5px;
+    margin-right: 10px;
+    margin-bottom: 10px;
+  }
 }
 
 #infoboxes {

+ 4 - 5
searx/templates/simple/results.html

@@ -23,11 +23,10 @@
     <div id="answers" role="complementary" aria-labelledby="answers-title"><h4 class="title" id="answers-title">{{ _('Answers') }} : </h4>
         {%- for answer in answers.values() -%}
         <div class="answer">
-              {% if answer.url %}
-                <a href="{{ answer.url }}">{{ answer.answer }}</a>
-              {% else %}
-                <span>{{ answer.answer }}</span>
-              {% endif %}
+        <span>{{ answer.answer }}</span>
+          {% if answer.url -%}
+          <a href="{{ answer.url }}" class="answer-url">{{ urlparse(answer.url).hostname }}</a>
+          {% endif -%}
         </div>
         {%- endfor -%}
     </div>

+ 2 - 1
searx/webapp.py

@@ -22,7 +22,7 @@ from typing import List, Dict, Iterable
 
 import urllib
 import urllib.parse
-from urllib.parse import urlencode, unquote
+from urllib.parse import urlencode, urlparse, unquote
 
 import httpx
 
@@ -444,6 +444,7 @@ def render(template_name: str, **kwargs):
             }
         )
     )
+    kwargs['urlparse'] = urlparse
 
     # scripts from plugins
     kwargs['scripts'] = set()