incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [25/28] git commit: [#2835] show search help on all search pages
Date Wed, 24 Apr 2013 17:16:34 GMT
[#2835] show search help on all search pages


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

Branch: refs/heads/db/2835
Commit: d958fae688f198dceb680709a09dadb62b9291f4
Parents: 62912a9
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Wed Apr 24 16:33:35 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Apr 24 16:34:43 2013 +0000

----------------------------------------------------------------------
 Allura/allura/ext/search/search_main.py            |    3 ++-
 Allura/allura/lib/widgets/search.py                |   12 ++++++++----
 Allura/allura/templates/widgets/search_help.html   |   13 +++++++++++++
 ForgeBlog/forgeblog/main.py                        |    4 +++-
 ForgeChat/forgechat/main.py                        |    3 ++-
 .../forgediscussion/controllers/root.py            |    4 +++-
 ForgeShortUrl/forgeshorturl/main.py                |    4 +++-
 ForgeWiki/forgewiki/templates/wiki/search_help.txt |    6 ------
 ForgeWiki/forgewiki/wiki_main.py                   |    6 +-----
 9 files changed, 35 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/Allura/allura/ext/search/search_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/search/search_main.py b/Allura/allura/ext/search/search_main.py
index 9b709f4..b543e62 100644
--- a/Allura/allura/ext/search/search_main.py
+++ b/Allura/allura/ext/search/search_main.py
@@ -26,7 +26,7 @@ from formencode import validators as V
 from allura.app import Application
 from allura import version
 from allura.lib.search import search_app
-from allura.lib.widgets.search import SearchResults
+from allura.lib.widgets.search import SearchResults, SearchHelp
 from allura.controllers import BaseController
 
 log = logging.getLogger(__name__)
@@ -68,6 +68,7 @@ class SearchController(BaseController):
     @with_trailing_slash
     def index(self, q=None, history=None, **kw):
         c.search_results = SearchResults()
+        c.help_modal = SearchHelp(comments=False)
         pids = [c.project._id] + [
             p._id for p in c.project.subprojects ]
         project_match = ' OR '.join(

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/Allura/allura/lib/widgets/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/search.py b/Allura/allura/lib/widgets/search.py
index 22f4d8a..e553842 100644
--- a/Allura/allura/lib/widgets/search.py
+++ b/Allura/allura/lib/widgets/search.py
@@ -17,6 +17,7 @@
 
 import ew as ew_core
 import ew.jinja2_ew as ew
+import jinja2
 
 from allura.lib.widgets import form_fields as ffw
 
@@ -47,8 +48,11 @@ class SearchHelp(ffw.Lightbox):
         name='search_help_modal',
         trigger='a.search_help_modal')
 
-    content_template = '<div style="height:400px; overflow:auto;">%s</div>'
-
-    def __init__(self, content=''):
+    def __init__(self, comments=True, history=True):
         super(SearchHelp, self).__init__()
-        self.content = self.content_template % content
+        # can't use g.jinja2_env since this widget gets imported too early :(
+        jinja2_env = jinja2.Environment(loader=jinja2.PackageLoader('allura', 'templates/widgets'))
+        self.content = jinja2_env.get_template('search_help.html').render(dict(
+            comments=comments,
+            history=history,
+        ))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/Allura/allura/templates/widgets/search_help.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/search_help.html b/Allura/allura/templates/widgets/search_help.html
new file mode 100644
index 0000000..89a4fbc
--- /dev/null
+++ b/Allura/allura/templates/widgets/search_help.html
@@ -0,0 +1,13 @@
+<div style="height:400px; overflow:auto;">
+    
+<h1>Searching</h1>
+<p>To search for an exact phrase, put it in quotes.  Example: "getting started docs"</p>
+<p>To exclude a word or phrase, put a dash in front of it.  Example: docs -help</p>
+{% if comments %}
+<p>You can use the 'Search comments?' checkbox to include comments in the search results.</p>
+{% endif %}
+{% if history %}
+<p>You can use the 'Search history?' checkbox to include previous revisions of items
in the search results.</p>
+{% endif %}
+
+</div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 91ed6b6..f745af9 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -43,7 +43,7 @@ from allura.lib.security import has_access, require_access
 from allura.lib import widgets as w
 from allura.lib.widgets.subscriptions import SubscribeForm
 from allura.lib.widgets import form_fields as ffw
-from allura.lib.widgets.search import SearchResults
+from allura.lib.widgets.search import SearchResults, SearchHelp
 from allura import model as M
 from allura.controllers import BaseController, AppDiscussionController
 
@@ -68,6 +68,7 @@ class W:
     preview_post_form = widgets.PreviewPostForm()
     subscribe_form = SubscribeForm()
     search_results = SearchResults()
+    help_modal = SearchHelp()
 
 class ForgeBlogApp(Application):
     __version__ = version.__version__
@@ -212,6 +213,7 @@ class RootController(BaseController):
                    project=validators.StringBool(if_empty=False)))
     def search(self, q=None, history=None, search_comments=None, project=None, limit=None,
page=0, **kw):
         c.search_results = W.search_results
+        c.help_modal = W.help_modal
         search_params = kw
         search_params.update({
             'q': q or '',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/ForgeChat/forgechat/main.py
----------------------------------------------------------------------
diff --git a/ForgeChat/forgechat/main.py b/ForgeChat/forgechat/main.py
index 05eaf94..d7a9860 100644
--- a/ForgeChat/forgechat/main.py
+++ b/ForgeChat/forgechat/main.py
@@ -33,7 +33,7 @@ from allura.lib import helpers as h
 from allura.lib.search import search_app
 from allura.lib.decorators import require_post
 from allura.lib.security import require_access
-from allura.lib.widgets.search import SearchResults
+from allura.lib.widgets.search import SearchResults, SearchHelp
 from allura import model as M
 from allura.controllers import BaseController
 
@@ -140,6 +140,7 @@ class RootController(BaseController):
                    project=validators.StringBool(if_empty=False)))
     def search(self, q=None, project=None, limit=None, page=0, **kw):
         c.search_results = SearchResults()
+        c.help_modal = SearchHelp(comments=False, history=False)
         search_params = kw
         search_params.update({
             'q': q or '',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index 3bd1b94..d9058fb 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -42,7 +42,7 @@ from forgediscussion import model
 from forgediscussion import utils
 from forgediscussion import widgets as FW
 from allura.lib.widgets import discuss as DW
-from allura.lib.widgets.search import SearchResults
+from allura.lib.widgets.search import SearchResults, SearchHelp
 
 from forgediscussion.widgets.admin import AddForumShort
 
@@ -56,6 +56,7 @@ class RootController(BaseController, DispatchIndex):
         announcements_table=FW.AnnouncementsTable()
         add_forum=AddForumShort()
         search_results = SearchResults()
+        search_help = SearchHelp(comments=False, history=False)
 
     def _check_security(self):
         require_access(c.app, 'read')
@@ -131,6 +132,7 @@ class RootController(BaseController, DispatchIndex):
                    page=validators.Int(if_empty=0)))
     def search(self, q=None, history=None, project=None, limit=None, page=0, **kw):
         c.search_results = self.W.search_results
+        c.help_modal = self.W.search_help
         search_params = kw
         search_params.update({
             'q': q or '',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/ForgeShortUrl/forgeshorturl/main.py
----------------------------------------------------------------------
diff --git a/ForgeShortUrl/forgeshorturl/main.py b/ForgeShortUrl/forgeshorturl/main.py
index 79c48ce..1ce62d8 100644
--- a/ForgeShortUrl/forgeshorturl/main.py
+++ b/ForgeShortUrl/forgeshorturl/main.py
@@ -25,7 +25,7 @@ from allura.lib import helpers as h
 from allura.lib.search import search_app
 from allura.controllers import BaseController
 from allura.lib.widgets import form_fields as ffw
-from allura.lib.widgets.search import SearchResults
+from allura.lib.widgets.search import SearchResults, SearchHelp
 
 from webob import exc
 from pylons import tmpl_context as c, app_globals as g
@@ -44,6 +44,7 @@ log = logging.getLogger(__name__)
 
 class W:
     search_results = SearchResults()
+    search_help = SearchHelp(comments=False, history=False)
     page_list = ffw.PageList()
     page_size = ffw.PageSize()
     create_short_url_lightbox = suw.CreateShortUrlWidget(
@@ -164,6 +165,7 @@ class RootController(BaseController):
                    project=validators.StringBool(if_empty=False)))
     def search(self, q=None, project=None, limit=None, page=0, **kw):
         c.search_results = W.search_results
+        c.help_modal = W.search_help
         search_params = kw
         search_params.update({
             'q': q or '',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/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
deleted file mode 100644
index dc2d380..0000000
--- a/ForgeWiki/forgewiki/templates/wiki/search_help.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-<h1>Searching the wiki</h1>
-<p>Searches use wiki page title and body text for matching.<p>
-<p>To search for an exact phrase, put it in quotes.  Example: "getting started docs"</p>
-<p>To exclude a word or phrase, put a dash in front of it.  Example: docs -help</p>
-<p>You can also use 'Search comments?' and 'Search history?' checkboxes to include
comments and previous revisions of pages in the search results.</p>
-

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index b2dbee7..23ca7f2 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -30,7 +30,6 @@ 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
@@ -54,9 +53,6 @@ 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(
@@ -72,7 +68,7 @@ class W:
     page_list = ffw.PageList()
     page_size = ffw.PageSize()
     search_results = SearchResults()
-    help_modal = SearchHelp(search_help_text)
+    help_modal = SearchHelp()
     icons={
         24:'images/wiki_24.png',
         32:'images/wiki_32.png',


Mime
View raw message