Diff
Modified: branches/packs/app/controllers/annotations_controller.rb (3682 => 3683)
--- branches/packs/app/controllers/annotations_controller.rb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/controllers/annotations_controller.rb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -9,31 +9,22 @@
class AnnotationsController < ApplicationController
- def index
- @pack = Pack.find(params[:pack_id])
+ before_filter :find_and_auth_resource_context
- @annotations = @pack.research_object.annotations_with_templates
+ def index
+ @annotations = @context.research_object.annotations_with_templates
end
def show
- @pack = Pack.find(params[:pack_id])
+ @annotation = @context.research_object.resources.find(:first, :conditions => { :uuid => params[:id] })
- @annotation = @pack.research_object.resources.find(:first, :conditions => { :uuid => params[:id] })
-
@graph = load_graph(@annotation.ao_body.content_blob.data, :content_type => @annotation.ao_body.content_type)
- @annotation_template, @parameters = @pack.research_object.find_template_from_graph(@graph, Conf.ro_templates)
+ @annotation_template, @parameters = @context.research_object.find_template_from_graph(@graph, Conf.ro_templates)
end
def create
- pack = Pack.find(params[:pack_id])
-
- unless Authorization.check('create', Resource, current_user, pack)
- render_401("You are not authorized to view this resource's relationships.")
- return
- end
-
template = Conf.ro_templates[params[:annotation_type]]
if template.nil?
@@ -57,7 +48,7 @@
RDF::URI(params[parameter["symbol"]])
end
when "resource"
- pack.research_object.find_using_path(params[parameter["symbol"]]).uri
+ @context.research_object.find_using_path(params[parameter["symbol"]]).uri
end
end
@@ -65,35 +56,31 @@
graph = Pack.first.research_object.create_graph_using_ro_template(parameters, template)
- pack.research_object.create_annotation(
+ @context.research_object.create_annotation(
:body_graph => graph,
:content_type => 'application/rdf+xml',
:resources => targets,
:creator_uri => user_path(current_user))
- redirect_to pack_path(pack)
+ redirect_to polymorphic_path(@context)
end
def destroy
- pack = Pack.find(params[:pack_id])
+ annotation = @context.research_object.resources.find_by_uuid(params[:id])
- annotation = pack.research_object.resources.find_by_uuid(params[:id])
-
# Destroy annotation body and also the annotation
annotation.ao_body.destroy
annotation.destroy
- pack.research_object.update_manifest!
+ @context.research_object.update_manifest!
- redirect_to pack_annotations_path(pack)
+ redirect_to polymorphic_path(address@hidden, :annotations])
end
def new
- @pack = Pack.find(params[:pack_id])
-
@annotation_template = Conf.ro_templates[params[:template]]
if address@hidden
@@ -102,4 +89,16 @@
end
end
+private
+
+ def find_and_auth_resource_context
+ @context = extract_resource_context(params)
+
+ if @context.nil?
+ render_404("Annotation context not found.")
+ elsif !Authorization.check('view', @context, current_user)
+ render_401("You are not authorized to view the annotations of this resource.")
+ end
+ end
+
end
Added: branches/packs/app/controllers/items_controller.rb (0 => 3683)
--- branches/packs/app/controllers/items_controller.rb (rev 0)
+++ branches/packs/app/controllers/items_controller.rb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -0,0 +1,79 @@
+# myExperiment: app/controllers/items_controller.rb
+#
+# Copyright (c) 2007-2013 The University of Manchester, the University of
+# Oxford, and the University of Southampton. See license.txt for details.
+
+class ItemsController < ApplicationController
+
+ include ResearchObjectsHelper
+
+ before_filter :find_and_auth_resource_context
+ before_filter :find_item
+
+ def index
+ show
+ end
+
+ def show
+
+ @annotations = @item.annotations_with_templates
+
+ @visible_annotations = @annotations.select { |a| a[:template] != nil }
+
+ @statements = merge_graphs(@annotations.map { |annotation| annotation[:graph] })
+
+ 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
+ @input_files_for_this_workflow = @statements.query(address@hidden, RDF::URI("http://purl.org/wf4ever/roterms#inputSelected"), nil]).objects
+ @requires_hardware = @statements.query(address@hidden, RDF::URI("http://purl.org/wf4ever/roterms#requiresHardware"), nil]).objects
+ @requires_software = @statements.query(address@hidden, RDF::URI("http://purl.org/wf4ever/roterms#requiresSoftware"), nil]).objects
+ @roles_in_time = @statements.query([nil, RDF::URI("http://purl.org/spar/pro/relatesToEntity"), @item.uri]).subjects
+ end
+
+ if @item.is_folder
+ render :action ="" 'folder_show'
+ end
+ end
+
+ def destroy
+
+ unless Authorization.check('destroy', @item, current_user)
+ render_401("You are not authorized to delete this item.")
+ return
+ end
+
+ # Delete the resource context if it exists.
+ @item.context.destroy if @item.context
+
+ # Delete the resource
+ @item.destroy
+
+ redirect_to @context
+ end
+
+private
+
+ def find_and_auth_resource_context
+ @context = extract_resource_context(params)
+
+ if @context.nil?
+ render_404("Item context not found.")
+ elsif !Authorization.check('view', @context, current_user)
+ render_401("You are not authorized to view the items of this resource.")
+ end
+ end
+
+ def find_item
+
+ if params[:action] == 'index'
+ @item = @context.research_object.root_folder
+ else
+ @item = @context.research_object.find_using_path(params[:id])
+ end
+
+ if @item.nil?
+ render_404("Relationship not found.")
+ end
+ end
+end
Modified: branches/packs/app/controllers/packs_controller.rb (3682 => 3683)
--- branches/packs/app/controllers/packs_controller.rb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/controllers/packs_controller.rb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -456,6 +456,7 @@
def items
respond_to do |format|
+ format.html { item_show }
format.rss { render :action ="" 'items.rxml', :layout => false }
end
end
@@ -478,61 +479,6 @@
end
end
- def item_show
-
- 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 }
-
- @statements = merge_graphs(@annotations.map { |annotation| annotation[:graph] })
-
- 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
- @input_files_for_this_workflow = @statements.query(address@hidden, RDF::URI("http://purl.org/wf4ever/roterms#inputSelected"), nil]).objects
- @requires_hardware = @statements.query(address@hidden, RDF::URI("http://purl.org/wf4ever/roterms#requiresHardware"), nil]).objects
- @requires_software = @statements.query(address@hidden, RDF::URI("http://purl.org/wf4ever/roterms#requiresSoftware"), nil]).objects
- @roles_in_time = @statements.query([nil, RDF::URI("http://purl.org/spar/pro/relatesToEntity"), @item.uri]).subjects
- end
-
- unless @item
- render_404("Pack item not found.")
- return
- end
-
- if @item.is_folder
- render :action ="" 'folder_show'
- end
- end
-
- def item_destroy
- @item = @pack.research_object.find_using_path(params[:item_path])
-
- if @item.nil?
- render_404("Pack item not found.")
- return
- end
-
- # Delete the resource context if it exists.
- pce = @item.context.destroy if @item.context
-
- # Delete the resource
- @item.destroy
-
- redirect_to @pack
- end
-
protected
# Check that a protocol is specified in the URI; prepend HTTP:// otherwise
Added: branches/packs/app/helpers/items_helper.rb (0 => 3683)
--- branches/packs/app/helpers/items_helper.rb (rev 0)
+++ branches/packs/app/helpers/items_helper.rb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -0,0 +1,68 @@
+# myExperiment: app/helpers/items_helper.rb
+#
+# Copyright (c) 2007-2013 The University of Manchester, the University of
+# Oxford, and the University of Southampton. See license.txt for details.
+
+module ItemsHelper
+
+ def find_association(resource)
+
+ is_folder = resource.is_folder
+ is_proxy = resource.is_proxy
+ extension = resource.folder_entry.entry_name.split(".").last
+ generic = nil
+
+ Conf.file_format_associations.each do |assoc|
+
+ if is_folder
+ return assoc if assoc["special"] == "folder"
+ next
+ end
+
+ if is_proxy
+ return assoc if assoc["special"] == "link"
+ next
+ end
+
+ generic = assoc if assoc["special"] == "generic"
+
+ if assoc["extensions"]
+ return assoc if assoc["extensions"].include?(extension)
+ end
+ end
+
+ generic
+ end
+
+ def user_link(uri)
+
+ # Get absolute URI.
+ uri = URI.parse(Conf.base_uri).merge(uri).to_s
+
+ # Match it up with the users
+ resource = parse_resource_uri(uri)
+
+ if resource && resource[0] == User
+ link_to(User.find(resource[1]).name, uri)
+ else
+ link_to(uri, uri)
+ end
+ end
+
+ def resource_link(resource)
+
+ association = find_association(resource)
+
+ image = "<img src=''>"
+
+ if resource.is_proxy
+ label = resource.proxy_for_path
+ else
+ label = resource.folder_entry.entry_name
+ end
+
+ uri = pack_items_path(resource.research_object.context) + "/" + resource.ore_path
+
+ "<span class='resource-link'>#{image} #{link_to(h(label), uri)}</span>"
+ end
+end
Modified: branches/packs/app/helpers/packs_helper.rb (3682 => 3683)
--- branches/packs/app/helpers/packs_helper.rb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/helpers/packs_helper.rb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -92,65 +92,4 @@
link_to(text, href)
end
-
- def find_association(resource)
-
- is_folder = resource.is_folder
- is_proxy = resource.is_proxy
- extension = resource.folder_entry.entry_name.split(".").last
- generic = nil
-
- Conf.file_format_associations.each do |assoc|
-
- if is_folder
- return assoc if assoc["special"] == "folder"
- next
- end
-
- if is_proxy
- return assoc if assoc["special"] == "link"
- next
- end
-
- generic = assoc if assoc["special"] == "generic"
-
- if assoc["extensions"]
- return assoc if assoc["extensions"].include?(extension)
- end
- end
-
- generic
- end
-
- def user_link(uri)
-
- # Get absolute URI.
- uri = URI.parse(Conf.base_uri).merge(uri).to_s
-
- # Match it up with the users
- resource = parse_resource_uri(uri)
-
- if resource && resource[0] == User
- link_to(User.find(resource[1]).name, uri)
- else
- link_to(uri, uri)
- end
- end
-
- def resource_link(resource)
-
- association = find_association(resource)
-
- image = "<img src=''>"
-
- if resource.is_proxy
- label = resource.proxy_for_path
- else
- label = resource.folder_entry.entry_name
- end
-
- uri = pack_items_path(resource.research_object.context) + "/" + resource.ore_path
-
- "<span class='resource-link'>#{image} #{link_to(h(label), uri)}</span>"
- end
end
Modified: branches/packs/app/views/annotations/_annotation.html.erb (3682 => 3683)
--- branches/packs/app/views/annotations/_annotation.html.erb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/views/annotations/_annotation.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -3,11 +3,11 @@
<p>
<div style="float: right">
<%= link_to("<img src='' />",
- pack_annotation_path(pack, annotation[:annotation].uuid),
+ polymorphic_path([context, :annotation], :id => annotation[:annotation].uuid),
:method => :delete,
:confirm => "Are you sure you want to delete this annotation?") %>
</div>
- <span class="type"><%= link_to(h(annotation[:template]["label"].capitalize), pack_annotation_path(pack, annotation[:annotation].uuid)) -%></span>
+ <span class="type"><%= link_to(h(annotation[:template]["label"].capitalize), polymorphic_path([context, :annotation], :id => annotation[:annotation].uuid)) -%></span>
</p>
</div>
<% if annotation[:template] %>
@@ -27,9 +27,9 @@
<td class="label"><%=h label -%></td>
<td class="value">
<% if parameter["type"] == "resource" %>
- <% resource = pack.find_resource_by_path(value) -%>
+ <% resource = context.find_resource_by_path(value) -%>
<% if resource %>
- <%= resource_link(pack.find_resource_by_path(value)) -%>
+ <%= resource_link(context.find_resource_by_path(value)) -%>
<% else %>
<%= link_to(h(value), value, :rel => 'nofollow') -%>
<% end %>
Modified: branches/packs/app/views/annotations/_breadcrumbs.html.erb (3682 => 3683)
--- branches/packs/app/views/annotations/_breadcrumbs.html.erb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/views/annotations/_breadcrumbs.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -1,10 +1,10 @@
-<li><%= link_to(Conf.to_visible(@pack.class.name).pluralize, polymorphic_path(@pack.class.name.underscore.pluralize.to_sym)) -%>
-<li><%= link_to(h(@pack.title), polymorphic_path(@pack)) -%></li>
+<li><%= link_to(Conf.to_visible(@context.class.name).pluralize, polymorphic_path(@context.class.name.underscore.pluralize.to_sym)) -%>
+<li><%= link_to(h(@context.label), polymorphic_path(@context)) -%></li>
<% if controller.action_name == "index" %>
<li>Annotations</li>
<% else %>
- <li><%= link_to("Annotations", polymorphic_path(address@hidden, :annotations])) -%></li>
+ <li><%= link_to("Annotations", polymorphic_path(address@hidden, :annotations])) -%></li>
<% end %>
<% case controller.action_name; when "new" %>
Modified: branches/packs/app/views/annotations/_form.html.erb (3682 => 3683)
--- branches/packs/app/views/annotations/_form.html.erb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/views/annotations/_form.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -18,7 +18,7 @@
<% if values[parameter["symbol"]] %>
<td>
<% if parameter["type"] == "resource" %>
- <%= resource_link(@pack.find_resource_by_ore_path(values[parameter["symbol"]])) -%>
+ <%= resource_link(@context.find_resource_by_ore_path(values[parameter["symbol"]])) -%>
<% else %>
<%=h values[parameter["symbol"]] -%>
<% end %>
Modified: branches/packs/app/views/annotations/index.html.erb (3682 => 3683)
--- branches/packs/app/views/annotations/index.html.erb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/views/annotations/index.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -1,7 +1,7 @@
-<h1>All annotations for <%=h @pack.title -%></h1>
+<h1>All annotations for <%=h @context.label -%></h1>
<% @annotations.each do |annotation| %>
<% next unless annotation[:template] %>
- <%= render(:partial => 'annotation', :locals => { :pack => @pack, :annotation => annotation } ) -%>
+ <%= render(:partial => 'annotation', :locals => { :context => @context, :annotation => annotation } ) -%>
<% end %>
Modified: branches/packs/app/views/annotations/new.html.erb (3682 => 3683)
--- branches/packs/app/views/annotations/new.html.erb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/views/annotations/new.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -1,8 +1,8 @@
<h1>New annotation</h1>
-<% form_tag(pack_annotations_path(@pack)) do |f| -%>
+<% form_tag(polymorphic_path(address@hidden, :annotations])) do |f| -%>
<%= render(:partial => "form", :locals => {
- :research_object => @pack.research_object,
+ :research_object => @context.research_object,
:template => params[:template],
:annotation_template => @annotation_template,
:values => params,
Added: branches/packs/app/views/items/_breadcrumbs.html.erb (0 => 3683)
--- branches/packs/app/views/items/_breadcrumbs.html.erb (rev 0)
+++ branches/packs/app/views/items/_breadcrumbs.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -0,0 +1,14 @@
+<% if @context %>
+ <li><%= link_to visible_name(@context).pluralize, polymorphic_url(@context.class.name.underscore.pluralize) %></li>
+ <li><%= link_to h(@context.label), @context %></li>
+ <li><%= link_to("Items", polymorphic_path(address@hidden, :items])) -%></li>
+<% end %>
+
+<% case controller.action_name.to_s; when "show" %>
+ <% unless @item.is_root_folder %>
+ <% parent_folders(@item).each do |folder| %>
+ <li><%= link_to(h(folder.folder_entry.entry_name), resource_path_fixed(@context, folder)) -%></li>
+ <% end %>
+ <li><%=h @item.folder_entry.entry_name -%></li>
+ <% end %>
+<% end %>
Copied: branches/packs/app/views/items/_folder_list.html.erb (from rev 3674, branches/packs/app/views/resources/_folder_list.html.erb) (0 => 3683)
--- branches/packs/app/views/items/_folder_list.html.erb (rev 0)
+++ branches/packs/app/views/items/_folder_list.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -0,0 +1,10 @@
+<% unless item.is_root_folder %>
+ <p>Parent folder is:
+ <% parent = @item.folder_entry.proxy_in %>
+ <% label = parent.is_root_folder ? "Top level" : item.folder_entry.proxy_in.folder_entry.entry_name %>
+ <%= link_to(h(label), resource_path_fixed(context, item.folder_entry.proxy_in)) -%>
+ </p>
+<% end %>
+
+<%= render :partial => 'resource_tiles', :locals => { :context => context,
+ :resources => item.proxies.map { |p| p.proxy_for } } -%>
Copied: branches/packs/app/views/items/_resource_tile.html.erb (from rev 3674, branches/packs/app/views/resources/_resource_tile.html.erb) (0 => 3683)
--- branches/packs/app/views/items/_resource_tile.html.erb (rev 0)
+++ branches/packs/app/views/items/_resource_tile.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -0,0 +1,20 @@
+<% ore_path = resource.ore_path %>
+<% association = find_association(resource) %>
+<tr>
+ <td><%= resource_link(resource) -%></td>
+ <% if resource.is_folder || resource.is_proxy %>
+ <td></td>
+ <% else %>
+ <td><%=h resource.size -%></td>
+ <% end %>
+ <td><%=h association["label"] -%></td>
+ <td><%=h resource.annotations.count -%></td>
+ <td>
+ <% if !resource.is_folder && Authorization.check('destroy', resource, current_user) %>
+ <%= link_to("<img src='' />",
+ "#{polymorphic_path([context, :items])}/#{ore_path}",
+ :method => :delete,
+ :confirm => "Are you sure you want to delete this item?") %>
+ <% end %>
+ </td>
+</tr>
Copied: branches/packs/app/views/items/_resource_tiles.html.erb (from rev 3674, branches/packs/app/views/resources/_resource_tiles.html.erb) (0 => 3683)
--- branches/packs/app/views/items/_resource_tiles.html.erb (rev 0)
+++ branches/packs/app/views/items/_resource_tiles.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -0,0 +1,16 @@
+<table class="simple">
+ <tr>
+ <th>Path</th>
+ <th>Size</th>
+ <th>Type</th>
+ <th>Annotations</th>
+ <th></th>
+ </tr>
+ <% resources.each do |resource| %>
+ <% ore_path = resource.ore_path %>
+ <% next unless ore_path %>
+ <% if Authorization.check('view', resource, current_user) %>
+ <%= render :partial => 'items/resource_tile', :locals => { :context => context, :resource => resource } -%>
+ <% end %>
+ <% end %>
+</table>
Copied: branches/packs/app/views/items/folder_show.html.erb (from rev 3676, branches/packs/app/views/packs/folder_show.html.erb) (0 => 3683)
--- branches/packs/app/views/items/folder_show.html.erb (rev 0)
+++ branches/packs/app/views/items/folder_show.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -0,0 +1,10 @@
+<% if @item.is_root_folder %>
+ <h1>Items in <%=h @context.label -%></h1>
+<% else %>
+ <% parent = @item.folder_entry.proxy_in %>
+ <h1>Folder: <%=h @item.folder_entry.entry_name -%></h1>
+<% end %>
+
+<div class="folder-list">
+ <%= render(:partial => 'folder_list', :locals => { :item => @item, :context => @context }) -%>
+</div>
Copied: branches/packs/app/views/items/show.html.erb (from rev 3677, branches/packs/app/views/packs/item_show.html.erb) (0 => 3683)
--- branches/packs/app/views/items/show.html.erb (rev 0)
+++ branches/packs/app/views/items/show.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -0,0 +1,163 @@
+<h1>Item: <%= @title -%></h1>
+
+<div id="tabsContainer" class="tabsContainer"></div>
+
+<div class="tabContainer">
+ <div class="tabTitle">Overview</div>
+ <div class="tabContent">
+
+ <h2>Metadata</h2>
+
+ <table class="metadata">
+ <tr>
+ <td>Title</td>
+ <td><%=h @title -%></td>
+ </tr>
+ <tr>
+ <td>Aggregator</td>
+ <td><%= user_link(@item.creator_uri) -%></td>
+ </tr>
+ <tr>
+ <td>File name</td>
+ <td><%=h @item.folder_entry.entry_name -%></td>
+ </tr>
+ <tr>
+ <td>Aggregated at</td>
+ <td><%= datetime(@item.created_at) -%></td>
+ </tr>
+ <tr>
+ <td>File size</td>
+ <td><%=h @item.size.to_s -%></td>
+ </tr>
+ <tr>
+ <td>SHA1</td>
+ <td class="sha1"><%=h @item.sha1 -%></td>
+ </tr>
+ <tr>
+ <td>Content type</td>
+ <td class="content_type"><%=h @item.content_type -%></td>
+ </tr>
+ </table>
+
+ <% if @description %>
+ <h2>Description</h2>
+ <p><%=h simple_format(@description) -%></p>
+ <% end %>
+
+ <% unless @roles_in_time.empty? %>
+ <h2>Roles</h2>
+ <table class="simple">
+ <% @roles_in_time.each do |role_in_time| %>
+ <% person = @statements.query([nil, RDF::URI("http://purl.org/spar/pro/holdsRoleInTime"), role_in_time]).first_subject %>
+ <% name = @statements.query([person, RDF::FOAF.name, nil]).first_literal %>
+ <% orcid = @statements.query([person, RDF::URI("http://purl.org/spar/scoro/hasORCID"), nil]).first_literal %>
+ <% role = @statements.query([role_in_time, RDF::URI("http://purl.org/spar/pro/withRole"), nil]).first_object %>
+ <tr>
+ <td><%=h name -%></td>
+ <td>
+ <% if orcid %>
+ (OrcID <%=h orcid -%>)
+ <% end %>
+ </td>
+ <td><%=h role -%></td>
+ </tr>
+ <% end %>
+ </table>
+ <% end %>
+
+ <% unless @input_files_for_this_workflow.empty? %>
+ <h2>Input files</h2>
+ <ul>
+ <% @input_files_for_this_workflow.each do |input| %>
+ <li><%= resource_link(@context.find_resource_by_path(input)) -%></li>
+ <% end %>
+ </ul>
+ <% end %>
+
+ <% unless @requires_hardware.empty? %>
+ <h2>Hardware requirements</h2>
+ <ul>
+ <% @requires_hardware.each do |hardware| %>
+ <% desc = @statements.query([hardware, RDF::DC.description, nil]).first_literal %>
+ <% link = @statements.query([hardware, RDF::RDFS.seeAlso, nil]).first_literal %>
+
+ <% if link %>
+ <li><%= link_to(h(desc), link.to_s, :rel => "nofollow") -%></li>
+ <% else %>
+ <li><%=h desc -%></li>
+ <% end %>
+ <% end %>
+ </ul>
+ <% end %>
+
+ <% unless @requires_software.empty? %>
+ <h2>Software requirements</h2>
+ <ul>
+ <% @requires_software.each do |software| %>
+ <% desc = @statements.query([software, RDF::DC.description, nil]).first_literal %>
+ <% link = @statements.query([software, RDF::RDFS.seeAlso, nil]).first_literal %>
+
+ <% if link %>
+ <li><%= link_to(h(desc), link.to_s, :rel => "nofollow") -%></li>
+ <% else %>
+ <li><%=h desc -%></li>
+ <% end %>
+ <% end %>
+ </ul>
+ <% end %>
+
+ <% if Authorization.check('edit', @context, current_user) %>
+ <h2>Actions</h2>
+
+ <ul>
+ <li><%= link_to('Add title', polymorphic_path([:new, @context, :annotation], { :template => 'title', :resource => @item.ore_path })) -%></li>
+ <li><%= link_to('Add resource type', polymorphic_path([:new, @context, :annotation], { :template => 'resource_type', :resource => @item.ore_path })) -%></li>
+ <li><%= link_to('Add description', polymorphic_path([:new, @context, :annotation], { :template => 'description', :resource => @item.ore_path })) -%></li>
+ <li><%= link_to('Add role', polymorphic_path([:new, @context, :annotation], { :template => 'role', :resource => @item.ore_path })) -%></li>
+ <li><%= link_to("Select an input file", polymorphic_path([:new, @context, :annotation], { :template => 'input_selection_relationship', :workflow => @item.ore_path })) -%></li>
+ <li><%= link_to("Add new hardware requirement", polymorphic_path([:new, @context, :annotation], { :template => 'requires_hardware', :resource => @item.ore_path })) -%></li>
+ <li><%= link_to("Add new software requirement", polymorphic_path([:new, @context, :annotation], { :template => 'requires_software', :resource => @item.ore_path })) -%></li>
+ </ul>
+ <% end %>
+ </div>
+</div>
+
+<div class="tabContainer">
+ <div class="tabTitle">Annotations</div>
+ <div class="tabContent">
+ <% @visible_annotations.each do |annotation| %>
+ <%= render(:partial => "annotations/annotation", :locals => { :context => @context, :annotation => annotation } ) -%>
+ <% end %>
+ </div>
+</div>
+
+<% if false %>
+<div class="tabContainer">
+ <div class="tabTitle">Annotation graphs</div>
+ <div class="tabContent">
+ <% @annotations.each do |annotation| %>
+
+ <h2><%=h annotation[:template].inspect -%></h2>
+ <p><%=h annotation[:annotation].uri.to_s -%></p>
+
+ <% annotation[:graph].each do |statement| %>
+ <div style="margin: 8px; box-shadow: 4px 4px 8px #ddd;">
+ <table class="simple" style="width: 100%">
+ <tr><td><%=h statement.subject -%></td></tr>
+ <tr><td><%=h statement.predicate -%></td></tr>
+ <tr><td><%=h statement.object -%></td></tr>
+ </table>
+ </div>
+ <% end %>
+ <% end %>
+ </div>
+</div>
+
+<div class="tabContainer">
+ <div class="tabTitle">Resource metadata</div>
+ <div class="tabContent">
+ <pre><%=h @item.to_yaml -%></pre>
+ </div>
+</div>
+
+<% end %>
Modified: branches/packs/app/views/packs/_breadcrumbs.rhtml (3682 => 3683)
--- branches/packs/app/views/packs/_breadcrumbs.rhtml 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/views/packs/_breadcrumbs.rhtml 2013-09-06 13:07:03 UTC (rev 3683)
@@ -27,15 +27,6 @@
<li>All Packs</li>
<% when "search" %>
<li>Search Results</li>
- <% when "item_show" %>
- <li><%= link_to "#{h(@pack.title)}", pack_path(@pack) %></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), resource_path_fixed(@pack, folder)) -%></li>
- <% end %>
- <li><%=h @item.folder_entry.entry_name -%></li>
- <% end %>
<% else %>
<!-- no breadcrumb -->
<% end %>
Deleted: branches/packs/app/views/packs/folder_show.html.erb (3682 => 3683)
--- branches/packs/app/views/packs/folder_show.html.erb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/views/packs/folder_show.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -1,8 +0,0 @@
-<% 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>
-<% end %>
-
-<%= render(:partial => 'resources/folder_list', :locals => { :item => @item, :context => @pack }) -%>
Deleted: branches/packs/app/views/packs/item_show.html.erb (3682 => 3683)
--- branches/packs/app/views/packs/item_show.html.erb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/views/packs/item_show.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -1,159 +0,0 @@
-<h1>Item: <%= @title -%></h1>
-
-<h2>Metadata</h2>
-
-<table class="metadata">
- <tr>
- <td>Title</td>
- <td><%=h @title -%></td>
- </tr>
- <tr>
- <td>Aggregator</td>
- <td><%= user_link(@item.creator_uri) -%></td>
- </tr>
- <tr>
- <td>File name</td>
- <td><%=h @item.folder_entry.entry_name -%></td>
- </tr>
- <tr>
- <td>Aggregated at</td>
- <td><%= datetime(@item.created_at) -%></td>
- </tr>
- <tr>
- <td>File size</td>
- <td><%=h @item.size.to_s -%></td>
- </tr>
- <tr>
- <td>SHA1</td>
- <td class="sha1"><%=h @item.sha1 -%></td>
- </tr>
- <tr>
- <td>Content type</td>
- <td class="content_type"><%=h @item.content_type -%></td>
- </tr>
-</table>
-
-<% if @description %>
- <h2>Description</h2>
- <p><%=h simple_format(@description) -%></p>
-<% end %>
-
-<% unless @roles_in_time.empty? %>
- <h2>Roles</h2>
- <table class="simple">
- <% @roles_in_time.each do |role_in_time| %>
- <% person = @statements.query([nil, RDF::URI("http://purl.org/spar/pro/holdsRoleInTime"), role_in_time]).first_subject %>
- <% name = @statements.query([person, RDF::FOAF.name, nil]).first_literal %>
- <% orcid = @statements.query([person, RDF::URI("http://purl.org/spar/scoro/hasORCID"), nil]).first_literal %>
- <% role = @statements.query([role_in_time, RDF::URI("http://purl.org/spar/pro/withRole"), nil]).first_object %>
- <tr>
- <td><%=h name -%></td>
- <td>
- <% if orcid %>
- (OrcID <%=h orcid -%>)
- <% end %>
- </td>
- <td><%=h role -%></td>
- </tr>
- <% end %>
- </table>
-<% end %>
-
-<% unless @input_files_for_this_workflow.empty? %>
- <h2>Input files</h2>
- <ul>
- <% @input_files_for_this_workflow.each do |input| %>
- <li><%= resource_link(@pack.find_resource_by_path(input)) -%></li>
- <% end %>
- </ul>
-<% end %>
-
-<% unless @requires_hardware.empty? %>
- <h2>Hardware requirements</h2>
- <ul>
- <% @requires_hardware.each do |hardware| %>
- <% desc = @statements.query([hardware, RDF::DC.description, nil]).first_literal %>
- <% link = @statements.query([hardware, RDF::RDFS.seeAlso, nil]).first_literal %>
-
- <% if link %>
- <li><%= link_to(h(desc), link.to_s, :rel => "nofollow") -%></li>
- <% else %>
- <li><%=h desc -%></li>
- <% end %>
- <% end %>
- </ul>
-<% end %>
-
-<% unless @requires_software.empty? %>
- <h2>Software requirements</h2>
- <ul>
- <% @requires_software.each do |software| %>
- <% desc = @statements.query([software, RDF::DC.description, nil]).first_literal %>
- <% link = @statements.query([software, RDF::RDFS.seeAlso, nil]).first_literal %>
-
- <% if link %>
- <li><%= link_to(h(desc), link.to_s, :rel => "nofollow") -%></li>
- <% else %>
- <li><%=h desc -%></li>
- <% end %>
- <% end %>
- </ul>
-<% end %>
-
-<% if Authorization.check('edit', @pack, current_user) %>
- <h2>Actions</h2>
-
- <ul>
- <li><%= link_to('Add title', new_pack_annotation_path(@pack, { :template => 'title', :resource => @item.ore_path })) -%></li>
- <li><%= link_to('Add resource type', new_pack_annotation_path(@pack, { :template => 'resource_type', :resource => @item.ore_path })) -%></li>
- <li><%= link_to('Add description', new_pack_annotation_path(@pack, { :template => 'description', :resource => @item.ore_path })) -%></li>
- <li><%= link_to('Add role', new_pack_annotation_path(@pack, { :template => 'role', :resource => @item.ore_path })) -%></li>
- <li><%= link_to("Select an input file", new_pack_annotation_path(@pack, { :template => 'input_selection_relationship', :workflow => @item.ore_path })) -%></li>
- <li><%= link_to("Add new hardware requirement", new_pack_annotation_path(@pack, { :template => 'requires_hardware', :resource => @item.ore_path })) -%></li>
- <li><%= link_to("Add new software requirement", new_pack_annotation_path(@pack, { :template => 'requires_software', :resource => @item.ore_path })) -%></li>
- </ul>
-<% end %>
-
-<h2>Debug</h2>
-
-<div id="tabsContainer" class="tabsContainer"></div>
-
-<div class="tabContainer">
- <div class="tabTitle">User level annotations</div>
- <div class="tabContent">
- <% @visible_annotations.each do |annotation| %>
- <%= render(:partial => "annotations/annotation", :locals => { :pack => @pack, :annotation => annotation } ) -%>
- <% end %>
- </div>
-</div>
-
-<% if false %>
-<div class="tabContainer">
- <div class="tabTitle">Annotation graphs</div>
- <div class="tabContent">
- <% @annotations.each do |annotation| %>
-
- <h2><%=h annotation[:template].inspect -%></h2>
- <p><%=h annotation[:annotation].uri.to_s -%></p>
-
- <% annotation[:graph].each do |statement| %>
- <div style="margin: 8px; box-shadow: 4px 4px 8px #ddd;">
- <table class="simple" style="width: 100%">
- <tr><td><%=h statement.subject -%></td></tr>
- <tr><td><%=h statement.predicate -%></td></tr>
- <tr><td><%=h statement.object -%></td></tr>
- </table>
- </div>
- <% end %>
- <% end %>
- </div>
-</div>
-
-<div class="tabContainer">
- <div class="tabTitle">Resource metadata</div>
- <div class="tabContent">
- <pre><%=h @item.to_yaml -%></pre>
- </div>
-</div>
-
-<% end %>
Modified: branches/packs/app/views/packs/show.rhtml (3682 => 3683)
--- branches/packs/app/views/packs/show.rhtml 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/views/packs/show.rhtml 2013-09-06 13:07:03 UTC (rev 3683)
@@ -10,7 +10,7 @@
<li><%= icon('manage', edit_pack_path(@pack), nil, nil, 'Manage Pack') -%></li>
<% end -%>
<% end %>
- <li><%= icon('folder', pack_items_path(@pack), nil, nil, 'Resources') -%></li>
+ <li><%= icon('folder', pack_items_path(@pack), nil, nil, 'Items') -%></li>
<li><%= icon('annotations', pack_annotations_path(@pack), nil, nil, 'Annotations') -%></li>
<li><%= icon('disk', download_pack_path(@pack), nil, nil, "Download") %></li>
<% if false %>
@@ -124,7 +124,7 @@
<div class="tabContainer">
<div class="tabTitle">ORE Entries</div>
<div class="tabContent">
- <%= render :partial => 'resources/resource_tiles', :locals => { :context => @pack,
+ <%= render :partial => 'items/resource_tiles', :locals => { :context => @pack,
:resources => @pack.research_object.resources.select { |r| !r.is_folder } } -%>
</div>
</div>
Deleted: branches/packs/app/views/resources/_folder_list.html.erb (3682 => 3683)
--- branches/packs/app/views/resources/_folder_list.html.erb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/views/resources/_folder_list.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -1,10 +0,0 @@
-<% unless item.is_root_folder %>
- <p>Parent folder is:
- <% parent = @item.folder_entry.proxy_in %>
- <% label = parent.is_root_folder ? "Top level" : item.folder_entry.proxy_in.folder_entry.entry_name %>
- <%= link_to(h(label), resource_path_fixed(context, item.folder_entry.proxy_in)) -%>
- </p>
-<% end %>
-
-<%= render :partial => 'resources/resource_tiles', :locals => { :context => context,
- :resources => item.proxies.map { |p| p.proxy_for } } -%>
Deleted: branches/packs/app/views/resources/_resource_tile.html.erb (3682 => 3683)
--- branches/packs/app/views/resources/_resource_tile.html.erb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/views/resources/_resource_tile.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -1,20 +0,0 @@
-<% ore_path = resource.ore_path %>
-<% association = find_association(resource) %>
-<tr>
- <td><%= resource_link(resource) -%></td>
- <% if resource.is_folder || resource.is_proxy %>
- <td></td>
- <% else %>
- <td><%=h resource.size -%></td>
- <% end %>
- <td><%=h association["label"] -%></td>
- <td><%=h resource.annotations.count -%></td>
- <td>
- <% if !resource.is_folder && Authorization.check('destroy', resource, current_user) %>
- <%= link_to("<img src='' />",
- "#{polymorphic_path([context, :items])}/#{ore_path}",
- :method => :delete,
- :confirm => "Are you sure you want to delete this item?") %>
- <% end %>
- </td>
-</tr>
Deleted: branches/packs/app/views/resources/_resource_tiles.html.erb (3682 => 3683)
--- branches/packs/app/views/resources/_resource_tiles.html.erb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/app/views/resources/_resource_tiles.html.erb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -1,16 +0,0 @@
-<table class="simple">
- <tr>
- <th>Path</th>
- <th>Size</th>
- <th>Type</th>
- <th>Annotations</th>
- <th></th>
- </tr>
- <% resources.each do |resource| %>
- <% ore_path = resource.ore_path %>
- <% next unless ore_path %>
- <% if Authorization.check('view', resource, current_user) %>
- <%= render :partial => "resources/resource_tile", :locals => { :context => context, :resource => resource } -%>
- <% end %>
- <% end %>
-</table>
Modified: branches/packs/config/routes.rb (3682 => 3683)
--- branches/packs/config/routes.rb 2013-09-06 10:20:39 UTC (rev 3682)
+++ branches/packs/config/routes.rb 2013-09-06 13:07:03 UTC (rev 3683)
@@ -68,15 +68,9 @@
pack.resources :comments, :collection => { :timeline => :get }
pack.resources :relationships, :collection => { :edit_relationships => :get }
pack.resources :annotations
+ pack.resources :items, :requirements => { :id => /[^;]+/ }
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/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,
:collection => { :search => :get },