@@ -30,7 +30,7 @@ from pylons import request, config, tmpl
from rhodecode.lib.auth import LoginRequired
from rhodecode.lib.base import BaseController, render
from rhodecode.lib.indexers import SCHEMA, IDX_NAME, ResultWrapper
from rhodecode.lib.indexers import SCHEMA, IDX_NAME, WhooshResultWrapper
from webhelpers.paginate import Page
from webhelpers.util import update_params
@@ -38,6 +38,7 @@ from webhelpers.util import update_param
from whoosh.index import open_dir, EmptyIndexError
from whoosh.qparser import QueryParser, QueryParserError
from whoosh.query import Phrase, Wildcard, Term, Prefix
from rhodecode.model.repo import RepoModel
log = logging.getLogger(__name__)
@@ -99,10 +100,10 @@ class SearchController(BaseController):
def url_generator(**kw):
return update_params("?q=%s&type=%s" \
% (c.cur_query, c.cur_search), **kw)
repo_location = RepoModel().repos_path
c.formated_results = Page(
ResultWrapper(search_type, searcher, matcher,
highlight_items),
WhooshResultWrapper(search_type, searcher, matcher,
highlight_items, repo_location),
page=p,
item_count=res_ln,
items_per_page=10,
@@ -129,13 +129,15 @@ class MakeIndex(BasePasterCommand):
default=False)
class ResultWrapper(object):
def __init__(self, search_type, searcher, matcher, highlight_items):
class WhooshResultWrapper(object):
def __init__(self, search_type, searcher, matcher, highlight_items,
repo_location):
self.search_type = search_type
self.searcher = searcher
self.matcher = matcher
self.highlight_items = highlight_items
self.fragment_size = 200
self.repo_location = repo_location
@LazyProperty
def doc_ids(self):
@@ -178,8 +180,9 @@ class ResultWrapper(object):
def get_full_content(self, docid):
res = self.searcher.stored_fields(docid[0])
f_path = res['path'][res['path'].find(res['repository']) \
+ len(res['repository']):].lstrip('/')
full_repo_path = jn(self.repo_location, res['repository'])
f_path = res['path'].split(full_repo_path)[-1]
f_path = f_path.lstrip(os.sep)
content_short = self.get_short_content(res, docid[1])
res.update({'content_short': content_short,
Status change: