myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3622] branches/packs: Added pack item pages


From: noreply
Subject: [myexperiment-hackers] [3622] branches/packs: Added pack item pages
Date: Wed, 21 Aug 2013 13:38:27 +0000 (UTC)

Revision
3622
Author
dgc
Date
2013-08-21 13:38:26 +0000 (Wed, 21 Aug 2013)

Log Message

Added pack item pages

Modified Paths

Diff

Modified: branches/packs/app/controllers/packs_controller.rb (3621 => 3622)


--- branches/packs/app/controllers/packs_controller.rb	2013-08-21 13:37:13 UTC (rev 3621)
+++ branches/packs/app/controllers/packs_controller.rb	2013-08-21 13:38:26 UTC (rev 3622)
@@ -466,6 +466,19 @@
     end
   end
 
+  def item_show
+    @item = @pack.research_object.find_using_path(params[:item_path])
+
+    @annotations = @item.annotations_with_templates
+
+    @visible_annotations = @annotations.select { |a| a[:template] != nil }
+
+    unless @item
+      render_404("Pack item not found.")
+      return
+    end
+  end
+
   protected
   
   # Check that a protocol is specified in the URI; prepend HTTP:// otherwise
@@ -492,6 +505,7 @@
       "favourite_delete" => "view",
       "index"            => "view",
       "items"            => "view",
+      "item_show"        => "view",
       "new"              => "create",
       "new_item"         => "edit",
       "quick_add"        => "edit",

Modified: branches/packs/app/models/resource.rb (3621 => 3622)


--- branches/packs/app/models/resource.rb	2013-08-21 13:37:13 UTC (rev 3621)
+++ branches/packs/app/models/resource.rb	2013-08-21 13:38:26 UTC (rev 3622)
@@ -179,6 +179,23 @@
     URI(path).path.split("/").last
   end
 
+  def ore_path
+
+    # Not all resources are listed in the ORE structure.
+    return nil if folder_entry.nil?
+
+    entry = folder_entry
+
+    bits = []
+
+    while entry
+      bits.unshift(entry.entry_name)
+      entry = entry.proxy_in.folder_entry
+    end
+
+    return bits.join("/")
+  end
+
   def update_graph!
 
     unless is_resource
@@ -209,11 +226,15 @@
 
   def annotations_with_templates
     annotations.map do |annotation|
-      template, parameters = research_object.find_template_from_graph(load_graph(annotation.ao_body.content_blob.data, annotation.ao_body.content_type), Conf.ro_templates)
+
+      graph = load_graph(annotation.ao_body.content_blob.data, annotation.ao_body.content_type)
+
+      template, parameters = research_object.find_template_from_graph(graph, Conf.ro_templates)
       {
         :annotation => annotation,
-        :template => template,
-        :paramters => parameters
+        :graph      => graph,
+        :template   => template,
+        :parameters => parameters
       }
     end
   end

Modified: branches/packs/config/routes.rb (3621 => 3622)


--- branches/packs/config/routes.rb	2013-08-21 13:37:13 UTC (rev 3621)
+++ branches/packs/config/routes.rb	2013-08-21 13:38:26 UTC (rev 3622)
@@ -68,7 +68,13 @@
     pack.resources :comments, :collection => { :timeline => :get }
     pack.resources :relationships, :collection => { :edit_relationships => :get }
   end
-    
+
+  # Pack entries.  These are not creating using the normal RESTful routes as
+  # they take a path instead of an id number.
+
+  map.pack_items '/packs/:id/items', :controller => 'packs', :action ="" 'item_index', :conditions => { :method => :get }
+  map.pack_item  '/packs/:id/items/:item_path', :controller => 'packs', :action ="" 'item_show',  :conditions => { :method => :get }, :requirements => { :item_path => /[^;]+/ }
+  
   # workflows (downloadable)
   map.resources :workflows, 
     :collection => { :search => :get }, 

reply via email to

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