OSDN Git Service

Download link for binary
authorDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>
Thu, 15 Dec 2011 06:42:24 +0000 (08:42 +0200)
committerDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>
Thu, 15 Dec 2011 06:42:24 +0000 (08:42 +0200)
app/assets/images/download.png [new file with mode: 0644]
app/decorators/tree_decorator.rb
app/views/projects/_form.html.haml
app/views/refs/_tree_file.html.haml

diff --git a/app/assets/images/download.png b/app/assets/images/download.png
new file mode 100644 (file)
index 0000000..50f672c
Binary files /dev/null and b/app/assets/images/download.png differ
index 11af972..c2a640f 100644 (file)
@@ -32,4 +32,13 @@ class TreeDecorator < ApplicationDecorator
   def history_path
     h.project_commits_path(project, :path => path, :ref => ref)
   end
+
+  def mb_size
+    size = (tree.size / 1024)
+    if size < 1024
+      "#{size} KB" 
+    else 
+      "#{size/1024} MB"
+    end
+  end
 end
index 0f4f108..254563b 100644 (file)
@@ -34,7 +34,7 @@
           %td= f.label :default_branch, "Default Branch"
           %td= f.select(:default_branch, @project.heads.map(&:name), {}, :style => "width:300px;")
 
-      %tr
+      -#%tr
         %td= f.label :tag_list
         %td= f.text_area :tag_list, :placeholder => "project tags", :style => "height:50px", :id => :tag_field
       %tr
index 51264e3..fdc2469 100644 (file)
     .view_file_content_image
       %img{ :src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
   - else
-    %p
-      %center No preview for this file type
-
+    %center
+      = link_to blob_project_ref_path(@project, @ref, :path => params[:path] ) do 
+        %div
+          %br
+          = image_tag "download.png", :width => 64
+          %h3 
+            Download (#{file.mb_size})