##// END OF EJS Templates
search: goto commit search will now use a safe search option and never...
marcink -
r1411:16beb154 default
parent child Browse files
Show More
@@ -178,7 +178,8 b' class HomeController(BaseController):'
178 user_id=c.rhodecode_user.user_id, ip_addr=self.ip_addr)
178 user_id=c.rhodecode_user.user_id, ip_addr=self.ip_addr)
179 searcher = searcher_from_config(config)
179 searcher = searcher_from_config(config)
180 result = searcher.search(
180 result = searcher.search(
181 'commit_id:%s*' % commit_hash_prefix, 'commit', auth_user)
181 'commit_id:%s*' % commit_hash_prefix, 'commit', auth_user,
182 raise_on_exc=False)
182
183
183 return [
184 return [
184 {
185 {
@@ -187,7 +188,8 b' class HomeController(BaseController):'
187 'type': 'commit',
188 'type': 'commit',
188 'obj': {'repo': entry['repository']},
189 'obj': {'repo': entry['repository']},
189 'url': url('changeset_home',
190 'url': url('changeset_home',
190 repo_name=entry['repository'], revision=entry['commit_id'])
191 repo_name=entry['repository'],
192 revision=entry['commit_id'])
191 }
193 }
192 for entry in result['results']]
194 for entry in result['results']]
193
195
@@ -39,9 +39,11 b' class BaseSearch(object):'
39 def cleanup(self):
39 def cleanup(self):
40 pass
40 pass
41
41
42 def search(self, query, document_type, search_user, repo_name=None):
42 def search(self, query, document_type, search_user, repo_name=None,
43 raise_on_exc=True):
43 raise Exception('NotImplemented')
44 raise Exception('NotImplemented')
44
45
46
45 def searcher_from_config(config, prefix='search.'):
47 def searcher_from_config(config, prefix='search.'):
46 _config = {}
48 _config = {}
47 for key in config.keys():
49 for key in config.keys():
@@ -60,12 +60,12 b' FRAGMENTER = ContextFragmenter(200)'
60 log = logging.getLogger(__name__)
60 log = logging.getLogger(__name__)
61
61
62
62
63
64 class Search(BaseSearch):
63 class Search(BaseSearch):
65
64
66 name = 'whoosh'
65 name = 'whoosh'
67
66
68 def __init__(self, config):
67 def __init__(self, config):
68 super(Search, self).__init__()
69 self.config = config
69 self.config = config
70 if not os.path.isdir(self.config['location']):
70 if not os.path.isdir(self.config['location']):
71 os.makedirs(self.config['location'])
71 os.makedirs(self.config['location'])
@@ -99,8 +99,9 b' class Search(BaseSearch):'
99 query = u'(%s) OR %s' % (query, hashes_or_query)
99 query = u'(%s) OR %s' % (query, hashes_or_query)
100 return query
100 return query
101
101
102 def search(self, query, document_type, search_user, repo_name=None,
102 def search(self, query, document_type, search_user,
103 requested_page=1, page_limit=10, sort=None):
103 repo_name=None, requested_page=1, page_limit=10, sort=None,
104 raise_on_exc=True):
104
105
105 original_query = query
106 original_query = query
106 query = self._extend_query(query)
107 query = self._extend_query(query)
General Comments 0
You need to be logged in to leave comments. Login now