Browse Source

Add non exclusif bang

Allow to perform a search while adding an engine (or a category) without adding it "officially" to the request.
'?' is used to add an engine without modifying anything else to the request. For example, you can perform a search in the 'general' category, and if you add '?tw' the result from Twitter will be added to the originals results.
Cqoicebordel 10 years ago
parent
commit
96c4d52eef
2 changed files with 6 additions and 2 deletions
  1. 5
    1
      searx/query.py
  2. 1
    1
      searx/search.py

+ 5
- 1
searx/query.py View File

38
         self.query_parts = []
38
         self.query_parts = []
39
         self.engines = []
39
         self.engines = []
40
         self.languages = []
40
         self.languages = []
41
+        self.specific = False
41
 
42
 
42
     # parse query, if tags are set, which
43
     # parse query, if tags are set, which
43
     # change the serch engine or search-language
44
     # change the serch engine or search-language
83
                         break
84
                         break
84
 
85
 
85
             # this force a engine or category
86
             # this force a engine or category
86
-            if query_part[0] == '!':
87
+            if query_part[0] == '!' or query_part[0] == '?':
87
                 prefix = query_part[1:].replace('_', ' ')
88
                 prefix = query_part[1:].replace('_', ' ')
88
 
89
 
89
                 # check if prefix is equal with engine shortcut
90
                 # check if prefix is equal with engine shortcut
110
                                         for engine in categories[prefix]
111
                                         for engine in categories[prefix]
111
                                         if engine not in self.blocked_engines)
112
                                         if engine not in self.blocked_engines)
112
 
113
 
114
+            if query_part[0] == '!':
115
+                self.specific = True
116
+
113
             # append query part to query_part list
117
             # append query part to query_part list
114
             self.query_parts.append(query_part)
118
             self.query_parts.append(query_part)
115
 
119
 

+ 1
- 1
searx/search.py View File

371
 
371
 
372
         # if engines are calculated from query,
372
         # if engines are calculated from query,
373
         # set categories by using that informations
373
         # set categories by using that informations
374
-        if self.engines:
374
+        if self.engines and query_obj.specific:
375
             self.categories = list(set(engine['category']
375
             self.categories = list(set(engine['category']
376
                                        for engine in self.engines))
376
                                        for engine in self.engines))
377
 
377