@@ -0,0 +1,15 | |||
|
1 | <h2><%=h @attachment.filename %></h2> | |
|
2 | ||
|
3 | <div class="attachments"> | |
|
4 | <p><%= h("#{@attachment.description} - ") unless @attachment.description.blank? %> | |
|
5 | <span class="author"><%= @attachment.author %>, <%= format_time(@attachment.created_on) %></span></p> | |
|
6 | <p><%= link_to l(:button_download), {:controller => 'attachments', :action => 'download', :id => @attachment } -%> | |
|
7 | <span class="size">(<%= number_to_human_size @attachment.filesize %>)</span></p> | |
|
8 | ||
|
9 | </div> | |
|
10 | | |
|
11 | <%= render :partial => 'common/diff', :locals => {:diff => @diff, :diff_type => @diff_type} %> | |
|
12 | ||
|
13 | <% content_for :header_tags do -%> | |
|
14 | <%= stylesheet_link_tag "scm" -%> | |
|
15 | <% end -%> |
@@ -19,19 +19,26 class AttachmentsController < ApplicationController | |||
|
19 | 19 | layout 'base' |
|
20 | 20 | before_filter :find_project, :check_project_privacy |
|
21 | 21 | |
|
22 | def show | |
|
23 | if @attachment.is_diff? | |
|
24 | @diff = File.new(@attachment.diskfile, "rb").read | |
|
25 | render :action => 'diff' | |
|
26 | else | |
|
27 | download | |
|
28 | end | |
|
29 | end | |
|
30 | ||
|
22 | 31 | def download |
|
23 | 32 | # images are sent inline |
|
24 | 33 | send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), |
|
25 | 34 | :type => @attachment.content_type, |
|
26 | 35 | :disposition => (@attachment.image? ? 'inline' : 'attachment') |
|
27 | rescue | |
|
28 | # in case the disk file was deleted | |
|
29 | render_404 | |
|
30 | 36 | end |
|
31 | 37 | |
|
32 | 38 | private |
|
33 | 39 | def find_project |
|
34 | 40 | @attachment = Attachment.find(params[:id]) |
|
41 | render_404 and return false unless File.readable?(@attachment.diskfile) | |
|
35 | 42 | @project = @attachment.project |
|
36 | 43 | rescue |
|
37 | 44 | render_404 |
@@ -22,4 +22,8 module AttachmentsHelper | |||
|
22 | 22 | render :partial => 'attachments/links', :locals => {:attachments => attachments, :options => options} |
|
23 | 23 | end |
|
24 | 24 | end |
|
25 | ||
|
26 | def to_utf8(str) | |
|
27 | str | |
|
28 | end | |
|
25 | 29 | end |
@@ -91,7 +91,7 module IssuesHelper | |||
|
91 | 91 | old_value = content_tag("strike", old_value) if detail.old_value and (!detail.value or detail.value.empty?) |
|
92 | 92 | if detail.property == 'attachment' && !value.blank? && Attachment.find_by_id(detail.prop_key) |
|
93 | 93 | # Link to the attachment if it has not been removed |
|
94 |
value = link_to(value, :controller => 'attachments', :action => ' |
|
|
94 | value = link_to(value, :controller => 'attachments', :action => 'show', :id => detail.prop_key) | |
|
95 | 95 | else |
|
96 | 96 | value = content_tag("i", h(value)) if value |
|
97 | 97 | end |
@@ -88,6 +88,10 class Attachment < ActiveRecord::Base | |||
|
88 | 88 | self.filename =~ /\.(jpe?g|gif|png)$/i |
|
89 | 89 | end |
|
90 | 90 | |
|
91 | def is_diff? | |
|
92 | self.filename =~ /\.(patch|diff)$/i | |
|
93 | end | |
|
94 | ||
|
91 | 95 | private |
|
92 | 96 | def sanitize_filename(value) |
|
93 | 97 | # get only the filename, not the whole path |
@@ -1,6 +1,6 | |||
|
1 | 1 | <div class="attachments"> |
|
2 | 2 | <% for attachment in attachments %> |
|
3 |
<p><%= link_to attachment.filename, {:controller => 'attachments', :action => ' |
|
|
3 | <p><%= link_to attachment.filename, {:controller => 'attachments', :action => 'show', :id => attachment }, :class => 'icon icon-attachment' -%> | |
|
4 | 4 | <%= h(" - #{attachment.description}") unless attachment.description.blank? %> |
|
5 | 5 | <span class="size">(<%= number_to_human_size attachment.filesize %>)</span> |
|
6 | 6 | <% if options[:delete_url] %> |
@@ -31,6 +31,8 ActionController::Routing::Routes.draw do |map| | |||
|
31 | 31 | omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate' |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | map.connect 'attachments/:id', :controller => 'attachments', :action => 'show' | |
|
35 | ||
|
34 | 36 | # Allow downloading Web Service WSDL as a file with an extension |
|
35 | 37 | # instead of a file named 'wsdl' |
|
36 | 38 | map.connect ':controller/service.wsdl', :action => 'wsdl' |
General Comments 0
You need to be logged in to leave comments.
Login now