myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2143] branches/apace: search and some refactorin


From: noreply
Subject: [myexperiment-hackers] [2143] branches/apace: search and some refactoring
Date: Sun, 29 Mar 2009 09:30:57 -0400 (EDT)

Revision
2143
Author
dgc
Date
2009-03-29 09:30:56 -0400 (Sun, 29 Mar 2009)

Log Message

search and some refactoring

Modified Paths

Diff

Modified: branches/apace/app/controllers/algorithms_controller.rb (2142 => 2143)


--- branches/apace/app/controllers/algorithms_controller.rb	2009-03-27 13:51:40 UTC (rev 2142)
+++ branches/apace/app/controllers/algorithms_controller.rb	2009-03-29 13:30:56 UTC (rev 2143)
@@ -1,4 +1,4 @@
-# myExperiment: app/controllers/blobs_controller.rb
+# myExperiment: app/controllers/algorithms_controller.rb
 #
 # Copyright (c) 2007 University of Manchester and the University of Southampton.
 # See license.txt for details.
@@ -16,7 +16,6 @@
   cache_sweeper :permission_sweeper,       : [ :create, :update, :destroy ]
   cache_sweeper :bookmark_sweeper,         : [ :destroy, :favourite, :favourite_delete ]
   cache_sweeper :tag_sweeper,              : [ :create, :update, :tag, :destroy ]
-  cache_sweeper :download_viewing_sweeper, : [ :show, :download, :named_download ]
   cache_sweeper :comment_sweeper,          : [ :comment, :comment_delete ]
   cache_sweeper :rating_sweeper,           : [ :rate ]
   
@@ -25,44 +24,22 @@
     @query = params[:query] || ''
     @query.strip!
     
-    @algorithms = (SOLR_ENABLE && address@hidden) ? Algorithm.find_by_solr(@query, :limit => 100).results : []
-    @algorithms_found_total_count = (SOLR_ENABLE && address@hidden) ? Algorithm.count_by_solr(@query) : 0
+    @contributables = (SOLR_ENABLE && address@hidden) ? Algorithm.find_by_solr(@query, :limit => 100).results : []
+    @total_count = (SOLR_ENABLE && address@hidden) ? Algorithm.count_by_solr(@query) : 0
     
     respond_to do |format|
       format.html # search.rhtml
     end
   end
   
-  # GET /files/1;download
-  def download
-    if allow_statistics_logging(@blob)
-      @download = Download.create(:contribution => @blob.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'], :accessed_from_site => accessed_from_website?())
-    end
-    
-    send_data(@blob.content_blob.data, :filename => @blob.local_name, :type => @blob.content_type)
-    
-    #send_file("#{RAILS_ROOT}/#{controller_name}/address@hidden/address@hidden/address@hidden", :filename => @blob.local_name, :type => @blob.content_type)
-  end
-
-  # GET /files/:id/download/:name
-  def named_download
-
-    # check that we got the right filename for this workflow
-    if params[:name] == @blob.local_name
-      download
-    else
-      render :nothing => true, :status => "404 Not Found"
-    end
-  end
-
-  # GET /files
+  # GET /algorithms
   def index
     respond_to do |format|
       format.html # index.rhtml
     end
   end
   
-  # GET /files/all
+  # GET /algorithms/all
   def all
     respond_to do |format|
       format.html # all.rhtml
@@ -71,8 +48,8 @@
   
   # GET /algorithms/1
   def show
-    if allow_statistics_logging(@algorithm)
-      @viewing = Viewing.create(:contribution => @algorithm.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'], :accessed_from_site => accessed_from_website?())
+    if allow_statistics_logging(@contributable)
+      @viewing = Viewing.create(:contribution => @contributable.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'], :accessed_from_site => accessed_from_website?())
     end
   end
   
@@ -87,37 +64,38 @@
   # POST /algorithms
   def create
   
-    @algorithm = Algorithm.new(
+    @contributable = Algorithm.new(
         :contributor => current_user,
-        :title       => params[:algorithm][:title],
-        :description => params[:algorithm][:description],
-        :license     => params[:algorithm][:license])
+        :title       => params[:contributable][:title],
+        :description => params[:contributable][:description],
+        :url         ="" params[:contributable][:title],
+        :license     => params[:contributable][:license])
 
-    if @algorithm.save == false
+    if @contributable.save == false
       render :action ="" "new"
       return
     end
 
-    if params[:algorithm][:tag_list]
-      @algorithm.tags_user_id = current_user
-      @algorithm.tag_list = convert_tags_to_gem_format params[:algorithm][:tag_list]
-      @algorithm.update_tags
+    if params[:contributable][:tag_list]
+      @contributable.tags_user_id = current_user
+      @contributable.tag_list = convert_tags_to_gem_format params[:contributable][:tag_list]
+      @contributable.update_tags
     end
 
     # update policy
-    @algorithm.contribution.update_attributes(params[:contribution])
+    @contributable.contribution.update_attributes(params[:contribution])
   
-    policy_err_msg = update_policy(@algorithm, params)
+    policy_err_msg = update_policy(@contributable, params)
   
-    update_credits(@algorithm, params)
-    update_attributions(@algorithm, params)
+    update_credits(@contributable, params)
+    update_attributions(@contributable, params)
   
     if policy_err_msg.blank?
       flash[:notice] = 'Algorithm was successfully created.'
-      redirect_to algorithm_url(@algorithm)
+      redirect_to algorithm_url(@contributable)
     else
       flash[:notice] = "Algorithm was successfully created. However some problems occurred, please see these below.</br></br><span style='color: red;'>" + policy_err_msg + "</span>"
-      redirect_to :controller => 'algorithms', :id => @algorithm, :action ="" "edit"
+      redirect_to :controller => 'algorithms', :id => @contributable, :action ="" "edit"
     end
   end
   
@@ -130,26 +108,26 @@
     end
     
     # remove protected columns
-    if params[:algorithm]
+    if params[:contributable]
       [:contributor_id, :contributor_type, :content_type, :local_name, :created_at, :updated_at].each do |column_name|
-        params[:algorithm].delete(column_name)
+        params[:contributable].delete(column_name)
       end
     end
     
     respond_to do |format|
-      if @algorithm.update_attributes(params[:algorithm])
-        @algorithm.refresh_tags(convert_tags_to_gem_format(params[:algorithm][:tag_list]), current_user) if params[:algorithm][:tag_list]
+      if @contributable.update_attributes(params[:contributable])
+        @contributable.refresh_tags(convert_tags_to_gem_format(params[:contributable][:tag_list]), current_user) if params[:contributable][:tag_list]
         
-        policy_err_msg = update_policy(@algorithm, params)
-        update_credits(@algorithm, params)
-        update_attributions(@algorithm, params)
+        policy_err_msg = update_policy(@contributable, params)
+        update_credits(@contributable, params)
+        update_attributions(@contributable, params)
         
         if policy_err_msg.blank?
           flash[:notice] = 'Algorithm was successfully updated.'
-          format.html { redirect_to algorithm_url(@algorithm) }
+          format.html { redirect_to algorithm_url(@contributable) }
         else
           flash[:error] = policy_err_msg
-          format.html { redirect_to :controller => 'algorithms', :id => @algorithm, :action ="" "edit" }
+          format.html { redirect_to :controller => 'algorithms', :id => @contributable, :action ="" "edit" }
         end
       else
         format.html { render :action ="" "edit" }
@@ -157,100 +135,100 @@
     end
   end
   
-  # DELETE /files/1
+  # DELETE /algorithms/1
   def destroy
-    success = @blob.destroy
+    success = @contributable.destroy
 
     respond_to do |format|
       if success
-        flash[:notice] = "File has been deleted."
-        format.html { redirect_to files_url }
+        flash[:notice] = "Algorithm has been deleted."
+        format.html { redirect_to algorithms_url }
       else
-        flash[:error] = "Failed to delete File. Please contact your administrator."
-        format.html { redirect_to file_url(@blob) }
+        flash[:error] = "Failed to delete Algorithm. Please contact your administrator."
+        format.html { redirect_to algorithm_url(@contributable) }
       end
     end
   end
   
-  # POST /files/1;comment
+  # POST /algorithms/1;comment
   def comment 
     text = params[:comment][:comment]
     
     if text and text.length > 0
       comment = Comment.create(:user => current_user, :comment => text)
-      @blob.comments << comment
+      @contributable.comments << comment
     end
     
     respond_to do |format|
-      format.html { render :partial => "comments/comments", :locals => { :commentable => @blob } }
+      format.html { render :partial => "comments/comments", :locals => { :commentable => @contributable } }
     end
   end
   
-  # DELETE /files/1;comment_delete
+  # DELETE /algorithms/1;comment_delete
   def comment_delete
     if params[:comment_id]
       comment = Comment.find(params[:comment_id].to_i)
       # security checks:
-      if comment.user_id == current_user.id and comment.commentable_type.downcase == 'blob' and comment.commentable_id == @blob.id
+      if comment.user_id == current_user.id and comment.commentable_type == 'Algorithm' and comment.commentable_id == @contributable.id
         comment.destroy
       end
     end
     
     respond_to do |format|
-      format.html { render :partial => "comments/comments", :locals => { :commentable => @blob } }
+      format.html { render :partial => "comments/comments", :locals => { :commentable => @contributable } }
     end
   end
   
-  # POST /files/1;rate
+  # POST /algorithms/1;rate
   def rate
-    if @blob.contributor_type == 'User' and @blob.contributor_id == current_user.id
-      error("You cannot rate your own file!", "")
+    if @contributable.contributor_type == 'User' and @contributable.contributor_id == current_user.id
+      error("You cannot rate your own content!", "")
     else
-      Rating.delete_all(["rateable_type = ? AND rateable_id = ? AND user_id = ?", @blob.class.to_s, @blob.id, current_user.id])
+      Rating.delete_all(["rateable_type = ? AND rateable_id = ? AND user_id = ?", @contributable.class.to_s, @contributable.id, current_user.id])
       
-      @blob.ratings << Rating.create(:user => current_user, :rating => params[:rating])
+      @contributable.ratings << Rating.create(:user => current_user, :rating => params[:rating])
       
       respond_to do |format|
         format.html { 
           render :update do |page|
-            page.replace_html "ratings_inner", :partial => "contributions/ratings_box_inner", :locals => { :contributable => @blob, :controller_name => controller.controller_name }
-            page.replace_html "ratings_breakdown", :partial => "contributions/ratings_box_breakdown", :locals => { :contributable => @blob }
+            page.replace_html "ratings_inner", :partial => "contributions/ratings_box_inner", :locals => { :contributable => @contributable, :controller_name => controller.controller_name }
+            page.replace_html "ratings_breakdown", :partial => "contributions/ratings_box_breakdown", :locals => { :contributable => @contributable }
           end }
       end
     end
   end
   
-  # POST /files/1;tag
+  # POST /algorithms/1;tag
   def tag
-    @blob.tags_user_id = current_user # acts_as_taggable_redux
-    @blob.tag_list = "address@hidden, #{convert_tags_to_gem_format params[:tag_list]}" if params[:tag_list]
-    @blob.update_tags # hack to get around acts_as_versioned
+    @contributable.tags_user_id = current_user # acts_as_taggable_redux
+    @contributable.tag_list = "address@hidden, #{convert_tags_to_gem_format params[:tag_list]}" if params[:tag_list]
+    @contributable.update_tags # hack to get around acts_as_versioned
     
     respond_to do |format|
       format.html { 
         render :update do |page|
-          unique_tag_count = @blob.tags.uniq.length
+          unique_tag_count = @contributable.tags.uniq.length
           page.replace_html "mini_nav_tag_link", "(#{unique_tag_count})"
           page.replace_html "tags_box_header_tag_count_span", "(#{unique_tag_count})"
-          page.replace_html "tags_inner_box", :partial => "tags/tags_box_inner", :locals => { :taggable => @blob, :owner_id => @blob.contributor_id } 
+          page.replace_html "tags_inner_box", :partial => "tags/tags_box_inner", :locals => { :taggable => @contributable, :owner_id => @contributable.contributor_id } 
         end
       }
     end
   end
   
-  # POST /files/1;favourite
+  # POST /algorithms/1;favourite
   def favourite
-    @blob.bookmarks << Bookmark.create(:user => current_user) unless @blob.bookmarked_by_user?(current_user)
+    @contributable.bookmarks << Bookmark.create(:user => current_user) unless @contributable.bookmarked_by_user?(current_user)
     
     respond_to do |format|
       flash[:notice] = "You have successfully added this item to your favourites."
-      format.html { redirect_to file_url(@blob) }
+      format.html { redirect_to algorithm_url(@contributable) }
     end
   end
   
-  # DELETE /files/1;favourite_delete
+  # DELETE /algorithms/1;favourite_delete
   def favourite_delete
-    @blob.bookmarks.each do |b|
+    @contributable.bookmarks.each do |b|
       if b.user_id == current_user.id
         b.destroy
       end
@@ -258,7 +236,7 @@
     
     respond_to do |format|
       flash[:notice] = "You have successfully removed this item from your favourites."
-      redirect_url = params[:return_to] ? params[:return_to] : file_url(@blob)
+      redirect_url = params[:return_to] ? params[:return_to] : algorithm_url(@contributable)
       format.html { redirect_to redirect_url }
     end
   end
@@ -266,16 +244,10 @@
   protected
   
   def find_algorithms
-    found = Blob.find(:all, 
-                       :order => "content_type ASC, local_name ASC, created_at DESC",
+    @contributables = Algorithm.find(:all, 
+                       :order => "created_at DESC",
                        :page => { :size => 20, 
                        :current => params[:page] })
-    
-    found.each do |blob|
-      blob.content_blob.data = "" unless Authorization.is_authorized?("download", nil, blob, current_user)
-    end
-    
-    @blobs = found
   end
   
   def find_algorithm_aux
@@ -283,11 +255,11 @@
       algorithm = Algorithm.find(params[:id])
       
       if Authorization.is_authorized?(action_name, nil, algorithm, current_user)
-        @algorithm = algorithm
+        @contributable = algorithm
         
-        @algorithm_entry_url = url_for : false,
+        @contributable_entry_url = url_for : false,
                             :host => base_host,
-                            :id => @algorithm.id
+                            :id => @contributable.id
 
       else
         if logged_in? 
@@ -304,7 +276,7 @@
   end
   
   def create_empty_object
-    @algorithm = Algorithm.new
+    @contributable = Algorithm.new
   end
   
   def set_sharing_mode_variables
@@ -316,13 +288,13 @@
         @sharing_mode  = params[:sharing][:class_id].to_i if params[:sharing]
         @updating_mode = params[:updating][:class_id].to_i if params[:updating]
       when "show", "edit"
-        @sharing_mode  = @algorithm.contribution.policy.share_mode
-        @updating_mode = @algorithm.contribution.policy.update_mode
+        @sharing_mode  = @contributable.contribution.policy.share_mode
+        @updating_mode = @contributable.contribution.policy.update_mode
     end
   end
 
   def check_can_edit
-    if @algorithm && !Authorization.is_authorized?('edit', nil, @algorithm, current_user)
+    if @contributable && !Authorization.is_authorized?('edit', nil, @contributable, current_user)
       error("You are not authorised to manage this Algorithm", "")
     end
   end

Modified: branches/apace/app/controllers/search_controller.rb (2142 => 2143)


--- branches/apace/app/controllers/search_controller.rb	2009-03-27 13:51:40 UTC (rev 2142)
+++ branches/apace/app/controllers/search_controller.rb	2009-03-29 13:30:56 UTC (rev 2143)
@@ -14,10 +14,10 @@
       return false
     end
 
-    # Hacks for 'Groups' --> 'Networks' and 'Files' --> 'Blobs' renames
-    @type = 'networks' if @type == 'groups'
-    @type = 'blobs' if @type == 'files'
-    
+    if Conf.model_aliases.key?(@type.camelize.singularize)
+      @type = address@hidden
+    end
+
     if @type == "all"
       search_all
     else
@@ -136,11 +136,13 @@
 
     if SOLR_ENABLE && address@hidden
 
-      categories = Conf.search_categories - ['all']
+      categories = (Conf.search_categories - ['all']).map do |category|
+        if Conf.model_aliases.key?(category.camelize.singularize)
+          category = Conf.model_aliases[category.camelize.singularize].pluralize.underscore
+        end
 
-      # Hack for renamed models
-      index = categories.index("groups"); categories[index] = "networks" unless index.nil?
-      index = categories.index("files");  categories[index] = "blobs"    unless index.nil?
+        category
+      end
 
       models = categories.map do |category| eval(category.singularize.camelize) end
 
@@ -162,20 +164,8 @@
           })
         end
       end
-
-      @users_found_total_count = User.count_by_solr(@query)
-      @workflows_found_total_count = Workflow.count_by_solr(@query)
-      @blobs_found_total_count = Blob.count_by_solr(@query)
-      @networks_found_total_count = Network.count_by_solr(@query)
-      @packs_found_total_count = Pack.count_by_solr(@query)
     end
 
-    @users     = @results.select do |r| r.instance_of?(User)     end
-    @workflows = @results.select do |r| r.instance_of?(Workflow) end
-    @blobs     = @results.select do |r| r.instance_of?(Blob)     end
-    @networks  = @results.select do |r| r.instance_of?(Network)  end
-    @packs     = @results.select do |r| r.instance_of?(Pack)     end
-
     respond_to do |format|
       format.html # search.rhtml
     end

Modified: branches/apace/app/views/algorithms/_breadcrumbs.rhtml (2142 => 2143)


--- branches/apace/app/views/algorithms/_breadcrumbs.rhtml	2009-03-27 13:51:40 UTC (rev 2142)
+++ branches/apace/app/views/algorithms/_breadcrumbs.rhtml	2009-03-29 13:30:56 UTC (rev 2143)
@@ -4,11 +4,11 @@
   <li><b>&#187;</b></li>
   
   <% case controller.action_name.to_s; when "show" -%>
-    <li><%= contributable_name(@algorithm.id, 'Algorithm') -%></li>
+    <li><%= contributable_name(@contributable.id, 'Algorithm') -%></li>
   <% when "new" %>
     <li>New Algorithm</li>
   <% when "edit" %>
-		<li><%= link_to "#{contributable_name(@algorithm.id, 'Algorithm')}", algorithm_path(@algorithm) -%></li>
+		<li><%= link_to "#{contributable_name(@contributable.id, 'Algorithm')}", algorithm_path(@contributable) -%></li>
 		<li><b>&#187;</b></li>
     <li>Manage</li>
   <% when "all" %>

Modified: branches/apace/app/views/algorithms/_license_form.rhtml (2142 => 2143)


--- branches/apace/app/views/algorithms/_license_form.rhtml	2009-03-27 13:51:40 UTC (rev 2142)
+++ branches/apace/app/views/algorithms/_license_form.rhtml	2009-03-29 13:30:56 UTC (rev 2143)
@@ -1,7 +1,7 @@
-<% if params[:algorithm] && !params[:algorithm][:license].blank? %>
-	<% license = params[:algorithm][:license] %>
+<% if params[:contributable] && !params[:contributable][:license].blank? %>
+	<% license = params[:contributable][:license] %>
 <% elsif edit %>
-	<% license = @algorithm.license %>
+	<% license = @contributable.license %>
 <% else %>
  	<% license = 'by-sa' %> 
 <% end %>
@@ -44,7 +44,7 @@
             	<tbody>
             		<tr>
 						<td style="vertical-align: top; text-align: center;">
-			                <input id="algorithm_license_bysa" <%= 'checked="checked"' if (license == 'by-sa') %> name="algorithm[license]" type="radio" value="by-sa"/>
+			                <input id="algorithm_license_bysa" <%= 'checked="checked"' if (license == 'by-sa') %> name="contributable[license]" type="radio" value="by-sa"/>
 						</td>
 						<td style="vertical-align: top; text-align: left;">
 			                <p style="padding: 0; margin: 0;">
@@ -57,7 +57,7 @@
             		</tr>
 					<tr>
 						<td style="vertical-align: top; text-align: center;">
-                			<input id="algorithm_license_by" <%= 'checked="checked"' if (license == 'by') %> name="algorithm[license]" type="radio" value="by"/>
+                			<input id="algorithm_license_by" <%= 'checked="checked"' if (license == 'by') %> name="contributable[license]" type="radio" value="by"/>
 						</td>
 						<td style="vertical-align: top; text-align: left;">	
             				<p style="padding: 0; margin: 0;">
@@ -69,7 +69,7 @@
             		</tr>
 					<tr>
 						<td style="vertical-align: top; text-align: center;">
-                			<input id="algorithm_license_bynd" <%= 'checked="checked"' if (license == 'by-nd') %> name="algorithm[license]" type="radio" value="by-nd"/>
+                			<input id="algorithm_license_bynd" <%= 'checked="checked"' if (license == 'by-nd') %> name="contributable[license]" type="radio" value="by-nd"/>
 						</td>
 						<td style="vertical-align: top; text-align: left;">
             				<p style="padding: 0; margin: 0;">

Modified: branches/apace/app/views/algorithms/all.rhtml (2142 => 2143)


--- branches/apace/app/views/algorithms/all.rhtml	2009-03-27 13:51:40 UTC (rev 2142)
+++ branches/apace/app/views/algorithms/all.rhtml	2009-03-29 13:30:56 UTC (rev 2143)
@@ -1,9 +1,9 @@
 <% t "All" -%>
 
-<h2>All Files</h2>
+<h2>All Algorithms</h2>
 
-<%= render :partial => "layouts/paginate", :locals => { :collection => @algorithms } %>
+<%= render :partial => "layouts/paginate", :locals => { :collection => @contributables } %>
 
-<%= render :partial => "algorithms/table", :locals => { :collection => @algorithms } %>
+<%= render :partial => "algorithms/table", :locals => { :collection => @contributables } %>
 
-<%= render :partial => "layouts/paginate", :locals => { :collection => @algorithms } %>
+<%= render :partial => "layouts/paginate", :locals => { :collection => @contributables } %>

Modified: branches/apace/app/views/algorithms/edit.rhtml (2142 => 2143)


--- branches/apace/app/views/algorithms/edit.rhtml	2009-03-27 13:51:40 UTC (rev 2142)
+++ branches/apace/app/views/algorithms/edit.rhtml	2009-03-29 13:30:56 UTC (rev 2143)
@@ -3,11 +3,11 @@
 <%= _javascript__include_tag :fckeditor %>
 <%= _javascript__include_tag "osp.js" %>
 
-<h1>Manage Algorithm: <%= contributable_name(@algorithm.id, 'Algorithm') %></h1>
+<h1>Manage Algorithm: <%= contributable_name(@contributable.id, 'Algorithm') %></h1>
 
-<%= error_messages_for :algorithm %>
+<%= error_messages_for :contributable %>
 
-<% form_for(:algorithm, :url ="" algorithm_path(@algorithm), :html => { :method => :put }) do |f| %>
+<% form_for(:contributable, :url ="" algorithm_path(@contributable), :html => { :method => :put }) do |f| %>
 
   <p style="text-align: center;">
   	<strong>Title: </strong>
@@ -21,24 +21,32 @@
   	<strong>Description: </strong>
 	</p>
 	<center>
-		<%= fckeditor_textarea(:algorithm, :description, :toolbarSet => 'Simple', :width => '600px', :height => '300px') %>
+		<%= fckeditor_textarea(:contributable, :description, :toolbarSet => 'Simple', :width => '600px', :height => '300px') %>
 	</center>
   
   <br/>
 
-  <%= render :partial => "tags/tags_form", :locals => { :edit => true, :taggable => @algorithm } %>
+  <p style="text-align: center;">
+  	<strong>URL: </strong>
+	<br/>
+	<%= f.text_field :url, :size => 60 %>
+  </p>
+	
+  <br />
+
+  <%= render :partial => "tags/tags_form", :locals => { :edit => true, :taggable => @contributable } %>
   
-  <%= render :partial => "contributions/credit_attribution_form", :locals => { :edit => true, :contributable => @algorithm } %>
+  <%= render :partial => "contributions/credit_attribution_form", :locals => { :edit => true, :contributable => @contributable } %>
 
-  <% if Authorization.is_authorized?("edit", nil, @algorithm, current_user) %>
-  	<%= render :partial => "contributions/sharing_form",  :locals => { :edit => true, :contributable => @algorithm, :update_perms => true } %>
+  <% if Authorization.is_authorized?("edit", nil, @contributable, current_user) %>
+  	<%= render :partial => "contributions/sharing_form",  :locals => { :edit => true, :contributable => @contributable, :update_perms => true } %>
 	<%= render :partial => "algorithms/license_form", :locals => { :edit => true } %>
   <% end %>
 
   <p>
     <center>
     	<%= submit_tag "Update",:disable_with => "Updating..." %> 
-		or <%= link_to "Cancel", algorithm_path(@algorithm) %>
+		or <%= link_to "Cancel", algorithm_path(@contributable) %>
 	</center>
   </p>
 <% end %>

Modified: branches/apace/app/views/algorithms/new.rhtml (2142 => 2143)


--- branches/apace/app/views/algorithms/new.rhtml	2009-03-27 13:51:40 UTC (rev 2142)
+++ branches/apace/app/views/algorithms/new.rhtml	2009-03-29 13:30:56 UTC (rev 2143)
@@ -5,14 +5,14 @@
 
 <h1>New Algorithm</h1>
 
-<%= error_messages_for :algorithm %>
+<%= error_messages_for :contributable %>
 
 <% form_tag({ :action ="" :create }, :multipart => true) do %>
 
   <p style="text-align: center;">
     <strong>Title: </strong>
     <br/>
-    <%= text_field_tag "algorithm[title]", nil, :size => 60 %>
+    <%= text_field_tag "contributable[title]", @contributable.title, :size => 60 %>
   </p>
 
   <br/>
@@ -22,17 +22,25 @@
   </p>
 
   <center>
-    <%= fckeditor_textarea(:algorithm, :description, :toolbarSet => 'Simple', :width => '600px', :height => '300px') %>
+    <%= fckeditor_textarea(:contributable, :description, :toolbarSet => 'Simple', :width => '600px', :height => '300px') %>
   </center>
 
   <br />
 
-  <%= render :partial => "tags/tags_form", :locals => { :edit => false, :taggable => @algorithm } %>
+  <p style="text-align: center;">
+    <strong>URL: </strong>
+    <br/>
+    <%= text_field_tag "contributable[url]", @contributable.url, :size => 60 %>
+  </p>
 
-  <%= render :partial => "contributions/credit_attribution_form", :locals => { :edit => false, :contributable => @algorithm } %>
+  <br />
 
-  <%= render :partial => "contributions/sharing_form",  :locals => { :edit => false, :contributable => @algorithm, :update_perms => true } %>
+  <%= render :partial => "tags/tags_form", :locals => { :edit => false, :taggable => @contributable } %>
 
+  <%= render :partial => "contributions/credit_attribution_form", :locals => { :edit => false, :contributable => @contributable } %>
+
+  <%= render :partial => "contributions/sharing_form",  :locals => { :edit => false, :contributable => @contributable, :update_perms => true } %>
+
   <%= render :partial => "algorithms/license_form", :locals => { :edit => false } %>
 
   <%= render :partial => 'contributions/terms_and_conditions' %>

Modified: branches/apace/app/views/algorithms/search.rhtml (2142 => 2143)


--- branches/apace/app/views/algorithms/search.rhtml	2009-03-27 13:51:40 UTC (rev 2142)
+++ branches/apace/app/views/algorithms/search.rhtml	2009-03-29 13:30:56 UTC (rev 2143)
@@ -2,11 +2,11 @@
 
 <h1>Search Results</h1>
 
-<h2>Showing <%= pluralize(@algorithms.length, "file") %> of <%= @algorithms_found_total_count -%> found for <%= @query ? "\"address@hidden"" : "" %></h2>
+<h2>Showing <%= pluralize(@contributables.length, "algorithm") %> of <%= @total_count -%> found for <%= @query ? "\"address@hidden"" : "" %></h2>
 
 <%= view_privileges_notice %>
 <br/>
 
-<%= render :partial => "algorithms/table", :locals => { :collection => @algorithms } %>
+<%= render :partial => "algorithms/table", :locals => { :collection => @contributables } %>
 
 <br />

Modified: branches/apace/app/views/algorithms/show.rhtml (2142 => 2143)


--- branches/apace/app/views/algorithms/show.rhtml	2009-03-27 13:51:40 UTC (rev 2142)
+++ branches/apace/app/views/algorithms/show.rhtml	2009-03-29 13:30:56 UTC (rev 2143)
@@ -1,44 +1,44 @@
-<% t "#{contributable_name(@algorithm.id, 'Algorithm')} (#{h @algorithm.contributor_name})" -%>
+<% t "#{contributable_name(@contributable.id, 'Algorithm')} (#{h @contributable.contributor_name})" -%>
 
 <ul class="sectionIcons">
-	<% if Authorization.is_authorized?('edit', nil, @algorithm, current_user) -%>
-		<li><%= icon('manage', edit_algorithm_path(@algorithm), nil, nil, 'Manage Algorithm Entry')%></li>
+	<% if Authorization.is_authorized?('edit', nil, @contributable, current_user) -%>
+		<li><%= icon('manage', edit_algorithm_path(@contributable), nil, nil, 'Manage Algorithm Entry')%></li>
 	<% end -%>
-	<% if Authorization.is_authorized?('destroy', nil, @algorithm, current_user) %>
-		<li><%= icon('destroy', algorithm_path(@algorithm), nil, { :confirm => 'This deletes the Algorithm and all metadata such as tags, comments and ratings. Are you sure?', :method => :delete }, 'Delete Algorithm Entry') %></li>
+	<% if Authorization.is_authorized?('destroy', nil, @contributable, current_user) %>
+		<li><%= icon('destroy', algorithm_path(@contributable), nil, { :confirm => 'This deletes the Algorithm and all metadata such as tags, comments and ratings. Are you sure?', :method => :delete }, 'Delete Algorithm Entry') %></li>
 	<% end %>
 </ul>
 
-<h1 class="contribution_title">Algorithm Entry: <%= contributable_name(@algorithm.id, 'Algorithm') %></h1>
+<h1 class="contribution_title">Algorithm Entry: <%= contributable_name(@contributable.id, 'Algorithm') %></h1>
 
-<%= render :partial => "contributions/datetime_info", :locals => { :contributable => @algorithm } -%>
+<%= render :partial => "contributions/datetime_info", :locals => { :contributable => @contributable } -%>
 
 <div class="contribution_mini_nav">
 	|
 	<%= link_to "License", "#license" %>
 	|
-	<%= link_to "Credits (address@hidden)", "#credits" %>
+	<%= link_to "Credits (address@hidden)", "#credits" %>
 	|
-	<%= link_to "Attributions (address@hidden)", "#attributions" %>
+	<%= link_to "Attributions (address@hidden)", "#attributions" %>
 	|
-	<%= link_to "Tags <span id='mini_nav_tag_link'>(address@hidden)</span>", "#tags" %>
+	<%= link_to "Tags <span id='mini_nav_tag_link'>(address@hidden)</span>", "#tags" %>
 	|
-	<%= link_to "Featured in Packs (#{Pack.packs_with_contributable(@algorithm).length})", "#featured_in_packs" %>
+	<%= link_to "Featured in Packs (#{Pack.packs_with_contributable(@contributable).length})", "#featured_in_packs" %>
 	|
-	<%= link_to "Ratings (address@hidden)", "#ratings" %>
+	<%= link_to "Ratings (address@hidden)", "#ratings" %>
 	|
-	<%= link_to "Attributed By (address@hidden)", "#attributed_by" %>
+	<%= link_to "Attributed By (address@hidden)", "#attributed_by" %>
 	|
-	<%= link_to "Favourited By (address@hidden)", "#favourited_by" %>
+	<%= link_to "Favourited By (address@hidden)", "#favourited_by" %>
 	| 
-	<% if logged_in? and @algorithm.owner?(current_user) %>
+	<% if logged_in? and @contributable.owner?(current_user) %>
 	  <br/>
 	  |
 		<!-- NB! Index of the 'sharing' tab might change! -->
 	  <a href="" 
 	  |
 	<% end %>
-	<%= link_to "Comments (address@hidden)", "#comments" %> 
+	<%= link_to "Comments (address@hidden)", "#comments" %> 
 	|
 </div>
 
@@ -47,7 +47,7 @@
 		<div class="contribution_version_inner_box">
 			<p>
 			    <b>Title:</b>
-			    <span class="title"><%=h @algorithm.title %></span>
+			    <span class="title"><%=h @contributable.title %></span>
 			</p>
 			
 			<h3>
@@ -55,9 +55,9 @@
 				Description
 			</h3>
 			
-			<% unless @algorithm.description.blank? %>
+			<% unless @contributable.description.blank? %>
 				<div class="contribution_description">
-					<%= @algorithm.description_html %>
+					<%= @contributable.description_html %>
 				</div>
 			<% else %>
 				<p class="none_text">
@@ -71,31 +71,31 @@
 </div>
 
 <div class="contribution_right_box">
-	<%= render :partial => "contributions/uploader_box", :locals => { :contributable => @algorithm } %>
+	<%= render :partial => "contributions/uploader_box", :locals => { :contributable => @contributable } %>
 	
-	<%= render :partial => "contributions/license_box", :locals => { :contributable => @algorithm } %>
+	<%= render :partial => "contributions/license_box", :locals => { :contributable => @contributable } %>
 	
-	<%= render :partial => "contributions/credits_attributions_box", :locals => { :contributable => @algorithm, :edit_path => edit_algorithm_path(@algorithm) } %>
+	<%= render :partial => "contributions/credits_attributions_box", :locals => { :contributable => @contributable, :edit_path => edit_algorithm_path(@contributable) } %>
 	
-	<%= render :partial => "tags/tags_box", :locals => { :taggable => @algorithm, 
-																											 :owner_id => ((@algorithm.contributor_type == 'User') ? @algorithm.contributor_id : nil), 
-																											 :add_path => tag_algorithm_path(@algorithm), 
-																											 :edit_path => edit_algorithm_path(@algorithm),
-																											 :allow_edit => Authorization.is_authorized?('edit', nil, @algorithm, current_user) } %>
+	<%= render :partial => "tags/tags_box", :locals => { :taggable => @contributable, 
+																											 :owner_id => ((@contributable.contributor_type == 'User') ? @contributable.contributor_id : nil), 
+																											 :add_path => tag_algorithm_path(@contributable), 
+																											 :edit_path => edit_algorithm_path(@contributable),
+																											 :allow_edit => Authorization.is_authorized?('edit', nil, @contributable, current_user) } %>
 																											 
-  <%= render :partial => "contributions/shared_with_groups_box", :locals => { :contributable => @algorithm } %>
+  <%= render :partial => "contributions/shared_with_groups_box", :locals => { :contributable => @contributable } %>
 	
-	<%= render :partial => "contributions/in_packs_box", :locals => { :contributable => @algorithm, :contributable_url => @algorithm_entry_url } %>
+	<%= render :partial => "contributions/in_packs_box", :locals => { :contributable => @contributable, :contributable_url => @contributable_entry_url } %>
 	
-	<%= render :partial => "contributions/ratings_box", :locals => { :contributable => @algorithm } %>
+	<%= render :partial => "contributions/ratings_box", :locals => { :contributable => @contributable } %>
 	
-	<%= render :partial => "contributions/attributed_by", :locals => { :contributable => @algorithm } %>
+	<%= render :partial => "contributions/attributed_by", :locals => { :contributable => @contributable } %>
 	
-	<%= render :partial => "contributions/favourited_box", :locals => { :contributable => @algorithm,
-																																			:add_to_favourites_path => favourite_file_url(@algorithm),
-																																			:remove_from_favourites_path => favourite_delete_file_url(@algorithm) } %>
+	<%= render :partial => "contributions/favourited_box", :locals => { :contributable => @contributable,
+																																			:add_to_favourites_path => favourite_algorithm_url(@contributable),
+																																			:remove_from_favourites_path => favourite_delete_algorithm_url(@contributable) } %>
 	
-	<%= render :partial => "contributions/statistics_box", :locals => { :contributable => @algorithm } %>
+	<%= render :partial => "contributions/statistics_box", :locals => { :contributable => @contributable } %>
 </div>	
 
 <div class="clearer">&nbsp;</div>
@@ -106,19 +106,19 @@
 
 <div id="tabsContainer" class="tabsContainer"></div>
 	
-<% if logged_in? and @algorithm.owner? current_user %>
+<% if logged_in? and @contributable.owner? current_user %>
   
 	<a name="sharing"></a>
 	<div class="tabContainer">
     <div class="tabTitle">Sharing</div>
     <div class="tabContent">
 
-      <%= render :partial => "contributions/sharing_summary",  :locals => { :contributable => @algorithm } %>
-      <%= render :partial => "contributions/updating_summary", :locals => { :contributable => @algorithm } %>
+      <%= render :partial => "contributions/sharing_summary",  :locals => { :contributable => @contributable } %>
+      <%= render :partial => "contributions/updating_summary", :locals => { :contributable => @contributable } %>
 	  
-      <% if Authorization.is_authorized?('edit', nil, @algorithm, current_user) %>
+      <% if Authorization.is_authorized?('edit', nil, @contributable, current_user) %>
         <ul class="sectionIcons">
-          <li><%= icon('edit', edit_algorithm_path(@algorithm), nil, nil, 'Edit')%></li>
+          <li><%= icon('edit', edit_algorithm_path(@contributable), nil, nil, 'Edit')%></li>
         </ul>
       <% end %>
     </div>
@@ -128,7 +128,7 @@
   <div class="tabContainer">
     <div class="tabTitle">Viewing History</div>
     <div class="tabContent">
-      <%= render :partial => "contributions/history", :object => @algorithm.contribution %>
+      <%= render :partial => "contributions/history", :object => @contributable.contribution %>
     </div>
   </div>
 	<% end %>
@@ -141,5 +141,5 @@
 <br/>
 
 <div id="commentsBox">
-	<%= render :partial => "comments/comments", :locals => { :commentable => @algorithm } %>
+	<%= render :partial => "comments/comments", :locals => { :commentable => @contributable } %>
 </div>

Modified: branches/apace/config/routes.rb (2142 => 2143)


--- branches/apace/config/routes.rb	2009-03-27 13:51:40 UTC (rev 2142)
+++ branches/apace/config/routes.rb	2009-03-29 13:30:56 UTC (rev 2143)
@@ -89,8 +89,7 @@
   # algorithms
   map.resources :algorithms, 
     :collection => { :all => :get, :search => :get }, 
-    :member => { :download => :get,
-                 :statistics => :get,
+    :member => { :statistics => :get,
                  :favourite => :post,
                  :favourite_delete => :delete,
                  :comment => :post, 

reply via email to

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