myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3645] branches/packs: added basic ORE structure


From: noreply
Subject: [myexperiment-hackers] [3645] branches/packs: added basic ORE structure navigation
Date: Sat, 31 Aug 2013 13:22:09 +0000 (UTC)

Revision
3645
Author
dgc
Date
2013-08-31 13:22:09 +0000 (Sat, 31 Aug 2013)

Log Message

added basic ORE structure navigation

Modified Paths

Added Paths

Diff

Modified: branches/packs/app/controllers/packs_controller.rb (3644 => 3645)


--- branches/packs/app/controllers/packs_controller.rb	2013-08-30 15:03:48 UTC (rev 3644)
+++ branches/packs/app/controllers/packs_controller.rb	2013-08-31 13:22:09 UTC (rev 3645)
@@ -472,8 +472,18 @@
   end
 
   def item_show
-    @item = @pack.research_object.find_using_path(params[:item_path])
 
+    if params[:item_path]
+      @item = @pack.research_object.find_using_path(params[:item_path])
+    else
+      @item = @pack.research_object.root_folder
+    end
+
+    unless @item
+      render_404("Pack resource not found")
+      return
+    end
+
     @annotations = @item.annotations_with_templates
 
     @visible_annotations = @annotations.select { |a| a[:template] != nil }
@@ -484,14 +494,19 @@
       @statements << annotation[:graph]
     end
 
-    @title = @statements.query(address@hidden, RDF::DC.title, nil]).first_value || @item.folder_entry.entry_name
+    unless @item.is_folder
+      @title = @statements.query(address@hidden, RDF::DC.title, nil]).first_value || @item.folder_entry.entry_name
+      @description = @statements.query(address@hidden, RDF::DC.description, nil]).first_value
+    end
 
-    @description = @statements.query(address@hidden, RDF::DC.description, nil]).first_value
-
     unless @item
       render_404("Pack item not found.")
       return
     end
+
+    if @item.is_folder
+      render :action ="" 'folder_show'
+    end
   end
 
   def item_destroy

Modified: branches/packs/app/helpers/application_helper.rb (3644 => 3645)


--- branches/packs/app/helpers/application_helper.rb	2013-08-30 15:03:48 UTC (rev 3644)
+++ branches/packs/app/helpers/application_helper.rb	2013-08-31 13:22:09 UTC (rev 3645)
@@ -745,6 +745,8 @@
       return "famfamfam_silk/note.png"
     when "annotation"
       return "famfamfam_silk/note.png"
+    when "folder"
+      return "famfamfam_silk/folder.png"
     else
       return Conf.label_icons[method.to_s] if Conf.label_icons[method.to_s]
     end

Modified: branches/packs/app/helpers/research_objects_helper.rb (3644 => 3645)


--- branches/packs/app/helpers/research_objects_helper.rb	2013-08-30 15:03:48 UTC (rev 3644)
+++ branches/packs/app/helpers/research_objects_helper.rb	2013-08-31 13:22:09 UTC (rev 3645)
@@ -203,5 +203,31 @@
     pretty_rdf_xml(render_rdf(graph))
   end
 
+  def pack_resource_path_fixed(pack, resource)
+
+    ore_path = resource.ore_path
+
+    if resource.is_root_folder?
+      "/packs/#{pack.id}/resources"
+    elsif ore_path
+      "/packs/#{pack.id}/resources/#{ore_path}"
+    else
+      throw "No ORE path to this resource"
+    end
+  end
+
+  def parent_folders(resource)
+
+    folders = []
+
+    return [] if resource.is_root_folder
+
+    while resource.folder_entry.proxy_in.is_root_folder == false
+      resource = resource.folder_entry.proxy_in
+      folders << resource
+    end
+
+    folders.reverse
+  end
 end
 

Modified: branches/packs/app/views/packs/_breadcrumbs.rhtml (3644 => 3645)


--- branches/packs/app/views/packs/_breadcrumbs.rhtml	2013-08-30 15:03:48 UTC (rev 3644)
+++ branches/packs/app/views/packs/_breadcrumbs.rhtml	2013-08-31 13:22:09 UTC (rev 3645)
@@ -29,7 +29,13 @@
     <li>Search Results</li>
   <% when "item_show" %>
 		<li><%= link_to "#{h(@pack.title)}", pack_path(@pack) %></li>
-    <li><%=h @item.folder_entry.entry_name -%></li>
+    <li><%= link_to("Resources", pack_items_path(@pack)) -%></li>
+    <% unless @item.is_root_folder %>
+      <% parent_folders(@item).each do |folder| %>
+        <li><%= link_to(h(folder.folder_entry.entry_name), pack_resource_path_fixed(@pack, folder)) -%></li>
+      <% end %>
+      <li><%=h @item.folder_entry.entry_name -%></li>
+    <% end %>
   <% else %>
     <!-- no breadcrumb -->
   <% end %>

Added: branches/packs/app/views/packs/folder_show.html.erb (0 => 3645)


--- branches/packs/app/views/packs/folder_show.html.erb	                        (rev 0)
+++ branches/packs/app/views/packs/folder_show.html.erb	2013-08-31 13:22:09 UTC (rev 3645)
@@ -0,0 +1,22 @@
+<% if @item.is_root_folder %>
+  <h1>Pack resources</h1>
+<% else %>
+  <% parent = @item.folder_entry.proxy_in %>
+  <h1>Pack folder: <%=h @item.folder_entry.entry_name -%></h1>
+  <p>Parent folder is:
+    <% label = parent.is_root_folder ? "Top level" : @item.folder_entry.proxy_in.folder_entry.entry_name %>
+    <%= link_to(h(label), pack_resource_path_fixed(@pack, @item.folder_entry.proxy_in)) -%>
+  </p>
+<% end %>
+
+<h2>Folder content:</h2>
+
+<ul>
+  <% @item.proxies.each do |r| %>
+    <% if r.proxy_for %>
+      <li><%= link_to(h(r.proxy_for.folder_entry.entry_name), pack_resource_path_fixed(@pack, r.proxy_for)) -%></li>
+    <% else %>
+      <li><%= link_to(h(r.proxy_for_path), r.proxy_for_path) -%> (External)</li>
+    <% end %>
+  <% end %>
+</ul>

Modified: branches/packs/app/views/packs/show.rhtml (3644 => 3645)


--- branches/packs/app/views/packs/show.rhtml	2013-08-30 15:03:48 UTC (rev 3644)
+++ branches/packs/app/views/packs/show.rhtml	2013-08-31 13:22:09 UTC (rev 3645)
@@ -10,6 +10,7 @@
 			<li><%= icon('manage', edit_pack_path(@pack), nil, nil, 'Manage Pack') -%></li>
 		<% end -%>
     <li><%= icon('pack', download_pack_path(@pack), nil, nil, "Download") %></li>
+    <li><%= icon('folder', pack_items_path(@pack), nil, nil, 'Resources') -%></li>
     <li><%= icon('annotations', pack_annotations_path(@pack), nil, nil, 'Annotations') -%></li>
     <% if false %>
     <% if @authorised_to_edit -%>

Modified: branches/packs/config/routes.rb (3644 => 3645)


--- branches/packs/config/routes.rb	2013-08-30 15:03:48 UTC (rev 3644)
+++ branches/packs/config/routes.rb	2013-08-31 13:22:09 UTC (rev 3645)
@@ -73,9 +73,9 @@
   # 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 => /[^;]+/ }
-  map.pack_item  '/packs/:id/items/:item_path', :controller => 'packs', :action ="" 'item_destroy',  :conditions => { :method => :delete }, :requirements => { :item_path => /[^;]+/ }
+  map.pack_items '/packs/:id/resources', :controller => 'packs', :action ="" 'item_show', :conditions => { :method => :get }
+  map.pack_item  '/packs/:id/resources/:item_path', :controller => 'packs', :action ="" 'item_show',  :conditions => { :method => :get }, :requirements => { :item_path => /[^;]+/ }
+  map.pack_item  '/packs/:id/resources/:item_path', :controller => 'packs', :action ="" 'item_destroy',  :conditions => { :method => :delete }, :requirements => { :item_path => /[^;]+/ }
   
   # workflows (downloadable)
   map.resources :workflows, 

reply via email to

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