| 90 |
90 |
def link_to_attachment(attachment, options={})
|
| 91 |
91 |
text = options.delete(:text) || attachment.filename
|
| 92 |
92 |
action = options.delete(:download) ? 'download' : 'show'
|
|
93 |
only_path = options.key?(:only_path) ? options.delete(:only_path) : true
|
| 93 |
94 |
|
| 94 |
|
link_to(h(text), {:controller => 'attachments', :action => action, :id => attachment, :filename => attachment.filename }, options)
|
|
95 |
link_to(h(text), {:only_path => only_path, :controller => 'attachments', :action => action, :id => attachment, :filename => attachment.filename }, options)
|
| 95 |
96 |
end
|
| 96 |
97 |
|
| 97 |
98 |
# Generates a link to a SCM revision
|
| ... | ... | |
| 99 |
100 |
# * :text - Link text (default to the formatted revision)
|
| 100 |
101 |
def link_to_revision(revision, project, options={})
|
| 101 |
102 |
text = options.delete(:text) || format_revision(revision)
|
| 102 |
|
|
| 103 |
|
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision}, :title => l(:label_revision_id, revision))
|
|
103 |
title = options.delete(:title) || l(:label_revision_id, revision)
|
|
104 |
only_path = options.key?(:only_path) ? options.delete(:only_path) : true
|
|
105 |
|
|
106 |
link_to(text, {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => revision},
|
|
107 |
:title => title,
|
|
108 |
:class => 'changeset')
|
| 104 |
109 |
end
|
| 105 |
110 |
|
| 106 |
111 |
def toggle_link(name, id, options={})
|
| ... | ... | |
| 557 |
562 |
if esc.nil?
|
| 558 |
563 |
if prefix.nil? && sep == 'r'
|
| 559 |
564 |
if project && (changeset = project.changesets.find_by_revision(identifier))
|
| 560 |
|
link = link_to("r#{identifier}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision},
|
| 561 |
|
:class => 'changeset',
|
|
565 |
link = link_to_revision(changeset.revision, project,
|
|
566 |
:only_path => only_path,
|
|
567 |
:text => "r#{identifier}",
|
| 562 |
568 |
:title => truncate_single_line(changeset.comments, :length => 100))
|
| 563 |
569 |
end
|
| 564 |
570 |
elsif sep == '#'
|
| ... | ... | |
| 630 |
636 |
when 'attachment'
|
| 631 |
637 |
attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
|
| 632 |
638 |
if attachments && attachment = attachments.detect {|a| a.filename == name }
|
| 633 |
|
link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment},
|
| 634 |
|
:class => 'attachment'
|
|
639 |
link = link_to_attachment(attachment,
|
|
640 |
:only_path => only_path,
|
|
641 |
:text => attachment.filename,
|
|
642 |
:download => true,
|
|
643 |
:class => 'attachment')
|
| 635 |
644 |
end
|
| 636 |
645 |
when 'project'
|
| 637 |
646 |
if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}])
|