myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3145] branches/wf4ever: started individual page


From: noreply
Subject: [myexperiment-hackers] [3145] branches/wf4ever: started individual page per research object resource
Date: Tue, 9 Oct 2012 01:16:03 +0000 (UTC)

Revision
3145
Author
dgc
Date
2012-10-09 01:16:03 +0000 (Tue, 09 Oct 2012)

Log Message

started individual page per research object resource

Modified Paths

Diff

Modified: branches/wf4ever/app/controllers/research_objects_controller.rb (3144 => 3145)


--- branches/wf4ever/app/controllers/research_objects_controller.rb	2012-10-08 12:50:19 UTC (rev 3144)
+++ branches/wf4ever/app/controllers/research_objects_controller.rb	2012-10-09 01:16:03 UTC (rev 3145)
@@ -9,7 +9,7 @@
 
   include ApplicationHelper
 
-  before_filter :find_research_object,  : [:show, :edit, :update]
+  before_filter :find_research_object,  : [:show, :edit, :update, :resource_show]
   before_filter :find_research_objects, : [:all]
   
   # GET /research_objects
@@ -137,6 +137,35 @@
   def destroy
   end
 
+  # GET /research_objects/:id/resource/:path
+  def resource_show
+
+    resource_object = Annotation.find(:first, :conditions => {
+        :research_object_id => @contributable.id,
+        :predicate_text => 'http://purl.org/wf4ever/ro#name',
+        :objekt_text => params[:path]})
+
+    raise ActiveRecord::RecordNotFound if resource_object.nil?
+
+    statements = Annotation.find(:all, :conditions => {
+        :subject_text => resource_object.subject_text
+    })
+    
+    statements.each do |statement|
+
+      case statement.predicate_text
+      when "http://purl.org/wf4ever/ro#name":      @name    = statement.objekt_text
+      when "http://purl.org/dc/terms/created":     @created = Date.parse(statement.objekt_text)
+      when "http://purl.org/dc/terms/creator":     @creator = statement.objekt_text
+      when "http://purl.org/wf4ever/ro#checksum" : @md5     = statement.objekt_text
+      when "http://purl.org/wf4ever/ro#filesize" : @size    = statement.objekt_text.to_i
+      end
+
+    end
+
+    render :resource_show
+  end
+
   protected
   
   def find_research_objects

Modified: branches/wf4ever/app/helpers/research_objects_helper.rb (3144 => 3145)


--- branches/wf4ever/app/helpers/research_objects_helper.rb	2012-10-08 12:50:19 UTC (rev 3144)
+++ branches/wf4ever/app/helpers/research_objects_helper.rb	2012-10-09 01:16:03 UTC (rev 3145)
@@ -51,4 +51,17 @@
                         "urn:MD5:#{hash.upcase}"])
   end
 
+  def research_object_resources(contributable)
+
+    markup = "<ul class='research_object_browser'>"
+
+    contributable.wf4ever_resources.each do |resource|
+      markup += "<li>#{link_to(resource[:name], research_object_resource_path(contributable, resource[:name]))}</li>"
+    end
+
+    markup += "</ul>"
+
+    markup
+  end
+
 end

Modified: branches/wf4ever/app/views/research_objects/_breadcrumbs.rhtml (3144 => 3145)


--- branches/wf4ever/app/views/research_objects/_breadcrumbs.rhtml	2012-10-08 12:50:19 UTC (rev 3144)
+++ branches/wf4ever/app/views/research_objects/_breadcrumbs.rhtml	2012-10-09 01:16:03 UTC (rev 3145)
@@ -8,6 +8,8 @@
   <li>Search Results</li>
 <% when "index" %>
   <li>Research objects</li>
+<% when "resource_show" %>
+  <li><%= link_to(@contributable.label, research_object_path(@contributable)) %></li>
 <% else %>
   <!-- no breadcrumb -->
 <% end %>

Modified: branches/wf4ever/app/views/research_objects/show.rhtml (3144 => 3145)


--- branches/wf4ever/app/views/research_objects/show.rhtml	2012-10-08 12:50:19 UTC (rev 3144)
+++ branches/wf4ever/app/views/research_objects/show.rhtml	2012-10-09 01:16:03 UTC (rev 3145)
@@ -39,27 +39,10 @@
 
 <% if resources.length > 0 %>
 
-  <h2>Aggregated resources</h2>
+  <h2>Pack Items</h2>
 
-  <table class="simple">
-    <tr>
-      <th>Name</th>
-      <th>Size</th>
-      <th>Created</th>
-      <th>Creator</th>
-    </tr>
-    <% resources.each do |resource| %>
-      <tr>
-        <td><%=h resource[:name] -%></td>
-        <td><%=h resource[:size] -%></td>
-        <td><%=h resource[:created] -%></td>
-        <td><%=h resource[:creator] -%></td>
-      </tr>
-    <% end %>
-  </table>
+  <%= research_object_resources(@contributable) -%>
 
-  <br />
-
 <% end %>
 
 <% if annotations.length > 0 %>

Modified: branches/wf4ever/config/routes.rb (3144 => 3145)


--- branches/wf4ever/config/routes.rb	2012-10-08 12:50:19 UTC (rev 3144)
+++ branches/wf4ever/config/routes.rb	2012-10-09 01:16:03 UTC (rev 3145)
@@ -192,6 +192,9 @@
   # research_objects
   map.resources :research_objects
 
+  map.research_object_resources '/research_objects/:id/resources',       :controller => 'research_objects', :action ="" 'resource_index', :conditions => { :method => :get }
+  map.research_object_resource  '/research_objects/:id/resources/:path', :controller => 'research_objects', :action ="" 'resource_show',  :conditions => { :method => :get }, :requirements => { :path => /.*/ }
+
   # content_types
   map.resources :content_types
 

Modified: branches/wf4ever/public/stylesheets/styles.css (3144 => 3145)


--- branches/wf4ever/public/stylesheets/styles.css	2012-10-08 12:50:19 UTC (rev 3144)
+++ branches/wf4ever/public/stylesheets/styles.css	2012-10-09 01:16:03 UTC (rev 3145)
@@ -2400,3 +2400,7 @@
   text-align: center;
 }
 
+.research_object_browser LI {
+  list-style-image: url('/images/famfamfam_silk/page.png');
+}
+

reply via email to

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