You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/03/26 22:13:54 UTC

[7/7] git commit: [#2835] ticket:291 Search help button

[#2835] ticket:291 Search help button


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/bcc5f812
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/bcc5f812
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/bcc5f812

Branch: refs/heads/db/42cc_2835_content_preview
Commit: bcc5f812a3958a1697d3a16d81e9a16f1fc63114
Parents: 218f4b4
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Mar 21 13:47:55 2013 +0000
Committer: Dave Brondsema <db...@geek.net>
Committed: Tue Mar 26 21:13:22 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/widgets/search.py                |   13 +++++++++++++
 .../allura/templates/widgets/search_results.html   |    5 +++--
 ForgeWiki/forgewiki/templates/wiki/search_help.txt |    8 ++++++++
 ForgeWiki/forgewiki/tests/functional/test_root.py  |    8 ++++++++
 ForgeWiki/forgewiki/wiki_main.py                   |    9 ++++++++-
 5 files changed, 40 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bcc5f812/Allura/allura/lib/widgets/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/search.py b/Allura/allura/lib/widgets/search.py
index fc17b3e..7426e5f 100644
--- a/Allura/allura/lib/widgets/search.py
+++ b/Allura/allura/lib/widgets/search.py
@@ -22,3 +22,16 @@ class SearchResults(ew_core.Widget):
             for r in f.resources():
                 yield r
         yield ew.CSSLink('css/search.css')
+
+
+class SearchHelp(ffw.Lightbox):
+    defaults=dict(
+        ffw.Lightbox.defaults,
+        name='search_help_modal',
+        trigger='a.search_help_modal')
+
+    content_template = '<div style="height:400px; overflow:auto;">%s</div>'
+
+    def __init__(self, content=''):
+        super(SearchHelp, self).__init__()
+        self.content = self.content_template % content

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bcc5f812/Allura/allura/templates/widgets/search_results.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/search_results.html b/Allura/allura/templates/widgets/search_results.html
index 1401f0c..5e906e2 100644
--- a/Allura/allura/templates/widgets/search_results.html
+++ b/Allura/allura/templates/widgets/search_results.html
@@ -5,14 +5,14 @@
   <div class="grid-3">
     <input type="submit" value="Search">
   </div>
+  {% if c.help_modal %}
   <div class="grid-6">
-    {# TODO: when help text provided, show button
     <a href="#" class="btn search_help_modal">
       <b data-icon="{{g.icons['help'].char}}" class="ico {{g.icons['help'].css}}"></b>
       Help
     </a>
-    #}
   </div>
+  {% endif %}
   <div class="grid-10">
     {% set search_project = request.GET['project'] == '1' %}
     <input type="radio" name="project" value="0" id="search-app" {% if not search_project %}checked{% endif %}>
@@ -67,3 +67,4 @@
     <a href="{{ sort_date_url }}" class="{{ 'strong' if sort_field == 'mod_date_dt' else '' }}">date</a>
   </p>
 </div>
+{% if c.help_modal %}{{ c.help_modal.display() }}{% endif %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bcc5f812/ForgeWiki/forgewiki/templates/wiki/search_help.txt
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/search_help.txt b/ForgeWiki/forgewiki/templates/wiki/search_help.txt
new file mode 100644
index 0000000..4a337b8
--- /dev/null
+++ b/ForgeWiki/forgewiki/templates/wiki/search_help.txt
@@ -0,0 +1,8 @@
+<h1>Searching wiki</h1>
+<p>Searches use wiki page title and inner text for matching.<p>
+<p>You can also use 'Search comments?' and 'Search history?' checkboxes to include comments and history of pages editing in the search results.</p>
+
+<p>If you want to see all the page with given label, you may use url like this (there is no UI for this):</p>
+<div class="codehilite">
+<pre>/p/yourproject/wiki/search/?q=labels_t:label&amp;parser=standard</pre>
+</div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bcc5f812/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index be4185d..3dcc1bc 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -107,6 +107,14 @@ class TestRootController(TestController):
         solr_query.pop('pf')
         search.assert_called_with('test', **solr_query)
 
+    def test_search_help(self):
+        r = self.app.get('/wiki/search?q=test')
+        btn = r.html.find('a', attrs={'class': 'btn search_help_modal'})
+        assert btn is not None, "Can't find a help button"
+        div = r.html.find('div', attrs={'id': 'lightbox_search_help_modal'})
+        assert div is not None, "Can't find help text"
+        assert_in('Searching wiki', div.text)
+
     def test_page_index(self):
         response = self.app.get('/wiki/tést/')
         assert 'tést' in response.follow()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bcc5f812/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index f978970..ac6667f 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -14,6 +14,7 @@ from pylons import request
 from formencode import validators
 from webob import exc
 from ming.orm import session
+import jinja2
 
 # Pyforge-specific imports
 from allura import model as M
@@ -28,7 +29,7 @@ from allura.controllers import attachments as ac
 from allura.lib import widgets as w
 from allura.lib.widgets import form_fields as ffw
 from allura.lib.widgets.subscriptions import SubscribeForm
-from allura.lib.widgets.search import SearchResults
+from allura.lib.widgets.search import SearchResults, SearchHelp
 
 # Local imports
 from forgewiki import model as WM
@@ -37,6 +38,10 @@ from forgewiki.widgets.wiki import CreatePageWidget
 
 log = logging.getLogger(__name__)
 
+jinja_env = jinja2.Environment(loader=jinja2.PackageLoader('forgewiki', 'templates'))
+search_help_text = jinja_env.get_template('wiki/search_help.txt').render()
+
+
 class W:
     thread=w.Thread(
         page=None, limit=None, page_size=None, count=None,
@@ -51,6 +56,7 @@ class W:
     page_list = ffw.PageList()
     page_size = ffw.PageSize()
     search_results = SearchResults()
+    help_modal = SearchHelp(search_help_text)
     icons={
         24:'images/wiki_24.png',
         32:'images/wiki_32.png',
@@ -360,6 +366,7 @@ class RootController(BaseController, DispatchIndex):
                 results = imap(historize_urls, results)
                 results = imap(add_matches, results)
         c.search_results = W.search_results
+        c.help_modal = W.help_modal
         score_url = 'score desc'
         date_url = 'mod_date_dt desc'
         try: