##// END OF EJS Templates
Added pagination on wiki page history....
Jean-Philippe Lang -
r568:6d7a855ca2f4
parent child
Show More
@@ -77,10 +77,17 class WikiController < ApplicationController
77 # show page history
77 # show page history
78 def history
78 def history
79 @page = @wiki.find_page(params[:page])
79 @page = @wiki.find_page(params[:page])
80 # don't load text
80
81 @version_count = @page.content.versions.count
82 @version_pages = Paginator.new self, @version_count, 25, params['p']
83 # don't load text
81 @versions = @page.content.versions.find :all,
84 @versions = @page.content.versions.find :all,
82 :select => "id, author_id, comments, updated_on, version",
85 :select => "id, author_id, comments, updated_on, version",
83 :order => 'version DESC'
86 :order => 'version DESC',
87 :limit => @version_pages.items_per_page,
88 :offset => @version_pages.current.offset
89
90 render :layout => false if request.xhr?
84 end
91 end
85
92
86 # remove a wiki page and its history
93 # remove a wiki page and its history
@@ -94,20 +94,22 module ApplicationHelper
94 end
94 end
95
95
96 def pagination_links_full(paginator, options={}, html_options={})
96 def pagination_links_full(paginator, options={}, html_options={})
97 page_param = options.delete(:page_param) || :page
98
97 html = ''
99 html = ''
98 html << link_to_remote(('&#171; ' + l(:label_previous)),
100 html << link_to_remote(('&#171; ' + l(:label_previous)),
99 {:update => "content", :url => options.merge(:page => paginator.current.previous)},
101 {:update => "content", :url => options.merge(page_param => paginator.current.previous)},
100 {:href => url_for(:params => options.merge(:page => paginator.current.previous))}) + ' ' if paginator.current.previous
102 {:href => url_for(:params => options.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
101
103
102 html << (pagination_links_each(paginator, options) do |n|
104 html << (pagination_links_each(paginator, options) do |n|
103 link_to_remote(n.to_s,
105 link_to_remote(n.to_s,
104 {:url => {:params => options.merge(:page => n)}, :update => 'content'},
106 {:url => {:params => options.merge(page_param => n)}, :update => 'content'},
105 {:href => url_for(:params => options.merge(:page => n))})
107 {:href => url_for(:params => options.merge(page_param => n))})
106 end || '')
108 end || '')
107
109
108 html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
110 html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
109 {:update => "content", :url => options.merge(:page => paginator.current.next)},
111 {:update => "content", :url => options.merge(page_param => paginator.current.next)},
110 {:href => url_for(:params => options.merge(:page => paginator.current.next))}) if paginator.current.next
112 {:href => url_for(:params => options.merge(page_param => paginator.current.next))}) if paginator.current.next
111 html
113 html
112 end
114 end
113
115
@@ -25,4 +25,7
25 </tbody>
25 </tbody>
26 </table>
26 </table>
27
27
28 <p><%= link_to l(:button_back), :action => 'index', :page => @page.title %></p> No newline at end of file
28 <p><%= pagination_links_full @version_pages, :page_param => :p %>
29 [ <%= @version_pages.current.first_item %> - <%= @version_pages.current.last_item %> / <%= @version_count %> ]</p>
30
31 <p><%= link_to l(:button_back), :action => 'index', :page => @page.title %></p>
General Comments 0
You need to be logged in to leave comments. Login now