|
a/Allura/allura/controllers/search.py |
|
b/Allura/allura/controllers/search.py |
|
... |
|
... |
20 |
from formencode import validators as V
|
20 |
from formencode import validators as V
|
21 |
from pylons import tmpl_context as c
|
21 |
from pylons import tmpl_context as c
|
22 |
from webob import exc
|
22 |
from webob import exc
|
23 |
import pymongo
|
23 |
import pymongo
|
24 |
|
24 |
|
25 |
from allura.lib import search
|
25 |
from allura.lib.search import search_app
|
|
|
26 |
from allura.lib.widgets.search import SearchResults
|
26 |
from allura.app import SitemapEntry
|
27 |
from allura.app import SitemapEntry
|
27 |
from allura import model as M
|
28 |
from allura import model as M
|
28 |
from allura.lib.widgets import project_list as plw
|
29 |
from allura.lib.widgets import project_list as plw
|
29 |
from allura.controllers import BaseController
|
30 |
from allura.controllers import BaseController
|
30 |
|
31 |
|
31 |
class W:
|
32 |
class W:
|
32 |
project_summary = plw.ProjectSummary()
|
33 |
project_summary = plw.ProjectSummary()
|
|
|
34 |
search_results = SearchResults()
|
33 |
|
35 |
|
34 |
class SearchController(BaseController):
|
36 |
class SearchController(BaseController):
|
35 |
|
37 |
|
36 |
@expose('jinja:allura:templates/search_index.html')
|
38 |
@expose('jinja:allura:templates/search_index.html')
|
37 |
@validate(dict(q=V.UnicodeString(),
|
39 |
@validate(dict(q=V.UnicodeString(),
|
38 |
history=V.StringBool(if_empty=False)))
|
40 |
history=V.StringBool(if_empty=False)))
|
39 |
@with_trailing_slash
|
41 |
@with_trailing_slash
|
40 |
def index(self, q=None, history=False, **kw):
|
42 |
def index(self, q=None, history=False, **kw):
|
41 |
results = []
|
43 |
c.search_results = W.search_results
|
42 |
count=0
|
44 |
search_params = kw
|
43 |
if not q:
|
45 |
search_params.update({
|
44 |
q = ''
|
|
|
45 |
else:
|
|
|
46 |
results = search.search(
|
|
|
47 |
q,
|
46 |
'q': q,
|
48 |
fq='is_history_b:%s' % history,
|
47 |
'history': history,
|
49 |
short_timeout=True)
|
48 |
'app': False,
|
50 |
if results: count=results.hits
|
49 |
})
|
51 |
return dict(q=q, history=history, results=results or [], count=count)
|
50 |
d = search_app(**search_params)
|
52 |
|
51 |
d['search_comments_disable'] = True
|
|
|
52 |
d['hide_app_project_switcher'] = True
|
|
|
53 |
return d
|
53 |
|
54 |
|
54 |
class ProjectBrowseController(BaseController):
|
55 |
class ProjectBrowseController(BaseController):
|
55 |
def __init__(self, category_name=None, parent_category=None):
|
56 |
def __init__(self, category_name=None, parent_category=None):
|
56 |
self.parent_category = parent_category
|
57 |
self.parent_category = parent_category
|
57 |
self.nav_stub = '/browse/'
|
58 |
self.nav_stub = '/browse/'
|