diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 39786341b..ae6f9d166 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -98,7 +98,7 @@ class WikiController < ApplicationController flash[:error] = l(:notice_locking_conflict) end - verify :method => :post, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } + verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } # Creates a new page or updates an existing one def update @page = @wiki.find_or_new_page(params[:id]) @@ -234,7 +234,7 @@ class WikiController < ApplicationController return render_403 unless editable? attachments = Attachment.attach_files(@page, params[:attachments]) render_attachment_warning_if_needed(@page) - redirect_to :action => 'show', :id => @page.title + redirect_to :action => 'show', :id => @page.title, :project_id => @project end private diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 12f4b6e5e..bf4e2d5ba 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -541,7 +541,8 @@ module ApplicationHelper when :local; "#{title}.html" when :anchor; "##{title}" # used for single-file wiki export else - url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project, :id => Wiki.titleize(page), :anchor => anchor) + wiki_page_id = page.present? ? Wiki.titleize(page) : nil + url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project, :id => wiki_page_id, :anchor => anchor) end link_to((title || page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new'))) else diff --git a/app/views/projects/settings/_versions.rhtml b/app/views/projects/settings/_versions.rhtml index eb04d6d43..c8a5db1cf 100644 --- a/app/views/projects/settings/_versions.rhtml +++ b/app/views/projects/settings/_versions.rhtml @@ -17,7 +17,7 @@
<%= submit_tag l(:button_save) %> <%= link_to_remote l(:label_preview), { :url => { :controller => 'wiki', :action => 'preview', :project_id => @project, :id => @page.title }, - :method => 'post', + :method => :post, :update => 'preview', :with => "Form.serialize('wiki_form')", :complete => "Element.scrollTo('preview')" diff --git a/app/views/wiki/history.rhtml b/app/views/wiki/history.rhtml index 5d44598f9..eac24705b 100644 --- a/app/views/wiki/history.rhtml +++ b/app/views/wiki/history.rhtml @@ -19,7 +19,7 @@ <% line_num = 1 %> <% @versions.each do |ver| %>
- <%= link_to(('« ' + l(:label_previous)), :action => 'show', :id => @page.title, :version => (@content.version - 1)) + " - " if @content.version > 1 %>
+ <%= link_to(('« ' + l(:label_previous)), :action => 'show', :id => @page.title, :project_id => @page.project, :version => (@content.version - 1)) + " - " if @content.version > 1 %>
<%= "#{l(:label_version)} #{@content.version}/#{@page.content.version}" %>
- <%= '(' + link_to('diff', :controller => 'wiki', :action => 'diff', :id => @page.title, :version => @content.version) + ')' if @content.version > 1 %> -
- <%= link_to((l(:label_next) + ' »'), :action => 'show', :id => @page.title, :version => (@content.version + 1)) + " - " if @content.version < @page.content.version %>
- <%= link_to(l(:label_current_version), :action => 'show', :id => @page.title) %>
+ <%= '(' + link_to('diff', :controller => 'wiki', :action => 'diff', :id => @page.title, :project_id => @page.project, :version => @content.version) + ')' if @content.version > 1 %> -
+ <%= link_to((l(:label_next) + ' »'), :action => 'show', :id => @page.title, :project_id => @page.project, :version => (@content.version + 1)) + " - " if @content.version < @page.content.version %>
+ <%= link_to(l(:label_current_version), :action => 'show', :id => @page.title, :project_id => @page.project) %>
<%= @content.author ? @content.author.name : "anonyme" %>, <%= format_time(@content.updated_on) %>
<%=h @content.comments %>
diff --git a/config/routes.rb b/config/routes.rb
index 0fa76f235..b062aea94 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -27,27 +27,6 @@ ActionController::Routing::Routes.draw do |map|
map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
- map.with_options :controller => 'wiki' do |wiki_routes|
- wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
- wiki_views.connect 'projects/:project_id/wiki/export', :action => 'export'
- wiki_views.connect 'projects/:project_id/wiki/index', :action => 'index'
- wiki_views.connect 'projects/:project_id/wiki/date_index', :action => 'date_index'
- wiki_views.connect 'projects/:project_id/wiki/:id', :action => 'show', :id => nil
- wiki_views.connect 'projects/:project_id/wiki/:id/edit', :action => 'edit'
- wiki_views.connect 'projects/:project_id/wiki/:id/rename', :action => 'rename'
- wiki_views.connect 'projects/:project_id/wiki/:id/history', :action => 'history'
- wiki_views.connect 'projects/:project_id/wiki/:id/diff/:version/vs/:version_from', :action => 'diff'
- wiki_views.connect 'projects/:project_id/wiki/:id/annotate/:version', :action => 'annotate'
- end
-
- wiki_routes.connect 'projects/:project_id/wiki/:id/:action',
- :action => /rename|preview|protect|add_attachment/,
- :conditions => {:method => :post}
-
- wiki_routes.connect 'projects/:project_id/wiki/:id/edit', :action => 'update', :conditions => {:method => :post}
-
- wiki_routes.connect 'projects/:project_id/wiki/:id', :action => 'destroy', :conditions => {:method => :delete}
- end
map.with_options :controller => 'messages' do |messages_routes|
messages_routes.with_options :conditions => {:method => :get} do |messages_views|
@@ -168,7 +147,21 @@ ActionController::Routing::Routes.draw do |map|
project.resources :news, :shallow => true
project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id'
-
+ project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
+ project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
+ project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
+ project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
+ project.resources :wiki, :except => [:new, :create], :member => {
+ :rename => [:get, :post],
+ :history => :get,
+ :preview => :any,
+ :protect => :post,
+ :add_attachment => :post
+ }, :collection => {
+ :export => :get,
+ :date_index => :get
+ }
+
end
# Destroy uses a get request to prompt the user before the actual DELETE request
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index 5bbeba9dc..4273dddd0 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -80,7 +80,7 @@ class WikiControllerTest < ActionController::TestCase
def test_create_page
@request.session[:user_id] = 2
- post :update, :project_id => 1,
+ put :update, :project_id => 1,
:id => 'New page',
:content => {:comments => 'Created the page',
:text => "h1. New page\n\nThis is a new page",
@@ -96,7 +96,7 @@ class WikiControllerTest < ActionController::TestCase
@request.session[:user_id] = 2
assert_difference 'WikiPage.count' do
assert_difference 'Attachment.count' do
- post :update, :project_id => 1,
+ put :update, :project_id => 1,
:id => 'New page',
:content => {:comments => 'Created the page',
:text => "h1. New page\n\nThis is a new page",
diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb
index 011193ea0..4624e7867 100644
--- a/test/integration/routing_test.rb
+++ b/test/integration/routing_test.rb
@@ -322,12 +322,13 @@ class RoutingTest < ActionController::IntegrationTest
should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'date_index', :project_id => '567'
should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'export', :project_id => '567'
- should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'update', :project_id => '567', :id => 'my_page'
should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :project_id => '567', :id => 'CookBook_documentation'
should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida'
should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :project_id => '22', :id => 'ladida'
should_route :post, "/projects/22/wiki/ladida/add_attachment", :controller => 'wiki', :action => 'add_attachment', :project_id => '22', :id => 'ladida'
+ should_route :put, "/projects/567/wiki/my_page", :controller => 'wiki', :action => 'update', :project_id => '567', :id => 'my_page'
+
should_route :delete, "/projects/22/wiki/ladida", :controller => 'wiki', :action => 'destroy', :project_id => '22', :id => 'ladida'
end
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index 83a508594..282a4cced 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -253,8 +253,8 @@ RAW
'[[Unknown page]]' => 'Unknown page',
'[[Unknown page|404]]' => '404',
# link to another project wiki
- '[[onlinestore:]]' => 'onlinestore',
- '[[onlinestore:|Wiki]]' => 'Wiki',
+ '[[onlinestore:]]' => 'onlinestore',
+ '[[onlinestore:|Wiki]]' => 'Wiki',
'[[onlinestore:Start page]]' => 'Start page',
'[[onlinestore:Start page|Text]]' => 'Text',
'[[onlinestore:Unknown page]]' => 'Unknown page',