summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Sørensen <johan@johansorensen.com>2009-06-15 13:53:29 +0200
committerJohan Sørensen <johan@johansorensen.com>2009-06-15 13:53:29 +0200
commit1b715df10c47e1cf164188895a32c2968463b315 (patch)
treec055b9feef92b7b2bab74fc4fb97289eb4e16a9d
parent2100329313d457fb30ceed324309fc5993ee6f24 (diff)
downloadgitorious-mainline-outdated-1b715df10c47e1cf164188895a32c2968463b315.zip
gitorious-mainline-outdated-1b715df10c47e1cf164188895a32c2968463b315.tar.gz
gitorious-mainline-outdated-1b715df10c47e1cf164188895a32c2968463b315.tar.bz2
Display some advanced search tips on the search page
-rw-r--r--app/controllers/searches_controller.rb3
-rw-r--r--app/views/searches/_search_box.html.erb9
-rw-r--r--app/views/searches/show.html.erb48
-rw-r--r--public/stylesheets/base.css4
4 files changed, 55 insertions, 9 deletions
diff --git a/app/controllers/searches_controller.rb b/app/controllers/searches_controller.rb
index 571884d..8530a56 100644
--- a/app/controllers/searches_controller.rb
+++ b/app/controllers/searches_controller.rb
@@ -24,7 +24,8 @@ class SearchesController < ApplicationController
def show
unless params[:q].blank?
@search = Ultrasphinx::Search.new({
- :query => params[:q], :page => (params[:page] || 1)
+ :query => params[:q], :page => (params[:page] || 1),
+ :per_page => 30,
})
@search.run
@results = @search.results
diff --git a/app/views/searches/_search_box.html.erb b/app/views/searches/_search_box.html.erb
index 2d91163..90f6d17 100644
--- a/app/views/searches/_search_box.html.erb
+++ b/app/views/searches/_search_box.html.erb
@@ -20,6 +20,8 @@
#++
%>
+<% hide_tips ||= false -%>
+
<div class="search_bar">
<% form_for :search, :url => search_path(:only_path => false,
:host => GitoriousConfig["gitorious_host"], :protocol => "http"),
@@ -28,6 +30,11 @@
<%= text_field_tag :q, params[:q], :class => "text search-field round-5" -%>
<input type="submit" value="<%= t("views.searches.search") %>" class="search-submit round-5" />
</p>
-<p class="hint search-hint"><%= t("views.searches.hint") %></p>
+<p class="hint search-hint">
+ <%= t("views.searches.hint") %>
+ <% unless hide_tips -%>
+ - <small><a href="#advanced" onclick="$('search_help').toggle()">Advanced search tips</a></small>
+ <% end -%>
+</p>
<% end -%>
</div> \ No newline at end of file
diff --git a/app/views/searches/show.html.erb b/app/views/searches/show.html.erb
index f7184b2..609f035 100644
--- a/app/views/searches/show.html.erb
+++ b/app/views/searches/show.html.erb
@@ -25,11 +25,50 @@
<%= @page_title -%>
</h1>
-<%= render :partial => "search_box" -%>
+<% if @search -%>
+ <p class="hint search_time">
+ <small><%= t("views.searches.found", :count => @search.total_entries,
+ :time => @search.time) %></small>
+ </p>
+<% end -%>
+
+<%= render :partial => "search_box", :locals => {:hide_tips => false} -%>
+
+<div id="search_help" style="display:none">
+<% help_box(:left) do -%>
+ <p>
+ Any combination of the following keys can be used to narrow down
+ the search results, simply type <code>key:text</code> into the search field
+ to search for <em>text</em> within the scope of the <em>key</em> described below:
+ </p>
+ <h5>Projects</h5>
+ <ul>
+ <li><code>title</code>: Project title</li>
+ <li><code>description</code>: Project description</li>
+ <li><code>slug</code>: Project slug</li>
+ <li><code>category</code>: Project category</li>
+ <li><code>user</code>: Project creator username</li>
+ </ul>
+ <h5>Repositories</h5>
+ <ul>
+ <li><code>name</code>: Repository name</li>
+ <li><code>description</code>: Repository description</li>
+ </ul>
+ <h5>Comments</h5>
+ <ul>
+ <li><code>body</code>: Comment body</li>
+ <li><code>commented_by</code>: Comment creator username</li>
+ </ul>
+ <h5>Merge Requests</h5>
+ <ul>
+ <li><code>proposal</code>: Merge request proposal body</li>
+ <li><code>proposed_by</code>: Merge request creator username</li>
+ </ul>
+<% end -%>
+</div>
<div class="search_results">
<% if @search -%>
-
<% if @results.empty? -%>
<p><%= t("views.searches.no_results", :term => h(force_utf8(params[:q]))) %></p>
<% else -%>
@@ -40,10 +79,5 @@
<% end -%>
<%= will_paginate(@search) -%>
<% end -%>
-
- <p class="hint">
- <small><%= t("views.searches.found", :count => @search.total_entries, :time => @search.time) %></small>
- </p>
-
<% end -%>
</div> \ No newline at end of file
diff --git a/public/stylesheets/base.css b/public/stylesheets/base.css
index 90bcc4c..bc99230 100644
--- a/public/stylesheets/base.css
+++ b/public/stylesheets/base.css
@@ -1898,6 +1898,10 @@ table.select_commits_from_list tr.commit_comments .commit-details .permalink a {
margin: 0 10px 10px 10px;
}
+.search_time {
+ float: right;
+}
+
.search_results strong.highlight {
background: #ff0;
font-weight: normal;