From 97dd339bbb53fec10f2c9a93250fdb9af6236bcd Mon Sep 17 00:00:00 2001
From: Eric Davis
Date: Fri, 8 Jul 2011 14:59:23 -0700
Subject: [PATCH 1/4] [#191] Refactor: extract methods to helper
---
app/helpers/search_helper.rb | 10 ++++++++++
app/views/search/index.rhtml | 6 ++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index 414e4391..98fc27fa 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -57,4 +57,14 @@ module SearchHelper
end
('' + links.map {|link| content_tag('li', link)}.join(' ') + '
') unless links.empty?
end
+
+ def link_to_previous_search_page(pagination_previous_date)
+ link_to_content_update('« ' + l(:label_previous),
+ params.merge(:previous => 1, :offset => pagination_previous_date.strftime("%Y%m%d%H%M%S")))
+ end
+
+ def link_to_next_search_page(pagination_next_date)
+ link_to_content_update(l(:label_next) + ' »',
+ params.merge(:previous => nil, :offset => pagination_next_date.strftime("%Y%m%d%H%M%S")))
+ end
end
diff --git a/app/views/search/index.rhtml b/app/views/search/index.rhtml
index 674cabf6..8e9e556c 100644
--- a/app/views/search/index.rhtml
+++ b/app/views/search/index.rhtml
@@ -38,12 +38,10 @@
<% if @pagination_previous_date %>
-<%= link_to_content_update('« ' + l(:label_previous),
- params.merge(:previous => 1, :offset => @pagination_previous_date.strftime("%Y%m%d%H%M%S"))) %>
+ <%= link_to_previous_search_page(@pagination_previous_date) %>
<% end %>
<% if @pagination_next_date %>
-<%= link_to_content_update(l(:label_next) + ' »',
- params.merge(:previous => nil, :offset => @pagination_next_date.strftime("%Y%m%d%H%M%S"))) %>
+ <%= link_to_next_search_page(@pagination_next_date) %>
<% end %>
From 0b042903cae8f7cd335576e7db95dadb6bfb9f3c Mon Sep 17 00:00:00 2001
From: Eric Davis
Date: Fri, 8 Jul 2011 15:04:11 -0700
Subject: [PATCH 2/4] [#191] Refactor HTML style to CSS
---
app/views/search/index.rhtml | 8 +++++---
public/stylesheets/application.css | 3 +++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/app/views/search/index.rhtml b/app/views/search/index.rhtml
index 8e9e556c..2e7e6853 100644
--- a/app/views/search/index.rhtml
+++ b/app/views/search/index.rhtml
@@ -36,13 +36,15 @@
<% end %>
-
+
<% html_title(l(:label_search)) -%>
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 0c79cd64..a7087308 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -331,6 +331,9 @@ dt.time-entry { background-image: url(../images/time.png); }
#search-results dt.issue.closed { background-image: url(../images/ticket_checked.png); }
+.search-pagination { text-align: center; }
+.search-pagination a {padding: 0 5px; }
+
div#roadmap .related-issues { margin-bottom: 1em; }
div#roadmap .related-issues td.checkbox { display: none; }
div#roadmap .wiki h1:first-child { display: none; }
From 839654fc85ddaa8281f8ac757d46c4a0785c4cac Mon Sep 17 00:00:00 2001
From: Eric Davis
Date: Fri, 8 Jul 2011 15:09:57 -0700
Subject: [PATCH 3/4] [#191] Refactor: extract search pagination to partial
---
app/views/search/_pagination.html.erb | 10 ++++++++++
app/views/search/index.rhtml | 11 +----------
2 files changed, 11 insertions(+), 10 deletions(-)
create mode 100644 app/views/search/_pagination.html.erb
diff --git a/app/views/search/_pagination.html.erb b/app/views/search/_pagination.html.erb
new file mode 100644
index 00000000..d06fe8eb
--- /dev/null
+++ b/app/views/search/_pagination.html.erb
@@ -0,0 +1,10 @@
+
diff --git a/app/views/search/index.rhtml b/app/views/search/index.rhtml
index 2e7e6853..c5a891d4 100644
--- a/app/views/search/index.rhtml
+++ b/app/views/search/index.rhtml
@@ -36,15 +36,6 @@
<% end %>
-
+<%= render :partial => 'pagination', :locals => {:pagination_previous_date => @pagination_previous_date, :pagination_next_date => @pagination_next_date } %>
<% html_title(l(:label_search)) -%>
From 38b7ec572697a71dc4c468e6a53ac8b018b3c298 Mon Sep 17 00:00:00 2001
From: Eric Davis
Date: Fri, 8 Jul 2011 15:11:53 -0700
Subject: [PATCH 4/4] [#191] Add pagination links above the search results
---
app/views/search/index.rhtml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/views/search/index.rhtml b/app/views/search/index.rhtml
index c5a891d4..db9e3b64 100644
--- a/app/views/search/index.rhtml
+++ b/app/views/search/index.rhtml
@@ -24,6 +24,9 @@
<%= l(:label_result_plural) %> (<%= @results_by_type.values.sum %>)
+
+ <%= render :partial => 'pagination', :locals => {:pagination_previous_date => @pagination_previous_date, :pagination_next_date => @pagination_next_date } %>
+
<% @results.each do |e| %>
-