myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3484] branches/wf4ever/app: changed creators and


From: noreply
Subject: [myexperiment-hackers] [3484] branches/wf4ever/app: changed creators and contributors from literals to resources
Date: Sun, 24 Mar 2013 11:23:53 +0000 (UTC)

Revision
3484
Author
dgc
Date
2013-03-24 11:23:52 +0000 (Sun, 24 Mar 2013)

Log Message

changed creators and contributors from literals to resources

Modified Paths

Diff

Modified: branches/wf4ever/app/controllers/application_controller.rb (3483 => 3484)


--- branches/wf4ever/app/controllers/application_controller.rb	2013-03-21 12:19:09 UTC (rev 3483)
+++ branches/wf4ever/app/controllers/application_controller.rb	2013-03-24 11:23:52 UTC (rev 3484)
@@ -524,10 +524,9 @@
       when "Title"
         ao_graph.graph << [RDF::URI(resource_uri), RDF::DC.title, params[:value]]
       when "Creator"
-        ## FIXME: dcterms:creator and contributor should be given as resources, not literal
-        ao_graph.graph << [RDF::URI(resource_uri), RDF::DC.creator, params[:value]]
+        ao_graph.graph << [RDF::URI(resource_uri), RDF::DC.creator, RDF::URI(params[:value])]
       when "Contributor"
-        ao_graph.graph << [RDF::URI(resource_uri), RDF::DC.contributor, params[:value]]
+        ao_graph.graph << [RDF::URI(resource_uri), RDF::DC.contributor, RDF::URI(params[:value])]
       when "Description"
         ao_graph.graph << [RDF::URI(resource_uri), RDF::DC.description, params[:value]]
       else

Modified: branches/wf4ever/app/helpers/application_helper.rb (3483 => 3484)


--- branches/wf4ever/app/helpers/application_helper.rb	2013-03-21 12:19:09 UTC (rev 3483)
+++ branches/wf4ever/app/helpers/application_helper.rb	2013-03-24 11:23:52 UTC (rev 3484)
@@ -1312,6 +1312,23 @@
     end
   end
 
+  # user_link creates a link to a user on the site if the URI matches an
+  # existing user.  Otherwise the URI is just shown with an optional label.
+
+  def user_link(uri, opts = {})
+
+    user_model, user_id = parse_resource_uri(uri)
+
+    user = User.activated_users.find_by_id(user_id) if user_model == User
+
+    if user
+      link_to(h(user.name), user)
+    elsif opts[:label]
+      link_to(h(opts[:label]), @creator)
+    else
+      link_to(h(@creator), @creator)
+    end
+  end
   
 protected
 

Modified: branches/wf4ever/app/models/user.rb (3483 => 3484)


--- branches/wf4ever/app/models/user.rb	2013-03-21 12:19:09 UTC (rev 3483)
+++ branches/wf4ever/app/models/user.rb	2013-03-24 11:23:52 UTC (rev 3484)
@@ -311,6 +311,8 @@
            :order => "created_at DESC",
            :dependent => :destroy
            
+  named_scope :activated_users, :conditions => "activated_at IS NOT NULL"
+
   def avatar?
     self.profile and !(self.profile.picture_id.nil? or self.profile.picture_id.zero?)
   end

Modified: branches/wf4ever/app/views/packs/resource_show.rhtml (3483 => 3484)


--- branches/wf4ever/app/views/packs/resource_show.rhtml	2013-03-21 12:19:09 UTC (rev 3483)
+++ branches/wf4ever/app/views/packs/resource_show.rhtml	2013-03-24 11:23:52 UTC (rev 3484)
@@ -72,7 +72,7 @@
   <% if @creator %>
     <tr>
       <td>Creator</td>
-      <td><%=h @creator -%></td>
+      <td><%= user_link(@creator) -%></td>
     </tr>
   <% end %>    
 
@@ -154,11 +154,12 @@
   <% end %>
 </ul>
 
+<% end %>
 
+<% if params[:show_annotation_graph] -%>
 
+<br /><br /><br />
 
-<h2>Debug</h2>
-
 <div class="fold">
 
   <div class="foldTitle">Merged annotation bodies (<%= @annotations.query([nil, nil, nil]).count -%>)</div>

reply via email to

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