Skip to content

Commit

Permalink
Refactor: change :id on WikiController to use :project_id
Browse files Browse the repository at this point in the history
Using :id to track projects on non-project controllers is confusing and
makes routing with resources difficult.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4265 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
edavis10 committed Oct 20, 2010
1 parent c058bc2 commit d3381fb
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 81 deletions.
14 changes: 7 additions & 7 deletions app/controllers/wiki_controller.rb
Expand Up @@ -79,7 +79,7 @@ def edit
attachments = Attachment.attach_files(@page, params[:attachments])
render_attachment_warning_if_needed(@page)
# don't save if text wasn't changed
redirect_to :action => 'index', :id => @project, :page => @page.title
redirect_to :action => 'index', :project_id => @project, :page => @page.title
return
end
#@content.text = params[:content][:text]
Expand All @@ -91,7 +91,7 @@ def edit
attachments = Attachment.attach_files(@page, params[:attachments])
render_attachment_warning_if_needed(@page)
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
redirect_to :action => 'index', :id => @project, :page => @page.title
redirect_to :action => 'index', :project_id => @project, :page => @page.title
end
end
rescue ActiveRecord::StaleObjectError
Expand All @@ -107,13 +107,13 @@ def rename
@original_title = @page.pretty_title
if request.post? && @page.update_attributes(params[:wiki_page])
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'index', :id => @project, :page => @page.title
redirect_to :action => 'index', :project_id => @project, :page => @page.title
end
end

def protect
@page.update_attribute :protected, params[:protected]
redirect_to :action => 'index', :id => @project, :page => @page.title
redirect_to :action => 'index', :project_id => @project, :page => @page.title
end

# show page history
Expand Down Expand Up @@ -166,7 +166,7 @@ def destroy
end
end
@page.destroy
redirect_to :action => 'page_index', :id => @project
redirect_to :action => 'page_index', :project_id => @project
end

# Export wiki to a single html file
Expand All @@ -176,7 +176,7 @@ def export
export = render_to_string :action => 'export_multiple', :layout => false
send_data(export, :type => 'text/html', :filename => "wiki.html")
else
redirect_to :action => 'index', :id => @project, :page => nil
redirect_to :action => 'index', :project_id => @project, :page => nil
end
end

Expand Down Expand Up @@ -210,7 +210,7 @@ def add_attachment
private

def find_wiki
@project = Project.find(params[:id])
@project = Project.find(params[:project_id])
@wiki = @project.wiki
render_404 unless @wiki
rescue ActiveRecord::RecordNotFound
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Expand Up @@ -182,7 +182,7 @@ def render_page_hierarchy(pages, node=nil)
content << "<ul class=\"pages-hierarchy\">\n"
pages[node].each do |page|
content << "<li>"
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'index', :id => page.project, :page => page.title},
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'index', :project_id => page.project, :page => page.title},
:title => (page.respond_to?(:updated_on) ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil))
content << "\n" + render_page_hierarchy(pages, page.id) if pages[page.id]
content << "</li>\n"
Expand Down Expand Up @@ -551,7 +551,7 @@ def parse_wiki_links(text, project, obj, attr, only_path, options)
when :local; "#{title}.html"
when :anchor; "##{title}" # used for single-file wiki export
else
url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :id => link_project, :page => Wiki.titleize(page), :anchor => anchor)
url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :project_id => link_project, :page => Wiki.titleize(page), :anchor => anchor)
end
link_to((title || page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new')))
else
Expand Down
2 changes: 1 addition & 1 deletion app/views/wiki/annotate.rhtml
Expand Up @@ -18,7 +18,7 @@
<% @annotate.lines.each do |line| -%>
<tr class="bloc-<%= colors[line[0]] %>">
<th class="line-num"><%= line_num %></th>
<td class="revision"><%= link_to line[0], :controller => 'wiki', :action => 'index', :id => @project, :page => @page.title, :version => line[0] %></td>
<td class="revision"><%= link_to line[0], :controller => 'wiki', :action => 'index', :project_id => @project, :page => @page.title, :version => line[0] %></td>
<td class="author"><%= h(line[1]) %></td>
<td class="line-code"><pre><%=h line[2] %></pre></td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/wiki/destroy.rhtml
Expand Up @@ -15,5 +15,5 @@
</div>

<%= submit_tag l(:button_apply) %>
<%= link_to l(:button_cancel), :controller => 'wiki', :action => 'index', :id => @project, :page => @page.title %>
<%= link_to l(:button_cancel), :controller => 'wiki', :action => 'index', :project_id => @project, :page => @page.title %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/wiki/edit.rhtml
Expand Up @@ -10,7 +10,7 @@

<p><%= submit_tag l(:button_save) %>
<%= link_to_remote l(:label_preview),
{ :url => { :controller => 'wiki', :action => 'preview', :id => @project, :page => @page.title },
{ :url => { :controller => 'wiki', :action => 'preview', :project_id => @project, :page => @page.title },
:method => 'post',
:update => 'preview',
:with => "Form.serialize('wiki_form')",
Expand Down
1 change: 1 addition & 0 deletions app/views/wiki/history.rhtml
Expand Up @@ -3,6 +3,7 @@
<h3><%= l(:label_history) %></h3>

<% form_tag({:action => "diff"}, :method => :get) do %>
<%= hidden_field_tag('project_id', h(@project.to_param)) %>
<table class="list">
<thead><tr>
<th>#</th>
Expand Down
20 changes: 10 additions & 10 deletions config/routes.rb
Expand Up @@ -29,18 +29,18 @@
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/:id/wiki/export', :action => 'export'
wiki_views.connect 'projects/:id/wiki/page_index', :action => 'page_index'
wiki_views.connect 'projects/:id/wiki/date_index', :action => 'date_index'
wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history'
wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff'
wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate'
wiki_views.connect 'projects/:project_id/wiki/export', :action => 'export'
wiki_views.connect 'projects/:project_id/wiki/page_index', :action => 'page_index'
wiki_views.connect 'projects/:project_id/wiki/date_index', :action => 'date_index'
wiki_views.connect 'projects/:project_id/wiki/:page', :action => 'index', :page => nil
wiki_views.connect 'projects/:project_id/wiki/:page/edit', :action => 'edit'
wiki_views.connect 'projects/:project_id/wiki/:page/rename', :action => 'rename'
wiki_views.connect 'projects/:project_id/wiki/:page/history', :action => 'history'
wiki_views.connect 'projects/:project_id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff'
wiki_views.connect 'projects/:project_id/wiki/:page/annotate/:version', :action => 'annotate'
end

wiki_routes.connect 'projects/:id/wiki/:page/:action',
wiki_routes.connect 'projects/:project_id/wiki/:page/:action',
:action => /edit|rename|destroy|preview|protect/,
:conditions => {:method => :post}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine.rb
Expand Up @@ -195,7 +195,7 @@
menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar
menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural
menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil },
menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil }, :param => :project_id,
:if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
:if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
Expand Down

0 comments on commit d3381fb

Please sign in to comment.