Browse Source

forward category to engine without highlighting on the ui

Noémi Ványi 6 years ago
parent
commit
8cc529e9a3
3 changed files with 19 additions and 11 deletions
  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 View File

33
 
33
 
34
 
34
 
35
 def request(query, params):
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
     params['url'] = search_url.format(
36
     params['url'] = search_url.format(
41
-        category=type_map[category],
37
+        category=type_map[params['category']],
42
         q=urlencode({
38
         q=urlencode({
43
             'q': query,
39
             'q': query,
44
             'page': params['pageno']
40
             'page': params['pageno']

+ 11
- 4
searx/query.py View File

107
                 # check if prefix is equal with engine shortcut
107
                 # check if prefix is equal with engine shortcut
108
                 if prefix in engine_shortcuts:
108
                 if prefix in engine_shortcuts:
109
                     parse_next = True
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
                 # check if prefix is equal with engine name
117
                 # check if prefix is equal with engine name
114
                 elif prefix in engines:
118
                 elif prefix in engines:
115
                     parse_next = True
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
                 # check if prefix is equal with categorie name
126
                 # check if prefix is equal with categorie name
120
                 elif prefix in categories:
127
                 elif prefix in categories:

+ 7
- 2
searx/search.py View File

258
     # if engines are calculated from query,
258
     # if engines are calculated from query,
259
     # set categories by using that informations
259
     # set categories by using that informations
260
     if query_engines and raw_text_query.specific:
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
     # otherwise, using defined categories to
269
     # otherwise, using defined categories to
265
     # calculate which engines should be used
270
     # calculate which engines should be used