|
a/ForgeDiscussion/forgediscussion/controllers/root.py |
|
b/ForgeDiscussion/forgediscussion/controllers/root.py |
|
... |
|
... |
22 |
from .forum import ForumController
|
22 |
from .forum import ForumController
|
23 |
from forgediscussion import import_support
|
23 |
from forgediscussion import import_support
|
24 |
from forgediscussion import model
|
24 |
from forgediscussion import model
|
25 |
from forgediscussion import widgets as FW
|
25 |
from forgediscussion import widgets as FW
|
26 |
from allura.lib.widgets import discuss as DW
|
26 |
from allura.lib.widgets import discuss as DW
|
|
|
27 |
from allura.lib.widgets.search import SearchResults
|
27 |
|
28 |
|
28 |
from forgediscussion.widgets.admin import AddForumShort
|
29 |
from forgediscussion.widgets.admin import AddForumShort
|
29 |
|
30 |
|
30 |
log = logging.getLogger(__name__)
|
31 |
log = logging.getLogger(__name__)
|
31 |
|
32 |
|
|
... |
|
... |
34 |
class W(object):
|
35 |
class W(object):
|
35 |
forum_subscription_form=FW.ForumSubscriptionForm()
|
36 |
forum_subscription_form=FW.ForumSubscriptionForm()
|
36 |
new_topic=DW.NewTopicPost(submit_text='Save')
|
37 |
new_topic=DW.NewTopicPost(submit_text='Save')
|
37 |
announcements_table=FW.AnnouncementsTable()
|
38 |
announcements_table=FW.AnnouncementsTable()
|
38 |
add_forum=AddForumShort()
|
39 |
add_forum=AddForumShort()
|
|
|
40 |
search_results = SearchResults()
|
39 |
|
41 |
|
40 |
def _check_security(self):
|
42 |
def _check_security(self):
|
41 |
require_access(c.app, 'read')
|
43 |
require_access(c.app, 'read')
|
42 |
|
44 |
|
43 |
@with_trailing_slash
|
45 |
@with_trailing_slash
|
|
... |
|
... |
92 |
|
94 |
|
93 |
@with_trailing_slash
|
95 |
@with_trailing_slash
|
94 |
@expose('jinja:forgediscussion:templates/discussionforums/search.html')
|
96 |
@expose('jinja:forgediscussion:templates/discussionforums/search.html')
|
95 |
@validate(dict(q=validators.UnicodeString(if_empty=None),
|
97 |
@validate(dict(q=validators.UnicodeString(if_empty=None),
|
96 |
history=validators.StringBool(if_empty=False),
|
98 |
history=validators.StringBool(if_empty=False),
|
97 |
project=validators.StringBool(if_empty=False)))
|
99 |
project=validators.StringBool(if_empty=False),
|
|
|
100 |
limit=validators.Int(if_empty=None),
|
|
|
101 |
page=validators.Int(if_empty=0)))
|
98 |
def search(self, q=None, history=False, project=False, **kw):
|
102 |
def search(self, q=None, history=False, project=False, limit=None, page=0, **kw):
|
99 |
'local tool search'
|
103 |
'local tool search'
|
100 |
if project:
|
104 |
if project:
|
101 |
redirect(c.project.url() + 'search?' + urlencode(dict(q=q, history=history)))
|
105 |
redirect(c.project.url() + 'search?' + urlencode(dict(q=q, history=history)))
|
102 |
results = []
|
106 |
results = []
|
103 |
count=0
|
107 |
count=0
|
|
|
108 |
limit, page, start = g.handle_paging(limit, page, default=25)
|
104 |
if not q:
|
109 |
if not q:
|
105 |
q = ''
|
110 |
q = ''
|
106 |
else:
|
111 |
else:
|
107 |
results = search(
|
112 |
results = search(
|
108 |
q,
|
113 |
q, rows=limit, start=start,
|
109 |
fq=[
|
114 |
fq=[
|
110 |
'is_history_b:%s' % history,
|
115 |
'is_history_b:%s' % history,
|
111 |
'project_id_s:%s' % c.project._id,
|
116 |
'project_id_s:%s' % c.project._id,
|
112 |
'mount_point_s:%s'% c.app.config.options.mount_point ])
|
117 |
'mount_point_s:%s'% c.app.config.options.mount_point ])
|
113 |
if results: count=results.hits
|
118 |
if results: count=results.hits
|
|
|
119 |
c.search_results = self.W.search_results
|
114 |
return dict(q=q, history=history, results=results or [], count=count)
|
120 |
return dict(q=q, history=history, results=results or [],
|
|
|
121 |
count=count, limit=limit, page=page)
|
115 |
|
122 |
|
116 |
@expose('jinja:allura:templates/markdown_syntax.html')
|
123 |
@expose('jinja:allura:templates/markdown_syntax.html')
|
117 |
def markdown_syntax(self):
|
124 |
def markdown_syntax(self):
|
118 |
'Static page explaining markdown.'
|
125 |
'Static page explaining markdown.'
|
119 |
return dict()
|
126 |
return dict()
|