summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-04-05 14:45:44 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-04-05 14:45:44 +0000
commitf3a1b4e38c25fd34ef19d9b04567d327c34f6713 (patch)
tree32509daacaca872a21ccbbc806caee2fb2cde6f3
parent7eb4abae80d7bd0b3b95c67b09f7b58b0b3ed031 (diff)
downloadredmine-f3a1b4e38c25fd34ef19d9b04567d327c34f6713.tar.gz
redmine-f3a1b4e38c25fd34ef19d9b04567d327c34f6713.zip
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
-rw-r--r--app/controllers/wiki_controller.rb5
-rw-r--r--app/models/wiki_page.rb6
-rw-r--r--app/views/wiki/show.rhtml1
-rw-r--r--lang/de.yml1
-rw-r--r--lang/en.yml1
-rw-r--r--lang/es.yml1
-rw-r--r--lang/fr.yml1
-rw-r--r--lang/it.yml1
-rw-r--r--lang/ja.yml1
-rw-r--r--lang/zh.yml1
10 files changed, 17 insertions, 2 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 552565668..5931a93ad 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -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
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index 19961cb0b..f2ea8fd59 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -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
diff --git a/app/views/wiki/show.rhtml b/app/views/wiki/show.rhtml
index 2e8ee4089..e4e1bc38d 100644
--- a/app/views/wiki/show.rhtml
+++ b/app/views/wiki/show.rhtml
@@ -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>
diff --git a/lang/de.yml b/lang/de.yml
index c08b4af40..c8d0aedd2 100644
--- a/lang/de.yml
+++ b/lang/de.yml
@@ -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
diff --git a/lang/en.yml b/lang/en.yml
index 4ce8bcb27..8c56811b3 100644
--- a/lang/en.yml
+++ b/lang/en.yml
@@ -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
diff --git a/lang/es.yml b/lang/es.yml
index a2014845e..8272cfea2 100644
--- a/lang/es.yml
+++ b/lang/es.yml
@@ -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
diff --git a/lang/fr.yml b/lang/fr.yml
index 8b52ac5de..b3efeebb1 100644
--- a/lang/fr.yml
+++ b/lang/fr.yml
@@ -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é
diff --git a/lang/it.yml b/lang/it.yml
index daaed6b79..0900a2a7a 100644
--- a/lang/it.yml
+++ b/lang/it.yml
@@ -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
diff --git a/lang/ja.yml b/lang/ja.yml
index bbeb6d453..babb212e0 100644
--- a/lang/ja.yml
+++ b/lang/ja.yml
@@ -381,6 +381,7 @@ button_cancel: キャンセル
button_activate: 有効にする
button_sort: ソート
button_log_time: 時間を記録
+button_rollback: Rollback to this version
status_active: 有効
status_registered: 登録
diff --git a/lang/zh.yml b/lang/zh.yml
index 6301b8235..42d69759d 100644
--- a/lang/zh.yml
+++ b/lang/zh.yml
@@ -383,6 +383,7 @@ button_cancel: 取消
button_activate: 激活
button_sort: 排序
button_log_time: 登记工时
+button_rollback: Rollback to this version
status_active: 激活
status_registered: 已注册