Пример #1
0
 def search(self,
            q=None,
            history=None,
            search_comments=None,
            project=None,
            limit=None,
            page=0,
            **kw):
     c.search_results = W.search_results
     c.help_modal = W.help_modal
     search_params = kw
     search_params.update({
         'q':
         q or '',
         'history':
         history,
         'search_comments':
         search_comments,
         'project':
         project,
         'limit':
         limit,
         'page':
         page,
         'allowed_types': ['Blog Post', 'Blog Post Snapshot'],
         'fq': ['state_s:published']
     })
     return search_app(**search_params)
Пример #2
0
 def search(self,
            q=None,
            history=None,
            project=None,
            limit=None,
            page=0,
            **kw):
     c.search_results = self.W.search_results
     c.help_modal = self.W.search_help
     search_params = kw
     search_params.update({
         'q':
         q or '',
         'history':
         history,
         'project':
         project,
         'limit':
         limit,
         'page':
         page,
         'allowed_types': ['Post', 'Post Snapshot', 'Discussion', 'Thread'],
     })
     d = search_app(**search_params)
     d['search_comments_disable'] = True
     return d
Пример #3
0
 def search(self,
            q=None,
            history=None,
            search_comments=None,
            project=None,
            limit=None,
            page=0,
            **kw):
     'local wiki search'
     c.search_results = W.search_results
     c.help_modal = W.help_modal
     search_params = kw
     search_params.update({
         'q':
         q or '',
         'history':
         history,
         'search_comments':
         search_comments,
         'project':
         project,
         'limit':
         limit,
         'page':
         page,
         'allowed_types': ['WikiPage', 'WikiPage Snapshot'],
     })
     return search_app(**search_params)
Пример #4
0
 def index(self, q=None, history=False, **kw):
     c.search_results = W.search_results
     search_params = kw
     search_params.update({
         'q': q,
         'history': history,
         'app': False,
     })
     d = search_app(**search_params)
     d['search_comments_disable'] = True
     d['hide_app_project_switcher'] = True
     return d
Пример #5
0
 def index(self, q=None, history=False, **kw):
     c.search_results = W.search_results
     search_params = kw
     search_params.update({
         'q': q,
         'history': history,
         'app': False,
     })
     d = search_app(**search_params)
     d['search_comments_disable'] = True
     d['hide_app_project_switcher'] = True
     return d
Пример #6
0
 def index(self, q=None, history=None, **kw):
     c.search_results = SearchResults()
     c.help_modal = SearchHelp(comments=False)
     pids = [c.project._id] + [p._id for p in c.project.subprojects]
     project_match = " OR ".join("project_id_s:%s" % pid for pid in pids)
     search_params = kw
     search_params.update(
         {"q": q, "history": history, "app": False, "fq": ["project_id_s:(%s)" % project_match, "-deleted_b:true"]}
     )
     d = search_app(**search_params)
     d["search_comments_disable"] = True
     d["hide_app_project_switcher"] = True
     return d
Пример #7
0
 def search(self, q=None, project=None, limit=None, page=0, **kw):
     c.search_results = W.search_results
     c.help_modal = W.search_help
     search_params = kw
     search_params.update(
         {"q": q or "", "project": project, "limit": limit, "page": page, "allowed_types": ["ShortUrl"]}
     )
     if not has_access(c.app, "view_private"):
         search_params["fq"] = ["private_b:False"]
     d = search_app(**search_params)
     d["search_comments_disable"] = True
     d["search_history_disable"] = True
     d["url_len"] = len(ShortUrl.build_short_url(c.app, short_name=""))
     return d
Пример #8
0
    def test_escape_solr_text(self, req, url_fn, solr_search):
        req.GET = dict()
        req.path = '/test/wiki/search'
        url_fn.side_effect = ['the-score-url', 'the-date-url']
        results = mock.Mock(hits=2, docs=[
            {'id': 123, 'type_s': 'WikiPage Snapshot',
             'url_s': '/test/wiki/Foo', 'version_i': 2},
            {'id': 321, 'type_s': 'Post'},
        ], highlighting={
            123: dict(
                title='some #ALLURA-HIGHLIGHT-START#Foo#ALLURA-HIGHLIGHT-END# stuff',
                text='scary <script>alert(1)</script> bar'),
            321: dict(title='blah blah',
                      text='less scary but still dangerous &lt;script&gt;alert(1)&lt;/script&gt; '
                      'blah #ALLURA-HIGHLIGHT-START#bar#ALLURA-HIGHLIGHT-END# foo foo'),
        },
        )
        results.__iter__ = lambda self: iter(results.docs)
        solr_search.return_value = results
        with h.push_context('test', 'wiki', neighborhood='Projects'):
            resp = search_app(q='foo bar')

        assert_equal(resp, dict(
            q='foo bar',
            history=None,
            count=2,
            limit=25,
            page=0,
            search_error=None,
            sort_score_url='the-score-url',
            sort_date_url='the-date-url',
            sort_field='score',
            results=[{
                'id': 123,
                'type_s': 'WikiPage Snapshot',
                'version_i': 2,
                'url_s': '/test/wiki/Foo?version=2',
                # highlighting works
                'title_match': Markup('some <strong>Foo</strong> stuff'),
                # HTML in the solr plaintext results get escaped
                'text_match': Markup('scary &lt;script&gt;alert(1)&lt;/script&gt; bar'),
            }, {
                'id': 321,
                'type_s': 'Post',
                'title_match': Markup('blah blah'),
                # highlighting in text
                'text_match': Markup('less scary but still dangerous &amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt; blah <strong>bar</strong> foo foo'),
            }]
        ))
Пример #9
0
    def test_escape_solr_text(self, req, url_fn, solr_search):
        req.GET = dict()
        req.path = '/test/wiki/search'
        url_fn.side_effect = ['the-score-url', 'the-date-url']
        results = mock.Mock(hits=2, docs=[
            {'id': 123, 'type_s': 'WikiPage Snapshot',
             'url_s': '/test/wiki/Foo', 'version_i': 2},
            {'id': 321, 'type_s': 'Post'},
        ], highlighting={
            123: dict(
                title='some #ALLURA-HIGHLIGHT-START#Foo#ALLURA-HIGHLIGHT-END# stuff',
                text='scary <script>alert(1)</script> bar'),
            321: dict(title='blah blah',
                      text='less scary but still dangerous &lt;script&gt;alert(1)&lt;/script&gt; '
                      'blah #ALLURA-HIGHLIGHT-START#bar#ALLURA-HIGHLIGHT-END# foo foo'),
        },
        )
        results.__iter__ = lambda self: iter(results.docs)
        solr_search.return_value = results
        with h.push_context('test', 'wiki', neighborhood='Projects'):
            resp = search_app(q='foo bar')

        assert_equal(resp, dict(
            q='foo bar',
            history=None,
            count=2,
            limit=25,
            page=0,
            search_error=None,
            sort_score_url='the-score-url',
            sort_date_url='the-date-url',
            sort_field='score',
            results=[{
                'id': 123,
                'type_s': 'WikiPage Snapshot',
                'version_i': 2,
                'url_s': '/test/wiki/Foo?version=2',
                # highlighting works
                'title_match': Markup('some <strong>Foo</strong> stuff'),
                # HTML in the solr plaintext results get escaped
                'text_match': Markup('scary &lt;script&gt;alert(1)&lt;/script&gt; bar'),
            }, {
                'id': 321,
                'type_s': 'Post',
                'title_match': Markup('blah blah'),
                # highlighting in text
                'text_match': Markup('less scary but still dangerous &amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt; blah <strong>bar</strong> foo foo'),
            }]
        ))
Пример #10
0
 def search(self, q=None, project=None, limit=None, page=0, **kw):
     c.search_results = SearchResults()
     c.help_modal = SearchHelp(comments=False, history=False)
     search_params = kw
     search_params.update({
         'q': q or '',
         'project': project,
         'limit': limit,
         'page': page,
         'allowed_types': ['Chat Message'],
     })
     d = search_app(**search_params)
     d['search_comments_disable'] = True
     d['search_history_disable'] = True
     return d
Пример #11
0
 def search(self, q=None, project=None, limit=None, page=0, **kw):
     c.search_results = SearchResults()
     c.help_modal = SearchHelp(comments=False, history=False)
     search_params = kw
     search_params.update({
         'q': q or '',
         'project': project,
         'limit': limit,
         'page': page,
         'allowed_types': ['Chat Message'],
     })
     d = search_app(**search_params)
     d['search_comments_disable'] = True
     d['search_history_disable'] = True
     return d
Пример #12
0
 def search(self, q=None, history=None, search_comments=None, project=None, limit=None, page=0, **kw):
     c.search_results = W.search_results
     c.help_modal = W.help_modal
     search_params = kw
     search_params.update({
         'q': q or '',
         'history': history,
         'search_comments': search_comments,
         'project': project,
         'limit': limit,
         'page': page,
         'allowed_types': ['Blog Post', 'Blog Post Snapshot'],
         'fq': ['state_s:published']
     })
     return search_app(**search_params)
Пример #13
0
 def search(self, q=None, history=None, project=None, limit=None, page=0, **kw):
     c.search_results = self.W.search_results
     c.help_modal = self.W.search_help
     search_params = kw
     search_params.update({
         'q': q or '',
         'history': history,
         'project': project,
         'limit': limit,
         'page': page,
         'allowed_types': ['Post', 'Post Snapshot', 'Discussion', 'Thread'],
     })
     d = search_app(**search_params)
     d['search_comments_disable'] = True
     return d
Пример #14
0
 def search(self, q=None, history=None, search_comments=None, project=None, limit=None, page=0, **kw):
     'local wiki search'
     c.search_results = W.search_results
     c.help_modal = W.help_modal
     search_params = kw
     search_params.update({
         'q': q or '',
         'history': history,
         'search_comments': search_comments,
         'project': project,
         'limit': limit,
         'page': page,
         'allowed_types': ['WikiPage', 'WikiPage Snapshot'],
     })
     return search_app(**search_params)
Пример #15
0
 def search(self, q=None, project=None, limit=None, page=0, **kw):
     c.search_results = W.search_results
     c.help_modal = W.search_help
     search_params = kw
     search_params.update({
         'q': q or '',
         'project': project,
         'limit': limit,
         'page': page,
         'allowed_types': ['ShortUrl'],
     })
     if not has_access(c.app, 'view_private'):
         search_params['fq'] = ['private_b:False']
     d = search_app(**search_params)
     d['search_comments_disable'] = True
     d['search_history_disable'] = True
     return d
Пример #16
0
 def search(self, q=None, history=None, search_comments=None, project=None, limit=None, page=0, **kw):
     c.search_results = W.search_results
     c.help_modal = W.help_modal
     search_params = kw
     search_params.update(
         {
             "q": q or "",
             "history": history,
             "search_comments": search_comments,
             "project": project,
             "limit": limit,
             "page": page,
             "allowed_types": ["Blog Post", "Blog Post Snapshot"],
             "fq": ["state_s:published"],
         }
     )
     return search_app(**search_params)
Пример #17
0
 def test_basic(self, req, url_fn):
     req.GET = dict()
     req.path = '/test/search'
     url_fn.side_effect = ['the-score-url', 'the-date-url']
     with h.push_context('test', 'wiki', neighborhood='Projects'):
         resp = search_app(q='foo bar')
     assert_equal(resp, dict(
         q='foo bar',
         history=None,
         results=[],
         count=0,
         limit=25,
         page=0,
         search_error=None,
         sort_score_url='the-score-url',
         sort_date_url='the-date-url',
         sort_field='score',
     ))
Пример #18
0
 def test_basic(self, req, url_fn):
     req.GET = dict()
     req.path = '/test/search'
     url_fn.side_effect = ['the-score-url', 'the-date-url']
     with h.push_context('test', 'wiki', neighborhood='Projects'):
         resp = search_app(q='foo bar')
     assert_equal(resp, dict(
         q='foo bar',
         history=None,
         results=[],
         count=0,
         limit=25,
         page=0,
         search_error=None,
         sort_score_url='the-score-url',
         sort_date_url='the-date-url',
         sort_field='score',
     ))
Пример #19
0
 def index(self, q=None, history=None, **kw):
     c.search_results = SearchResults()
     c.help_modal = SearchHelp(comments=False)
     pids = [c.project._id] + [
         p._id for p in c.project.subprojects ]
     project_match = ' OR '.join(
         'project_id_s:%s' % pid
         for pid in pids )
     search_params = kw
     search_params.update({
         'q': q,
         'history': history,
         'app': False,
         'fq': [
             'project_id_s:(%s)' % project_match,
             '-deleted_b:true',
         ],
     })
     d = search_app(**search_params)
     d['search_comments_disable'] = True
     d['hide_app_project_switcher'] = True
     return d
Пример #20
0
 def index(self, q=None, history=None, **kw):
     c.search_results = SearchResults()
     c.help_modal = SearchHelp(comments=False)
     pids = [c.project._id] + [p._id for p in c.project.subprojects]
     project_match = ' OR '.join(map(str, pids))
     search_params = kw
     search_params.update({
         'q':
         q,
         'history':
         history,
         'app':
         False,
         'fq': [
             'project_id_s:(%s)' % project_match,
             '-deleted_b:true',
         ],
     })
     d = search_app(**search_params)
     d['search_comments_disable'] = True
     d['hide_app_project_switcher'] = True
     return d