bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pe...@apache.org
Subject svn commit: r1455474 - in /incubator/bloodhound/trunk: bloodhound_search/bhsearch/ bloodhound_search/bhsearch/search_resources/ bloodhound_search/bhsearch/templates/ bloodhound_theme/bhtheme/ bloodhound_theme/bhtheme/templates/
Date Tue, 12 Mar 2013 10:08:00 GMT
Author: peter
Date: Tue Mar 12 10:08:00 2013
New Revision: 1455474

URL: http://svn.apache.org/r1455474
Log:
#458 - quick search box integration for search 

Added:
    incubator/bloodhound/trunk/bloodhound_search/bhsearch/templates/bhsearch_breadcrumbs.html
Modified:
    incubator/bloodhound/trunk/bloodhound_search/bhsearch/search_resources/ticket_search.py
    incubator/bloodhound/trunk/bloodhound_search/bhsearch/templates/bhsearch.html
    incubator/bloodhound/trunk/bloodhound_search/bhsearch/web_ui.py
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py

Modified: incubator/bloodhound/trunk/bloodhound_search/bhsearch/search_resources/ticket_search.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_search/bhsearch/search_resources/ticket_search.py?rev=1455474&r1=1455473&r2=1455474&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_search/bhsearch/search_resources/ticket_search.py
(original)
+++ incubator/bloodhound/trunk/bloodhound_search/bhsearch/search_resources/ticket_search.py
Tue Mar 12 10:08:00 2013
@@ -205,5 +205,6 @@ class TicketSearchParticipant(BaseSearch
 
         id = res['hilited_id'] or res['id']
         id = tag.span('#', id, class_=css_class)
-        return tag(id, ': ', res['hilited_summary'], ' (%s)' % stat)
+        summary = res['hilited_summary'] or res['summary']
+        return tag(id, ': ', summary, ' (%s)' % stat)
 

Modified: incubator/bloodhound/trunk/bloodhound_search/bhsearch/templates/bhsearch.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_search/bhsearch/templates/bhsearch.html?rev=1455474&r1=1455473&r2=1455474&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_search/bhsearch/templates/bhsearch.html (original)
+++ incubator/bloodhound/trunk/bloodhound_search/bhsearch/templates/bhsearch.html Tue Mar
12 10:08:00 2013
@@ -56,33 +56,6 @@
   <body>
     <div id="content" class="row">
       <div class="span12">
-        <h1>Advanced search</h1>
-          <form id="fullsearch" action="${href.bhsearch()}" method="get">
-            <!--So far, we will not support noquickjump mode for form submission-->
-            <!--<input type="hidden" name="noquickjump" value="1" />-->
-            <input py:if="active_type" type="hidden" name="type" value="${active_type}"
/>
-            <input py:if="active_view" type="hidden" name="view" value="${active_view}"
/>
-            <input py:if="active_sort" type="hidden" name="sort" value="${active_sort.expression}"
/>
-            <py:for each="active_filter in active_filter_queries">
-              <input type="hidden" name="fq" value="${active_filter.query}" />
-            </py:for>
-
-            <div class="input-append">
-              <input type="text" id="q" name="q" class="span4" value="${query}" />
-              <button type="submit" class="btn btn-warning">
-                <span class="hidden-phone">${_('Search')}</span>
-                <i class="icon-search icon-white"></i>
-              </button>
-            </div>
-
-            <div id="active_sort" py:if="active_sort">
-                Sort by: <strong>${active_sort.expression}</strong> (<a href="${active_sort.href}">remove</a>)
-            </div>
-
-          </form>
-      </div>
-
-      <div class="span12">
         <py:if test="quickjump">
           <dt id="quickjump">
             <a href="${quickjump.href}" i18n:msg="name">Quickjump to ${quickjump.name}</a>
@@ -102,13 +75,6 @@
           </ul>
         </div>
 
-        <!--Render filters breadcrumbs-->
-        <div id="active_filter_queries" py:if="active_filter_queries">
-          <py:for each="active_filter in active_filter_queries">
-            &gt; <a href="${active_filter.href}">${active_filter.label}</a>
-          </py:for>
-        </div>
-
         <div py:if="results" class="row">
           <div class="span3 facets">
             <py:if test="facet_counts">
@@ -128,7 +94,8 @@
             </py:if>
           </div>
 
-          <div class="${'span12' if not facet_counts else 'span9 search_results'}">
+            <div class="${'span12' if not facet_counts else 'span9'}${
+                        ' search_results'}">
             <h2>
               Results <small>(${results.displayed_items()})</small>
             </h2>
@@ -200,7 +167,7 @@
                 <dl id="results">
                   <py:for each="result in results">
                     <dt><a href="${result.href}" class="searchable">${result.title}</a></dt>
-                    <dd class="searchable">${result.content}</dd>
+                    <dd class="searchable">${result.hilited_content or result.content}</dd>
                     <dd>
                       <py:if test="result.author"><span class="author" i18n:msg="author">By
${format_author(result.author)}</span> &mdash;</py:if>
                       <span class="date">${result.date}</span>

Added: incubator/bloodhound/trunk/bloodhound_search/bhsearch/templates/bhsearch_breadcrumbs.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_search/bhsearch/templates/bhsearch_breadcrumbs.html?rev=1455474&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_search/bhsearch/templates/bhsearch_breadcrumbs.html
(added)
+++ incubator/bloodhound/trunk/bloodhound_search/bhsearch/templates/bhsearch_breadcrumbs.html
Tue Mar 12 10:08:00 2013
@@ -0,0 +1,33 @@
+<!DOCTYPE html
+        PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:py="http://genshi.edgewall.org/"
+      xmlns:i18n="http://genshi.edgewall.org/i18n"
+      xmlns:xi="http://www.w3.org/2001/XInclude">
+<a href="${href.bhsearch()}">Search</a>
+<py:for each="active_filter in active_filter_queries">
+    &gt; <a href="${active_filter.href}">${active_filter.label}</a>
+</py:for>
+<py:if test="query">
+    &gt; "${query}"
+</py:if>
+</html>

Modified: incubator/bloodhound/trunk/bloodhound_search/bhsearch/web_ui.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_search/bhsearch/web_ui.py?rev=1455474&r1=1455473&r2=1455474&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_search/bhsearch/web_ui.py (original)
+++ incubator/bloodhound/trunk/bloodhound_search/bhsearch/web_ui.py Tue Mar 12 10:08:00 2013
@@ -272,6 +272,9 @@ class BloodhoundSearchModule(Component):
             self.default_facets
         )
 
+        # compatibility with legacy search
+        req.search_query = request_context.parameters.query
+
         query_result = BloodhoundSearchApi(self.env).query(
             request_context.parameters.query,
             pagenum=request_context.page,
@@ -301,20 +304,19 @@ class BloodhoundSearchModule(Component):
 
 class RequestContext(object):
     DATA_ACTIVE_FILTER_QUERIES = 'active_filter_queries'
-    DATA_ACTIVE_TYPE = "active_type"
-    DATA_ACTIVE_SORT = "active_sort"
+    DATA_BREADCRUMBS_TEMPLATE = 'resourcepath_template'
     DATA_TYPES = "types"
     DATA_HEADERS = "headers"
     DATA_ALL_VIEWS = "all_views"
-    DATA_ACTIVE_VIEW = "active_view"
     DATA_VIEW = "view"
     DATA_VIEW_GRID = "grid"
     DATA_FACET_COUNTS = 'facet_counts'
     DATA_DEBUG = 'debug'
     DATA_PAGE_HREF = 'page_href'
     DATA_RESULTS = 'results'
+    DATA_QUERY = 'query'
     DATA_QUICK_JUMP = "quickjump"
-
+    DATA_SEARCH_EXTRAS = 'extra_search_fields'
 
     #bhsearch may support more pluggable views later
     VIEWS_SUPPORTED = {
@@ -338,7 +340,10 @@ class RequestContext(object):
         self.env = env
         self.req = req
         self.parameters = RequestParameters(req)
-        self.data = {'query': self.parameters.query}
+        self.data = {
+            self.DATA_QUERY: self.parameters.query,
+            self.DATA_SEARCH_EXTRAS: [],
+        }
         self.search_participants = search_participants
         self.default_view = default_view
         self.all_grid_fields = all_grid_fields
@@ -349,9 +354,8 @@ class RequestContext(object):
 
         if self.parameters.sort:
             self.sort = self.parameters.sort
-            self.data[self.DATA_ACTIVE_SORT] = dict(
-                expression=self.parameters.sort_string,
-                href=self.parameters.create_href(skip_sort=True)
+            self.data[self.DATA_SEARCH_EXTRAS].append(
+                (RequestParameters.SORT, self.parameters.sort_string)
             )
         else:
             self.sort = self.DEFAULT_SORT
@@ -417,7 +421,9 @@ class RequestContext(object):
                 ),
             ))
         self.data[self.DATA_TYPES] = allowed_types
-        self.data[self.DATA_ACTIVE_TYPE] = active_type
+        self.data[self.DATA_SEARCH_EXTRAS].append(
+            (RequestParameters.TYPE, active_type)
+        )
 
     def _prepare_active_filter_queries(self):
         current_filters = self.parameters.filter_queries
@@ -435,6 +441,10 @@ class RequestContext(object):
             ) for filter_query in self.parameters.filter_queries
         ]
         self.data[self.DATA_ACTIVE_FILTER_QUERIES] = active_filter_queries
+        for filter_query in active_filter_queries:
+            self.data[self.DATA_SEARCH_EXTRAS].append(
+                (RequestParameters.FILTER_QUERY, filter_query['query'])
+            )
 
     def _prepare_quick_jump(self):
         if not self.parameters.query:
@@ -497,7 +507,9 @@ class RequestContext(object):
     def _add_views_selector(self):
         active_view = self.parameters.view
         if active_view:
-            self.data[self.DATA_ACTIVE_VIEW] = active_view
+            self.data[self.DATA_SEARCH_EXTRAS].append(
+                (RequestParameters.VIEW, active_view)
+            )
 
         all_views = []
         for view, label in self.VIEWS_SUPPORTED.iteritems():
@@ -635,6 +647,7 @@ class RequestContext(object):
                                   query_result.highlighting)
         self._prepare_results(docs, query_result.hits)
         self._prepare_result_facet_counts(query_result.facets)
+        self._prepare_breadcrumbs_template()
         self.data[self.DATA_DEBUG] = query_result.debug
         self.data[self.DATA_PAGE_HREF] = self.parameters.create_href()
 
@@ -697,3 +710,6 @@ class RequestContext(object):
 
     def _create_genshi_fragment(self, html_fragment):
         return tag(HTML(html_fragment))
+
+    def _prepare_breadcrumbs_template(self):
+        self.data[self.DATA_BREADCRUMBS_TEMPLATE] = 'bhsearch_breadcrumbs.html'

Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html?rev=1455474&r1=1455473&r2=1455474&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html Tue
Mar 12 10:08:00 2013
@@ -90,11 +90,20 @@
           <div class="span6">
             <div id="searchbox" class="btn-toolbar">
               <div class="btn-group">
-                <form id="mainsearch" class="form-inline" action="${href.search()}" method="get">
+                <form id="mainsearch" class="form-inline"
+                      action="${href.search()   if req.path_info == u'/search' else
+                                href.bhsearch() if (req.path_info == u'/bhsearch' or
+                                                    is_bhsearch_default) else
+                                href.search()}"
+                      method="get">
                   <div class="input-append">
                     <input type="text" class="span3" id="q" name="q"
                         placeholder="Search anything. Try #EF-492."
                         value="${req.search_query}" />
+                    <input py:for="name, value in extra_search_fields"
+                           type="hidden"
+                           name="$name"
+                           value="$value" />
                     <button type="submit" class="btn btn-warning">
                       <span class="hidden-phone hidden-tablet">Search</span>
                       <i class="icon-search icon-white"></i>

Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py?rev=1455474&r1=1455473&r2=1455474&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Tue Mar 12 10:08:00 2013
@@ -23,7 +23,7 @@ from genshi.core import TEXT
 from genshi.filters.transform import Transformer
 from genshi.output import DocType
 
-from trac.config import Option
+from trac.config import Option, BoolOption
 from trac.core import *
 from trac.config import ListOption
 from trac.mimeview.api import get_mimetype
@@ -148,6 +148,8 @@ class BloodhoundTheme(ThemeBase):
     
     labels_footer_right = Option('labels', 'footer_right', '')
 
+    is_bhsearch_default = BoolOption('bhsearch', 'is_default', False)
+
     _wiki_pages = None
     Chrome.default_html_doctype = DocType.HTML5
 
@@ -274,6 +276,7 @@ class BloodhoundTheme(ThemeBase):
         if is_active_theme and data is not None:
             data['responsive_layout'] = self.env.config.getbool(
                     'bloodhound', 'responsive_layout', 'true')
+            data['is_bhsearch_default'] = self.is_bhsearch_default
 
         return template, data, content_type
 



Mime
View raw message