search: fix search timeout error page not appearing.

Bug: when a search timed out we got the generic failbooru page instead
of the search timeout error page.

Cause: when rendering the <link rel="next"> / <link rel="prev"> tags in
the header, we may need to evaluate the search to determine the next or
previous page, but if the searches times out then this fails, which
caused Rails to throw a ActionView::Template::Error because an exception
was thrown while rendering the template.

Likewise, rendering the attributes for the <body> tag could fail with an
ActionView::Template::Error because the call to `current_item.present?`
forced evaluation of the search.
This commit is contained in:
evazion
2020-07-03 12:42:04 -05:00
parent e822d5f16e
commit f97c62c71d
6 changed files with 49 additions and 19 deletions

View File

@@ -1,13 +1,11 @@
<%# collection %>
<% content_for(:html_header) do %>
<% if collection.try(:records).present? %>
<% if collection.try(:prev_page) %>
<%= tag.link rel: "prev", href: url_for(nav_params_for(collection.prev_page)) %>
<% end %>
<% if collection.try(:prev_page) %>
<%= tag.link rel: "prev", href: url_for(nav_params_for(collection.prev_page)) %>
<% end %>
<% if collection.try(:next_page) %>
<%= tag.link rel: "next", href: url_for(nav_params_for(collection.next_page)) %>
<% end %>
<% if collection.try(:next_page) %>
<%= tag.link rel: "next", href: url_for(nav_params_for(collection.next_page)) %>
<% end %>
<% end %>