incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [10/28] git commit: [#2835] ticket:291 Search help button
Date Wed, 24 Apr 2013 17:16:19 GMT
[#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/1f5a295d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1f5a295d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1f5a295d

Branch: refs/heads/db/2835
Commit: 1f5a295dfb8cb1b39b3eacf52e91596e1341c0a4
Parents: 248e5b6
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Thu Mar 21 13:47:55 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Apr 24 16:34:41 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/1f5a295d/Allura/allura/lib/widgets/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/search.py b/Allura/allura/lib/widgets/search.py
index bebbe20..22f4d8a 100644
--- a/Allura/allura/lib/widgets/search.py
+++ b/Allura/allura/lib/widgets/search.py
@@ -39,3 +39,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/1f5a295d/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 feaa60f..500f639 100644
--- a/Allura/allura/templates/widgets/search_results.html
+++ b/Allura/allura/templates/widgets/search_results.html
@@ -23,14 +23,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 %}>
@@ -85,3 +85,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/1f5a295d/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/1f5a295d/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 838086c..029bf56 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -125,6 +125,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/1f5a295d/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index fc5b566..eed1467 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -31,6 +31,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
@@ -45,7 +46,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
@@ -54,6 +55,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,
@@ -68,6 +73,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',
@@ -377,6 +383,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:


Mime
View raw message