Mercurial > kallithea
comparison pylons_app/controllers/search.py @ 525:87d80c84df09
added search in specific repository
added delete to my page view handled by separate controller for deleting users own repos, added fork draft
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 29 Sep 2010 22:38:54 +0200 |
parents | 7010af6efde5 |
children |
comparison
equal
deleted
inserted
replaced
524:63212fea2471 | 525:87d80c84df09 |
---|---|
42 | 42 |
43 @LoginRequired() | 43 @LoginRequired() |
44 def __before__(self): | 44 def __before__(self): |
45 super(SearchController, self).__before__() | 45 super(SearchController, self).__before__() |
46 | 46 |
47 def index(self): | 47 def index(self, search_repo=None): |
48 c.repo_name = search_repo | |
48 c.formated_results = [] | 49 c.formated_results = [] |
49 c.runtime = '' | 50 c.runtime = '' |
50 c.cur_query = request.GET.get('q', None) | 51 c.cur_query = request.GET.get('q', None) |
51 if c.cur_query: | 52 if c.cur_query: |
52 cur_query = c.cur_query.lower() | 53 cur_query = c.cur_query.lower() |
57 try: | 58 try: |
58 idx = open_dir(IDX_LOCATION, indexname=IDX_NAME) | 59 idx = open_dir(IDX_LOCATION, indexname=IDX_NAME) |
59 searcher = idx.searcher() | 60 searcher = idx.searcher() |
60 | 61 |
61 qp = QueryParser("content", schema=SCHEMA) | 62 qp = QueryParser("content", schema=SCHEMA) |
63 if c.repo_name: | |
64 cur_query = u'repository:%s %s' % (c.repo_name, cur_query) | |
62 try: | 65 try: |
63 query = qp.parse(unicode(cur_query)) | 66 query = qp.parse(unicode(cur_query)) |
64 | 67 |
65 if isinstance(query, Phrase): | 68 if isinstance(query, Phrase): |
66 highlight_items.update(query.words) | 69 highlight_items.update(query.words) |