[ARVADOS] created: c9f04f87062eec4097dc74dcc79b364fb905851c

git at public.curoverse.com git at public.curoverse.com
Tue Apr 15 11:12:24 EDT 2014


        at  c9f04f87062eec4097dc74dcc79b364fb905851c (commit)


commit c9f04f87062eec4097dc74dcc79b364fb905851c
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Apr 15 10:58:13 2014 -0400

    Added thumbnail option to #link_to_if_arvados_object, enabled on pipeline instance and job pages.
    Refactored #is_image and #file_path to CollectionsHelper.

diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index 26c3074..b4d1693 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -78,6 +78,19 @@ module ApplicationHelper
             link_name += ' <span class="label label-info">' + html_escape(tag.name) + '</span>'
           end
         end
+        if opts[:thumbnail] and resource_class == Collection
+          maximg = 3
+          Collection.where(uuid: link_uuid).each do |c|
+            c.files.each do |file|
+              if CollectionsHelper::is_image file[1]
+                link_name += " "
+                link_name += image_tag "#{url_for c}/#{CollectionsHelper::file_path file}", style: "height: 4em; width: auto"
+                maximg -= 1
+              end
+              break if maximg == 0
+            end
+          end
+        end
       end
       style_opts[:class] = (style_opts[:class] || '') + ' nowrap'
       if opts[:no_link]
diff --git a/apps/workbench/app/helpers/collections_helper.rb b/apps/workbench/app/helpers/collections_helper.rb
index 7b548df..1f867a6 100644
--- a/apps/workbench/app/helpers/collections_helper.rb
+++ b/apps/workbench/app/helpers/collections_helper.rb
@@ -8,4 +8,16 @@ module CollectionsHelper
   def self.match(uuid)
     /^([a-f0-9]{32})(\+[0-9]+)?(\+.*?)?(\/.*)?$/.match(uuid.to_s)
   end
+
+  def self.is_image file
+    /\.(jpg|jpeg|gif|png|svg)$/i.match(file)
+  end
+
+  def self.file_path file
+    f0 = file[0]
+    f0 = '' if f0 == '.'
+    f0 = f0[2..-1] if f0[0..1] == './'
+    f0 += '/' if not f0.empty?
+    file_path = "#{f0}#{file[1]}"
+  end
 end
diff --git a/apps/workbench/app/views/application/_arvados_attr_value.html.erb b/apps/workbench/app/views/application/_arvados_attr_value.html.erb
index 80dfa33..3efca72 100644
--- a/apps/workbench/app/views/application/_arvados_attr_value.html.erb
+++ b/apps/workbench/app/views/application/_arvados_attr_value.html.erb
@@ -12,7 +12,7 @@
       <% elsif attr == 'uuid' %>
         <%= link_to_if_arvados_object attrvalue, {referring_attr: attr, referring_object: obj, with_class_name: false, friendly_name: false} %>
       <% else %>
-        <%= link_to_if_arvados_object attrvalue, {referring_attr: attr, referring_object: obj, with_class_name: true, friendly_name: true} %>
+        <%= link_to_if_arvados_object attrvalue, {referring_attr: attr, referring_object: obj, with_class_name: true, friendly_name: true, thumbnail: true} %>
       <% end %>
       <!--
       <% if resource_class_for_uuid(attrvalue, {referring_object: obj, referring_attr: attr}) %>
diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb
index 4bd1821..c3a2c78 100644
--- a/apps/workbench/app/views/collections/_show_files.html.erb
+++ b/apps/workbench/app/views/collections/_show_files.html.erb
@@ -23,11 +23,7 @@
     </tr>
   </thead><tbody>
     <% if @object then @object.files.sort_by{|f|[f[0],f[1]]}.each do |file| %>
-      <% f0 = file[0] %>
-      <% f0 = '' if f0 == '.' %>
-      <% f0 = f0[2..-1] if f0[0..1] == './' %>
-      <% f0 += '/' if not f0.empty? %>
-      <% file_path = "#{f0}#{file[1]}" %>
+      <% file_path = CollectionsHelper::file_path file %>
       <tr>
         <td>
           <%= check_box_tag 'uuids[]', @object.uuid+'/'+file_path, false, {
@@ -43,13 +39,13 @@
         </td>
 
       <td>
-        <%= link_to((if /\.(jpg|jpeg|gif|png|svg)$/i.match(file[1]) then
+        <%= link_to (if CollectionsHelper::is_image file[1]
                        image_tag "#{url_for @object}/#{file_path}", class: "file-list-inline-image"
                      else
                        file[1]
                      end),
-                    {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'},
-                    {title: file_path}) %>
+            {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'},
+            {title: file_path} %>
       </td>
 
         <td style="text-align:right">
diff --git a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
index 119415b..a33a393 100644
--- a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
@@ -60,7 +60,7 @@
         <%= render(partial: 'job_status_label',
                                locals: { :j => pj[:job] }) %>
       </td><td>
-        <%= link_to_if_arvados_object pj[:output] %>
+        <%= link_to_if_arvados_object pj[:output], {:thumbnail => true} %>
       </td>
     </tr>
     <% end %>

commit 1b7d5cef1b7890994826a44102b589124a2a2340
Merge: 7a98271 d66cd99
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Apr 15 10:04:54 2014 -0400

    Merge branch '2376-show-collection-tags-everywhere' into 1971-show-image-thumbnails
    
    Conflicts:
    	apps/workbench/app/controllers/actions_controller.rb
    	apps/workbench/app/views/collections/_show_files.html.erb


commit 7a98271d94163cdc4afa5bfcf275db353bc062d2
Merge: 6d59f29 bb45025
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Apr 15 10:02:02 2014 -0400

    Merge branch 'master' into 1971-show-image-thumbnails
    
    Conflicts:
    	apps/workbench/app/views/collections/_show_files.html.erb

diff --cc apps/workbench/app/views/collections/_show_files.html.erb
index 15daaf7,956958e..a56e885
--- a/apps/workbench/app/views/collections/_show_files.html.erb
+++ b/apps/workbench/app/views/collections/_show_files.html.erb
@@@ -1,10 -1,3 +1,10 @@@
 +<% content_for :css do %>
 +.file-list-inline-image {
 +  width: 50%;
-   height: auto; 
++  height: auto;
 +}
 +<% end %>
 +
  <table class="table table-condensed table-fixedlayout">
    <colgroup>
      <col width="4%" />
@@@ -23,42 -16,38 +23,44 @@@
      </tr>
    </thead><tbody>
      <% if @object then @object.files.sort_by{|f|[f[0],f[1]]}.each do |file| %>
-     <% file_path = "#{file[0]}/#{file[1]}" %>
-     <tr>
-       <td>
-         <% fp2 = file_path[2..-1] if file_path[0..1] == './' %>
-         <% fp2 ||= file_path %>
- <%= check_box_tag 'uuids[]', @object.uuid+file_path, false, {
-   :class => 'persistent-selection', 
-   :friendly_type => "File",
-   :friendly_name => "#{@object.uuid}/#{fp2}",
-   :href => "#{url_for controller: 'collections', action: 'show', id: @object.uuid }/#{file_path}" 
-       } %>
-       </td>
-       <td>
-         <%= file[0] %>
-       </td>
+       <% f0 = file[0] %>
+       <% f0 = '' if f0 == '.' %>
+       <% f0 = f0[2..-1] if f0[0..1] == './' %>
+       <% f0 += '/' if not f0.empty? %>
+       <% file_path = "#{f0}#{file[1]}" %>
+       <tr>
+         <td>
+           <%= check_box_tag 'uuids[]', @object.uuid+'/'+file_path, false, {
 -                :class => 'persistent-selection', 
++                :class => 'persistent-selection',
+                 :friendly_type => "File",
+                 :friendly_name => "#{@object.uuid}/#{file_path}",
 -                :href => "#{url_for controller: 'collections', action: 'show', id: @object.uuid }/#{file_path}" 
++                :href => "#{url_for controller: 'collections', action: 'show', id: @object.uuid }/#{file_path}"
+               } %>
+         </td>
+         <td>
+           <%= file[0] %>
+         </td>
  
 -        <td>
 -          <%= link_to file[1], {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, {title: 'View in browser'} %>
 -        </td>
 +      <td>
 +        <%= link_to((if /\.(jpg|jpeg|gif|png|svg)$/i.match(file[1]) then
 +                       image_tag "#{url_for @object}/#{file_path}", class: "file-list-inline-image"
 +                     else
 +                       file[1]
-                      end), 
-                     {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, 
++                     end),
++                    {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'},
 +                    {title: file_path}) %>
 +      </td>
  
-       <td style="text-align:right">
-         <%= raw(human_readable_bytes_html(file[2])) %>
-       </td>
+         <td style="text-align:right">
+           <%= raw(human_readable_bytes_html(file[2])) %>
+         </td>
  
-       <td>
-         <div style="display:inline-block">
-           <%= link_to raw('<i class="glyphicon glyphicon-download-alt"></i>'), {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'attachment'}, {class: 'btn btn-info btn-sm', title: 'Download'} %>
-         </div>
-       </td>
-     </tr>
+         <td>
+           <div style="display:inline-block">
+             <%= link_to raw('<i class="glyphicon glyphicon-download-alt"></i>'), {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'attachment'}, {class: 'btn btn-info btn-sm', title: 'Download'} %>
+           </div>
+         </td>
+       </tr>
      <% end; end %>
    </tbody>
  </table>

commit 6d59f29ba37c608e4b01b27a2fa78bc065fdc2a6
Merge: b6ee74d dc97d88
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Fri Mar 7 13:43:51 2014 -0500

    Merge remote-tracking branch 'origin/master' into 1971-show-image-thumbnails


commit b6ee74d757dc98b558dfdb420be46d0b954dc446
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Thu Mar 6 08:50:46 2014 -0500

    Made regex case-insensitive and added svg to list of extensions.

diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb
index d1c4b80..15daaf7 100644
--- a/apps/workbench/app/views/collections/_show_files.html.erb
+++ b/apps/workbench/app/views/collections/_show_files.html.erb
@@ -40,7 +40,7 @@
       </td>
 
       <td>
-        <%= link_to((if /\.(jpg|jpeg|gif|png)$/.match(file[1]) then
+        <%= link_to((if /\.(jpg|jpeg|gif|png|svg)$/i.match(file[1]) then
                        image_tag "#{url_for @object}/#{file_path}", class: "file-list-inline-image"
                      else
                        file[1]

commit f7bec4b4fde3c9cdec0823719f4d0806ee27021a
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Wed Mar 5 17:09:03 2014 -0500

    Tested, works great.

diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb
index 357c841..d1c4b80 100644
--- a/apps/workbench/app/views/collections/_show_files.html.erb
+++ b/apps/workbench/app/views/collections/_show_files.html.erb
@@ -1,7 +1,7 @@
 <% content_for :css do %>
 .file-list-inline-image {
-  height: 4em; 
-  width: auto
+  width: 50%;
+  height: auto; 
 }
 <% end %>
 
@@ -46,7 +46,7 @@
                        file[1]
                      end), 
                     {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, 
-                    {title: 'View in browser'}) %>
+                    {title: file_path}) %>
       </td>
 
       <td style="text-align:right">

commit 7b3f8ace626fa8fe401742fd9b2a616d651d6c2b
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Mar 3 08:55:06 2014 -0500

    In theory this works but I need a keep server to test it.

diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb
index 08e0ff6..357c841 100644
--- a/apps/workbench/app/views/collections/_show_files.html.erb
+++ b/apps/workbench/app/views/collections/_show_files.html.erb
@@ -1,3 +1,10 @@
+<% content_for :css do %>
+.file-list-inline-image {
+  height: 4em; 
+  width: auto
+}
+<% end %>
+
 <table class="table table-condensed table-fixedlayout">
   <colgroup>
     <col width="4%" />
@@ -34,7 +41,7 @@
 
       <td>
         <%= link_to((if /\.(jpg|jpeg|gif|png)$/.match(file[1]) then
-                       image_tag "#{url_for @object}/#{file_path}"
+                       image_tag "#{url_for @object}/#{file_path}", class: "file-list-inline-image"
                      else
                        file[1]
                      end), 

commit 0d4ddf36fb71ecf7cc981c67c07584a3a7fcac46
Merge: 5f3de04 ac5a69c
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Mar 3 08:43:55 2014 -0500

    Merge branch '2049-run-job-from-workbench' into 1971-show-image-thumbnails


commit 5f3de04d46dd4aeec45731b4e5c479c689eee7b6
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Mar 3 08:43:12 2014 -0500

    Show images in files inline.

diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb
index 385af8a..9a50329 100644
--- a/apps/workbench/app/views/collections/_show_files.html.erb
+++ b/apps/workbench/app/views/collections/_show_files.html.erb
@@ -21,7 +21,13 @@
       </td>
 
       <td>
-        <%= link_to file[1], {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, {title: 'View in browser'} %>
+        <%= link_to((if /\.(jpg|jpeg|gif|png)$/.match(file[1]) then
+                       image_tag "#{url_for @object}/#{file_path}"
+                     else
+                       file[1]
+                     end), 
+                    {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, 
+                    {title: 'View in browser'}) %>
       </td>
 
       <td style="text-align:right">

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list