summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-06-23 18:53:45 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-06-23 18:53:45 +0000
commit6d7a855ca2f497a0deeb728d4d7da5cf4afa1d51 (patch)
tree88235a1694001e53894f387e7823af9d9aa672a1 /app
parent600018d5adfd627f8a72d39c19f770e64b40ba72 (diff)
downloadredmine-6d7a855ca2f497a0deeb728d4d7da5cf4afa1d51.tar.gz
redmine-6d7a855ca2f497a0deeb728d4d7da5cf4afa1d51.zip
Added pagination on wiki page history.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@571 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/wiki_controller.rb11
-rw-r--r--app/helpers/application_helper.rb14
-rw-r--r--app/views/wiki/history.rhtml5
3 files changed, 21 insertions, 9 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index bad9b28f0..bebe1d5ac 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -77,10 +77,17 @@ class WikiController < ApplicationController
# show page history
def history
@page = @wiki.find_page(params[:page])
- # don't load text
+
+ @version_count = @page.content.versions.count
+ @version_pages = Paginator.new self, @version_count, 25, params['p']
+ # don't load text
@versions = @page.content.versions.find :all,
:select => "id, author_id, comments, updated_on, version",
- :order => 'version DESC'
+ :order => 'version DESC',
+ :limit => @version_pages.items_per_page,
+ :offset => @version_pages.current.offset
+
+ render :layout => false if request.xhr?
end
# remove a wiki page and its history
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 564a9938f..0c2b6edc3 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -94,20 +94,22 @@ module ApplicationHelper
end
def pagination_links_full(paginator, options={}, html_options={})
+ page_param = options.delete(:page_param) || :page
+
html = ''
html << link_to_remote(('&#171; ' + l(:label_previous)),
- {:update => "content", :url => options.merge(:page => paginator.current.previous)},
- {:href => url_for(:params => options.merge(:page => paginator.current.previous))}) + ' ' if paginator.current.previous
+ {:update => "content", :url => options.merge(page_param => paginator.current.previous)},
+ {:href => url_for(:params => options.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
html << (pagination_links_each(paginator, options) do |n|
link_to_remote(n.to_s,
- {:url => {:params => options.merge(:page => n)}, :update => 'content'},
- {:href => url_for(:params => options.merge(:page => n))})
+ {:url => {:params => options.merge(page_param => n)}, :update => 'content'},
+ {:href => url_for(:params => options.merge(page_param => n))})
end || '')
html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
- {:update => "content", :url => options.merge(:page => paginator.current.next)},
- {:href => url_for(:params => options.merge(:page => paginator.current.next))}) if paginator.current.next
+ {:update => "content", :url => options.merge(page_param => paginator.current.next)},
+ {:href => url_for(:params => options.merge(page_param => paginator.current.next))}) if paginator.current.next
html
end
diff --git a/app/views/wiki/history.rhtml b/app/views/wiki/history.rhtml
index 78dc70cc5..6040072ea 100644
--- a/app/views/wiki/history.rhtml
+++ b/app/views/wiki/history.rhtml
@@ -25,4 +25,7 @@
</tbody>
</table>
-<p><%= link_to l(:button_back), :action => 'index', :page => @page.title %></p> \ No newline at end of file
+<p><%= pagination_links_full @version_pages, :page_param => :p %>
+[ <%= @version_pages.current.first_item %> - <%= @version_pages.current.last_item %> / <%= @version_count %> ]</p>
+
+<p><%= link_to l(:button_back), :action => 'index', :page => @page.title %></p>