From c514dd6885af45ebb38d00ba4a8c61b1ea206d2c Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Thu, 28 Oct 2010 21:25:38 +0000 Subject: Refactor: convert WikiController to a REST resource git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4303 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/wiki_controller.rb | 4 ++-- app/helpers/application_helper.rb | 3 ++- app/views/projects/settings/_versions.rhtml | 2 +- app/views/wiki/date_index.html.erb | 2 +- app/views/wiki/edit.rhtml | 4 ++-- app/views/wiki/history.rhtml | 2 +- app/views/wiki/show.rhtml | 10 +++++----- 7 files changed, 14 insertions(+), 13 deletions(-) (limited to 'app') 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 @@ <%=h version.description %> <%= l("version_status_#{version.status}") %> <%=h format_version_sharing(version.sharing) %> - <%= link_to(h(version.wiki_page_title), :controller => 'wiki', :id => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %> + <%= link_to(h(version.wiki_page_title), :controller => 'wiki', :action => 'show', :id => Wiki.titleize(version.wiki_page_title), :project_id => @project) unless version.wiki_page_title.blank? || @project.wiki.nil? %> <% if version.project == @project %> <%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %> diff --git a/app/views/wiki/date_index.html.erb b/app/views/wiki/date_index.html.erb index 01385bc49..65af6084e 100644 --- a/app/views/wiki/date_index.html.erb +++ b/app/views/wiki/date_index.html.erb @@ -12,7 +12,7 @@

<%= format_date(date) %>

<% end %> diff --git a/app/views/wiki/edit.rhtml b/app/views/wiki/edit.rhtml index a140e2088..2615075e2 100644 --- a/app/views/wiki/edit.rhtml +++ b/app/views/wiki/edit.rhtml @@ -1,6 +1,6 @@

<%=h @page.pretty_title %>

-<% form_for :content, @content, :url => {:action => 'update', :id => @page.title}, :html => {:multipart => true, :id => 'wiki_form'} do |f| %> +<% form_for :content, @content, :url => {:action => 'update', :id => @page.title}, :html => {:method => :put, :multipart => true, :id => 'wiki_form'} do |f| %> <%= f.hidden_field :version %> <%= error_messages_for 'content' %> @@ -11,7 +11,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 ver.version, :action => 'show', :id => @page.title, :version => ver.version %> + <%= link_to ver.version, :action => 'show', :id => @page.title, :project_id => @page.project, :version => ver.version %> <%= radio_button_tag('version', ver.version, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('cbto-#{line_num+1}').checked=true;") if show_diff && (line_num < @versions.size) %> <%= radio_button_tag('version_from', ver.version, (line_num==2), :id => "cbto-#{line_num}") if show_diff && (line_num > 1) %> <%= format_time(ver.updated_on) %> diff --git a/app/views/wiki/show.rhtml b/app/views/wiki/show.rhtml index 173ac9ee2..9b2f2de28 100644 --- a/app/views/wiki/show.rhtml +++ b/app/views/wiki/show.rhtml @@ -11,15 +11,15 @@ <%= link_to_if_authorized(l(:label_history), {:action => 'history', :id => @page.title}, :class => 'icon icon-history') %> -<%= breadcrumb(@page.ancestors.reverse.collect {|parent| link_to h(parent.pretty_title), {:id => parent.title}}) %> +<%= breadcrumb(@page.ancestors.reverse.collect {|parent| link_to h(parent.pretty_title), {:id => parent.title, :project_id => parent.project}}) %> <% if @content.version != @page.content.version %>

- <%= 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 %> -- cgit v1.2.3