aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/general_controller.rb16
-rw-r--r--app/views/request/_request_listing_single.rhtml17
-rw-r--r--app/views/request/_request_listing_via_incoming.rhtml2
-rw-r--r--app/views/request/_request_listing_via_outgoing.rhtml2
4 files changed, 27 insertions, 10 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 986579874..4b3ee0998 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -5,7 +5,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: general_controller.rb,v 1.4 2008-03-07 23:13:38 francis Exp $
+# $Id: general_controller.rb,v 1.5 2008-03-10 00:48:55 francis Exp $
class GeneralController < ApplicationController
@@ -57,8 +57,20 @@ class GeneralController < ApplicationController
@highlight_words = query_nopunc.split(" ")
@solr_object = InfoRequest.multi_solr_search(@query, :models => [ OutgoingMessage, IncomingMessage, PublicBody, User ],
- :limit => @per_page, :offset => ((params[:page]||"1").to_i-1) * @per_page)
+ :limit => @per_page, :offset => ((params[:page]||"1").to_i-1) * @per_page,
+ :highlight => {
+ :prefix => '<span class="highlight">',
+ :suffix => '</span>',
+ :fragsize => 250,
+ :fields => ["title", "initial_request_text", # InfoRequest
+ "body", # OutgoingMessage
+ "get_text_for_indexing", # IncomingMessage
+ "name", "short_name", # PublicBody
+ "name" # User
+ ]}
+ )
@search_results = @solr_object.results
+ @highlighting = @solr_object.highlights
end
private
diff --git a/app/views/request/_request_listing_single.rhtml b/app/views/request/_request_listing_single.rhtml
index e680fb362..be419b8f7 100644
--- a/app/views/request/_request_listing_single.rhtml
+++ b/app/views/request/_request_listing_single.rhtml
@@ -1,12 +1,17 @@
-<% if @highlight_words.nil?
- @highlight_words = []
- end %>
-
<p class="request_listing">
- <%= link_to highlight_words(info_request.title, @highlight_words), request_url(info_request) %>
+ <% if not @highlighting.nil? and @highlighting['InfoRequest'][info_request.id].include?('title') %>
+ <%= link_to @highlighting['InfoRequest'][info_request.id]["title"], request_url(info_request) %>
+ <% @highlighting['InfoRequest'][info_request.id].delete("title") %>
+ <% else %>
+ <%= link_to h(info_request.title), request_url(info_request) %>
+ <% end %>
<br>
- <%= excerpt_and_highlight(info_request.initial_request_text, @highlight_words) %>
+ <% if not @highlighting.nil? and @highlighting['InfoRequest'][info_request.id].size > 0 %>
+ <%= @highlighting['InfoRequest'][info_request.id].values.join(" ") %>
+ <% else %>
+ <%= excerpt(info_request.initial_request_text, "", 150) %>
+ <% end %>
<br>
<span class="request_listing_bottomline">
diff --git a/app/views/request/_request_listing_via_incoming.rhtml b/app/views/request/_request_listing_via_incoming.rhtml
index 80efb1eb3..3f7026cc4 100644
--- a/app/views/request/_request_listing_via_incoming.rhtml
+++ b/app/views/request/_request_listing_via_incoming.rhtml
@@ -2,7 +2,7 @@
<%= link_to "Response to '" + h(info_request.title) + "'", request_url(info_request)+"#incoming-"+incoming_message.id.to_s %>
<br>
- <%= excerpt_and_highlight(incoming_message.get_text_for_indexing, @highlight_words) %>
+ <%= @highlighting['IncomingMessage'][incoming_message.id].values.join(" ") %>
<br>
<span class="request_listing_bottomline">
diff --git a/app/views/request/_request_listing_via_outgoing.rhtml b/app/views/request/_request_listing_via_outgoing.rhtml
index 02e236dad..55af9fa6c 100644
--- a/app/views/request/_request_listing_via_outgoing.rhtml
+++ b/app/views/request/_request_listing_via_outgoing.rhtml
@@ -8,7 +8,7 @@
<% end %>
<br>
- <%= excerpt_and_highlight(outgoing_message.body, @highlight_words) %>
+ <%= @highlighting['OutgoingMessage'][outgoing_message.id].values.join(" ") %>
<br>
<span class="request_listing_bottomline">