Added the ability to easily rollback to a previous version of a wiki page.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@424 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
7eb4abae80
commit
f3a1b4e38c
|
@ -27,7 +27,7 @@ class WikiController < ApplicationController
|
|||
edit
|
||||
render :action => 'edit' and return
|
||||
end
|
||||
@content = (params[:version] ? @page.content.versions.find_by_version(params[:version]) : @page.content)
|
||||
@content = @page.content_for_version(params[:version])
|
||||
if params[:export] == 'html'
|
||||
export = render_to_string :action => 'export', :layout => false
|
||||
send_data(export, :type => 'text/html', :filename => "#{@page.title}.html")
|
||||
|
@ -43,7 +43,8 @@ class WikiController < ApplicationController
|
|||
def edit
|
||||
@page = @wiki.find_or_new_page(params[:page])
|
||||
@page.content = WikiContent.new(:page => @page) if @page.new_record?
|
||||
@content = @page.content
|
||||
|
||||
@content = @page.content_for_version(params[:version])
|
||||
@content.text = "h1. #{@page.pretty_title}" if @content.text.blank?
|
||||
# don't keep previous comment
|
||||
@content.comment = nil
|
||||
|
|
|
@ -32,6 +32,12 @@ class WikiPage < ActiveRecord::Base
|
|||
WikiPage.pretty_title(title)
|
||||
end
|
||||
|
||||
def content_for_version(version=nil)
|
||||
result = content.versions.find_by_version(version.to_i) if version
|
||||
result ||= content
|
||||
result
|
||||
end
|
||||
|
||||
def self.pretty_title(str)
|
||||
(str && str.is_a?(String)) ? str.tr('_', ' ') : str
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<div class="contextual">
|
||||
<%= link_to(l(:button_edit), {:action => 'edit', :page => @page.title}, :class => 'icon icon-edit') if @content.version == @page.content.version %>
|
||||
<%= link_to(l(:button_rollback), {:action => 'edit', :page => @page.title, :version => @content.version }, :class => 'icon icon-cancel') if @content.version < @page.content.version %>
|
||||
<%= link_to(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %>
|
||||
<%= link_to(l(:label_page_index), {:action => 'special', :page => 'Page_index'}, :class => 'icon icon-index') %>
|
||||
</div>
|
||||
|
|
|
@ -380,6 +380,7 @@ button_cancel: Abbrechen
|
|||
button_activate: Aktivieren
|
||||
button_sort: Sortieren
|
||||
button_log_time: Log time
|
||||
button_rollback: Rollback to this version
|
||||
|
||||
status_active: aktiv
|
||||
status_registered: angemeldet
|
||||
|
|
|
@ -380,6 +380,7 @@ button_cancel: Cancel
|
|||
button_activate: Activate
|
||||
button_sort: Sort
|
||||
button_log_time: Log time
|
||||
button_rollback: Rollback to this version
|
||||
|
||||
status_active: active
|
||||
status_registered: registered
|
||||
|
|
|
@ -380,6 +380,7 @@ button_cancel: Cancelar
|
|||
button_activate: Activar
|
||||
button_sort: Clasificar
|
||||
button_log_time: Log time
|
||||
button_rollback: Rollback to this version
|
||||
|
||||
status_active: active
|
||||
status_registered: registered
|
||||
|
|
|
@ -380,6 +380,7 @@ button_cancel: Annuler
|
|||
button_activate: Activer
|
||||
button_sort: Trier
|
||||
button_log_time: Saisir temps
|
||||
button_rollback: Revenir à cette version
|
||||
|
||||
status_active: actif
|
||||
status_registered: enregistré
|
||||
|
|
|
@ -380,6 +380,7 @@ button_cancel: Annulla
|
|||
button_activate: Attiva
|
||||
button_sort: Ordina
|
||||
button_log_time: Log time
|
||||
button_rollback: Rollback to this version
|
||||
|
||||
status_active: active
|
||||
status_registered: registered
|
||||
|
|
|
@ -381,6 +381,7 @@ button_cancel: キャンセル
|
|||
button_activate: 有効にする
|
||||
button_sort: ソート
|
||||
button_log_time: 時間を記録
|
||||
button_rollback: Rollback to this version
|
||||
|
||||
status_active: 有効
|
||||
status_registered: 登録
|
||||
|
|
|
@ -383,6 +383,7 @@ button_cancel: 取消
|
|||
button_activate: 激活
|
||||
button_sort: 排序
|
||||
button_log_time: 登记工时
|
||||
button_rollback: Rollback to this version
|
||||
|
||||
status_active: 激活
|
||||
status_registered: 已注册
|
||||
|
|
Loading…
Reference in New Issue