##// END OF EJS Templates
Use page parameter instead of p for pagination....
Jean-Philippe Lang -
r10529:fe690dcf20cb
parent child
Show More
@@ -1,363 +1,363
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang
2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require 'diff'
18 require 'diff'
19
19
20 # The WikiController follows the Rails REST controller pattern but with
20 # The WikiController follows the Rails REST controller pattern but with
21 # a few differences
21 # a few differences
22 #
22 #
23 # * index - shows a list of WikiPages grouped by page or date
23 # * index - shows a list of WikiPages grouped by page or date
24 # * new - not used
24 # * new - not used
25 # * create - not used
25 # * create - not used
26 # * show - will also show the form for creating a new wiki page
26 # * show - will also show the form for creating a new wiki page
27 # * edit - used to edit an existing or new page
27 # * edit - used to edit an existing or new page
28 # * update - used to save a wiki page update to the database, including new pages
28 # * update - used to save a wiki page update to the database, including new pages
29 # * destroy - normal
29 # * destroy - normal
30 #
30 #
31 # Other member and collection methods are also used
31 # Other member and collection methods are also used
32 #
32 #
33 # TODO: still being worked on
33 # TODO: still being worked on
34 class WikiController < ApplicationController
34 class WikiController < ApplicationController
35 default_search_scope :wiki_pages
35 default_search_scope :wiki_pages
36 before_filter :find_wiki, :authorize
36 before_filter :find_wiki, :authorize
37 before_filter :find_existing_or_new_page, :only => [:show, :edit, :update]
37 before_filter :find_existing_or_new_page, :only => [:show, :edit, :update]
38 before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy, :destroy_version]
38 before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy, :destroy_version]
39 accept_api_auth :index, :show, :update, :destroy
39 accept_api_auth :index, :show, :update, :destroy
40
40
41 helper :attachments
41 helper :attachments
42 include AttachmentsHelper
42 include AttachmentsHelper
43 helper :watchers
43 helper :watchers
44 include Redmine::Export::PDF
44 include Redmine::Export::PDF
45
45
46 # List of pages, sorted alphabetically and by parent (hierarchy)
46 # List of pages, sorted alphabetically and by parent (hierarchy)
47 def index
47 def index
48 load_pages_for_index
48 load_pages_for_index
49
49
50 respond_to do |format|
50 respond_to do |format|
51 format.html {
51 format.html {
52 @pages_by_parent_id = @pages.group_by(&:parent_id)
52 @pages_by_parent_id = @pages.group_by(&:parent_id)
53 }
53 }
54 format.api
54 format.api
55 end
55 end
56 end
56 end
57
57
58 # List of page, by last update
58 # List of page, by last update
59 def date_index
59 def date_index
60 load_pages_for_index
60 load_pages_for_index
61 @pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
61 @pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
62 end
62 end
63
63
64 # display a page (in editing mode if it doesn't exist)
64 # display a page (in editing mode if it doesn't exist)
65 def show
65 def show
66 if @page.new_record?
66 if @page.new_record?
67 if User.current.allowed_to?(:edit_wiki_pages, @project) && editable? && !api_request?
67 if User.current.allowed_to?(:edit_wiki_pages, @project) && editable? && !api_request?
68 edit
68 edit
69 render :action => 'edit'
69 render :action => 'edit'
70 else
70 else
71 render_404
71 render_404
72 end
72 end
73 return
73 return
74 end
74 end
75 if params[:version] && !User.current.allowed_to?(:view_wiki_edits, @project)
75 if params[:version] && !User.current.allowed_to?(:view_wiki_edits, @project)
76 deny_access
76 deny_access
77 return
77 return
78 end
78 end
79 @content = @page.content_for_version(params[:version])
79 @content = @page.content_for_version(params[:version])
80 if User.current.allowed_to?(:export_wiki_pages, @project)
80 if User.current.allowed_to?(:export_wiki_pages, @project)
81 if params[:format] == 'pdf'
81 if params[:format] == 'pdf'
82 send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf")
82 send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf")
83 return
83 return
84 elsif params[:format] == 'html'
84 elsif params[:format] == 'html'
85 export = render_to_string :action => 'export', :layout => false
85 export = render_to_string :action => 'export', :layout => false
86 send_data(export, :type => 'text/html', :filename => "#{@page.title}.html")
86 send_data(export, :type => 'text/html', :filename => "#{@page.title}.html")
87 return
87 return
88 elsif params[:format] == 'txt'
88 elsif params[:format] == 'txt'
89 send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt")
89 send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt")
90 return
90 return
91 end
91 end
92 end
92 end
93 @editable = editable?
93 @editable = editable?
94 @sections_editable = @editable && User.current.allowed_to?(:edit_wiki_pages, @page.project) &&
94 @sections_editable = @editable && User.current.allowed_to?(:edit_wiki_pages, @page.project) &&
95 @content.current_version? &&
95 @content.current_version? &&
96 Redmine::WikiFormatting.supports_section_edit?
96 Redmine::WikiFormatting.supports_section_edit?
97
97
98 respond_to do |format|
98 respond_to do |format|
99 format.html
99 format.html
100 format.api
100 format.api
101 end
101 end
102 end
102 end
103
103
104 # edit an existing page or a new one
104 # edit an existing page or a new one
105 def edit
105 def edit
106 return render_403 unless editable?
106 return render_403 unless editable?
107 if @page.new_record?
107 if @page.new_record?
108 @page.content = WikiContent.new(:page => @page)
108 @page.content = WikiContent.new(:page => @page)
109 if params[:parent].present?
109 if params[:parent].present?
110 @page.parent = @page.wiki.find_page(params[:parent].to_s)
110 @page.parent = @page.wiki.find_page(params[:parent].to_s)
111 end
111 end
112 end
112 end
113
113
114 @content = @page.content_for_version(params[:version])
114 @content = @page.content_for_version(params[:version])
115 @content.text = initial_page_content(@page) if @content.text.blank?
115 @content.text = initial_page_content(@page) if @content.text.blank?
116 # don't keep previous comment
116 # don't keep previous comment
117 @content.comments = nil
117 @content.comments = nil
118
118
119 # To prevent StaleObjectError exception when reverting to a previous version
119 # To prevent StaleObjectError exception when reverting to a previous version
120 @content.version = @page.content.version
120 @content.version = @page.content.version
121
121
122 @text = @content.text
122 @text = @content.text
123 if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
123 if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
124 @section = params[:section].to_i
124 @section = params[:section].to_i
125 @text, @section_hash = Redmine::WikiFormatting.formatter.new(@text).get_section(@section)
125 @text, @section_hash = Redmine::WikiFormatting.formatter.new(@text).get_section(@section)
126 render_404 if @text.blank?
126 render_404 if @text.blank?
127 end
127 end
128 end
128 end
129
129
130 # Creates a new page or updates an existing one
130 # Creates a new page or updates an existing one
131 def update
131 def update
132 return render_403 unless editable?
132 return render_403 unless editable?
133 was_new_page = @page.new_record?
133 was_new_page = @page.new_record?
134 @page.content = WikiContent.new(:page => @page) if @page.new_record?
134 @page.content = WikiContent.new(:page => @page) if @page.new_record?
135 @page.safe_attributes = params[:wiki_page]
135 @page.safe_attributes = params[:wiki_page]
136
136
137 @content = @page.content
137 @content = @page.content
138 content_params = params[:content]
138 content_params = params[:content]
139 if content_params.nil? && params[:wiki_page].is_a?(Hash)
139 if content_params.nil? && params[:wiki_page].is_a?(Hash)
140 content_params = params[:wiki_page].slice(:text, :comments, :version)
140 content_params = params[:wiki_page].slice(:text, :comments, :version)
141 end
141 end
142 content_params ||= {}
142 content_params ||= {}
143
143
144 if !@page.new_record? && content_params.present? && @content.text == content_params[:text]
144 if !@page.new_record? && content_params.present? && @content.text == content_params[:text]
145 attachments = Attachment.attach_files(@page, params[:attachments])
145 attachments = Attachment.attach_files(@page, params[:attachments])
146 render_attachment_warning_if_needed(@page)
146 render_attachment_warning_if_needed(@page)
147 # don't save content if text wasn't changed
147 # don't save content if text wasn't changed
148 @page.save
148 @page.save
149 redirect_to :action => 'show', :project_id => @project, :id => @page.title
149 redirect_to :action => 'show', :project_id => @project, :id => @page.title
150 return
150 return
151 end
151 end
152
152
153 @content.comments = content_params[:comments]
153 @content.comments = content_params[:comments]
154 @text = content_params[:text]
154 @text = content_params[:text]
155 if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
155 if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
156 @section = params[:section].to_i
156 @section = params[:section].to_i
157 @section_hash = params[:section_hash]
157 @section_hash = params[:section_hash]
158 @content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(params[:section].to_i, @text, @section_hash)
158 @content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(params[:section].to_i, @text, @section_hash)
159 else
159 else
160 @content.version = content_params[:version] if content_params[:version]
160 @content.version = content_params[:version] if content_params[:version]
161 @content.text = @text
161 @content.text = @text
162 end
162 end
163 @content.author = User.current
163 @content.author = User.current
164 @page.content = @content
164 @page.content = @content
165 if @page.save
165 if @page.save
166 attachments = Attachment.attach_files(@page, params[:attachments])
166 attachments = Attachment.attach_files(@page, params[:attachments])
167 render_attachment_warning_if_needed(@page)
167 render_attachment_warning_if_needed(@page)
168 call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
168 call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
169
169
170 respond_to do |format|
170 respond_to do |format|
171 format.html { redirect_to :action => 'show', :project_id => @project, :id => @page.title }
171 format.html { redirect_to :action => 'show', :project_id => @project, :id => @page.title }
172 format.api {
172 format.api {
173 if was_new_page
173 if was_new_page
174 render :action => 'show', :status => :created, :location => url_for(:controller => 'wiki', :action => 'show', :project_id => @project, :id => @page.title)
174 render :action => 'show', :status => :created, :location => url_for(:controller => 'wiki', :action => 'show', :project_id => @project, :id => @page.title)
175 else
175 else
176 render_api_ok
176 render_api_ok
177 end
177 end
178 }
178 }
179 end
179 end
180 else
180 else
181 respond_to do |format|
181 respond_to do |format|
182 format.html { render :action => 'edit' }
182 format.html { render :action => 'edit' }
183 format.api { render_validation_errors(@content) }
183 format.api { render_validation_errors(@content) }
184 end
184 end
185 end
185 end
186
186
187 rescue ActiveRecord::StaleObjectError, Redmine::WikiFormatting::StaleSectionError
187 rescue ActiveRecord::StaleObjectError, Redmine::WikiFormatting::StaleSectionError
188 # Optimistic locking exception
188 # Optimistic locking exception
189 respond_to do |format|
189 respond_to do |format|
190 format.html {
190 format.html {
191 flash.now[:error] = l(:notice_locking_conflict)
191 flash.now[:error] = l(:notice_locking_conflict)
192 render :action => 'edit'
192 render :action => 'edit'
193 }
193 }
194 format.api { render_api_head :conflict }
194 format.api { render_api_head :conflict }
195 end
195 end
196 rescue ActiveRecord::RecordNotSaved
196 rescue ActiveRecord::RecordNotSaved
197 respond_to do |format|
197 respond_to do |format|
198 format.html { render :action => 'edit' }
198 format.html { render :action => 'edit' }
199 format.api { render_validation_errors(@content) }
199 format.api { render_validation_errors(@content) }
200 end
200 end
201 end
201 end
202
202
203 # rename a page
203 # rename a page
204 def rename
204 def rename
205 return render_403 unless editable?
205 return render_403 unless editable?
206 @page.redirect_existing_links = true
206 @page.redirect_existing_links = true
207 # used to display the *original* title if some AR validation errors occur
207 # used to display the *original* title if some AR validation errors occur
208 @original_title = @page.pretty_title
208 @original_title = @page.pretty_title
209 if request.post? && @page.update_attributes(params[:wiki_page])
209 if request.post? && @page.update_attributes(params[:wiki_page])
210 flash[:notice] = l(:notice_successful_update)
210 flash[:notice] = l(:notice_successful_update)
211 redirect_to :action => 'show', :project_id => @project, :id => @page.title
211 redirect_to :action => 'show', :project_id => @project, :id => @page.title
212 end
212 end
213 end
213 end
214
214
215 def protect
215 def protect
216 @page.update_attribute :protected, params[:protected]
216 @page.update_attribute :protected, params[:protected]
217 redirect_to :action => 'show', :project_id => @project, :id => @page.title
217 redirect_to :action => 'show', :project_id => @project, :id => @page.title
218 end
218 end
219
219
220 # show page history
220 # show page history
221 def history
221 def history
222 @version_count = @page.content.versions.count
222 @version_count = @page.content.versions.count
223 @version_pages = Paginator.new self, @version_count, per_page_option, params['p']
223 @version_pages = Paginator.new self, @version_count, per_page_option, params['page']
224 # don't load text
224 # don't load text
225 @versions = @page.content.versions.find :all,
225 @versions = @page.content.versions.find :all,
226 :select => "id, author_id, comments, updated_on, version",
226 :select => "id, author_id, comments, updated_on, version",
227 :order => 'version DESC',
227 :order => 'version DESC',
228 :limit => @version_pages.items_per_page + 1,
228 :limit => @version_pages.items_per_page + 1,
229 :offset => @version_pages.current.offset
229 :offset => @version_pages.current.offset
230
230
231 render :layout => false if request.xhr?
231 render :layout => false if request.xhr?
232 end
232 end
233
233
234 def diff
234 def diff
235 @diff = @page.diff(params[:version], params[:version_from])
235 @diff = @page.diff(params[:version], params[:version_from])
236 render_404 unless @diff
236 render_404 unless @diff
237 end
237 end
238
238
239 def annotate
239 def annotate
240 @annotate = @page.annotate(params[:version])
240 @annotate = @page.annotate(params[:version])
241 render_404 unless @annotate
241 render_404 unless @annotate
242 end
242 end
243
243
244 # Removes a wiki page and its history
244 # Removes a wiki page and its history
245 # Children can be either set as root pages, removed or reassigned to another parent page
245 # Children can be either set as root pages, removed or reassigned to another parent page
246 def destroy
246 def destroy
247 return render_403 unless editable?
247 return render_403 unless editable?
248
248
249 @descendants_count = @page.descendants.size
249 @descendants_count = @page.descendants.size
250 if @descendants_count > 0
250 if @descendants_count > 0
251 case params[:todo]
251 case params[:todo]
252 when 'nullify'
252 when 'nullify'
253 # Nothing to do
253 # Nothing to do
254 when 'destroy'
254 when 'destroy'
255 # Removes all its descendants
255 # Removes all its descendants
256 @page.descendants.each(&:destroy)
256 @page.descendants.each(&:destroy)
257 when 'reassign'
257 when 'reassign'
258 # Reassign children to another parent page
258 # Reassign children to another parent page
259 reassign_to = @wiki.pages.find_by_id(params[:reassign_to_id].to_i)
259 reassign_to = @wiki.pages.find_by_id(params[:reassign_to_id].to_i)
260 return unless reassign_to
260 return unless reassign_to
261 @page.children.each do |child|
261 @page.children.each do |child|
262 child.update_attribute(:parent, reassign_to)
262 child.update_attribute(:parent, reassign_to)
263 end
263 end
264 else
264 else
265 @reassignable_to = @wiki.pages - @page.self_and_descendants
265 @reassignable_to = @wiki.pages - @page.self_and_descendants
266 # display the destroy form if it's a user request
266 # display the destroy form if it's a user request
267 return unless api_request?
267 return unless api_request?
268 end
268 end
269 end
269 end
270 @page.destroy
270 @page.destroy
271 respond_to do |format|
271 respond_to do |format|
272 format.html { redirect_to :action => 'index', :project_id => @project }
272 format.html { redirect_to :action => 'index', :project_id => @project }
273 format.api { render_api_ok }
273 format.api { render_api_ok }
274 end
274 end
275 end
275 end
276
276
277 def destroy_version
277 def destroy_version
278 return render_403 unless editable?
278 return render_403 unless editable?
279
279
280 @content = @page.content_for_version(params[:version])
280 @content = @page.content_for_version(params[:version])
281 @content.destroy
281 @content.destroy
282 redirect_to_referer_or :action => 'history', :id => @page.title, :project_id => @project
282 redirect_to_referer_or :action => 'history', :id => @page.title, :project_id => @project
283 end
283 end
284
284
285 # Export wiki to a single pdf or html file
285 # Export wiki to a single pdf or html file
286 def export
286 def export
287 @pages = @wiki.pages.all(:order => 'title', :include => [:content, :attachments], :limit => 75)
287 @pages = @wiki.pages.all(:order => 'title', :include => [:content, :attachments], :limit => 75)
288 respond_to do |format|
288 respond_to do |format|
289 format.html {
289 format.html {
290 export = render_to_string :action => 'export_multiple', :layout => false
290 export = render_to_string :action => 'export_multiple', :layout => false
291 send_data(export, :type => 'text/html', :filename => "wiki.html")
291 send_data(export, :type => 'text/html', :filename => "wiki.html")
292 }
292 }
293 format.pdf {
293 format.pdf {
294 send_data(wiki_pages_to_pdf(@pages, @project), :type => 'application/pdf', :filename => "#{@project.identifier}.pdf")
294 send_data(wiki_pages_to_pdf(@pages, @project), :type => 'application/pdf', :filename => "#{@project.identifier}.pdf")
295 }
295 }
296 end
296 end
297 end
297 end
298
298
299 def preview
299 def preview
300 page = @wiki.find_page(params[:id])
300 page = @wiki.find_page(params[:id])
301 # page is nil when previewing a new page
301 # page is nil when previewing a new page
302 return render_403 unless page.nil? || editable?(page)
302 return render_403 unless page.nil? || editable?(page)
303 if page
303 if page
304 @attachements = page.attachments
304 @attachements = page.attachments
305 @previewed = page.content
305 @previewed = page.content
306 end
306 end
307 @text = params[:content][:text]
307 @text = params[:content][:text]
308 render :partial => 'common/preview'
308 render :partial => 'common/preview'
309 end
309 end
310
310
311 def add_attachment
311 def add_attachment
312 return render_403 unless editable?
312 return render_403 unless editable?
313 attachments = Attachment.attach_files(@page, params[:attachments])
313 attachments = Attachment.attach_files(@page, params[:attachments])
314 render_attachment_warning_if_needed(@page)
314 render_attachment_warning_if_needed(@page)
315 redirect_to :action => 'show', :id => @page.title, :project_id => @project
315 redirect_to :action => 'show', :id => @page.title, :project_id => @project
316 end
316 end
317
317
318 private
318 private
319
319
320 def find_wiki
320 def find_wiki
321 @project = Project.find(params[:project_id])
321 @project = Project.find(params[:project_id])
322 @wiki = @project.wiki
322 @wiki = @project.wiki
323 render_404 unless @wiki
323 render_404 unless @wiki
324 rescue ActiveRecord::RecordNotFound
324 rescue ActiveRecord::RecordNotFound
325 render_404
325 render_404
326 end
326 end
327
327
328 # Finds the requested page or a new page if it doesn't exist
328 # Finds the requested page or a new page if it doesn't exist
329 def find_existing_or_new_page
329 def find_existing_or_new_page
330 @page = @wiki.find_or_new_page(params[:id])
330 @page = @wiki.find_or_new_page(params[:id])
331 if @wiki.page_found_with_redirect?
331 if @wiki.page_found_with_redirect?
332 redirect_to params.update(:id => @page.title)
332 redirect_to params.update(:id => @page.title)
333 end
333 end
334 end
334 end
335
335
336 # Finds the requested page and returns a 404 error if it doesn't exist
336 # Finds the requested page and returns a 404 error if it doesn't exist
337 def find_existing_page
337 def find_existing_page
338 @page = @wiki.find_page(params[:id])
338 @page = @wiki.find_page(params[:id])
339 if @page.nil?
339 if @page.nil?
340 render_404
340 render_404
341 return
341 return
342 end
342 end
343 if @wiki.page_found_with_redirect?
343 if @wiki.page_found_with_redirect?
344 redirect_to params.update(:id => @page.title)
344 redirect_to params.update(:id => @page.title)
345 end
345 end
346 end
346 end
347
347
348 # Returns true if the current user is allowed to edit the page, otherwise false
348 # Returns true if the current user is allowed to edit the page, otherwise false
349 def editable?(page = @page)
349 def editable?(page = @page)
350 page.editable_by?(User.current)
350 page.editable_by?(User.current)
351 end
351 end
352
352
353 # Returns the default content of a new wiki page
353 # Returns the default content of a new wiki page
354 def initial_page_content(page)
354 def initial_page_content(page)
355 helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting)
355 helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting)
356 extend helper unless self.instance_of?(helper)
356 extend helper unless self.instance_of?(helper)
357 helper.instance_method(:initial_page_content).bind(self).call(page)
357 helper.instance_method(:initial_page_content).bind(self).call(page)
358 end
358 end
359
359
360 def load_pages_for_index
360 def load_pages_for_index
361 @pages = @wiki.pages.with_updated_on.order("#{WikiPage.table_name}.title").includes(:wiki => :project).includes(:parent).all
361 @pages = @wiki.pages.with_updated_on.order("#{WikiPage.table_name}.title").includes(:wiki => :project).includes(:parent).all
362 end
362 end
363 end
363 end
@@ -1,42 +1,42
1 <%= wiki_page_breadcrumb(@page) %>
1 <%= wiki_page_breadcrumb(@page) %>
2
2
3 <h2><%= h(@page.pretty_title) %></h2>
3 <h2><%= h(@page.pretty_title) %></h2>
4
4
5 <h3><%= l(:label_history) %></h3>
5 <h3><%= l(:label_history) %></h3>
6
6
7 <%= form_tag({:controller => 'wiki', :action => 'diff',
7 <%= form_tag({:controller => 'wiki', :action => 'diff',
8 :project_id => @page.project, :id => @page.title},
8 :project_id => @page.project, :id => @page.title},
9 :method => :get) do %>
9 :method => :get) do %>
10 <table class="list wiki-page-versions">
10 <table class="list wiki-page-versions">
11 <thead><tr>
11 <thead><tr>
12 <th>#</th>
12 <th>#</th>
13 <th></th>
13 <th></th>
14 <th></th>
14 <th></th>
15 <th><%= l(:field_updated_on) %></th>
15 <th><%= l(:field_updated_on) %></th>
16 <th><%= l(:field_author) %></th>
16 <th><%= l(:field_author) %></th>
17 <th><%= l(:field_comments) %></th>
17 <th><%= l(:field_comments) %></th>
18 <th></th>
18 <th></th>
19 </tr></thead>
19 </tr></thead>
20 <tbody>
20 <tbody>
21 <% show_diff = @versions.size > 1 %>
21 <% show_diff = @versions.size > 1 %>
22 <% line_num = 1 %>
22 <% line_num = 1 %>
23 <% @versions.each do |ver| %>
23 <% @versions.each do |ver| %>
24 <tr class="wiki-page-version <%= cycle("odd", "even") %>">
24 <tr class="wiki-page-version <%= cycle("odd", "even") %>">
25 <td class="id"><%= link_to h(ver.version), :action => 'show', :id => @page.title, :project_id => @page.project, :version => ver.version %></td>
25 <td class="id"><%= link_to h(ver.version), :action => 'show', :id => @page.title, :project_id => @page.project, :version => ver.version %></td>
26 <td class="checkbox"><%= radio_button_tag('version', ver.version, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('#cbto-#{line_num+1}').attr('checked', true);") if show_diff && (line_num < @versions.size) %></td>
26 <td class="checkbox"><%= radio_button_tag('version', ver.version, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('#cbto-#{line_num+1}').attr('checked', true);") if show_diff && (line_num < @versions.size) %></td>
27 <td class="checkbox"><%= radio_button_tag('version_from', ver.version, (line_num==2), :id => "cbto-#{line_num}") if show_diff && (line_num > 1) %></td>
27 <td class="checkbox"><%= radio_button_tag('version_from', ver.version, (line_num==2), :id => "cbto-#{line_num}") if show_diff && (line_num > 1) %></td>
28 <td class="updated_on"><%= format_time(ver.updated_on) %></td>
28 <td class="updated_on"><%= format_time(ver.updated_on) %></td>
29 <td class="author"><%= link_to_user ver.author %></td>
29 <td class="author"><%= link_to_user ver.author %></td>
30 <td class="comments"><%=h ver.comments %></td>
30 <td class="comments"><%=h ver.comments %></td>
31 <td class="buttons">
31 <td class="buttons">
32 <%= link_to l(:button_annotate), :action => 'annotate', :id => @page.title, :version => ver.version %>
32 <%= link_to l(:button_annotate), :action => 'annotate', :id => @page.title, :version => ver.version %>
33 <%= delete_link wiki_page_path(@page, :version => ver.version) if User.current.allowed_to?(:delete_wiki_pages, @page.project) && @version_count > 1 %>
33 <%= delete_link wiki_page_path(@page, :version => ver.version) if User.current.allowed_to?(:delete_wiki_pages, @page.project) && @version_count > 1 %>
34 </td>
34 </td>
35 </tr>
35 </tr>
36 <% line_num += 1 %>
36 <% line_num += 1 %>
37 <% end %>
37 <% end %>
38 </tbody>
38 </tbody>
39 </table>
39 </table>
40 <%= submit_tag l(:label_view_diff), :class => 'small' if show_diff %>
40 <%= submit_tag l(:label_view_diff), :class => 'small' if show_diff %>
41 <span class="pagination"><%= pagination_links_full @version_pages, @version_count, :page_param => :p %></span>
41 <span class="pagination"><%= pagination_links_full @version_pages, @version_count %></span>
42 <% end %>
42 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now