Example #1
0
    def get_search_results(self, req, terms, filters):
        """Return a list of search results matching each search term in `terms`.

        The `filters` parameters is a list of the enabled filters, each item
        being the name of the tuples returned by `get_search_events`.

        The events returned by this function must be tuples of the form
        `(href, title, date, author, excerpt).`
        """
        blog_realm = Resource('blog')
        if not 'BLOG_VIEW' in req.perm(blog_realm):
            return
        if 'blog' in filters:
            # Blog posts
            results = search_blog_posts(self.env, terms)
            for name, version, publish_time, author, title, body in results:
                bp_resource = blog_realm(id=name, version=version)
                if 'BLOG_VIEW' in req.perm(bp_resource):
                    yield (req.href.blog(name), 'Blog: ' + title, publish_time,
                           author, shorten_result(text=body, keywords=terms))
            # Blog comments
            results = search_blog_comments(self.env, terms)
            for post_name, comment_number, comment, comment_author, \
                    comment_time in results:
                bp_resource = blog_realm(id=post_name, version=None)
                if 'BLOG_VIEW' in req.perm(bp_resource):
                    bp = BlogPost(self.env, post_name)
                    yield (req.href.blog(post_name) + '#comment-' +
                           str(comment_number), 'Blog: ' + bp.title +
                           ' (Comment ' + str(comment_number) + ')',
                           comment_time, comment_author,
                           shorten_result(text=comment, keywords=terms))
Example #2
0
    def get_search_results(self, req, terms, filters):
        """Return a list of search results matching each search term in `terms`.
        
        The `filters` parameters is a list of the enabled filters, each item
        being the name of the tuples returned by `get_search_events`.

        The events returned by this function must be tuples of the form
        `(href, title, date, author, excerpt).`
        """
        blog_realm = Resource('blog')
        if not 'BLOG_VIEW' in req.perm(blog_realm):
            return
        if 'blog' in filters:
            # Blog posts
            results = search_blog_posts(self.env, terms)
            for name, version, publish_time, author, title, body in results:
                bp_resource = blog_realm(id=name, version=version)
                if 'BLOG_VIEW' in req.perm(bp_resource):
                    yield (req.href.blog(name), 'Blog: '+title,
                        publish_time, author, shorten_result(
                                text=body, keywords=terms))
            # Blog comments
            results = search_blog_comments(self.env, terms)
            for post_name, comment_number, comment, comment_author, \
                    comment_time in results:
                bp_resource = blog_realm(id=post_name, version=None)
                if 'BLOG_VIEW' in req.perm(bp_resource):
                    bp = BlogPost(self.env, post_name)
                    yield (req.href.blog(
                            post_name)+'#comment-'+str(comment_number),
                        'Blog: '+bp.title+' (Comment '+str(comment_number)+')',
                        comment_time, comment_author,
                        shorten_result(text=comment, keywords=terms))
Example #3
0
 def get_search_results(self, req, terms, filters):
     if 'agilo-help' not in filters:
         return []
     
     results = []
     for pkg, name in get_all_help_pages():
         contents = resource_string(pkg, name).decode('UTF-8')
         if self._look_for_terms(contents, terms):
             title = self._extract_title(contents)
             author = 'agile42'
             excerpt = shorten_result(contents, terms)
             
             href = self._build_href(req, pkg, name)
             result = [href, title, now(), author, excerpt]
             results.append(result)
     
     return results
Example #4
0
    def get_search_results(self, req, terms, filters):
        if not 'form' in filters:
            return
        env = self.env
        results = self.search_tracforms(env, terms)

        for id, realm, parent, subctxt, state, author, updated_on in results:
            # DEVEL: support for handling form revisions not implemented yet
            #form = Form(env, realm, parent, subctxt, id, version)
            form = Form(env, realm, parent, subctxt, id)
            if 'FORM_VIEW' in req.perm(form):
                form = form.resource
                # build a more human-readable form values representation,
                # especially with unicode character escapes removed
                state = _render_values(state)
                yield (get_resource_url(env, form, req.href),
                       get_resource_description(env, form),
                       to_datetime(updated_on), author,
                       shorten_result(state, terms))