Patch #5554 ยป more_consistent_links.diff
| ../workspace/redmine/redmine-trunk/app/helpers/application_helper.rb (working copy) | ||
|---|---|---|
|
def link_to_attachment(attachment, options={})
|
||
|
text = options.delete(:text) || attachment.filename
|
||
|
action = options.delete(:download) ? 'download' : 'show'
|
||
|
only_path = options.key?(:only_path) ? options.delete(:only_path) : true
|
||
|
link_to(h(text), {:controller => 'attachments', :action => action, :id => attachment, :filename => attachment.filename }, options)
|
||
|
link_to(h(text), {:only_path => only_path, :controller => 'attachments', :action => action, :id => attachment, :filename => attachment.filename }, options)
|
||
|
end
|
||
|
# Generates a link to a SCM revision
|
||
| ... | ... | |
|
# * :text - Link text (default to the formatted revision)
|
||
|
def link_to_revision(revision, project, options={})
|
||
|
text = options.delete(:text) || format_revision(revision)
|
||
|
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision}, :title => l(:label_revision_id, revision))
|
||
|
title = options.delete(:title) || l(:label_revision_id, revision)
|
||
|
only_path = options.key?(:only_path) ? options.delete(:only_path) : true
|
||
|
|
||
|
link_to(text, {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => revision},
|
||
|
:title => title,
|
||
|
:class => 'changeset')
|
||
|
end
|
||
|
def toggle_link(name, id, options={})
|
||
| ... | ... | |
|
if esc.nil?
|
||
|
if prefix.nil? && sep == 'r'
|
||
|
if project && (changeset = project.changesets.find_by_revision(identifier))
|
||
|
link = link_to("r#{identifier}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision},
|
||
|
:class => 'changeset',
|
||
|
link = link_to_revision(changeset.revision, project,
|
||
|
:only_path => only_path,
|
||
|
:text => "r#{identifier}",
|
||
|
:title => truncate_single_line(changeset.comments, :length => 100))
|
||
|
end
|
||
|
elsif sep == '#'
|
||
| ... | ... | |
|
when 'attachment'
|
||
|
attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
|
||
|
if attachments && attachment = attachments.detect {|a| a.filename == name }
|
||
|
link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment},
|
||
|
:class => 'attachment'
|
||
|
link = link_to_attachment(attachment,
|
||
|
:only_path => only_path,
|
||
|
:text => attachment.filename,
|
||
|
:download => true,
|
||
|
:class => 'attachment')
|
||
|
end
|
||
|
when 'project'
|
||
|
if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}])
|
||