myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3326] branches/wf4ever: WFE-819 Download button


From: noreply
Subject: [myexperiment-hackers] [3326] branches/wf4ever: WFE-819 Download button
Date: Tue, 22 Jan 2013 15:32:22 +0000 (UTC)

Revision
3326
Author
stain
Date
2013-01-22 15:32:22 +0000 (Tue, 22 Jan 2013)

Log Message

WFE-819 Download button

.. including human-readable size and checksum formatting

Modified Paths

Diff

Modified: branches/wf4ever/app/controllers/packs_controller.rb (3325 => 3326)


--- branches/wf4ever/app/controllers/packs_controller.rb	2013-01-22 14:28:03 UTC (rev 3325)
+++ branches/wf4ever/app/controllers/packs_controller.rb	2013-01-22 15:32:22 UTC (rev 3326)
@@ -4,9 +4,11 @@
 # See license.txt for details.
 
 require 'wf4ever/transformation-client'
+require "rdf/vocab/foaf"
 
 class PacksController < ApplicationController
   include ApplicationHelper
+  include ActionView::Helpers::NumberHelper
   
   before_filter :login_required, :except => [:index, :show, :search, :items, :download, :statistics]
   
@@ -634,19 +636,33 @@
 
     session = ROSRS::Session.new(@pack.ro_uri, Conf.rodl_bearer_token)
 
+    @resource_path = params[:resource_path]
     @resuri = @pack.resolve_resource_uri(params[:resource_path])
-
+    manifest_creator = nil
     @pack.contributable_entries.manifest.query(address@hidden, nil, nil]).each do |statement|
 
       case statement.predicate.to_s
       when "http://purl.org/wf4ever/ro#name":     @manifest_name    = statement.object.to_s
       when "http://purl.org/dc/terms/created":    @manifest_created = Date.parse(statement.object.to_s)
-      when "http://purl.org/dc/terms/creator":    @manifest_creator = statement.object.to_s
-      when "http://purl.org/wf4ever/ro#checksum": @manifest_md5     = statement.object.to_s
-      when "http://purl.org/wf4ever/ro#filesize": @manifest_size    = statement.object.to_s.to_i
+      when "http://purl.org/dc/terms/creator":    manifest_creator = statement.object.to_s
+      when "http://purl.org/wf4ever/ro#checksum": @manifest_md5     = statement.object.to_s.sub("urn:MD5:", "")
+      when "http://purl.org/wf4ever/ro#filesize": begin
+        @manifest_size    = statement.object.to_s.to_i
+        @manifest_size_human = number_to_human_size(@manifest_size)
+        end
       end
+    end
 
-    end
+    # TODO: Find a nicer way to extract creator's foaf:name
+    @manifest_creator = nil
+    if manifest_creator
+      ## Silly fallback
+      @manifest_creator = "(unknown name)"
+      @pack.contributable_entries.manifest.query([manifest_creator, RDF::FOAF.name, nil]).each do |statement|
+        @manifest_creator = statement.object.to_s
+      end
+    end  
+    
   end
   
 

Modified: branches/wf4ever/app/views/packs/resource_show.rhtml (3325 => 3326)


--- branches/wf4ever/app/views/packs/resource_show.rhtml	2013-01-22 14:28:03 UTC (rev 3325)
+++ branches/wf4ever/app/views/packs/resource_show.rhtml	2013-01-22 15:32:22 UTC (rev 3326)
@@ -15,30 +15,29 @@
 <table class="simple">
 
   <tr>
-    <td>Name</td>
-    <td><%=h @manifest_name -%></td>
+    <td>Path</td>
+    <td><%=h @resource_path -%></td>    
   </tr>
 
   <tr>
-    <td>Size</td>
-    <td><%=h @manifest_size -%></td>
+    <td>URI</td>
+    <td><%= link_to @resuri.to_s, @resuri.to_s, :rel => 'nofollow' -%>
   </tr>
 
+  
+
+  <% if @manifest_creator %>
   <tr>
     <td>Creator</td>
     <td><%=h @manifest_creator -%></td>
   </tr>
+  <% end %>
 
   <tr>
     <td>Created at</td>
     <td><%=h @manifest_created -%></td>
   </tr>
 
-  <tr>
-    <td>MD5</td>
-    <td><%=h @manifest_md5 -%></td>
-  </tr>
-
 </table>
 
 <h2>Annotations specific to this resource</h2>
@@ -67,6 +66,28 @@
 
 </table>
 
+<div class="download">
+	<h3>
+				<%= info_icon_with_tooltip("This section provides links to the download(s) for this File") %>
+				Download
+			</h3>
+				<ul class="sectionIcons">
+        <% if @manifest_size_human 
+          txt = "Download/View (" + @manifest_size_human + ")"
+        else
+          txt = "Download/View"
+        end
+        %>
+					<li><%= icon('blob', @resuri.to_s, "Download File" ,  {:rel => 'nofollow'}, txt) %></li>
+				</ul>      
+
+<% if @manifest_md5 %>
+      <div class="checksum">MD5 checksum: <span class="md5"><%= @manifest_md5 -%></span></div>
+<% end %>
+       
+</div>
+
+
 <% if false %>
 
 <h2>Workflow inputs (via WF-DESC)</h2>
@@ -87,6 +108,8 @@
   <% end %>
 </ul>
 
+
+
 <% end %>
 
 <h2>Debug</h2>

Modified: branches/wf4ever/public/stylesheets/styles.css (3325 => 3326)


--- branches/wf4ever/public/stylesheets/styles.css	2013-01-22 14:28:03 UTC (rev 3325)
+++ branches/wf4ever/public/stylesheets/styles.css	2013-01-22 15:32:22 UTC (rev 3326)
@@ -2494,7 +2494,7 @@
   font-weight: bold;
 }
 .live {
-  font-family: "Margarine", Inconsolata, Consolas, cursive;
+  font-family: "Margarine", Consolas, Inconsolata, cursive;
   text-transform: lowercase;
 }
 
@@ -2528,7 +2528,7 @@
   content: "–";
 }
 
-pre, code {
+pre, code, .md5 {
   font-family: Consolas, "Inconsolata", monospace;
 }
 
@@ -2577,4 +2577,9 @@
 }
 .mockup .mockup {
   border: none;
-}
\ No newline at end of file
+}
+
+.checksum {
+  font-size: smaller; 
+  text-align: center;
+}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]