diff options
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/general/frontpage.rhtml | 6 | ||||
-rw-r--r-- | app/views/general/search.rhtml | 18 | ||||
-rw-r--r-- | app/views/request/_request_listing_via_event.rhtml | 41 | ||||
-rw-r--r-- | app/views/request/list.rhtml | 6 | ||||
-rw-r--r-- | app/views/track/atom_feed.atom.builder | 10 | ||||
-rw-r--r-- | app/views/track_mailer/event_digest.rhtml | 20 | ||||
-rw-r--r-- | app/views/user/_user_listing_single.rhtml | 2 |
7 files changed, 56 insertions, 47 deletions
diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml index ddbe20ea1..9584b1608 100644 --- a/app/views/general/frontpage.rhtml +++ b/app/views/general/frontpage.rhtml @@ -62,10 +62,10 @@ <p>None yet.</p> <% else %> <% for search_result in @search_results %> - <% if search_result.class.to_s == 'InfoRequestEvent' %> - <%= render :partial => 'request/request_listing_via_event', :locals => { :event => search_result, :info_request => search_result.info_request } %> + <% if search_result[:model].class.to_s == 'InfoRequestEvent' %> + <%= render :partial => 'request/request_listing_via_event', :locals => { :event => search_result[:model], :info_request => search_result[:model].info_request } %> <% else %> - <p><strong>Unexpected search result type <%=search_result.class.to_s%></strong></p> + <p><strong>Unexpected search result type <%=search_result[:model].class.to_s%></strong></p> <% end %> <% end %> <% end %> diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml index d94272922..a919bff45 100644 --- a/app/views/general/search.rhtml +++ b/app/views/general/search.rhtml @@ -26,17 +26,21 @@ <h1><%=@title%></h1> + <% if @search_spelling %> + <p id="did_you_mean">Did you mean: <%= link_to @search_spelling, search_url(:query => @search_spelling) %></p> + <% end %> + <% if @search_results.empty? %> <% else %> <% for search_result in @search_results %> - <% if search_result.class.to_s == 'PublicBody' %> - <%= render :partial => 'body/body_listing_single', :locals => { :public_body => search_result } %> - <% elsif search_result.class.to_s == 'User' %> - <%= render :partial => 'user/user_listing_single', :locals => { :display_user => search_result } %> - <% elsif search_result.class.to_s == 'InfoRequestEvent' %> - <%= render :partial => 'request/request_listing_via_event', :locals => { :event => search_result, :info_request => search_result.info_request } %> + <% if search_result[:model].class.to_s == 'PublicBody' %> + <%= render :partial => 'body/body_listing_single', :locals => { :public_body => search_result[:model] } %> + <% elsif search_result[:model].class.to_s == 'User' %> + <%= render :partial => 'user/user_listing_single', :locals => { :display_user => search_result[:model] } %> + <% elsif search_result[:model].class.to_s == 'InfoRequestEvent' %> + <%= render :partial => 'request/request_listing_via_event', :locals => { :event => search_result[:model], :info_request => search_result[:model].info_request } %> <% else %> - <p><strong>Unknown search result type <%=search_result.class.to_s%></strong></p> + <p><strong>Unknown search result type <%=search_result[:model].class.to_s%></strong></p> <% end %> <% end %> <% end %> diff --git a/app/views/request/_request_listing_via_event.rhtml b/app/views/request/_request_listing_via_event.rhtml index 8fe1d23ca..c292f8122 100644 --- a/app/views/request/_request_listing_via_event.rhtml +++ b/app/views/request/_request_listing_via_event.rhtml @@ -1,26 +1,29 @@ +<% if @highlight_words.nil? + @highlight_words = [] +end %> + <div class="request_listing"> <span class="head"> - <% if not @highlighting.nil? and @highlighting['InfoRequestEvent'][event.id].include?('title') %> - <%= link_to @highlighting['InfoRequestEvent'][event.id]["title"], request_url(info_request) %> - <% @highlighting['InfoRequestEvent'][event.id].delete("title") %> - <% elsif not event.incoming_message.nil? %> - <%= link_to "Response to '" + h(info_request.title) + "'", incoming_message_url(event.incoming_message) %> - <% elsif not event.outgoing_message.nil? and event.event_type == 'followup_sent' %> - <%= link_to "Follow up message for '" + h(info_request.title) + "'", outgoing_message_url(event.outgoing_message) %> - <% else %> - <%= link_to h(info_request.title), request_url(info_request) %> - <% end %> + <% if not event.incoming_message.nil? %> + <%= link_to "Response to '" + h(info_request.title) + "'", incoming_message_url(event.incoming_message) %> + <% elsif not event.outgoing_message.nil? and event.event_type == 'followup_sent' %> + <%= link_to "Follow up message for '" + h(info_request.title) + "'", outgoing_message_url(event.outgoing_message) %> + <% else %> + <%= link_to highlight_words(info_request.title, @highlight_words), request_url(info_request) %> + <% end %> </span> <span class="desc"> - <% if not @highlighting.nil? and @highlighting['InfoRequestEvent'][event.id].size > 0 %> - <%= @highlighting['InfoRequestEvent'][event.id].values.join(" ") %> - <% elsif not event.outgoing_message.nil? %> - <%= excerpt(event.outgoing_message.body_without_salutation, "", 150) %> - <% elsif not event.incoming_message.nil? %> - <%= excerpt(event.incoming_message.get_body_for_quoting, "", 150) %> - <% else %> - <%= excerpt(info_request.initial_request_text, "", 150) %> - <% end %> + <% + # this will work, but will spawn catdoc and be slow! + #highlight_and_excerpt(event.search_text_main, @highlight_words, 150) + %> + <% if not event.outgoing_message.nil? %> + <%= highlight_and_excerpt(event.outgoing_message.body_without_salutation, @highlight_words, 150) %> + <% elsif not event.incoming_message.nil? %> + <%= highlight_and_excerpt(event.incoming_message.get_body_for_quoting, @highlight_words, 150) %> + <% else %> + <%= highlight_and_excerpt(info_request.initial_request_text, @highlight_words, 150) %> + <% end %> </span> <span class="bottomline icon_<%= info_request.calculate_status %>"> diff --git a/app/views/request/list.rhtml b/app/views/request/list.rhtml index f35f217d1..3b024b764 100644 --- a/app/views/request/list.rhtml +++ b/app/views/request/list.rhtml @@ -4,10 +4,10 @@ <p>No requests made yet.</p> <% else %> <% for search_result in @search_results %> - <% if search_result.class.to_s == 'InfoRequestEvent' %> - <%= render :partial => 'request/request_listing_via_event', :locals => { :event => search_result, :info_request => search_result.info_request } %> + <% if search_result[:model].class.to_s == 'InfoRequestEvent' %> + <%= render :partial => 'request/request_listing_via_event', :locals => { :event => search_result[:model], :info_request => search_result[:model].info_request } %> <% else %> - <p><strong>Unexpected search result type <%=search_result.class.to_s%></strong></p> + <p><strong>Unexpected search result type <%=search_result[:model].class.to_s%></strong></p> <% end %> <% end %> <% end %> diff --git a/app/views/track/atom_feed.atom.builder b/app/views/track/atom_feed.atom.builder index 627c53d11..bc7a48de2 100644 --- a/app/views/track/atom_feed.atom.builder +++ b/app/views/track/atom_feed.atom.builder @@ -2,16 +2,16 @@ atom_feed do |feed| feed.title(@track_thing.params[:title_in_rss]) for search_result in @search_results - feed.entry(search_result) do |entry| + feed.entry(search_result[:model]) do |entry| # Get the HTML content from the same partial template as website search does content = '' - if search_result.class.to_s == 'InfoRequestEvent' - content += render :partial => 'request/request_listing_via_event', :locals => { :event => search_result, :info_request => search_result.info_request } + if search_result[:model].class.to_s == 'InfoRequestEvent' + content += render :partial => 'request/request_listing_via_event', :locals => { :event => search_result[:model], :info_request => search_result[:model].info_request } else - content = "<p><strong>Unknown search result type " + search_result.class.to_s + "</strong></p>" + content = "<p><strong>Unknown search result type " + search_result[:model].class.to_s + "</strong></p>" end # Pull out the heading as separate item, from the partial template - content.match(/(<a href="[^>]*">(.*)<\/a>\s+<br>)/) + content.match(/(<span class="head">\s+<a href="[^>]*">(.*)<\/a>\s+<\/span>)/) heading = $1 heading_text = $2 content.sub!(heading, "") diff --git a/app/views/track_mailer/event_digest.rhtml b/app/views/track_mailer/event_digest.rhtml index ee702cb77..1eb33a892 100644 --- a/app/views/track_mailer/event_digest.rhtml +++ b/app/views/track_mailer/event_digest.rhtml @@ -1,3 +1,7 @@ +<% if @highlight_words.nil? + @highlight_words = [] +end %> + <% # Construct the main text of the mail main_text = '' @@ -5,17 +9,15 @@ main_text += track_thing.params[:title_in_email] + "\n" main_text += ("=" * track_thing.params[:title_in_email].size) + "\n\n" for result in alert_results.reverse - if result.class.to_s == "InfoRequestEvent" - event = result + if result[:model].class.to_s == "InfoRequestEvent" + event = result[:model] - if not @highlighting.nil? and @highlighting['InfoRequestEvent'][event.id].size > 0 - extract = @highlighting['InfoRequestEvent'][event.id].values.join(" ") - elsif not event.outgoing_message.nil? - extract = excerpt(event.outgoing_message.body_without_salutation, "", 150) + if not event.outgoing_message.nil? + extract = highlight_and_excerpt(event.outgoing_message.body_without_salutation, @highlight_words, 150, false) elsif not event.incoming_message.nil? - extract = excerpt(event.incoming_message.get_body_for_quoting, "", 150) + extract = highlight_and_excerpt(event.incoming_message.get_body_for_quoting, @highlight_words, 150, false) else - extract = excerpt(info_request.initial_request_text, "", 150) + extract = highlight_and_excerpt(info_request.initial_request_text, @highlight_words, 150, false) end extract.gsub!(/\s+/, ' ') @@ -44,7 +46,7 @@ main_text += "\n" end - #STDERR.puts main_text + STDERR.puts main_text #STDERR.puts @unsubscribe_url %><%=main_text%>Alter your subscription ======================= diff --git a/app/views/user/_user_listing_single.rhtml b/app/views/user/_user_listing_single.rhtml index b8517c671..3e5368b54 100644 --- a/app/views/user/_user_listing_single.rhtml +++ b/app/views/user/_user_listing_single.rhtml @@ -1,6 +1,6 @@ <% if @highlight_words.nil? @highlight_words = [] - end %> +end %> <p class="user_listing"> <%= link_to highlight_words(display_user.name, @highlight_words), user_url(display_user) %> |