Skip to content

Commit

Permalink
Refactor: use :id instead of :page when linking to Wiki Pages
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4296 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
edavis10 committed Oct 27, 2010
1 parent 70bf070 commit e9efa5b
Show file tree
Hide file tree
Showing 66 changed files with 281 additions and 281 deletions.
22 changes: 11 additions & 11 deletions app/controllers/wiki_controller.rb
Expand Up @@ -49,7 +49,7 @@ def index

# display a page (in editing mode if it doesn't exist)
def show
page_title = params[:page]
page_title = params[:id]
@page = @wiki.find_or_new_page(page_title)
if @page.new_record?
if User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
Expand Down Expand Up @@ -82,7 +82,7 @@ def show

# edit an existing page or a new one
def edit
@page = @wiki.find_or_new_page(params[:page])
@page = @wiki.find_or_new_page(params[:id])
return render_403 unless editable?
@page.content = WikiContent.new(:page => @page) if @page.new_record?

Expand All @@ -101,7 +101,7 @@ def edit
verify :method => :post, :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[:page])
@page = @wiki.find_or_new_page(params[:id])
return render_403 unless editable?
@page.content = WikiContent.new(:page => @page) if @page.new_record?

Expand All @@ -114,7 +114,7 @@ def update
attachments = Attachment.attach_files(@page, params[:attachments])
render_attachment_warning_if_needed(@page)
# don't save if text wasn't changed
redirect_to :action => 'show', :project_id => @project, :page => @page.title
redirect_to :action => 'show', :project_id => @project, :id => @page.title
return
end
@content.attributes = params[:content]
Expand All @@ -124,7 +124,7 @@ def update
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 => 'show', :project_id => @project, :page => @page.title
redirect_to :action => 'show', :project_id => @project, :id => @page.title
end

rescue ActiveRecord::StaleObjectError
Expand All @@ -140,13 +140,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 => 'show', :project_id => @project, :page => @page.title
redirect_to :action => 'show', :project_id => @project, :id => @page.title
end
end

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

# show page history
Expand Down Expand Up @@ -210,7 +210,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 => 'show', :project_id => @project, :page => nil
redirect_to :action => 'show', :project_id => @project, :id => nil
end
end

Expand All @@ -219,7 +219,7 @@ def date_index
end

def preview
page = @wiki.find_page(params[:page])
page = @wiki.find_page(params[:id])
# page is nil when previewing a new page
return render_403 unless page.nil? || editable?(page)
if page
Expand All @@ -234,7 +234,7 @@ def add_attachment
return render_403 unless editable?
attachments = Attachment.attach_files(@page, params[:attachments])
render_attachment_warning_if_needed(@page)
redirect_to :action => 'show', :page => @page.title
redirect_to :action => 'show', :id => @page.title
end

private
Expand All @@ -249,7 +249,7 @@ def find_wiki

# Finds the requested page and returns a 404 error if it doesn't exist
def find_existing_page
@page = @wiki.find_page(params[:page])
@page = @wiki.find_page(params[:id])
render_404 if @page.nil?
end

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Expand Up @@ -177,7 +177,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 => 'show', :project_id => page.project, :page => page.title},
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id => 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 @@ -541,7 +541,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 => 'show', :project_id => link_project, :page => Wiki.titleize(page), :anchor => anchor)
url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project, :id => Wiki.titleize(page), :anchor => anchor)
end
link_to((title || page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new')))
else
Expand Down
10 changes: 5 additions & 5 deletions app/models/mailer.rb
Expand Up @@ -178,9 +178,9 @@ def wiki_content_added(wiki_content)
message_id wiki_content
recipients wiki_content.recipients
cc(wiki_content.page.wiki.watcher_recipients - recipients)
subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :page => wiki_content.page.pretty_title)}"
subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}"
body :wiki_content => wiki_content,
:wiki_content_url => url_for(:controller => 'wiki', :action => 'index', :id => wiki_content.project, :page => wiki_content.page.title)
:wiki_content_url => url_for(:controller => 'wiki', :action => 'index', :id => wiki_content.project, :id => wiki_content.page.title)
render_multipart('wiki_content_added', body)
end

Expand All @@ -195,10 +195,10 @@ def wiki_content_updated(wiki_content)
message_id wiki_content
recipients wiki_content.recipients
cc(wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients)
subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :page => wiki_content.page.pretty_title)}"
subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}"
body :wiki_content => wiki_content,
:wiki_content_url => url_for(:controller => 'wiki', :action => 'index', :id => wiki_content.project, :page => wiki_content.page.title),
:wiki_diff_url => url_for(:controller => 'wiki', :action => 'diff', :id => wiki_content.project, :page => wiki_content.page.title, :version => wiki_content.version)
:wiki_content_url => url_for(:controller => 'wiki', :action => 'index', :id => wiki_content.project, :id => wiki_content.page.title),
:wiki_diff_url => url_for(:controller => 'wiki', :action => 'diff', :id => wiki_content.project, :id => wiki_content.page.title, :version => wiki_content.version)
render_multipart('wiki_content_updated', body)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/wiki_content.rb
Expand Up @@ -54,7 +54,7 @@ class Version
:description => :comments,
:datetime => :updated_on,
:type => 'wiki-page',
:url => Proc.new {|o| {:controller => 'wiki', :action => 'show', :project_id => o.page.wiki.project, :page => o.page.title, :version => o.version}}
:url => Proc.new {|o| {:controller => 'wiki', :action => 'show', :project_id => o.page.wiki.project, :id => o.page.title, :version => o.version}}

acts_as_activity_provider :type => 'wiki_edits',
:timestamp => "#{WikiContent.versioned_table_name}.updated_on",
Expand Down
4 changes: 2 additions & 2 deletions app/models/wiki_page.rb
Expand Up @@ -28,7 +28,7 @@ class WikiPage < ActiveRecord::Base
acts_as_event :title => Proc.new {|o| "#{l(:label_wiki)}: #{o.title}"},
:description => :text,
:datetime => :created_on,
:url => Proc.new {|o| {:controller => 'wiki', :action => 'show', :project_id => o.wiki.project, :page => o.title}}
:url => Proc.new {|o| {:controller => 'wiki', :action => 'show', :project_id => o.wiki.project, :id => o.title}}

acts_as_searchable :columns => ['title', 'text'],
:include => [{:wiki => :project}, :content],
Expand Down Expand Up @@ -139,7 +139,7 @@ def parent_title=(t)
parent_page = t.blank? ? nil : self.wiki.find_page(t)
self.parent = parent_page
end

protected

def validate
Expand Down
2 changes: 1 addition & 1 deletion app/views/mailer/wiki_content_added.text.html.rhtml
@@ -1,3 +1,3 @@
<p><%= l(:mail_body_wiki_content_added, :page => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url),
<p><%= l(:mail_body_wiki_content_added, :id => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url),
:author => h(@wiki_content.author)) %><br />
<em><%=h @wiki_content.comments %></em></p>
2 changes: 1 addition & 1 deletion app/views/mailer/wiki_content_added.text.plain.rhtml
@@ -1,4 +1,4 @@
<%= l(:mail_body_wiki_content_added, :page => h(@wiki_content.page.pretty_title),
<%= l(:mail_body_wiki_content_added, :id => h(@wiki_content.page.pretty_title),
:author => h(@wiki_content.author)) %>
<%= @wiki_content.comments %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/mailer/wiki_content_updated.text.html.rhtml
@@ -1,4 +1,4 @@
<p><%= l(:mail_body_wiki_content_updated, :page => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url),
<p><%= l(:mail_body_wiki_content_updated, :id => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url),
:author => h(@wiki_content.author)) %><br />
<em><%=h @wiki_content.comments %></em></p>

Expand Down
2 changes: 1 addition & 1 deletion app/views/mailer/wiki_content_updated.text.plain.rhtml
@@ -1,4 +1,4 @@
<%= l(:mail_body_wiki_content_updated, :page => h(@wiki_content.page.pretty_title),
<%= l(:mail_body_wiki_content_updated, :id => h(@wiki_content.page.pretty_title),
:author => h(@wiki_content.author)) %>
<%= @wiki_content.comments %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/projects/settings/_versions.rhtml
Expand Up @@ -17,7 +17,7 @@
<td class="description"><%=h version.description %></td>
<td class="status"><%= l("version_status_#{version.status}") %></td>
<td class="sharing"><%=h format_version_sharing(version.sharing) %></td>
<td><%= link_to(h(version.wiki_page_title), :controller => 'wiki', :page => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %></td>
<td><%= 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? %></td>
<td class="buttons">
<% if version.project == @project %>
<%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/versions/show.rhtml
@@ -1,6 +1,6 @@
<div class="contextual">
<%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => @version}, :class => 'icon icon-edit' %>
<%= link_to_if_authorized(l(:button_edit_associated_wikipage, :page_title => @version.wiki_page_title), {:controller => 'wiki', :action => 'edit', :page => Wiki.titleize(@version.wiki_page_title)}, :class => 'icon icon-edit') unless @version.wiki_page_title.blank? || @project.wiki.nil? %>
<%= link_to_if_authorized(l(:button_edit_associated_wikipage, :page_title => @version.wiki_page_title), {:controller => 'wiki', :action => 'edit', :id => Wiki.titleize(@version.wiki_page_title)}, :class => 'icon icon-edit') unless @version.wiki_page_title.blank? || @project.wiki.nil? %>
<%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %>
</div>

Expand Down
2 changes: 1 addition & 1 deletion app/views/wiki/_sidebar.rhtml
Expand Up @@ -4,6 +4,6 @@

<h3><%= l(:label_wiki) %></h3>

<%= link_to l(:field_start_page), {:action => 'show', :page => nil} %><br />
<%= link_to l(:field_start_page), {:action => 'show', :id => nil} %><br />
<%= link_to l(:label_index_by_title), {:action => 'index'} %><br />
<%= link_to l(:label_index_by_date), {:action => 'date_index'} %><br />
8 changes: 4 additions & 4 deletions app/views/wiki/annotate.rhtml
@@ -1,12 +1,12 @@
<div class="contextual">
<%= link_to(l(:button_edit), {:action => 'edit', :page => @page.title}, :class => 'icon icon-edit') %>
<%= link_to(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %>
<%= link_to(l(:button_edit), {:action => 'edit', :id => @page.title}, :class => 'icon icon-edit') %>
<%= link_to(l(:label_history), {:action => 'history', :id => @page.title}, :class => 'icon icon-history') %>
</div>

<h2><%= @page.pretty_title %></h2>

<p>
<%= l(:label_version) %> <%= link_to @annotate.content.version, :action => 'show', :page => @page.title, :version => @annotate.content.version %>
<%= l(:label_version) %> <%= link_to @annotate.content.version, :action => 'show', :id => @page.title, :version => @annotate.content.version %>
<em>(<%= @annotate.content.author ? @annotate.content.author.name : "anonyme" %>, <%= format_time(@annotate.content.updated_on) %>)</em>
</p>

Expand All @@ -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 => 'show', :project_id => @project, :page => @page.title, :version => line[0] %></td>
<td class="revision"><%= link_to line[0], :controller => 'wiki', :action => 'show', :project_id => @project, :id => @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/date_index.html.erb
Expand Up @@ -12,7 +12,7 @@
<h3><%= format_date(date) %></h3>
<ul>
<% @pages_by_date[date].each do |page| %>
<li><%= link_to page.pretty_title, :action => 'show', :page => page.title %></li>
<li><%= link_to page.pretty_title, :action => 'show', :id => page.title %></li>
<% end %>
</ul>
<% end %>
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 => 'show', :project_id => @project, :page => @page.title %>
<%= link_to l(:button_cancel), :controller => 'wiki', :action => 'show', :project_id => @project, :id => @page.title %>
<% end %>
6 changes: 3 additions & 3 deletions app/views/wiki/diff.rhtml
@@ -1,14 +1,14 @@
<div class="contextual">
<%= link_to(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %>
<%= link_to(l(:label_history), {:action => 'history', :id => @page.title}, :class => 'icon icon-history') %>
</div>

<h2><%= @page.pretty_title %></h2>

<p>
<%= l(:label_version) %> <%= link_to @diff.content_from.version, :action => 'show', :page => @page.title, :version => @diff.content_from.version %>
<%= l(:label_version) %> <%= link_to @diff.content_from.version, :action => 'show', :id => @page.title, :version => @diff.content_from.version %>
<em>(<%= @diff.content_from.author ? @diff.content_from.author.name : "anonyme" %>, <%= format_time(@diff.content_from.updated_on) %>)</em>
&#8594;
<%= l(:label_version) %> <%= link_to @diff.content_to.version, :action => 'show', :page => @page.title, :version => @diff.content_to.version %>/<%= @page.content.version %>
<%= l(:label_version) %> <%= link_to @diff.content_to.version, :action => 'show', :id => @page.title, :version => @diff.content_to.version %>/<%= @page.content.version %>
<em>(<%= @diff.content_to.author ? @diff.content_to.author.name : "anonyme" %>, <%= format_time(@diff.content_to.updated_on) %>)</em>
</p>

Expand Down
4 changes: 2 additions & 2 deletions app/views/wiki/edit.rhtml
@@ -1,6 +1,6 @@
<h2><%=h @page.pretty_title %></h2>

<% form_for :content, @content, :url => {:action => 'update', :page => @page.title}, :html => {:multipart => true, :id => 'wiki_form'} do |f| %>
<% form_for :content, @content, :url => {:action => 'update', :id => @page.title}, :html => {:multipart => true, :id => 'wiki_form'} do |f| %>
<%= f.hidden_field :version %>
<%= error_messages_for 'content' %>

Expand All @@ -10,7 +10,7 @@

<p><%= submit_tag l(:button_save) %>
<%= link_to_remote l(:label_preview),
{ :url => { :controller => 'wiki', :action => 'preview', :project_id => @project, :page => @page.title },
{ :url => { :controller => 'wiki', :action => 'preview', :project_id => @project, :id => @page.title },
:method => 'post',
:update => 'preview',
:with => "Form.serialize('wiki_form')",
Expand Down
4 changes: 2 additions & 2 deletions app/views/wiki/history.rhtml
Expand Up @@ -19,13 +19,13 @@
<% line_num = 1 %>
<% @versions.each do |ver| %>
<tr class="<%= cycle("odd", "even") %>">
<td class="id"><%= link_to ver.version, :action => 'show', :page => @page.title, :version => ver.version %></td>
<td class="id"><%= link_to ver.version, :action => 'show', :id => @page.title, :version => ver.version %></td>
<td class="checkbox"><%= 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) %></td>
<td class="checkbox"><%= radio_button_tag('version_from', ver.version, (line_num==2), :id => "cbto-#{line_num}") if show_diff && (line_num > 1) %></td>
<td align="center"><%= format_time(ver.updated_on) %></td>
<td><%= link_to_user ver.author %></td>
<td><%=h ver.comments %></td>
<td align="center"><%= link_to l(:button_annotate), :action => 'annotate', :page => @page.title, :version => ver.version %></td>
<td align="center"><%= link_to l(:button_annotate), :action => 'annotate', :id => @page.title, :version => ver.version %></td>
</tr>
<% line_num += 1 %>
<% end %>
Expand Down

0 comments on commit e9efa5b

Please sign in to comment.