myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3374] branches/wf4ever/app: WFE-878 Show type in


From: noreply
Subject: [myexperiment-hackers] [3374] branches/wf4ever/app: WFE-878 Show type instead of "Resource"
Date: Tue, 29 Jan 2013 18:41:16 +0000 (UTC)

Revision
3374
Author
stain
Date
2013-01-29 18:41:16 +0000 (Tue, 29 Jan 2013)

Log Message

WFE-878 Show type instead of "Resource"

Modified Paths

Diff

Modified: branches/wf4ever/app/controllers/packs_controller.rb (3373 => 3374)


--- branches/wf4ever/app/controllers/packs_controller.rb	2013-01-29 18:41:07 UTC (rev 3373)
+++ branches/wf4ever/app/controllers/packs_controller.rb	2013-01-29 18:41:16 UTC (rev 3374)
@@ -113,25 +113,36 @@
 
   end
 
+  def resource_types(resuri)
+    @annotations.query([resuri, RDF::type, nil]).map do |s,p,type|
+      type.to_s
+    end
+  end
+  
+  def textual_type(typeuri)
+    type = Conf.ro_resource_types.rassoc(typeuri)
+    type.first if type
+  end
+  
   # GET /packs/:id/resources/:resource_path
   def resource_show
-
     # Get annotations as merged graph.  This will be pulled from cache
     # eventually.
 
     session = ROSRS::Session.new(@pack.ro_uri, Conf.rodl_bearer_token)
-
     @annotations = session.get_annotation_graph(@pack.ro_uri, @resuri)
-
     @annotations.query(address@hidden, nil, nil]).each do |statement|
-
+      puts statement
       case statement.predicate.to_s
       when "http://purl.org/dc/terms/title":       @title       = statement.object.to_s
       when "http://purl.org/dc/terms/description": @description = statement.object.to_s
       when "http://purl.org/dc/terms/creator":     @creator     = statement.object.to_s
       when "http://purl.org/dc/terms/created":     @created     = Date.parse(statement.object.to_s)
       end
+    end
 
+    @types = resource_types(@resuri).map do |typeuri|
+      textual_type(typeuri) or typeuri
     end
 
     render :resource_show

Modified: branches/wf4ever/app/views/packs/resource_show.rhtml (3373 => 3374)


--- branches/wf4ever/app/views/packs/resource_show.rhtml	2013-01-29 18:41:07 UTC (rev 3373)
+++ branches/wf4ever/app/views/packs/resource_show.rhtml	2013-01-29 18:41:16 UTC (rev 3374)
@@ -1,5 +1,13 @@
-<h1>Resource: <%=h @manifest_name -%></h1>
+<h1>
+  <%= @types and @types.first or "Resource"%>:
 
+  <%=h @manifest_name -%>
+  
+<% if @types.length > 1 %>
+  (<%= @types[1..-1].join ", "-%>)
+<% end %>
+</h1>
+  
 <div style="margin-top: 1em;">
   <ul class="sectionIcons" style="margin-top: 0.7em; margin-bottom: 0.6em;">
     <% if Authorization.check("edit", @pack, current_user) %>

reply via email to

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