You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by gj...@apache.org on 2012/05/02 13:51:25 UTC

svn commit: r1333006 - in /incubator/bloodhound/trunk/bloodhound_theme/bhtheme: templates/bh_page_index.html templates/bh_path_search.html templates/bh_search.html templates/bloodhound_theme.html theme.py

Author: gjm
Date: Wed May  2 11:51:24 2012
New Revision: 1333006

URL: http://svn.apache.org/viewvc?rev=1333006&view=rev
Log:
theme: change search web UI to use bootstrap - towards #10 (patch from Olemis)

Added:
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_page_index.html   (with props)
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_path_search.html   (with props)
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_search.html   (with props)
Modified:
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py

Added: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_page_index.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_page_index.html?rev=1333006&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_page_index.html (added)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_page_index.html Wed May  2 11:51:24 2012
@@ -0,0 +1,29 @@
+<!--!  Display a page index.
+
+  `paginator` must be a trac.util.presentation.Paginator instance
+
+  -->
+<div xmlns="http://www.w3.org/1999/xhtml" 
+     xmlns:py="http://genshi.edgewall.org/" 
+     class="pagination pagination-centered" py:if="paginator.has_more_pages">
+  <ul>
+    <li py:if="paginator.has_previous_page" 
+          py:with="prevlink = chrome.links.prev[0]" class="previous"> 
+      <a href="${prevlink.href}" title="${prevlink.title}">&larr;</a> 
+    </li>
+    <py:for each="page in paginator.shown_pages"> 
+      <li py:if="page.string == paginator.current_page.string" class="active"> 
+        <a class="${paginator.current_page['class']}"
+            href="#">${paginator.current_page.string}</a>
+      </li> 
+      <li py:if="page.string != paginator.current_page.string"> 
+        <a href="${page.href}" title="${page.title}">${page.string}</a> 
+      </li> 
+    </py:for> 
+    <li py:if="paginator.has_next_page" 
+          py:with="nextlink = chrome.links.next[0]" class="next"> 
+      <a href="${nextlink.href}" title="${nextlink.title}">&rarr;</a> 
+    </li> 
+  </ul>
+</div> 
+

Propchange: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_page_index.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_page_index.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_path_search.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_path_search.html?rev=1333006&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_path_search.html (added)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_path_search.html Wed May  2 11:51:24 2012
@@ -0,0 +1,10 @@
+<div 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"
+    py:strip="" py:if="query">
+  <li>Search <span class="divider">/</span></li>
+  <li py:with="query_summary = query[:15] + ' ...'" title="$query">
+    <code>${query_summary if len(query) &gt; 19 else query}</code>
+  </li>
+</div>

Propchange: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_path_search.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_path_search.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_search.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_search.html?rev=1333006&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_search.html (added)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_search.html Wed May  2 11:51:24 2012
@@ -0,0 +1,94 @@
+<!DOCTYPE html
+    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<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">
+  <xi:include href="layout.html" />
+  <head>
+    <title py:choose="">
+      <py:when test="query">Search Results</py:when>
+      <py:otherwise>Search</py:otherwise>
+    </title>
+    <py:if test="results">
+        <meta name="startIndex" content="${results.span[0] + 1}"/>
+        <meta name="totalResults" content="$results.num_items"/>
+        <meta name="itemsPerPage" content="$results.max_per_page"/>
+    </py:if>
+    <script type="text/javascript">
+      jQuery(document).ready(function($) {$("#q").get(0).focus()});
+    </script>
+  </head>
+  <body>
+    <py:choose>
+      <div py:when="query" id="content" class="row">
+  
+        <div class="span12">
+          <div class="btn-toolbar">
+            <div class="btn-group" 
+                py:with="filter_args = [(f.name, 'on') for f in filters if f.active]">
+              <py:for each="filter in filters">
+                <a id="${filter.name}"
+                    py:with="sf = [x for x in filter_args 
+                                      if x[0] != filter.name] + 
+                                  ([(filter.name, 'on')] if not filter.active else [])"
+                    class="btn ${filter.active and 'active' or None}" 
+                    href="${href.search(q=query, noquickjump=1, **dict(sf))}">
+                  <i py:if="filter.active" class="icon-ok-sign"></i>
+                  ${filter.label}
+                </a>
+              </py:for>
+            </div>
+          </div>
+        </div>
+  
+        <div class="span12" py:if="results or quickjump">
+          <h2 py:if="results">
+            Results <small>(${results.displayed_items()})</small>
+          </h2>
+          <xi:include py:with="paginator = results" href="bh_page_index.html" />
+          <div>
+            <dl id="results">
+              <py:if test="quickjump">
+                <dt id="quickjump">
+                  <a href="${quickjump.href}" i18n:msg="name">Quickjump to ${quickjump.name}</a>
+                </dt>
+                <dd>${quickjump.description}</dd>
+              </py:if>
+              <py:for each="result in results">
+                <dt><a href="${result.href}" class="searchable">${result.title}</a></dt>
+                <dd class="searchable">${result.excerpt}</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>
+                </dd>
+              </py:for>
+            </dl>
+          </div>
+          <xi:include py:with="paginator = results" href="bh_page_index.html" />
+        </div>
+  
+        <div class="span12"
+            py:if="query and not (results or quickjump)">
+          <p id="notfound" class="alert">
+            No matches found.
+          </p>
+        </div>
+  
+      </div>
+      <p py:otherwise="" class="alert">
+        <span class="label label-warning">Warning</span>
+        Search query too short. Query must be at least 3 characters long.
+        Please type your query string in search box and try again.
+      </p>
+    </py:choose>
+    <div id="help" class="help-block pull-right" i18n:msg="">
+      <span class="label label-info">Note:</span>
+      See <a href="${href.wiki('TracSearch')}">TracSearch</a>
+      for help on searching.
+    </div>
+    <br/>
+
+  </body>
+</html>

Propchange: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_search.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_search.html
------------------------------------------------------------------------------
    svn:mime-type = text/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=1333006&r1=1333005&r2=1333006&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bloodhound_theme.html Wed May  2 11:51:24 2012
@@ -71,7 +71,8 @@
         <div class="span4">
           <form id="mainsearch" class="form-inline" action="${href.search()}" method="get">
             <input type="text" class="span3" name="q"
-                placeholder="Search anything. Try #EF-492." />
+                placeholder="Search anything. Try #EF-492." 
+                value="${req.search_query}" />
             <input type="submit" value="Search" class="btn btn-warning"/>
           </form>
         </div>

Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py?rev=1333006&r1=1333005&r2=1333006&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Wed May  2 11:51:24 2012
@@ -24,8 +24,9 @@ from trac.core import *
 from trac.ticket.api import TicketSystem
 from trac.ticket.model import Ticket
 from trac.ticket.web_ui import TicketModule
+from trac.util.translation import _
 from trac.web.api import Request, IRequestFilter, IRequestHandler
-from trac.web.chrome import Chrome
+from trac.web.chrome import Chrome, prevnext_nav
 from trac.web.main import RequestDispatcher
 
 from themeengine.api import ThemeBase, ThemeEngineSystem
@@ -73,6 +74,7 @@ class BloodhoundTheme(ThemeBase):
     template = htdocs = css = screenshot = disable_trac_css = True
     disable_all_trac_css = True
     BLOODHOUND_TEMPLATE_MAP = {
+        # Admin
         'admin_basics.html' : ('bh_admin_basics.html', None),
         'admin_components.html' : ('bh_admin_components.html', None),
         'admin_enums.html' : ('bh_admin_enums.html', None),
@@ -82,6 +84,9 @@ class BloodhoundTheme(ThemeBase):
         'admin_plugins.html' : ('bh_admin_plugins.html', None),
         'admin_repositories.html' : ('bh_admin_repositories.html', None),
         'admin_versions.html' : ('bh_admin_versions.html', None),
+
+        # Search
+        'search.html' : ('bh_search.html', '_modify_search_data'),
     }
     implements(IRequestFilter)
 
@@ -118,6 +123,19 @@ class BloodhoundTheme(ThemeBase):
                 modifier(req, template, data, content_type, is_active_theme)
         return template, data, content_type
 
+    # Request modifiers
+
+    def _modify_search_data(self, req, template, data, content_type, is_active):
+        """Insert breadcumbs and context navigation items in search web UI
+        """
+        if is_active:
+            # Insert query string in search box (see bloodhound_theme.html)
+            req.search_query = data.get('query')
+            # Breadcrumbs nav
+            data['resourcepath_template'] = 'bh_path_search.html'
+            # Context nav
+            prevnext_nav(req, _('Previous'), _('Next'))
+
 class QuickCreateTicketDialog(Component):
     implements(IRequestFilter, IRequestHandler)