Diff
Modified: branches/apace/app/controllers/algorithms_controller.rb (2155 => 2156)
--- branches/apace/app/controllers/algorithms_controller.rb 2009-04-01 08:52:12 UTC (rev 2155)
+++ branches/apace/app/controllers/algorithms_controller.rb 2009-04-02 15:40:06 UTC (rev 2156)
@@ -6,7 +6,7 @@
class AlgorithmsController < ApplicationController
before_filter :login_required, :except => [:index, :show, :statistics, :search, :all]
before_filter :find_algorithms, : [:all]
- before_filter :find_algorithm_aux, :except => [:search, :index, :new, :create, :all]
+ before_filter :find_algorithm_auth, :except => [:search, :index, :new, :create, :all, :auto_complete]
before_filter :create_empty_object, : [:new, :create]
before_filter :set_sharing_mode_variables, : [:show, :new, :create, :edit, :update]
before_filter :check_can_edit, : [:edit, :update]
@@ -51,6 +51,8 @@
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
+
+ @apps = @contributable.apps.uniq
end
# GET /algorithms/new
@@ -241,6 +243,21 @@
end
end
+ def auto_complete
+
+ @algorithms = Algorithm.find(:all,
+ :conditions => ["LOWER(title) LIKE ?", params["algorithm_input"].downcase + '%'],
+ :order => 'title ASC',
+ :limit => 20,
+ :select => 'DISTINCT *')
+
+ @algorithms = @algorithms.select do |algorithm|
+ Authorization.is_authorized?('view', nil, algorithm, current_user)
+ end
+
+ render :inline => "<%= auto_complete_result @algorithms, 'title' %>"
+ end
+
protected
def find_algorithms
@@ -250,7 +267,7 @@
:current => params[:page] })
end
- def find_algorithm_aux
+ def find_algorithm_auth
begin
algorithm = Algorithm.find(params[:id])
@@ -261,12 +278,20 @@
:host => base_host,
:id => @contributable.id
+ @contributable_label = @contributable.label
+ @contributable_path = algorithm_path(@contributable)
+ @edit_contributable_path = edit_algorithm_path(@contributable)
+ @tag_contributable_path = tag_algorithm_path(@contributable)
+ @favourite_contributable_url = favourite_algorithm_url(@contributable)
+ @favourite_delete_contributable_url = favourite_delete_algorithm_url(@contributable)
+
+
else
if logged_in?
error("Algorithm not found (id not authorized)", "is invalid (not authorized)")
return false
else
- find_algorithm_aux if login_required
+ find_algorithm_auth if login_required
end
end
rescue ActiveRecord::RecordNotFound
Modified: branches/apace/app/controllers/apps_controller.rb (2155 => 2156)
--- branches/apace/app/controllers/apps_controller.rb 2009-04-01 08:52:12 UTC (rev 2155)
+++ branches/apace/app/controllers/apps_controller.rb 2009-04-02 15:40:06 UTC (rev 2156)
@@ -6,10 +6,11 @@
class AppsController < ApplicationController
before_filter :login_required, :except => [:index, :show, :statistics, :search, :all]
before_filter :find_apps, : [:all]
- before_filter :find_app_aux, :except => [:search, :index, :new, :create, :all]
+ before_filter :find_app_auth, :except => [:search, :index, :new, :create, :all]
before_filter :create_empty_object, : [:new, :create]
before_filter :set_sharing_mode_variables, : [:show, :new, :create, :edit, :update]
- before_filter :check_can_edit, : [:edit, :update]
+ before_filter :check_can_edit, : [:edit, :update, :edit_content, :algorithm_create,
+ :algorithm_destroy]
# declare sweepers and which actions should invoke them
cache_sweeper :blob_sweeper, : [ :create, :update, :destroy ]
@@ -51,6 +52,8 @@
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
+
+ @algorithms = @contributable.algorithms.uniq
end
# GET /applications/new
@@ -240,6 +243,37 @@
end
end
+ # GET /applications/1/edit_content
+ def edit_content
+ end
+
+ def algorithm_create
+ algorithm = Algorithm.find_by_title(params["algorithm_input"])
+
+ if algorithm.nil?
+ flash[:error] = "Algorithm Instance not found"
+ else
+ @contributable.algorithms << algorithm
+ end
+
+ render :partial => "algorithm_list"
+ end
+
+ def algorithm_destroy
+
+ ai = AlgorithmInstance.find_by_id(params["algorithm_instance_id"])
+
+ if ai.nil? || (ai.app != @contributable)
+ flash[:error] = "Algorithm Instance not found"
+ redirect_to(application_url(@contributables))
+ return
+ end
+
+ ai.destroy
+
+ render :partial => "algorithm_list"
+ end
+
protected
def find_apps
@@ -249,29 +283,42 @@
:current => params[:page] })
end
- def find_app_aux
- begin
- app = App.find(params[:id])
+ def find_app_auth
+
+ contributable = App.find_by_id(params[:id])
+
+ if contributable.nil?
+ error("Application not found", "is invalid")
+ return false
+ end
- if Authorization.is_authorized?(action_name, nil, app, current_user)
- @contributable = app
-
- @contributable_entry_url = url_for : false,
- :host => base_host,
- :id => @contributable.id
+ # controller specific actions
+ action = "" action_name
+ when 'show'
+ 'view'
+ when 'edit', 'edit_content', 'update', 'destroy', 'algorithm_create', 'algorithm_destroy'
+ 'edit'
else
- if logged_in?
- error("Application not found (id not authorized)", "is invalid (not authorized)")
- return false
- else
- find_app_aux if login_required
- end
- end
- rescue ActiveRecord::RecordNotFound
- error("Application not found", "is invalid")
+ action_name
+ end
+
+ if !Authorization.is_authorized?(action, nil, contributable, current_user)
+ error("Application not found (id not authorized)", "is invalid (not authorized)")
return false
end
+
+ @contributable = contributable
+
+ @contributable_entry_url = url_for(: false, :host => base_host, :id => @contributable.id)
+
+ @contributable_label = @contributable.label
+ @contributable_path = application_path(@contributable)
+ @edit_contributable_path = edit_application_path(@contributable)
+ @tag_contributable_path = tag_application_path(@contributable)
+ @favourite_contributable_url = favourite_application_url(@contributable)
+ @favourite_delete_contributable_url = favourite_delete_application_url(@contributable)
+ @edit_content_contributable_path = edit_content_application_path(@contributable)
end
def create_empty_object
Modified: branches/apace/app/helpers/application_helper.rb (2155 => 2156)
--- branches/apace/app/helpers/application_helper.rb 2009-04-01 08:52:12 UTC (rev 2155)
+++ branches/apace/app/helpers/application_helper.rb 2009-04-02 15:40:06 UTC (rev 2156)
@@ -428,7 +428,7 @@
if c = eval(contributabletype).find_by_id(contributableid)
name = h(c.label)
- return link ? link_to(name, contributable_url(c)) : name
+ return link ? link_to(name, contributable_url(c.contribution.contributable_id, c.contribution.contributable_type)) : name
else
return nil
end
Modified: branches/apace/app/views/algorithms/_table.rhtml (2155 => 2156)
--- branches/apace/app/views/algorithms/_table.rhtml 2009-04-01 08:52:12 UTC (rev 2155)
+++ branches/apace/app/views/algorithms/_table.rhtml 2009-04-02 15:40:06 UTC (rev 2156)
@@ -12,16 +12,16 @@
<% end -%>
<% if show -%>
<tr class="<%= (odd_row = !odd_row) ? "odd_row" : "even_row" %>">
- <% cache(:controller => 'files_cache', :action ="" 'listing', :id => contributable.id) do -%>
+ <% cache(:controller => 'algorithms_cache', :action ="" 'listing', :id => contributable.id) do -%>
<td style="width: 100px;">
<p style="margin-top:0; padding-top:0; text-align: center;"><b>Uploader:</b></p>
<center><%= contributor(contributable.contribution.contributor_id, contributable.contribution.contributor_type, true, 60) %></center>
</td>
<td style="text-align: left;">
<p class="title">
- <%= icon "algorithm", nil, nil, nil, '' %>
- <% title = contributable_name(contributable.id, 'Algorithm') %>
- <%=link_to(query ? highlight_all(title, query) : title, algorithm_path(contributable)) %>
+ <%= icon contributable.class.to_s.underscore, nil, nil, nil, '' %>
+ <% title = contributable.label %>
+ <%= link_to(query ? highlight_all(title, query) : title, algorithm_path(contributable)) %>
</p>
<p style="font-size: 85%; margin-top: 0; padding-top: 0;">
@@ -81,14 +81,14 @@
<a href="" algorithm_path(contributable) + '#tags' -%>"><p style="font-size: 85%;"><b>Tags:</b></p></a>
<div style="display:inline;" class="tags_onesize"><%= tag_cloud_from_collection tags, true %></div>
<% else %>
- <p style="font-size: 85%;"><i>This File has no tags!</i></p>
+ <p style="font-size: 85%;"><i>This Algorithm has no tags!</i></p>
<% end %>
</td>
<% end %>
<td class="actions" style="width: 80px;">
<%= icon "show", algorithm_path(contributable), nil, nil, "View" %>
- <% if mine?(contributable) %><%= icon "manage", edit_file_path(contributable), nil, nil, "Manage" %><% end %>
+ <% if mine?(contributable) %><%= icon "manage", edit_algorithm_path(contributable), nil, nil, "Manage" %><% end %>
</td>
</tr>
<% end %>
Modified: branches/apace/app/views/algorithms/edit.rhtml (2155 => 2156)
--- branches/apace/app/views/algorithms/edit.rhtml 2009-04-01 08:52:12 UTC (rev 2155)
+++ branches/apace/app/views/algorithms/edit.rhtml 2009-04-02 15:40:06 UTC (rev 2156)
@@ -3,33 +3,34 @@
<%= _javascript__include_tag :fckeditor %>
<%= _javascript__include_tag "osp.js" %>
-<h1>Manage Algorithm: <%= contributable_name(@contributable.id, 'Algorithm') %></h1>
+<h1>Manage <%= visible_name(@contributable.class) -%>: <%= @contributable.label %></h1>
<%= error_messages_for :contributable %>
<% form_for(:contributable, :url ="" algorithm_path(@contributable), :html => { :method => :put }) do |f| %>
<p style="text-align: center;">
- <strong>Title: </strong>
- <br/>
- <%= f.text_field :title, :size => 60 %>
+ <strong>Title: </strong>
+ <br />
+ <%= f.text_field :title, :size => 60 %>
</p>
-
- <br/>
+
+ <br />
<p style="text-align: center;">
- <strong>Description: </strong>
- </p>
- <center>
- <%= fckeditor_textarea(:contributable, :description, :toolbarSet => 'Simple', :width => '600px', :height => '300px') %>
- </center>
-
- <br/>
+ <strong>Description: </strong>
+ </p>
+ <center>
+ <%= fckeditor_textarea(:contributable, :description, :toolbarSet => 'Simple', :width => '600px', :height => '300px') %>
+ </center>
+
+ <br />
+
<p style="text-align: center;">
- <strong>URL: </strong>
- <br/>
- <%= f.text_field :url, :size => 60 %>
+ <strong>URL: </strong>
+ <br />
+ <%= f.text_field :url, :size => 60 %>
</p>
<br />
@@ -38,15 +39,12 @@
<%= render :partial => "contributions/credit_attribution_form", :locals => { :edit => true, :contributable => @contributable } %>
- <% 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 %>
+ <%= render :partial => "contributions/sharing_form", :locals => { :edit => true, :contributable => @contributable, :update_perms => true } %>
- <p>
- <center>
- <%= submit_tag "Update",:disable_with => "Updating..." %>
- or <%= link_to "Cancel", algorithm_path(@contributable) %>
- </center>
- </p>
+ <%= render :partial => "license_form", :locals => { :edit => true } %>
+
+ <center>
+ <%= submit_tag "Update",:disable_with => "Updating..." %> or <%= link_to "Cancel", algorithm_path(@contributable) %>
+ </center>
+
<% end %>
Modified: branches/apace/app/views/algorithms/show.rhtml (2155 => 2156)
--- branches/apace/app/views/algorithms/show.rhtml 2009-04-01 08:52:12 UTC (rev 2155)
+++ branches/apace/app/views/algorithms/show.rhtml 2009-04-02 15:40:06 UTC (rev 2156)
@@ -1,138 +1,139 @@
-<% t "#{contributable_name(@contributable.id, 'Algorithm')} (#{h @contributable.contributor_name})" -%>
+<% @contributable_class_label = visible_name(@contributable.class) %>
+<% t "address@hidden (#{h @contributable.contributor_name})" -%>
+
<ul class="sectionIcons">
- <% 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, @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 %>
+ <% if Authorization.is_authorized?('edit', nil, @contributable, current_user) -%>
+ <li><%= icon('manage', @edit_contributable_path, nil, nil, "Manage address@hidden Entry")%></li>
+ <% end -%>
+ <% if Authorization.is_authorized?('destroy', nil, @contributable, current_user) %>
+ <li><%= icon('destroy', @contributable_path, nil, { :confirm => "This deletes the address@hidden and all metadata such as tags, comments and ratings. Are you sure?", :method => :delete }, "Delete address@hidden Entry") %></li>
+ <% end %>
</ul>
-<h1 class="contribution_title">Algorithm Entry: <%= contributable_name(@contributable.id, 'Algorithm') %></h1>
+<h1 class="contribution_title"><%= @contributable_class_label -%> Entry: <%= @contributable.label %></h1>
<%= 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 "Attributions (address@hidden)", "#attributions" %>
- |
- <%= link_to "Tags <span id='mini_nav_tag_link'>(address@hidden)</span>", "#tags" %>
- |
- <%= link_to "Featured in Packs (#{Pack.packs_with_contributable(@contributable).length})", "#featured_in_packs" %>
- |
- <%= link_to "Ratings (address@hidden)", "#ratings" %>
- |
- <%= link_to "Attributed By (address@hidden)", "#attributed_by" %>
- |
- <%= link_to "Favourited By (address@hidden)", "#favourited_by" %>
- |
- <% 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 "License", "#license" %>
+ |
+ <%= link_to "Credits (address@hidden)", "#credits" %>
+ |
+ <%= link_to "Attributions (address@hidden)", "#attributions" %>
+ |
+ <%= link_to "Tags <span id='mini_nav_tag_link'>(address@hidden)</span>", "#tags" %>
+ |
+ <%= link_to "Featured in Packs (#{Pack.packs_with_contributable(@contributable).length})", "#featured_in_packs" %>
+ |
+ <%= link_to "Ratings (address@hidden)", "#ratings" %>
+ |
+ <%= link_to "Attributed By (address@hidden)", "#attributed_by" %>
+ |
+ <%= link_to "Favourited By (address@hidden)", "#favourited_by" %>
+ |
+ <% 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" %>
+ |
</div>
<div class="contribution_left_box">
- <div class="contribution_version_box">
- <div class="contribution_version_inner_box">
- <p>
- <b>Title:</b>
- <span class="title"><%=h @contributable.title %></span>
- </p>
-
- <h3>
- <%= info_icon_with_tooltip("This section shows the overall description for this Algorithm") %>
- Description
- </h3>
-
- <% unless @contributable.description.blank? %>
- <div class="contribution_description">
- <%= @contributable.description_html %>
- </div>
- <% else %>
- <p class="none_text">
- Not set
- </p>
- <% end %>
- </div>
-
- </div>
+ <div class="contribution_version_box">
+ <div class="contribution_version_inner_box">
+ <p>
+ <b>Title:</b>
+ <span class="title"><%=h @contributable.title %></span>
+ </p>
+
+ <h3>
+ <%= info_icon_with_tooltip("This section shows the overall description for this address@hidden") %>
+ Description
+ </h3>
+
+ <% unless @contributable.description.blank? %>
+ <div class="contribution_description">
+ <%= @contributable.description_html %>
+ </div>
+ <% else %>
+ <p class="none_text">
+ Not set
+ </p>
+ <% end %>
+ </div>
+
+ </div>
+ <div class="contribution_version_box">
+ <div class="contribution_version_inner_box">
+ <h3>Applications that use '<%=h @contributable.label -%>'</h3>
+ <%= render :partial => "apps/table", :locals => { :collection => @apps } %>
+ </div>
+ </div>
+
+
</div>
<div class="contribution_right_box">
- <%= render :partial => "contributions/uploader_box", :locals => { :contributable => @contributable } %>
-
- <%= render :partial => "contributions/license_box", :locals => { :contributable => @contributable } %>
-
- <%= render :partial => "contributions/credits_attributions_box", :locals => { :contributable => @contributable, :edit_path => edit_algorithm_path(@contributable) } %>
-
- <%= 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/uploader_box", :locals => { :contributable => @contributable } %>
+
+ <%= render :partial => "contributions/license_box", :locals => { :contributable => @contributable } %>
+
+ <%= render :partial => "contributions/credits_attributions_box", :locals => { :contributable => @contributable, :edit_path => @edit_contributable_path } %>
+
+ <%= render :partial => "tags/tags_box", :locals => { :taggable => @contributable,
+ :owner_id => ((@contributable.contributor_type == 'User') ? @contributable.contributor_id : nil),
+ :add_path => @tag_contributable_path,
+ :edit_path => @edit_contributable_path,
+ :allow_edit => Authorization.is_authorized?('edit', nil, @contributable, current_user) } %>
+
<%= render :partial => "contributions/shared_with_groups_box", :locals => { :contributable => @contributable } %>
-
- <%= render :partial => "contributions/in_packs_box", :locals => { :contributable => @contributable, :contributable_url => @contributable_entry_url } %>
-
- <%= render :partial => "contributions/ratings_box", :locals => { :contributable => @contributable } %>
-
- <%= render :partial => "contributions/attributed_by", :locals => { :contributable => @contributable } %>
-
- <%= 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 => @contributable } %>
-</div>
+
+ <%= render :partial => "contributions/in_packs_box", :locals => { :contributable => @contributable, :contributable_url => @contributable_entry_url } %>
+
+ <%= render :partial => "contributions/ratings_box", :locals => { :contributable => @contributable } %>
+
+ <%= render :partial => "contributions/attributed_by", :locals => { :contributable => @contributable } %>
+
+ <%= render :partial => "contributions/favourited_box", :locals => { :contributable => @contributable,
+ :add_to_favourites_path => @favourite_contribution_url,
+ :remove_from_favourites_path => @favourite_delete_contribution_url } %>
+
+ <%= render :partial => "contributions/statistics_box", :locals => { :contributable => @contributable } %>
+</div>
<div class="clearer"> </div>
<!-- BEGIN tabs -->
-
+
<br/>
<div id="tabsContainer" class="tabsContainer"></div>
-
+
<% if logged_in? and @contributable.owner? current_user %>
- <a name="sharing"></a>
- <div class="tabContainer">
+ <a name="sharing"></a>
+ <div class="tabContainer">
<div class="tabTitle">Sharing</div>
<div class="tabContent">
<%= render :partial => "contributions/sharing_summary", :locals => { :contributable => @contributable } %>
<%= render :partial => "contributions/updating_summary", :locals => { :contributable => @contributable } %>
-
+
<% if Authorization.is_authorized?('edit', nil, @contributable, current_user) %>
<ul class="sectionIcons">
- <li><%= icon('edit', edit_algorithm_path(@contributable), nil, nil, 'Edit')%></li>
+ <li><%= icon('edit', @edit_contributable_path, nil, nil, 'Edit')%></li>
</ul>
<% end %>
</div>
</div>
-
- <% if false %>
- <div class="tabContainer">
- <div class="tabTitle">Viewing History</div>
- <div class="tabContent">
- <%= render :partial => "contributions/history", :object => @contributable.contribution %>
- </div>
- </div>
- <% end %>
-
+
<% end %>
<!-- END tabs -->
@@ -141,5 +142,5 @@
<br/>
<div id="commentsBox">
- <%= render :partial => "comments/comments", :locals => { :commentable => @contributable } %>
+ <%= render :partial => "comments/comments", :locals => { :commentable => @contributable } %>
</div>
Added: branches/apace/app/views/apps/_algorithm_list.rhtml (0 => 2156)
--- branches/apace/app/views/apps/_algorithm_list.rhtml (rev 0)
+++ branches/apace/app/views/apps/_algorithm_list.rhtml 2009-04-02 15:40:06 UTC (rev 2156)
@@ -0,0 +1,17 @@
+<ul>
+ <% @contributable.algorithm_instances.each do |algorithm_instance| %>
+ <% algorithm = algorithm_instance.algorithm %>
+ <li><%= algorithm.label -%>
+ <small>
+ [
+ <%= link_to_remote( "remove",
+ :update => "algorithm_list",
+ :url ="" algorithm_destroy_application_path(:id => @contributable.id, :algorithm_instance_id => algorithm_instance.id),
+ :method => :delete,
+ :complete => "new Effect.Highlight('algorithm_list', { duration: 1.5 }); $('comment').value = '';",
+ :confirm => "Are you sure you want to remove '#{algorithm.title}' from this Application?" ) %>
+ ]
+ </small>
+ </li>
+ <% end %>
+</ul>
Modified: branches/apace/app/views/apps/_table.rhtml (2155 => 2156)
--- branches/apace/app/views/apps/_table.rhtml 2009-04-01 08:52:12 UTC (rev 2155)
+++ branches/apace/app/views/apps/_table.rhtml 2009-04-02 15:40:06 UTC (rev 2156)
@@ -12,16 +12,16 @@
<% end -%>
<% if show -%>
<tr class="<%= (odd_row = !odd_row) ? "odd_row" : "even_row" %>">
- <% cache(:controller => 'files_cache', :action ="" 'listing', :id => contributable.id) do -%>
+ <% cache(:controller => 'apps_cache', :action ="" 'listing', :id => contributable.id) do -%>
<td style="width: 100px;">
<p style="margin-top:0; padding-top:0; text-align: center;"><b>Uploader:</b></p>
<center><%= contributor(contributable.contribution.contributor_id, contributable.contribution.contributor_type, true, 60) %></center>
</td>
<td style="text-align: left;">
<p class="title">
- <%= icon "app", nil, nil, nil, '' %>
- <% title = contributable_name(contributable.id, 'App') %>
- <%=link_to(query ? highlight_all(title, query) : title, application_path(contributable)) %>
+ <%= icon contributable.class.to_s.underscore, nil, nil, nil, '' %>
+ <% title = contributable.label %>
+ <%= link_to(query ? highlight_all(title, query) : title, application_path(contributable)) %>
</p>
<p style="font-size: 85%; margin-top: 0; padding-top: 0;">
@@ -81,14 +81,14 @@
<a href="" application_path(contributable) + '#tags' -%>"><p style="font-size: 85%;"><b>Tags:</b></p></a>
<div style="display:inline;" class="tags_onesize"><%= tag_cloud_from_collection tags, true %></div>
<% else %>
- <p style="font-size: 85%;"><i>This File has no tags!</i></p>
+ <p style="font-size: 85%;"><i>This Application has no tags!</i></p>
<% end %>
</td>
<% end %>
<td class="actions" style="width: 80px;">
<%= icon "show", application_path(contributable), nil, nil, "View" %>
- <% if mine?(contributable) %><%= icon "manage", edit_file_path(contributable), nil, nil, "Manage" %><% end %>
+ <% if mine?(contributable) %><%= icon "manage", edit_application_path(contributable), nil, nil, "Manage" %><% end %>
</td>
</tr>
<% end %>
Modified: branches/apace/app/views/apps/edit.rhtml (2155 => 2156)
--- branches/apace/app/views/apps/edit.rhtml 2009-04-01 08:52:12 UTC (rev 2155)
+++ branches/apace/app/views/apps/edit.rhtml 2009-04-02 15:40:06 UTC (rev 2156)
@@ -3,42 +3,41 @@
<%= _javascript__include_tag :fckeditor %>
<%= _javascript__include_tag "osp.js" %>
-<h1>Manage Application: <%= contributable_name(@contributable.id, 'App') %></h1>
+<h1>Manage <%= visible_name(@contributable.class) -%>: <%= @contributable.label %></h1>
<%= error_messages_for :contributable %>
<% form_for(:contributable, :url ="" application_path(@contributable), :html => { :method => :put }) do |f| %>
<p style="text-align: center;">
- <strong>Title: </strong>
- <br/>
- <%= f.text_field :title, :size => 60 %>
+ <strong>Title: </strong>
+ <br />
+ <%= f.text_field :title, :size => 60 %>
</p>
-
- <br/>
+
+ <br />
<p style="text-align: center;">
- <strong>Description: </strong>
- </p>
- <center>
- <%= fckeditor_textarea(:contributable, :description, :toolbarSet => 'Simple', :width => '600px', :height => '300px') %>
- </center>
-
- <br/>
+ <strong>Description: </strong>
+ </p>
+ <center>
+ <%= fckeditor_textarea(:contributable, :description, :toolbarSet => 'Simple', :width => '600px', :height => '300px') %>
+ </center>
+
+ <br />
+
+
<%= render :partial => "tags/tags_form", :locals => { :edit => true, :taggable => @contributable } %>
<%= render :partial => "contributions/credit_attribution_form", :locals => { :edit => true, :contributable => @contributable } %>
- <% if Authorization.is_authorized?("edit", nil, @contributable, current_user) %>
- <%= render :partial => "contributions/sharing_form", :locals => { :edit => true, :contributable => @contributable, :update_perms => true } %>
- <%= render :partial => "apps/license_form", :locals => { :edit => true } %>
- <% end %>
+ <%= render :partial => "contributions/sharing_form", :locals => { :edit => true, :contributable => @contributable, :update_perms => true } %>
- <p>
- <center>
- <%= submit_tag "Update",:disable_with => "Updating..." %>
- or <%= link_to "Cancel", application_path(@contributable) %>
- </center>
- </p>
+ <%= render :partial => "license_form", :locals => { :edit => true } %>
+
+ <center>
+ <%= submit_tag "Update",:disable_with => "Updating..." %> or <%= link_to "Cancel", application_path(@contributable) %>
+ </center>
+
<% end %>
Added: branches/apace/app/views/apps/edit_content.rhtml (0 => 2156)
--- branches/apace/app/views/apps/edit_content.rhtml (rev 0)
+++ branches/apace/app/views/apps/edit_content.rhtml 2009-04-02 15:40:06 UTC (rev 2156)
@@ -0,0 +1,34 @@
+<% @contributable_class_label = visible_name(@contributable.class) %>
+
+<% t "Edit address@hidden (#{h @contributable.contributor_name})" -%>
+
+<h3>Algorithms:</h3>
+
+<div id="algorithm_list">
+ <%= render :partial => "algorithm_list" %>
+</div>
+
+<h3>Add an Algorithm to this Application</h3>
+
+<% remote_form_for(:algorithm_instance,
+ :url ="" algorithm_create_application_path(@contributable),
+ :html => { :method => :post },
+ :complete => "new Effect.Highlight('algorithm_list', { duration: 1.5 }); $('algorithm_input').value = '';",
+ :update => "algorithm_list") do |f| %>
+
+ <input id="algorithm_input" type="text" style="width: 500px;" name="algorithm_input" autocomplete="off"/>
+
+ <div class="auto_complete" id="algorithm_auto_complete" ></div>
+
+ <%= auto_complete_field "algorithm_input",
+ :update => "algorithm_auto_complete",
+ :url ="" {:controller => 'algorithms', :action ="" 'auto_complete'},
+ :tokens => ',',
+ :indicator => "algorithm_auto_complete_indicator" -%>
+
+ <img id="algorithm_auto_complete_indicator" style="margin-top: 0.2em; display: none;" src="" />
+
+ <%= submit_tag "Add" %>
+
+<% end %>
+
Modified: branches/apace/app/views/apps/show.rhtml (2155 => 2156)
--- branches/apace/app/views/apps/show.rhtml 2009-04-01 08:52:12 UTC (rev 2155)
+++ branches/apace/app/views/apps/show.rhtml 2009-04-02 15:40:06 UTC (rev 2156)
@@ -1,138 +1,139 @@
-<% t "#{contributable_name(@contributable.id, 'App')} (#{h @contributable.contributor_name})" -%>
+<% @contributable_class_label = visible_name(@contributable.class) %>
+<% t "address@hidden (#{h @contributable.contributor_name})" -%>
+
<ul class="sectionIcons">
- <% if Authorization.is_authorized?('edit', nil, @contributable, current_user) -%>
- <li><%= icon('manage', edit_application_path(@contributable), nil, nil, 'Manage Application Entry')%></li>
- <% end -%>
- <% if Authorization.is_authorized?('destroy', nil, @contributable, current_user) %>
- <li><%= icon('destroy', application_path(@contributable), nil, { :confirm => 'This deletes the Application and all metadata such as tags, comments and ratings. Are you sure?', :method => :delete }, 'Delete Application Entry') %></li>
- <% end %>
+ <% if Authorization.is_authorized?('edit', nil, @contributable, current_user) -%>
+ <li><%= icon('manage', @edit_contributable_path, nil, nil, "Manage address@hidden Entry")%></li>
+ <li><%= icon('edit', @edit_content_contributable_path, nil, nil, "Edit address@hidden")%></li>
+ <% end -%>
+ <% if Authorization.is_authorized?('destroy', nil, @contributable, current_user) %>
+ <li><%= icon('destroy', @contributable_path, nil, { :confirm => "This deletes the address@hidden and all metadata such as tags, comments and ratings. Are you sure?", :method => :delete }, "Delete address@hidden Entry") %></li>
+ <% end %>
</ul>
-<h1 class="contribution_title">Application Entry: <%= contributable_name(@contributable.id, 'App') %></h1>
+<h1 class="contribution_title"><%= @contributable_class_label -%> Entry: <%= @contributable.label %></h1>
<%= 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 "Attributions (address@hidden)", "#attributions" %>
- |
- <%= link_to "Tags <span id='mini_nav_tag_link'>(address@hidden)</span>", "#tags" %>
- |
- <%= link_to "Featured in Packs (#{Pack.packs_with_contributable(@contributable).length})", "#featured_in_packs" %>
- |
- <%= link_to "Ratings (address@hidden)", "#ratings" %>
- |
- <%= link_to "Attributed By (address@hidden)", "#attributed_by" %>
- |
- <%= link_to "Favourited By (address@hidden)", "#favourited_by" %>
- |
- <% 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 "License", "#license" %>
+ |
+ <%= link_to "Credits (address@hidden)", "#credits" %>
+ |
+ <%= link_to "Attributions (address@hidden)", "#attributions" %>
+ |
+ <%= link_to "Tags <span id='mini_nav_tag_link'>(address@hidden)</span>", "#tags" %>
+ |
+ <%= link_to "Featured in Packs (#{Pack.packs_with_contributable(@contributable).length})", "#featured_in_packs" %>
+ |
+ <%= link_to "Ratings (address@hidden)", "#ratings" %>
+ |
+ <%= link_to "Attributed By (address@hidden)", "#attributed_by" %>
+ |
+ <%= link_to "Favourited By (address@hidden)", "#favourited_by" %>
+ |
+ <% 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" %>
+ |
</div>
<div class="contribution_left_box">
- <div class="contribution_version_box">
- <div class="contribution_version_inner_box">
- <p>
- <b>Title:</b>
- <span class="title"><%=h @contributable.title %></span>
- </p>
-
- <h3>
- <%= info_icon_with_tooltip("This section shows the overall description for this Application") %>
- Description
- </h3>
-
- <% unless @contributable.description.blank? %>
- <div class="contribution_description">
- <%= @contributable.description_html %>
- </div>
- <% else %>
- <p class="none_text">
- Not set
- </p>
- <% end %>
- </div>
-
- </div>
+ <div class="contribution_version_box">
+ <div class="contribution_version_inner_box">
+ <p>
+ <b>Title:</b>
+ <span class="title"><%=h @contributable.title %></span>
+ </p>
+
+ <h3>
+ <%= info_icon_with_tooltip("This section shows the overall description for this address@hidden") %>
+ Description
+ </h3>
+
+ <% unless @contributable.description.blank? %>
+ <div class="contribution_description">
+ <%= @contributable.description_html %>
+ </div>
+ <% else %>
+ <p class="none_text">
+ Not set
+ </p>
+ <% end %>
+ </div>
+
+ </div>
+ <div class="contribution_version_box">
+ <div class="contribution_version_inner_box">
+ <h3>Algorithms used in <%=h @contributable.label -%></h3>
+ <%= render :partial => "algorithms/table", :locals => { :collection => @algorithms } %>
+ </div>
+ </div>
+
</div>
<div class="contribution_right_box">
- <%= render :partial => "contributions/uploader_box", :locals => { :contributable => @contributable } %>
-
- <%= render :partial => "contributions/license_box", :locals => { :contributable => @contributable } %>
-
- <%= render :partial => "contributions/credits_attributions_box", :locals => { :contributable => @contributable, :edit_path => edit_application_path(@contributable) } %>
-
- <%= render :partial => "tags/tags_box", :locals => { :taggable => @contributable,
- :owner_id => ((@contributable.contributor_type == 'User') ? @contributable.contributor_id : nil),
- :add_path => tag_application_path(@contributable),
- :edit_path => edit_application_path(@contributable),
- :allow_edit => Authorization.is_authorized?('edit', nil, @contributable, current_user) } %>
-
+ <%= render :partial => "contributions/uploader_box", :locals => { :contributable => @contributable } %>
+
+ <%= render :partial => "contributions/license_box", :locals => { :contributable => @contributable } %>
+
+ <%= render :partial => "contributions/credits_attributions_box", :locals => { :contributable => @contributable, :edit_path => @edit_contributable_path } %>
+
+ <%= render :partial => "tags/tags_box", :locals => { :taggable => @contributable,
+ :owner_id => ((@contributable.contributor_type == 'User') ? @contributable.contributor_id : nil),
+ :add_path => @tag_contributable_path,
+ :edit_path => @edit_contributable_path,
+ :allow_edit => Authorization.is_authorized?('edit', nil, @contributable, current_user) } %>
+
<%= render :partial => "contributions/shared_with_groups_box", :locals => { :contributable => @contributable } %>
-
- <%= render :partial => "contributions/in_packs_box", :locals => { :contributable => @contributable, :contributable_url => @contributable_entry_url } %>
-
- <%= render :partial => "contributions/ratings_box", :locals => { :contributable => @contributable } %>
-
- <%= render :partial => "contributions/attributed_by", :locals => { :contributable => @contributable } %>
-
- <%= render :partial => "contributions/favourited_box", :locals => { :contributable => @contributable,
- :add_to_favourites_path => favourite_application_url(@contributable),
- :remove_from_favourites_path => favourite_delete_application_url(@contributable) } %>
-
- <%= render :partial => "contributions/statistics_box", :locals => { :contributable => @contributable } %>
-</div>
+
+ <%= render :partial => "contributions/in_packs_box", :locals => { :contributable => @contributable, :contributable_url => @contributable_entry_url } %>
+
+ <%= render :partial => "contributions/ratings_box", :locals => { :contributable => @contributable } %>
+
+ <%= render :partial => "contributions/attributed_by", :locals => { :contributable => @contributable } %>
+
+ <%= render :partial => "contributions/favourited_box", :locals => { :contributable => @contributable,
+ :add_to_favourites_path => @favourite_contribution_url,
+ :remove_from_favourites_path => @favourite_delete_contribution_url } %>
+
+ <%= render :partial => "contributions/statistics_box", :locals => { :contributable => @contributable } %>
+</div>
<div class="clearer"> </div>
<!-- BEGIN tabs -->
-
+
<br/>
<div id="tabsContainer" class="tabsContainer"></div>
-
+
<% if logged_in? and @contributable.owner? current_user %>
- <a name="sharing"></a>
- <div class="tabContainer">
+ <a name="sharing"></a>
+ <div class="tabContainer">
<div class="tabTitle">Sharing</div>
<div class="tabContent">
<%= render :partial => "contributions/sharing_summary", :locals => { :contributable => @contributable } %>
<%= render :partial => "contributions/updating_summary", :locals => { :contributable => @contributable } %>
-
+
<% if Authorization.is_authorized?('edit', nil, @contributable, current_user) %>
<ul class="sectionIcons">
- <li><%= icon('edit', edit_application_path(@contributable), nil, nil, 'Edit')%></li>
+ <li><%= icon('edit', @edit_contributable_path, nil, nil, 'Edit')%></li>
</ul>
<% end %>
</div>
</div>
-
- <% if false %>
- <div class="tabContainer">
- <div class="tabTitle">Viewing History</div>
- <div class="tabContent">
- <%= render :partial => "contributions/history", :object => @contributable.contribution %>
- </div>
- </div>
- <% end %>
-
+
<% end %>
<!-- END tabs -->
@@ -141,5 +142,5 @@
<br/>
<div id="commentsBox">
- <%= render :partial => "comments/comments", :locals => { :commentable => @contributable } %>
+ <%= render :partial => "comments/comments", :locals => { :commentable => @contributable } %>
</div>
Modified: branches/apace/config/routes.rb (2155 => 2156)
--- branches/apace/config/routes.rb 2009-04-01 08:52:12 UTC (rev 2155)
+++ branches/apace/config/routes.rb 2009-04-02 15:40:06 UTC (rev 2156)
@@ -88,7 +88,7 @@
# algorithms
map.resources :algorithms,
- :collection => { :all => :get, :search => :get },
+ :collection => { :all => :get, :search => :get, :auto_complete => :get },
:member => { :statistics => :get,
:favourite => :post,
:favourite_delete => :delete,
@@ -103,8 +103,11 @@
:controller => :apps,
:collection => { :all => :get, :search => :get },
:member => { :statistics => :get,
+ :edit_content => :get,
:favourite => :post,
:favourite_delete => :delete,
+ :algorithm_create => :post,
+ :algorithm_destroy => :delete,
:comment => :post,
:comment_delete => :delete,
:rate => :post,