Kaynağa Gözat

forward category to engine without highlighting on the ui

Noémi Ványi 6 yıl önce
ebeveyn
işleme
8cc529e9a3
3 değiştirilmiş dosya ile 19 ekleme ve 11 silme
  1. 1
    5
      searx/engines/findx.py
  2. 11
    4
      searx/query.py
  3. 7
    2
      searx/search.py

+ 1
- 5
searx/engines/findx.py Dosyayı Görüntüle

@@ -33,12 +33,8 @@ type_map = {
33 33
 
34 34
 
35 35
 def request(query, params):
36
-    category = 'general'
37
-    if 'category' in params and len(params['category']) == 1:
38
-        category = params['category'][0]
39
-
40 36
     params['url'] = search_url.format(
41
-        category=type_map[category],
37
+        category=type_map[params['category']],
42 38
         q=urlencode({
43 39
             'q': query,
44 40
             'page': params['pageno']

+ 11
- 4
searx/query.py Dosyayı Görüntüle

@@ -107,14 +107,21 @@ class RawTextQuery(object):
107 107
                 # check if prefix is equal with engine shortcut
108 108
                 if prefix in engine_shortcuts:
109 109
                     parse_next = True
110
-                    self.engines.append({'category': 'none',
111
-                                         'name': engine_shortcuts[prefix]})
110
+                    engine_name = engine_shortcuts[prefix]
111
+                    if engine_name in engines:
112
+                        for engine_category in engines[engine_name].categories:
113
+                            self.engines.append({'category': engine_category,
114
+                                                 'name': engine_name,
115
+                                                 'from_bang': True})
112 116
 
113 117
                 # check if prefix is equal with engine name
114 118
                 elif prefix in engines:
115 119
                     parse_next = True
116
-                    self.engines.append({'category': 'none',
117
-                                         'name': prefix})
120
+                    if prefix in engines:
121
+                        for engine_category in engines[engine_name].categories:
122
+                            self.engines.append({'category': engine_category,
123
+                                                 'name': engine_name,
124
+                                                 'from_bang': True})
118 125
 
119 126
                 # check if prefix is equal with categorie name
120 127
                 elif prefix in categories:

+ 7
- 2
searx/search.py Dosyayı Görüntüle

@@ -258,8 +258,13 @@ def get_search_query_from_webapp(preferences, form):
258 258
     # if engines are calculated from query,
259 259
     # set categories by using that informations
260 260
     if query_engines and raw_text_query.specific:
261
-        query_categories = list(set(engine['category']
262
-                                    for engine in query_engines))
261
+        additional_categories = set()
262
+        for engine in query_engines:
263
+            if 'from_bang' in engine and engine['from_bang']:
264
+                additional_categories.add('none')
265
+            else:
266
+                additional_categories.add(engine['category'])
267
+        query_categories = list(additional_categories)
263 268
 
264 269
     # otherwise, using defined categories to
265 270
     # calculate which engines should be used