myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2432] trunk: initial "linked data" support


From: noreply
Subject: [myexperiment-hackers] [2432] trunk: initial "linked data" support
Date: Fri, 11 Jun 2010 11:41:19 -0400 (EDT)

Revision
2432
Author
dgc
Date
2010-06-11 11:41:18 -0400 (Fri, 11 Jun 2010)

Log Message

initial "linked data" support

Modified Paths

Added Paths

Diff

Modified: trunk/app/controllers/announcements_controller.rb (2431 => 2432)


--- trunk/app/controllers/announcements_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/announcements_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -22,6 +22,16 @@
 
   def show
     @announcement = Announcement.find(params[:id])
+
+    respond_to do |format|
+      format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} announcements address@hidden
+        }
+      end
+    end
   end
 
   def new

Modified: trunk/app/controllers/blobs_controller.rb (2431 => 2432)


--- trunk/app/controllers/blobs_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/blobs_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -65,6 +65,12 @@
     
     respond_to do |format|
       format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} files address@hidden
+        }
+      end
     end
   end
   

Modified: trunk/app/controllers/content_types_controller.rb (2431 => 2432)


--- trunk/app/controllers/content_types_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/content_types_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -22,6 +22,16 @@
     @blob_count = Blob.count(:conditions => ['content_type_id = ?', @content_type.id])
 
     @total_count = @workflow_count + @blob_count
+
+    respond_to do |format|
+      format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} content_types address@hidden
+        }
+      end
+    end
   end
 
   private

Modified: trunk/app/controllers/experiments_controller.rb (2431 => 2432)


--- trunk/app/controllers/experiments_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/experiments_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -19,6 +19,12 @@
   def show
     respond_to do |format|
       format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} experiments address@hidden
+        }
+      end
     end
   end
 

Modified: trunk/app/controllers/group_announcements_controller.rb (2431 => 2432)


--- trunk/app/controllers/group_announcements_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/group_announcements_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -29,6 +29,12 @@
   def show
     respond_to do |format|
       format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} group_announcements address@hidden
+        }
+      end
     end
   end
 

Modified: trunk/app/controllers/jobs_controller.rb (2431 => 2432)


--- trunk/app/controllers/jobs_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/jobs_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -39,6 +39,12 @@
 
     respond_to do |format|
       format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} jobs address@hidden
+        }
+      end
     end
   end
 

Modified: trunk/app/controllers/licenses_controller.rb (2431 => 2432)


--- trunk/app/controllers/licenses_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/licenses_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -11,6 +11,16 @@
 
   def show
     @license = License.find(params[:id])
+
+    respond_to do |format|
+      format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} licenses address@hidden
+        }
+      end
+    end
   end
 
   def new

Added: trunk/app/controllers/linked_data_controller.rb (0 => 2432)


--- trunk/app/controllers/linked_data_controller.rb	                        (rev 0)
+++ trunk/app/controllers/linked_data_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -0,0 +1,200 @@
+# myExperiment: app/controllers/linked_data_controller.rb
+#
+# Copyright (c) 2007 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class LinkedDataController < ApplicationController
+
+  before_filter :check_contributable_for_view_permission, : [ :attributions, :citations, :comments, :credits, :local_pack_entries, :remote_pack_entries, :policies, :ratings ]
+
+  def attributions
+
+    attribution = Attribution.find_by_id(params[:attribution_id])
+
+    return not_found if attribution.nil?
+    return not_found if attribution.attributable != @contributable
+
+    respond_to do |format|
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} attributions #{attribution.id}`
+        }
+      end
+    end
+  end
+
+  def citations
+
+    citation = Citation.find_by_id(params[:citation_id])
+
+    return not_found if citation.nil?
+    return not_found if citation.workflow != @contributable
+
+    respond_to do |format|
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} citations #{citation.id}`
+        }
+      end
+    end
+  end
+
+  def comments
+
+    comment = Comment.find_by_id(params[:comment_id])
+
+    return not_found if comment.nil?
+    return not_found if comment.commentable != @contributable
+
+    respond_to do |format|
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} comments #{comment.id}`
+        }
+      end
+    end
+  end
+
+  def credits
+
+    credit = Creditation.find_by_id(params[:credit_id])
+
+    return not_found if credit.nil?
+    return not_found if credit.creditable != @contributable
+
+    respond_to do |format|
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} creditations #{credit.id}`
+        }
+      end
+    end
+  end
+
+  def favourites
+
+    user      = User.find_by_id(params[:user_id])
+    favourite = Bookmark.find_by_id(params[:favourite_id])
+
+    return not_found if user.nil?
+    return not_found if favourite.nil?
+    return not_found if favourite.user != user
+
+    respond_to do |format|
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} favourites #{favourite.id}`
+        }
+      end
+    end
+  end
+
+  def local_pack_entries
+
+    local_pack_entry = PackContributableEntry.find_by_id(params[:local_pack_entry_id])
+
+    return not_found if local_pack_entry.nil?
+    return not_found if local_pack_entry.pack != @contributable
+
+    respond_to do |format|
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} local_pack_entries #{local_pack_entry.id}`
+        }
+      end
+    end
+  end
+
+  def remote_pack_entries
+
+    remote_pack_entry = PackRemoteEntry.find_by_id(params[:remote_pack_entry_id])
+
+    return not_found if remote_pack_entry.nil?
+    return not_found if remote_pack_entry.pack != @contributable
+
+    respond_to do |format|
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} remote_pack_entries #{remote_pack_entry.id}`
+        }
+      end
+    end
+  end
+
+  def policies
+
+    policy = Policy.find_by_id(params[:policy_id])
+
+    return not_found if policy.nil?
+    return not_found if policy.contributions.include?(@contributable.contribution) == false
+
+    respond_to do |format|
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} policies #{policy.id}`
+        }
+      end
+    end
+  end
+
+  def ratings
+
+    rating = Rating.find_by_id(params[:rating_id])
+
+    return not_found if rating.nil?
+    return not_found if rating.rateable != @contributable
+
+    respond_to do |format|
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} ratings #{rating.id}`
+        }
+      end
+    end
+  end
+
+  def taggings
+
+    tag     = Tag.find_by_id(params[:tag_id])
+    tagging = Tagging.find_by_id(params[:tagging_id])
+
+    return not_found if tag.nil?
+    return not_found if tagging.nil?
+    return not_found if tagging.tag != tag
+    return not_auth  if Authorization.is_authorized?('view', nil, tagging.taggable, current_user) == false
+
+    respond_to do |format|
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} taggings #{tagging.id}`
+        }
+      end
+    end
+  end
+
+  private
+
+  def check_contributable_for_view_permission
+
+    @contributable = case params[:contributable_type]
+      when 'workflows'; Workflow.find_by_id(params[:contributable_id])
+      when 'files';     Blob.find_by_id(params[:contributable_id])
+      when 'packs';     Pack.find_by_id(params[:contributable_id])
+    end
+
+    return not_found if @contributable.nil?
+    return not_auth  if Authorization.is_authorized?('view', nil, @contributable, current_user) == false
+  end
+
+  def not_found
+    render(:inline => 'Not Found', :status => "404 Not Found")
+    false
+  end
+
+  def not_auth
+    response.headers['WWW-Authenticate'] = "Basic realm=\"#{Conf.sitename}\""
+    render(:inline => 'Not Found', :status => "401 Unauthorized")
+    false
+  end
+end
+

Modified: trunk/app/controllers/memberships_controller.rb (2431 => 2432)


--- trunk/app/controllers/memberships_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/memberships_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -61,6 +61,12 @@
   def show
     respond_to do |format|
       format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} memberships address@hidden
+        }
+      end
     end
   end
 

Modified: trunk/app/controllers/messages_controller.rb (2431 => 2432)


--- trunk/app/controllers/messages_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/messages_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -67,6 +67,12 @@
       @message_folder = message_folder
       respond_to do |format|
         format.html # show.rhtml
+
+        if Conf.rdfgen_enable
+          format.rdf {
+            render :inline => `#{Conf.rdfgen_tool} messages address@hidden
+          }
+        end
       end  
     end
     

Modified: trunk/app/controllers/networks_controller.rb (2431 => 2432)


--- trunk/app/controllers/networks_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/networks_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -332,6 +332,12 @@
 
     respond_to do |format|
       format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} groups address@hidden
+        }
+      end
     end
   end
 

Modified: trunk/app/controllers/packs_controller.rb (2431 => 2432)


--- trunk/app/controllers/packs_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/packs_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -41,6 +41,12 @@
     
     respond_to do |format|
       format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} packs address@hidden
+        }
+      end
     end
   end
   

Modified: trunk/app/controllers/reviews_controller.rb (2431 => 2432)


--- trunk/app/controllers/reviews_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/reviews_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -30,6 +30,12 @@
   def show
     respond_to do |format|
       format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} reviews address@hidden
+        }
+      end
     end
   end
 

Modified: trunk/app/controllers/runners_controller.rb (2431 => 2432)


--- trunk/app/controllers/runners_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/runners_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -21,6 +21,12 @@
   def show
     respond_to do |format|
       format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} runners address@hidden
+        }
+      end
     end
   end
 

Modified: trunk/app/controllers/tags_controller.rb (2431 => 2432)


--- trunk/app/controllers/tags_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/tags_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -18,6 +18,12 @@
   def show
     respond_to do |format|
       format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} tags address@hidden
+        }
+      end
     end
   end
   

Modified: trunk/app/controllers/users_controller.rb (2431 => 2432)


--- trunk/app/controllers/users_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/users_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -46,6 +46,12 @@
     
     respond_to do |format|
       format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          render :inline => `#{Conf.rdfgen_tool} users address@hidden
+        }
+      end
     end
   end
 

Modified: trunk/app/controllers/workflows_controller.rb (2431 => 2432)


--- trunk/app/controllers/workflows_controller.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/app/controllers/workflows_controller.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -231,6 +231,16 @@
 
     respond_to do |format|
       format.html # show.rhtml
+
+      if Conf.rdfgen_enable
+        format.rdf {
+          if params[:version]
+            render :inline => `#{Conf.rdfgen_tool} workflows address@hidden versions/address@hidden
+          else
+            render :inline => `#{Conf.rdfgen_tool} workflows address@hidden
+          end
+        }
+      end
     end
   end
 

Modified: trunk/config/default_settings.yml (2431 => 2432)


--- trunk/config/default_settings.yml	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/config/default_settings.yml	2010-06-11 15:41:18 UTC (rev 2432)
@@ -421,3 +421,8 @@
 
 label_icons:
 
+# rdfgen_enable
+
+rdfgen_enable: false
+
+rdfgen_tool:

Modified: trunk/config/routes.rb (2431 => 2432)


--- trunk/config/routes.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/config/routes.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -5,6 +5,42 @@
   # rest routes
   rest_routes(map)
 
+  # LoD routes
+  if Conf.rdfgen_enable
+
+    map.connect '/:contributable_type/:contributable_id/attributions/:attribution_id.:format',
+      :controller => 'linked_data', :action ="" 'attributions'
+
+    map.connect '/:contributable_type/:contributable_id/citations/:citation_id.:format',
+      :controller => 'linked_data', :action ="" 'citations'
+
+    map.connect '/:contributable_type/:contributable_id/comments/:comment_id.:format',
+      :controller => 'linked_data', :action ="" 'comments'
+
+    map.connect '/:contributable_type/:contributable_id/credits/:credit_id.:format',
+      :controller => 'linked_data', :action ="" 'credits'
+
+    map.connect '/users/:user_id/favourites/:favourite_id.:format',
+      :controller => 'linked_data', :action ="" 'favourites'
+
+    map.connect '/packs/:contributable_id/local_pack_entries/:local_pack_entry_id.:format',
+      :controller => 'linked_data', :action ="" 'local_pack_entries',
+      :contributable_type => 'packs'
+
+    map.connect '/packs/:contributable_id/remote_pack_entries/:remote_pack_entry_id.:format',
+      :controller => 'linked_data', :action ="" 'remote_pack_entries',
+      :contributable_type => 'packs'
+
+    map.connect '/:contributable_type/:contributable_id/policies/:policy_id.:format',
+      :controller => 'linked_data', :action ="" 'policies'
+
+    map.connect '/:contributable_type/:contributable_id/ratings/:rating_id.:format',
+      :controller => 'linked_data', :action ="" 'ratings'
+
+    map.connect '/tags/:tag_id/taggings/:tagging_id.:format',
+      :controller => 'linked_data', :action ="" 'taggings'
+  end
+
   # Runners
   map.resources :runners, :member => { :verify => :get }
   

Modified: trunk/lib/conf.rb (2431 => 2432)


--- trunk/lib/conf.rb	2010-06-09 09:37:24 UTC (rev 2431)
+++ trunk/lib/conf.rb	2010-06-11 15:41:18 UTC (rev 2432)
@@ -134,6 +134,14 @@
     self.fetch_entry('validate_email_veracity')
   end
 
+  def self.rdfgen_enable
+    self.fetch_entry('rdfgen_enable')
+  end
+
+  def self.rdfgen_tool
+    self.fetch_entry('rdfgen_tool')
+  end
+
   # This method is required to create an administrator in the test fixtures
 
   def self.admins=(value)

reply via email to

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