Mercurial > kallithea
comparison rhodecode/lib/indexers/__init__.py @ 2319:4c239e0dcbb7 beta
fixes issue #454 Search results under Windows include preceeding backslash
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 20 May 2012 16:38:00 +0200 |
parents | 8ecfed1d8f8b |
children | 1828eb7fa688 |
comparison
equal
deleted
inserted
replaced
2318:058e2743e7b7 | 2319:4c239e0dcbb7 |
---|---|
127 help="Specifies that index should be made full i.e" | 127 help="Specifies that index should be made full i.e" |
128 " destroy old and build from scratch", | 128 " destroy old and build from scratch", |
129 default=False) | 129 default=False) |
130 | 130 |
131 | 131 |
132 class ResultWrapper(object): | 132 class WhooshResultWrapper(object): |
133 def __init__(self, search_type, searcher, matcher, highlight_items): | 133 def __init__(self, search_type, searcher, matcher, highlight_items, |
134 repo_location): | |
134 self.search_type = search_type | 135 self.search_type = search_type |
135 self.searcher = searcher | 136 self.searcher = searcher |
136 self.matcher = matcher | 137 self.matcher = matcher |
137 self.highlight_items = highlight_items | 138 self.highlight_items = highlight_items |
138 self.fragment_size = 200 | 139 self.fragment_size = 200 |
140 self.repo_location = repo_location | |
139 | 141 |
140 @LazyProperty | 142 @LazyProperty |
141 def doc_ids(self): | 143 def doc_ids(self): |
142 docs_id = [] | 144 docs_id = [] |
143 while self.matcher.is_active(): | 145 while self.matcher.is_active(): |
176 slices.append(self.get_full_content(docid)) | 178 slices.append(self.get_full_content(docid)) |
177 return slices | 179 return slices |
178 | 180 |
179 def get_full_content(self, docid): | 181 def get_full_content(self, docid): |
180 res = self.searcher.stored_fields(docid[0]) | 182 res = self.searcher.stored_fields(docid[0]) |
181 f_path = res['path'][res['path'].find(res['repository']) \ | 183 full_repo_path = jn(self.repo_location, res['repository']) |
182 + len(res['repository']):].lstrip('/') | 184 f_path = res['path'].split(full_repo_path)[-1] |
185 f_path = f_path.lstrip(os.sep) | |
183 | 186 |
184 content_short = self.get_short_content(res, docid[1]) | 187 content_short = self.get_short_content(res, docid[1]) |
185 res.update({'content_short': content_short, | 188 res.update({'content_short': content_short, |
186 'content_short_hl': self.highlight(content_short), | 189 'content_short_hl': self.highlight(content_short), |
187 'f_path': f_path}) | 190 'f_path': f_path}) |