annotate app/views/search/index.rhtml @ 498:87bfac1079fd bug_94

If a search matches any project titles (and projects are in scope for the search), show those projects separately at the start of the search results provided there are no more than 5 of them (further fix to bug #94)
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 13 Jul 2011 12:45:24 +0100
parents 1333582e34c4
children 85fd403a7daa
rev   line source
Chris@0 1 <h2><%= l(:label_search) %></h2>
Chris@0 2
Chris@0 3 <div class="box">
Chris@0 4 <% form_tag({}, :method => :get) do %>
Chris@0 5 <p><%= text_field_tag 'q', @question, :size => 60, :id => 'search-input' %>
Chris@0 6 <%= javascript_tag "Field.focus('search-input')" %>
Chris@0 7 <%= project_select_tag %>
Chris@0 8 <label><%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %></label>
Chris@0 9 <label><%= check_box_tag 'titles_only', 1, @titles_only %> <%= l(:label_search_titles_only) %></label>
Chris@0 10 </p>
Chris@0 11 <p>
Chris@0 12 <% @object_types.each do |t| %>
Chris@0 13 <label><%= check_box_tag t, 1, @scope.include?(t) %> <%= type_label(t) %></label>
Chris@0 14 <% end %>
Chris@0 15 </p>
Chris@0 16
Chris@0 17 <p><%= submit_tag l(:button_submit), :name => 'submit' %></p>
Chris@0 18 <% end %>
Chris@0 19 </div>
Chris@0 20
chris@498 21 <% if @project_matches and !@project_matches.empty? and (@project_matches.count < 6) and !@pagination_previous_date %>
chris@498 22 <h3><%= l(:label_matching_project_plural) %> (<%= @project_matches.count %>)</h3>
chris@498 23 <dl id="search-results">
chris@498 24 <% @project_matches.each do |e| %>
chris@498 25 <dt class="<%= e.event_type %>"><%= content_tag('span', h(e.project), :class => 'project') unless @project == e.project %> <%= link_to highlight_tokens(truncate(e.event_title, :length => 255), @tokens), e.event_url %></dt>
chris@498 26 <dd><span class="description"><%= e.short_description %></span>
chris@498 27 <% end %>
chris@498 28 </dl>
chris@498 29 <% end %>
chris@498 30
Chris@0 31 <% if @results %>
chris@323 32
chris@323 33 <h3><%= l(:label_result_plural) %> (<%= @results_by_type.values.sum %>)</h3>
Chris@0 34 <div id="search-results-counts">
Chris@0 35 <%= render_results_by_type(@results_by_type) unless @scope.size == 1 %>
Chris@0 36 </div>
Chris@0 37 <dl id="search-results">
Chris@0 38 <% @results.each do |e| %>
Chris@0 39 <dt class="<%= e.event_type %>"><%= content_tag('span', h(e.project), :class => 'project') unless @project == e.project %> <%= link_to highlight_tokens(truncate(e.event_title, :length => 255), @tokens), e.event_url %></dt>
Chris@0 40 <dd><span class="description"><%= highlight_tokens(e.event_description, @tokens) %></span>
Chris@0 41 <span class="author"><%= format_time(e.event_datetime) %></span></dd>
Chris@0 42 <% end %>
Chris@0 43 </dl>
Chris@0 44 <% end %>
Chris@0 45
Chris@0 46 <p><center>
Chris@0 47 <% if @pagination_previous_date %>
Chris@0 48 <%= link_to_remote ('&#171; ' + l(:label_previous)),
Chris@0 49 {:update => :content,
Chris@0 50 :url => params.merge(:previous => 1, :offset => @pagination_previous_date.strftime("%Y%m%d%H%M%S"))
Chris@0 51 }, :href => url_for(params.merge(:previous => 1, :offset => @pagination_previous_date.strftime("%Y%m%d%H%M%S"))) %>&nbsp;
Chris@0 52 <% end %>
Chris@0 53 <% if @pagination_next_date %>
Chris@0 54 <%= link_to_remote (l(:label_next) + ' &#187;'),
Chris@0 55 {:update => :content,
Chris@0 56 :url => params.merge(:previous => nil, :offset => @pagination_next_date.strftime("%Y%m%d%H%M%S"))
Chris@0 57 }, :href => url_for(params.merge(:previous => nil, :offset => @pagination_next_date.strftime("%Y%m%d%H%M%S"))) %>
Chris@0 58 <% end %>
Chris@0 59 </center></p>
Chris@0 60
Chris@0 61 <% html_title(l(:label_search)) -%>