Diff
Modified: branches/biocat/app/controllers/application.rb (2651 => 2652)
--- branches/biocat/app/controllers/application.rb 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/controllers/application.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -385,6 +385,16 @@
end
end
+ def send_cached_data(file_name, *opts)
+
+ if !File.exists?(file_name)
+ FileUtils.mkdir_p(File.dirname(file_name))
+ File.open(file_name, "wb+") { |f| f.write(yield) }
+ end
+
+ send_file(file_name, *opts)
+ end
+
# Pivot code
def pivot_options
Modified: branches/biocat/app/controllers/pictures_controller.rb (2651 => 2652)
--- branches/biocat/app/controllers/pictures_controller.rb 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/controllers/pictures_controller.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -173,17 +173,5 @@
format.html { redirect_to logged_in? ? pictures_url(current_user) : '' }
end
end
-
- # file system cache
-
- def send_cached_data(file_name, *opts)
-
- if !File.exists?(file_name)
- FileUtils.mkdir_p(File.dirname(file_name))
- File.open(file_name, "wb+") { |f| f.write(yield) }
- end
-
- send_file(file_name, *opts)
- end
end
Copied: branches/biocat/app/controllers/previews_controller.rb (from rev 2651, trunk/app/controllers/previews_controller.rb) (0 => 2652)
--- branches/biocat/app/controllers/previews_controller.rb (rev 0)
+++ branches/biocat/app/controllers/previews_controller.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -0,0 +1,94 @@
+# myExperiment: app/controllers/previews_controller.rb
+#
+# Copyright (c) 2011 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class PreviewsController < ApplicationController
+
+ before_filter :find_context
+
+ def show
+
+ auth = request.env["HTTP_AUTHORIZATION"]
+ user = current_user
+
+ if auth and auth.starts_with?("Basic ")
+ credentials = Base64.decode64(auth.sub(/^Basic /, '')).split(':')
+ user = User.authenticate(credentials[0], credentials[1])
+
+ if user.nil?
+ render :nothing => true, :status => "401 Unauthorized"
+ response.headers['WWW-Authenticate'] = "Basic realm=\"#{Conf.sitename} REST API\""
+ return
+ end
+ end
+
+ if @context.preview.nil?
+ render :nothing => true, :status => "404 Not Found"
+ return
+ end
+
+ if @context.respond_to?("versioned_resource")
+ auth_object = @context.versioned_resource
+ else
+ auth_object = @context
+ end
+
+ if Authorization.check(:action ="" 'view', :object => auth_object, :user => user) == false
+ render :nothing => true, :status => "401 Unauthorized"
+ response.headers['WWW-Authenticate'] = "Basic realm=\"#{Conf.sitename} REST API\""
+ return
+ end
+
+ type = params[:id]
+
+ case type
+
+ when 'full'; name = 'full'; source = 'image'; size = nil; mime_type = 'image/jpeg'
+ when 'medium'; name = 'medium'; source = 'image'; size = 500; mime_type = 'image/jpeg'
+ when 'thumb'; name = 'thumb'; source = 'image'; size = 100; mime_type = 'image/jpeg'
+ when 'svg'; name = 'svg'; source = 'svg'; size = nil; mime_type = 'image/svg+xml'
+ else
+ render(:inline => 'Bad preview type', :status => "400 Bad Request")
+ return
+ end
+
+ file_name = @context.preview.file_name(type)
+
+ send_cached_data(file_name, :type => mime_type, :disposition => 'inline') {
+
+ case source
+ when 'image'; content_blob = @context.preview.image_blob
+ when 'svg'; content_blob = @context.preview.svg_blob
+ end
+
+ data = ""
+
+ if size
+
+ img = Magick::Image.from_blob(data).first
+ img = img.change_geometry("#{size}x#{size}>") do |c, r, i| i.resize(c, r) end
+
+ result = Magick::Image.new(img.columns, img.rows)
+ result = result.composite(img, 0, 0, Magick::OverCompositeOp)
+ result.format = "jpg"
+
+ data = ""
+ end
+
+ data
+ }
+ end
+
+ private
+
+ def find_context
+ @context = extract_resource_context(params)
+ return false unless @context
+
+ @context = @context.find_version(params[:version]) if params[:version]
+ return false unless @context
+ end
+
+end
+
Modified: branches/biocat/app/controllers/users_controller.rb (2651 => 2652)
--- branches/biocat/app/controllers/users_controller.rb 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/controllers/users_controller.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -44,8 +44,6 @@
@lod_rdf = formatted_user_url(:id => @user.id, :format => 'rdf')
@lod_xml = formatted_user_url(:id => @user.id, :format => 'xml')
- @tab = "News" if @tab.nil?
-
@user.salt = nil
@user.crypted_password = nil
Modified: branches/biocat/app/controllers/workflows_controller.rb (2651 => 2652)
--- branches/biocat/app/controllers/workflows_controller.rb 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/controllers/workflows_controller.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -9,6 +9,7 @@
before_filter :login_required, :except => [:index, :show, :download, :named_download, :galaxy_tool, :galaxy_tool_download, :statistics, :launch, :search]
+ before_filter :store_callback, : [:index, :search]
before_filter :find_workflows_rss, : [:index]
before_filter :find_workflow_auth, :except => [:search, :index, :new, :create]
@@ -116,14 +117,14 @@
@download = Download.create(:contribution => @workflow.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'], :accessed_from_site => accessed_from_website?())
end
- send_data(@viewing_version.content_blob.data, :filename => @workflow.filename(@viewing_version_number), :type => @workflow.content_type.mime_type)
+ send_data(@viewing_version.content_blob.data, :filename => @workflow.filename(@viewing_version_number), :type => @viewing_version.content_type.mime_type)
end
# GET /workflows/:id/download/:name
def named_download
# check that we got the right filename for this workflow
- if params[:name] == @workflow.filename
+ if params[:name] == @workflow.filename(@viewing_version_number)
download
else
render :nothing => true, :status => "404 Not Found"
@@ -546,13 +547,16 @@
logger.debug("Preview image provided. Attempting to set the version's preview image.")
# Disable updating image on windows due to issues to do with file locking, that prevent file_column from working sometimes.
+ #
+ # The dependency on file_column has been removed, but this code remains
+ # disabled on Windows until it is confirmed as working.
if RUBY_PLATFORM =~ /mswin32/
success = false
else
success = @workflow.update_version(params[:version],
:title => params[:workflow][:title],
:body => params[:workflow][:body],
- :image => params[:workflow][:preview],
+ :image => params[:workflow][:preview].read,
:last_edited_by => current_user.id)
end
end
@@ -643,6 +647,26 @@
protected
+ def store_callback
+ if params[:callback]
+ session_object={ :url ="" params[:callback], :label => 'Launch', :additional => 'externally', :format => 'xml' }
+ if params[:callback_contenttypes]
+ session_object[:types] =
+ params[:callback_contenttypes].split(',').map {|x| x.to_i }
+ end
+ if params[:callback_label]
+ session_object[:label] = params[:callback_label]
+ end
+ if params[:callback_additional]
+ session_object[:additional] = params[:callback_additional]
+ end
+ if params[:callback_format]
+ session_object[:format] = params[:callback_format]
+ end
+ session[:callback]=session_object
+ end
+ end
+
def find_workflows_rss
# Only carry out if request is for RSS
if params[:format] and params[:format].downcase == 'rss'
@@ -694,7 +718,7 @@
:id => @workflow.id,
:version => @viewing_version_number.to_s
- @named_download_url = url_for @workflow.named_download_url + "address@hidden"
+ @named_download_url = url_for @workflow.named_download_url(@viewing_version_number) + "address@hidden"
@launch_url = "/workflows/address@hidden/address@hidden"
@@ -895,8 +919,8 @@
# Set the internal unique name for this particular workflow (or workflow_version).
workflow_to_set.set_unique_name
- workflow_to_set.image = processor_instance.get_preview_image if processor_class.can_generate_preview_image?
- workflow_to_set.svg = processor_instance.get_preview_svg if processor_class.can_generate_preview_svg?
+ workflow_to_set.image = processor_instance.get_preview_image.read if processor_class.can_generate_preview_image?
+ workflow_to_set.svg = processor_instance.get_preview_svg.read if processor_class.can_generate_preview_svg?
rescue Exception => ex
worked = false
err_msg = "ERROR: some processing failed in workflow processor '#{processor_class.to_s}'.\nEXCEPTION: #{ex}"
@@ -948,8 +972,11 @@
# Preview image
# TODO: kept getting permission denied errors from the file_column and rmagick code, so disable for windows, for now.
+ #
+ # The dependency on file_column has been removed, but this code remains
+ # disabled on Windows until it is confirmed as working.
unless RUBY_PLATFORM =~ /mswin32/
- workflow_to_set.image = params[:workflow][:preview]
+ workflow_to_set.image = params[:workflow][:preview] unless params[:workflow][:preview].empty?
end
# Set the internal unique name for this particular workflow (or workflow_version).
Modified: branches/biocat/app/helpers/application_helper.rb (2651 => 2652)
--- branches/biocat/app/helpers/application_helper.rb 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/helpers/application_helper.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -1570,4 +1570,22 @@
return "Your OpenID URL is: #{user.openid_url}" if user.openid_url
end
+ def callback_url(item)
+ item_url = nil
+ if session && session[:callback]:
+ case session[:callback][:format]
+ when 'uri'
+ item_url = rest_resource_uri(item)
+ when 'xml'
+ item_url = rest_access_uri(item)
+ else
+ return nil
+ end
+ end
+ if item_url
+ return session[:callback][:url]+URI.escape(item_url,'?!#&/')
+ else
+ return nil
+ end
+ end
end
Modified: branches/biocat/app/models/blob.rb (2651 => 2652)
--- branches/biocat/app/models/blob.rb 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/models/blob.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -42,6 +42,12 @@
validates_presence_of :title
+ validates_each :content_blob do |record, attr, value|
+ if value.data.size > Conf.max_upload_size
+ record.errors.add(:file, "is too big. Maximum size is #{Conf.max_upload_size} bytes.")
+ end
+ end
+
format_attribute :body
def type
Modified: branches/biocat/app/models/pack.rb (2651 => 2652)
--- branches/biocat/app/models/pack.rb 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/models/pack.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -45,7 +45,7 @@
:dependent => :destroy
def items_count
- return contributable_entries_count + remote_entries_count
+ return contributable_entries.count + remote_entries.count
end
# returns packs that have largest total number of items
Copied: branches/biocat/app/models/preview.rb (from rev 2651, trunk/app/models/preview.rb) (0 => 2652)
--- branches/biocat/app/models/preview.rb (rev 0)
+++ branches/biocat/app/models/preview.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -0,0 +1,23 @@
+# myExperiment: app/models/preview.rb
+#
+# Copyright (c) 2011 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class Preview < ActiveRecord::Base
+
+ PREFIX = "tmp/previews"
+
+ acts_as_structured_data
+
+ # :dependent => :destroy is not supported in belongs_to in rails 1.2.6
+ after_destroy { |p| p.content_blob.destroy }
+
+ def file_name(type)
+ "#{PREFIX}/#{id}/#{type}"
+ end
+
+ def clear_cache
+ FileUtils.rm_rf("#{PREFIX}/#{id}")
+ end
+end
+
Modified: branches/biocat/app/models/workflow.rb (2651 => 2652)
--- branches/biocat/app/models/workflow.rb 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/models/workflow.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -11,6 +11,7 @@
require 'explicit_versioning'
require 'acts_as_reviewable'
require 'acts_as_runnable'
+require 'lib/previews'
require 'scufl/model'
require 'scufl/parser'
@@ -50,20 +51,14 @@
acts_as_reviewable
+ acts_as_structured_data
+
+ has_previews
+
explicit_versioning(:version_column => "current_version",
- :file_columns => ["image", "svg"],
+ :extra_attributes => ["image", "svg"],
:white_list_columns => ["body"]) do
- file_column :image, :magick => {
- :versions => {
- :thumb => { :size => "100x100" },
- :medium => { :size => "500x500>" },
- :full => { }
- }
- }
-
- file_column :svg
-
format_attribute :body
belongs_to :content_blob
@@ -78,7 +73,9 @@
# Update the parent contribution model buy only if this isn't the current version (because the workflow model will take care of that).
# This is required to keep the contribution's updated_at field accurate.
after_save { |wv| wv.workflow.contribution.save if wv.workflow.contribution && wv.version != wv.workflow.current_version }
-
+
+ has_previews
+
def components
if workflow.processor_class
workflow.processor_class.new(content_blob.data).get_components
@@ -86,9 +83,21 @@
XML::Node.new('components')
end
end
+
+ def processor_class
+ if self.content_type
+ @processor_class ||= WorkflowTypesHandler.processor_class_for_type_display_name(self.content_type.title)
+ end
+ end
+
+ def display_data_format
+ klass = self.processor_class
+ @display_data_format = (klass.nil? ? self.file_ext : klass.display_data_format)
+ end
+
end
- non_versioned_columns.push("license_id", "tag_list")
+ non_versioned_columns.push("license_id", "tag_list", "preview_id")
acts_as_solr(:fields => [ :title, :body, :tag_list, :contributor_name, :kind, :get_all_search_terms ],
:boost => "rank",
@@ -106,16 +115,6 @@
validates_presence_of :content_blob
validates_presence_of :content_type
- file_column :image, :magick => {
- :versions => {
- :thumb => { :size => "100x100>" },
- :medium => { :size => "500x500>" },
- :full => { },
- }
- }
-
- file_column :svg
-
def tag_list_comma
list = ''
tags.each do |t|
@@ -176,7 +175,7 @@
metadata
end
- # This method is called before save and attempts to pull out metadata if it
+ # This method is called before validation and attempts to pull out metadata if it
# hasn't been set
def apply_extracted_metadata
@@ -236,12 +235,12 @@
return "#{unique_name}.#{file_ext}"
else
return nil unless (workflow_version = self.find_version(version))
- return "#{workflow_version.unique_name}.#{file_ext}"
+ return "#{workflow_version.unique_name}.#{workflow_version.file_ext}"
end
end
- def named_download_url
- "#{Conf.base_uri}/workflows/#{id}/download/#{filename}"
+ def named_download_url(version = nil)
+ "#{Conf.base_uri}/workflows/#{id}/download/#{filename(version)}"
end
def get_all_search_terms
Modified: branches/biocat/app/views/blobs/_table.rhtml (2651 => 2652)
--- branches/biocat/app/views/blobs/_table.rhtml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/views/blobs/_table.rhtml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -79,8 +79,8 @@
<p style="font-size:85%;"><b>File type: </b><%= h blob.content_type.title %></p>
<p style="font-size: 85%;">
- <a href="" file_path(blob) + '#ratings' -%>"><b>Rating: </b><%= number_with_precision(blob.rating, 1) %> / 5 (<%= pluralize blob.ratings_count, 'rating' %>)</a> |
- <a href="" file_path(blob) + '#comments' -%>"><b>Comments: </b><%= blob.comments_count %></a> |
+ <a href="" file_path(blob) + '#ratings' -%>"><b>Rating: </b><%= number_with_precision(blob.rating, 1) %> / 5 (<%= pluralize blob.ratings.count, 'rating' %>)</a> |
+ <a href="" file_path(blob) + '#comments' -%>"><b>Comments: </b><%= blob.comments.count %></a> |
<b>Viewed:</b> <%=pluralize blob.contribution.site_viewings_count, "time" %> |
<b>Downloaded:</b> <%=pluralize blob.contribution.site_downloads_count, "time" %>
</p>
Modified: branches/biocat/app/views/content_types/index.rhtml (2651 => 2652)
--- branches/biocat/app/views/content_types/index.rhtml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/views/content_types/index.rhtml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -15,6 +15,7 @@
<thead>
<tr>
<td>Title</td>
+ <td>Count</td>
<td>Category</td>
</tr>
</thead>
@@ -22,6 +23,7 @@
<% @content_types.each do |ct| %>
<tr>
<td><%= link_to(h(ct.title), content_type_path(ct)) %></td>
+ <td style="text-align: right"><%= Contribution.count(:conditions => ['content_type_id = ?', ct.id]) -%></td>
<td><%= visible_name(ct.category) %></td>
<% end %>
</tbody>
Modified: branches/biocat/app/views/content_types/show.rhtml (2651 => 2652)
--- branches/biocat/app/views/content_types/show.rhtml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/views/content_types/show.rhtml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -1,7 +1,8 @@
<% t "#{h @content_type.title}" -%>
<ul class="sectionIcons">
- <li><%= icon('workflow', content_types_path, nil, nil, 'All Types')%></li>
+ <li><%= icon('workflow', content_types_path, nil, nil, 'Show all types')%></li>
+ <li><%= icon('workflow', "/address@hidden", nil, nil, 'Browse content')%></li>
<% if Authorization.check(:action ="" 'edit', :object => @content_type, :user => current_user) %>
<li><%= icon('manage', edit_content_type_path(@content_type), nil, nil, 'Manage Content Type Entry')%></li>
<% end -%>
Modified: branches/biocat/app/views/contributions/_ratings_box.rhtml (2651 => 2652)
--- branches/biocat/app/views/contributions/_ratings_box.rhtml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/views/contributions/_ratings_box.rhtml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -1,7 +1,7 @@
<div class="contribution_section_box">
<p class="heading">
<%= info_icon_with_tooltip("How does this #{visible_name contributable} rate overall?") %>
- Ratings <font class="count_text">(<%= contributable.ratings_count -%>)</font>
+ Ratings <font class="count_text">(<%= contributable.ratings.count -%>)</font>
<a name="ratings"></a>
</p>
@@ -19,4 +19,4 @@
</div>
</div>
<% end %>
-</div>
\ No newline at end of file
+</div>
Modified: branches/biocat/app/views/contributions/_statistics_box.rhtml (2651 => 2652)
--- branches/biocat/app/views/contributions/_statistics_box.rhtml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/views/contributions/_statistics_box.rhtml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -30,13 +30,13 @@
<% if favouritable? type -%>
<p>
- <a href="" pluralize contributable.bookmarks_count, "favourite" -%></a>
+ <a href="" pluralize contributable.bookmarks.count, "favourite" -%></a>
</p>
<% end -%>
<% if rateable? type -%>
<p>
- <a href="" pluralize contributable.ratings_count, "rating" -%></a>
+ <a href="" pluralize contributable.ratings.count, "rating" -%></a>
</p>
<% end -%>
@@ -44,19 +44,19 @@
<p>
<!-- for this to work properly, view for every resource that supports citations will need to have -->
<!-- tab system with 'tabsContainer' element + anchor called 'citations' -->
- <a href="" pluralize contributable.citations_count, "citation" %></a>
+ <a href="" pluralize contributable.citations.count, "citation" %></a>
</p>
<% end %>
<% if reviewable? type %>
<p>
- <a href="" pluralize contributable.reviews_count, "review" -%></a>
+ <a href="" pluralize contributable.reviews.count, "review" -%></a>
</p>
<% end %>
<% if commentable? type -%>
<p>
- <a href="" pluralize contributable.comments_count, "comment" -%></a>
+ <a href="" pluralize contributable.comments.count, "comment" -%></a>
</p>
<% end -%>
</div>
@@ -66,4 +66,4 @@
</div>
-</div>
\ No newline at end of file
+</div>
Modified: branches/biocat/app/views/packs/_table.rhtml (2651 => 2652)
--- branches/biocat/app/views/packs/_table.rhtml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/views/packs/_table.rhtml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -46,7 +46,7 @@
</p>
<p style="font-size: 85%;">
- <a href="" pack_path(pack) + '#comments' -%>"><b>Comments: </b><%= pack.comments_count %></a> |
+ <a href="" pack_path(pack) + '#comments' -%>"><b>Comments: </b><%= pack.comments.count %></a> |
<b>Viewed:</b> <%=pluralize pack.contribution.site_viewings_count, "time" %> |
<b>Downloaded:</b> <%=pluralize pack.contribution.site_downloads_count, "time" %>
</p>
Modified: branches/biocat/app/views/users/show.rhtml (2651 => 2652)
--- branches/biocat/app/views/users/show.rhtml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/views/users/show.rhtml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -219,13 +219,13 @@
<p>
<b>
- <%= link_to(pluralize(@user.networks_owned_count, "Group") + " (admin)", url_for(:action ="" 'groups')) -%>
+ <%= link_to(pluralize(@user.networks_owned.count, "Group") + " (admin)", url_for(:action ="" 'groups')) -%>
</b>
</p>
<p>
<b>
- <%= link_to(pluralize(@user.networks_count, "Group") + " (member)", url_for(:action ="" 'groups')) -%>
+ <%= link_to(pluralize(@user.networks.length, "Group") + " (member)", url_for(:action ="" 'groups')) -%>
</b>
</p>
@@ -239,7 +239,7 @@
<p>
<b>
- <%= link_to(pluralize(@user.bookmarks_count, "Favourite"), url_for(:action ="" 'favourites')) -%>
+ <%= link_to(pluralize(@user.bookmarks.count, "Favourite"), url_for(:action ="" 'favourites')) -%>
</b>
</p>
</div>
@@ -360,7 +360,7 @@
<% tabnav :user do %>
- <% case @tab; when "News" %>
+ <% case (@tab||"News"); when "News" %>
<%= render :partial => "layouts/news", :locals => { :collection => news(@user, true) } %>
Modified: branches/biocat/app/views/workflows/_table.rhtml (2651 => 2652)
--- branches/biocat/app/views/workflows/_table.rhtml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/views/workflows/_table.rhtml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -78,7 +78,7 @@
<% unless workflow.image.nil? -%>
<p style="margin: 0; border: 0; width: 101px; float: left">
- <%= link_to image_tag(url_for_file_column(workflow, "image", "thumb"), :class => 'framed_nospace'), workflow_path(workflow) %>
+ <%= link_to image_tag(workflow_preview_path(workflow, 'thumb'), :class => 'framed_nospace'), workflow_path(workflow) %>
</p>
<% desc_style << " margin-left: 110px; width: 250px;" %>
@@ -98,11 +98,11 @@
<div style="clear: both"></div>
<p style="font-size: 85%;">
- <a href="" workflow_path(workflow) + '#ratings' -%>"><b>Rating: </b><%= number_with_precision(workflow.rating, 1) %> / 5 (<%= pluralize workflow.ratings_count, 'rating' %>)</a> |
- <a href="" workflow_path(workflow) + '#versions' -%>"><b>Versions: </b><%= workflow.versions_count %></a> |
- <a href="" workflow_path(workflow) + '#reviews' -%>"><b>Reviews: </b><%= workflow.reviews_count %></a> |
- <a href="" workflow_path(workflow) + '#comments' -%>"><b>Comments: </b><%= workflow.comments_count %></a> |
- <a href="" workflow_path(workflow) + '#citations' -%>"><b>Citations: </b><%= workflow.citations_count %></a>
+ <a href="" workflow_path(workflow) + '#ratings' -%>"><b>Rating: </b><%= number_with_precision(workflow.rating, 1) %> / 5 (<%= pluralize workflow.ratings.count, 'rating' %>)</a> |
+ <a href="" workflow_path(workflow) + '#versions' -%>"><b>Versions: </b><%= workflow.versions.count %></a> |
+ <a href="" workflow_path(workflow) + '#reviews' -%>"><b>Reviews: </b><%= workflow.reviews.count %></a> |
+ <a href="" workflow_path(workflow) + '#comments' -%>"><b>Comments: </b><%= workflow.comments.count %></a> |
+ <a href="" workflow_path(workflow) + '#citations' -%>"><b>Citations: </b><%= workflow.citations.count %></a>
</p>
<p style="font-size: 85%;">
@@ -120,7 +120,12 @@
<% end -%>
<td class="actions" style="width: 120px;">
<%= icon "show", workflow_path(workflow), nil, nil, "View" %>
- <% if Authorization.is_authorized?("download", nil, workflow, current_user) %><%= icon "download", download_workflow_path(workflow), nil, nil, "Download (v#{workflow.versions.count})" %><% end %>
+ <% if Authorization.is_authorized?("download", nil, workflow, current_user) -%>
+ <%= icon "download", download_workflow_path(workflow), nil, nil, "Download (v#{workflow.versions.count})" %>
+ <% if ( session[:callback] && (session[:callback][:types].include?(workflow.content_type_id))) -%>
+ <%= icon "download", callback_url(workflow).to_s, nil, {:rel => 'nofollow'}, session[:callback][:label] -%>
+ <% end %>
+ <% end %>
<% if mine?(workflow) %><%= icon "manage", edit_workflow_path(workflow), nil, nil, "Manage" %><% end %>
<br/><br/>
Modified: branches/biocat/app/views/workflows/galaxy_tool.rhtml (2651 => 2652)
--- branches/biocat/app/views/workflows/galaxy_tool.rhtml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/views/workflows/galaxy_tool.rhtml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -59,7 +59,7 @@
<p>The URL to the test Taverna 2 server is:
-<div style="padding: 1em; font-family: monospace">http://taverna-server.biosemantics.org/</div>
+<div style="padding: 1em; font-family: monospace">http://test.mybiobank.org/taverna-server</div>
</p>
<h2>Further information</h2>
Modified: branches/biocat/app/views/workflows/show.rhtml (2651 => 2652)
--- branches/biocat/app/views/workflows/show.rhtml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/app/views/workflows/show.rhtml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -148,7 +148,7 @@
<p>
<b>Type:</b>
- <%= link_to(h(@workflow.content_type.title), content_type_path(@workflow.content_type)) %>
+ <%= link_to(h(@viewing_version.content_type.title), content_type_path(@viewing_version.content_type)) %>
</p>
<br/>
@@ -164,7 +164,7 @@
</p>
<div class="contribution_preview" style="width: 100%;">
<center>
- <%= link_to image_tag(url_for_file_column(@viewing_version, "image", "medium")), url_for_file_column(@viewing_version, "image"), :popup => true %>
+ <%= link_to image_tag(workflow_version_preview_path(@workflow, @viewing_version.version, 'medium')), workflow_version_preview_path(@workflow, @viewing_version.version, 'full'), :popup => true %>
</center>
</div>
<% if @authorised_to_edit %>
@@ -184,7 +184,7 @@
<% unless @viewing_version.svg.nil? %>
<ul class="sectionIcons">
- <li style="margin-left: 0;"><%= icon('picture', url_for_file_column(@viewing_version, "svg"), nil, nil, 'Download Scalable Diagram (SVG)') %></li>
+ <li style="margin-left: 0;"><%= icon('picture', workflow_version_preview_path(@workflow, @viewing_version.version, 'svg'), nil, nil, 'Download Scalable Diagram (SVG)') %></li>
</ul>
<% end %>
@@ -222,11 +222,17 @@
<br />
<ul class="sectionIcons">
- <li style="margin-left: 0;"><%= icon('workflow', @named_download_url, "Download Workflow file/package (for version address@hidden)", nil, "Download Workflow File/Package (address@hidden)") -%></li>
+ <li style="margin-left: 0;"><%= icon('workflow', @named_download_url, "Download Workflow file/package (for version address@hidden)", nil, "Download Workflow File/Package (address@hidden)") -%></li>
</ul>
-
- <% if @workflow.content_type.title == "Taverna 2" %>
+ <% if session[:callback] &&
+ session[:callback][:types].include?(@workflow.content_type_id) -%>
<br />
+ <ul class="sectionIcons">
+ <li style="margin-left: 0;"><%= icon('workflow', callback_url(@workflow).to_s, "#{session[:callback][:label]} Workflow file/package (for version address@hidden)", {:rel => 'nofollow'}, "#{session[:callback][:label]} Workflow #{session[:callback][:additional]}") -%></li>
+ </ul>
+ <% end %>
+ <% if @viewing_version.content_type.title == "Taverna 2" %>
+ <br />
<ul class="sectionIcons">
<li style="margin-left: 0;"><%= icon('workflow', galaxy_tool_path(:id => @workflow.id, :version => @viewing_version_number.to_s), "Download Workflow file/package (for version address@hidden)", nil, "Download Workflow as a Galaxy tool") -%></li>
@@ -291,7 +297,7 @@
<div class="contribution_right_box">
<div class="contribution_section_box" style= "font-size: 100%; padding: 0.7em 0.9em; font-weight: bold;">
<p><%= info_icon_with_tooltip("The type of workflow system that this Workflow is designed for.") %> Workflow Type</p>
- <p><%= link_to(h(@workflow.content_type.title), content_type_path(@workflow.content_type)) %></p>
+ <p><%= link_to(h(@viewing_version.content_type.title), content_type_path(@viewing_version.content_type)) %></p>
</div>
<%= render :partial => "contributions/uploader_box", :locals => { :contributable => @workflow } %>
Modified: branches/biocat/config/base_schema.xml (2651 => 2652)
--- branches/biocat/config/base_schema.xml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/config/base_schema.xml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -38,7 +38,7 @@
<column type="integer" name="user_id"/>
<column type="datetime" name="created_at"/>
<column type="string" name="user_agent"/>
- <column type="boolean" name="accessed_from_site" default="0"/>
+ <column type="boolean" name="accessed_from_site" default="false"/>
<column type="string" name="kind"/>
<index>
@@ -60,5 +60,16 @@
</table>
+ <table name="previews">
+
+ <column type="integer" name="image_blob_id"/>
+ <column type="integer" name="svg_blob_id"/>
+ <column type="datetime" name="created_at"/>
+
+ <belongs-to target="image_blob" class_name="ContentBlob" foreign_key="image_blob_id"/>
+ <belongs-to target="svg_blob" class_name="ContentBlob" foreign_key="svg_blob_id"/>
+
+ </table>
+
</schema>
Modified: branches/biocat/config/default_settings.yml (2651 => 2652)
--- branches/biocat/config/default_settings.yml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/config/default_settings.yml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -106,6 +106,7 @@
- obsolete
- incomplete
- junk
+ - decommissioned services
# main_tabs - These are the main tabs of the website. Each entry requires at
# least a label and a link. If you specify a controller in a tab,
Modified: branches/biocat/config/environment.rb (2651 => 2652)
--- branches/biocat/config/environment.rb 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/config/environment.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -83,5 +83,14 @@
ActionMailer::Base.smtp_settings = Conf.smtp
+# don't require actual keys for recaptcha during tests
+
+if RAILS_ENV == 'test'
+ Recaptcha.configure do |config|
+ config.public_key = ''
+ config.private_key = ''
+ end
+end
+
load 'config/environment_private.rb' if FileTest.exist?('config/environment_private.rb')
Modified: branches/biocat/config/routes.rb (2651 => 2652)
--- branches/biocat/config/routes.rb 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/config/routes.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -117,6 +117,7 @@
# workflows have nested citations
workflow.resources :citations
workflow.resources :reviews
+ workflow.resources :previews
workflow.resources :comments, :collection => { :timeline => :get }
end
@@ -124,6 +125,16 @@
map.workflow_version '/workflows/:id/versions/:version', :conditions => { :method => :get }, :controller => 'workflows', :action ="" 'show'
map.formatted_workflow_version '/workflows/:id/versions/:version.:format', :conditions => { :method => :get }, :controller => 'workflows', :action ="" 'show'
+ # versioned preview images
+ ['workflow'].each do |x|
+
+ eval("map.#{x}_version_preview '/#{x.pluralize}/:#{x}_id/versions/:version/previews/:id'," +
+ " :conditions => { :method => :get}, :controller => 'previews', :action ="" 'show'")
+
+ eval("map.formatted_#{x}_version_preview '/#{x.pluralize}/:#{x}_id/versions/:version/previews/:id.:format'," +
+ " :conditions => { :method => :get}, :controller => 'previews', :action ="" 'show'")
+ end
+
map.galaxy_tool 'workflows/:id/versions/:version/galaxy_tool', :controller => 'workflows', :action ="" 'galaxy_tool'
map.galaxy_tool_download 'workflows/:id/versions/:version/galaxy_tool_download', :controller => 'workflows', :action ="" 'galaxy_tool_download'
Modified: branches/biocat/config/schema.d/workflows.xml (2651 => 2652)
--- branches/biocat/config/schema.d/workflows.xml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/config/schema.d/workflows.xml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -1,6 +1,56 @@
<?xml version="1.0"?>
<schema>
+ <table name="workflows">
+
+ <column type="integer" name="contributor_id"/>
+ <column type="string" name="contributor_type"/>
+ <column type="string" name="title"/>
+ <column type="string" name="unique_name"/>
+ <column type="text" name="body"/>
+ <column type="text" name="body_html"/>
+ <column type="datetime" name="created_at"/>
+ <column type="datetime" name="updated_at"/>
+ <column type="string" name="image"/>
+ <column type="string" name="svg"/>
+ <column type="integer" name="current_version"/>
+ <column type="integer" name="content_blob_id"/>
+ <column type="string" name="file_ext"/>
+ <column type="string" name="last_edited_by"/>
+ <column type="integer" name="content_type_id"/>
+ <column type="integer" name="license_id"/>
+ <column type="integer" name="preview_id"/>
+
+ </table>
+
+ <table name="workflow_versions">
+
+ <column type="integer" name="workflow_id"/>
+ <column type="integer" name="version"/>
+ <column type="text" name="revision_comments"/>
+ <column type="integer" name="contributor_id"/>
+ <column type="string" name="contributor_type"/>
+ <column type="string" name="title"/>
+ <column type="string" name="unique_name"/>
+ <column type="text" name="body"/>
+ <column type="text" name="body_html"/>
+ <column type="datetime" name="created_at"/>
+ <column type="datetime" name="updated_at"/>
+ <column type="string" name="image"/>
+ <column type="string" name="svg"/>
+ <column type="string" name="license"/>
+ <column type="integer" name="content_blob_id"/>
+ <column type="string" name="file_ext"/>
+ <column type="string" name="last_edited_by"/>
+ <column type="integer" name="content_type_id"/>
+ <column type="integer" name="preview_id"/>
+
+ <index>
+ <column name="workflow_id"/>
+ </index>
+
+ </table>
+
<table name="workflow_processors">
<column type="integer" name="workflow_id"/>
Modified: branches/biocat/config/tables.xml
(Binary files differ)
Copied: branches/biocat/db/migrate/090_adjust_pictures.rb (from rev 2651, trunk/db/migrate/090_adjust_pictures.rb) (0 => 2652)
--- branches/biocat/db/migrate/090_adjust_pictures.rb (rev 0)
+++ branches/biocat/db/migrate/090_adjust_pictures.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -0,0 +1,67 @@
+# myExperiment: db/migrate/090_adjust_pictures.rb
+#
+# Copyright (c) 2007 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class AdjustPictures < ActiveRecord::Migration
+ def self.up
+
+ conn = ActiveRecord::Base.connection
+
+ # collect all the file_column paths
+
+ workflow_image = {}
+ workflow_svg = {}
+ workflow_version_image = {}
+ workflow_version_svg = {}
+
+ Workflow.find(:all, :select => 'id, image AS image_fc, svg AS svg_fc').each do |workflow|
+ workflow_image[workflow.id] = workflow.image_fc
+ workflow_svg[workflow.id] = workflow.svg_fc
+ end
+
+ Workflow::Version.find(:all, :select => 'id, image AS image_fc, svg AS svg_fc').each do |workflow_version|
+ workflow_version_image[workflow_version.id] = workflow_version.image_fc
+ workflow_version_svg[workflow_version.id] = workflow_version.svg_fc
+ end
+
+ # save the previews into the database
+
+ Workflow.find(:all).each do |workflow|
+
+ if workflow_image[workflow.id] || workflow_svg[workflow.id]
+
+ if workflow_image[workflow.id]
+ workflow.image = File.new("public/workflow/image/#{workflow.id}/#{workflow_image[workflow.id]}").read
+ end
+
+ if workflow_svg[workflow.id]
+ workflow.svg = File.new("public/workflow/svg/#{workflow.id}/#{workflow_svg[workflow.id]}").read
+ end
+
+ workflow.preview.save
+ conn.execute("UPDATE workflows SET preview_id = #{workflow.preview.id} WHERE id = #{workflow.id}")
+ end
+ end
+
+ Workflow::Version.find(:all).each do |workflow_version|
+
+ if workflow_version_image[workflow_version.id] || workflow_version_svg[workflow_version.id]
+
+ if workflow_version_image[workflow_version.id]
+ workflow_version.image = File.new("public/workflow/version/image/#{workflow_version.id}/#{workflow_version_image[workflow_version.id]}").read
+ end
+
+ if workflow_version_svg[workflow_version.id]
+ workflow_version.svg = File.new("public/workflow/version/svg/#{workflow_version.id}/#{workflow_version_svg[workflow_version.id]}").read
+ end
+
+ workflow_version.preview.save
+ conn.execute("UPDATE workflow_versions SET preview_id = #{workflow_version.preview.id} WHERE id = #{workflow_version.id}")
+ end
+ end
+ end
+
+ def self.down
+ end
+end
Modified: branches/biocat/lib/explicit_versioning.rb (2651 => 2652)
--- branches/biocat/lib/explicit_versioning.rb 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/lib/explicit_versioning.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -15,7 +15,7 @@
send :include, Jits::Acts::ExplicitVersioning::ActMethods
cattr_accessor :versioned_class_name, :versioned_foreign_key, :versioned_table_name, :versioned_inheritance_column,
- :version_column, :version_sequence_name, :non_versioned_columns, :file_columns, :white_list_columns, :revision_comments_column,
+ :version_column, :version_sequence_name, :non_versioned_columns, :file_columns, :extra_attributes, :white_list_columns, :revision_comments_column,
:version_association_options, :timestamp_columns, :sync_ignore_columns
self.versioned_class_name = options[:class_name] || "Version"
@@ -25,6 +25,7 @@
self.version_column = options[:version_column] || 'version'
self.non_versioned_columns = [self.primary_key, inheritance_column, 'version', 'lock_version', versioned_inheritance_column, version_column]
self.file_columns = options[:file_columns] || []
+ self.extra_attributes = options[:extra_attributes] || []
self.white_list_columns = options[:white_list_columns] || []
self.revision_comments_column = options[:revision_comments_column] || "revision_comments"
self.version_association_options = {
@@ -159,10 +160,10 @@
# Saves a version of the model in the versioned table. This is called in the after_create callback by default
def save_version_on_create(revision_comment=nil)
rev = self.class.versioned_class.new
- self.clone_versioned_model(self, rev)
rev.version = send(self.class.version_column)
rev.send("#{self.class.revision_comments_column}=", revision_comment)
rev.send("#{self.class.versioned_foreign_key}=", self.id)
+ self.clone_versioned_model(self, rev)
saved = rev.save
if saved
@@ -282,7 +283,7 @@
# Returns an array of attribute keys that are versioned. See non_versioned_columns
def versioned_attributes
- self.attributes.keys.select { |k| !self.class.non_versioned_columns.include?(k) }
+ self.attributes.keys.select { |k| !self.class.non_versioned_columns.include?(k) } + extra_attributes
end
module ClassMethods
Copied: branches/biocat/lib/previews.rb (from rev 2651, trunk/lib/previews.rb) (0 => 2652)
--- branches/biocat/lib/previews.rb (rev 0)
+++ branches/biocat/lib/previews.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -0,0 +1,59 @@
+
+class ActiveRecord::Base
+
+ def self.has_previews
+
+ self.class_eval do
+
+ belongs_to :preview
+
+ def image
+ preview.image_blob.data if preview && preview.image_blob
+ end
+
+ def svg
+ preview.svg_blob.data if preview && preview.svg_blob
+ end
+
+ def image=(x)
+
+ self.preview = Preview.new if self.preview.nil?
+ self.preview.image_blob = ContentBlob.new if self.preview.image_blob.nil?
+
+ self.preview.image_blob.data = x
+ end
+
+ def svg=(x)
+
+ self.preview = Preview.new if self.preview.nil?
+ self.preview.svg_blob = ContentBlob.new if self.preview.svg_blob.nil?
+
+ self.preview.svg_blob.data = x
+ end
+
+ after_save { |ob|
+
+ p = ob.preview
+
+ if p
+
+ ib = p.image_blob
+ sb = p.svg_blob
+
+ if ib && ib.data_changed?
+ ib.save
+ ob.preview.clear_cache
+ end
+
+ if sb && sb.data_changed?
+ sb.save
+ ob.preview.clear_cache
+ end
+
+ p.save
+ end
+ }
+ end
+ end
+end
+
Modified: branches/biocat/lib/rest.rb (2651 => 2652)
--- branches/biocat/lib/rest.rb 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/lib/rest.rb 2011-07-13 10:33:59 UTC (rev 2652)
@@ -98,13 +98,11 @@
render(:xml => doc.to_s, :status => "#{code} #{message}")
end
-def file_column_url(ob, field)
-
- fields = (field.split('/').map do |f| "'#{f}'" end).join(', ')
-
- path = eval("ActionView::Base.new.url_for_file_column(ob, #{fields})")
-
- "#{request.protocol}#{request.host_with_port}#{path}"
+def preview_url(ob, type)
+ url = ""
+ url.path << "/versions/#{ob.current_version}" if ob.respond_to?('current_version')
+ url.path << "/previews/#{type}"
+ url.to_s
end
def model_entity_to_rest_entity(model_entity)
@@ -241,9 +239,9 @@
else
- if model_data['Encoding'][i] == 'file-column'
+ if model_data['Encoding'][i] == 'preview'
- text = file_column_url(ob, model_data['Accessor'][i])
+ text = preview_url(ob, model_data['Accessor'][i])
else
@@ -958,17 +956,7 @@
end
if preview
-
- image = Tempfile.new('image')
- image.write(preview)
- image.rewind
-
- image.extend FileUpload
- image.original_filename = 'preview'
-
- ob.image = image
-
- image.close
+ ob.image = preview
end
if svg.nil? and content
@@ -977,17 +965,7 @@
end
if svg
-
- svg_file = Tempfile.new('image')
- svg_file.write(svg)
- svg_file.rewind
-
- svg_file.extend FileUpload
- svg_file.original_filename = 'svg'
-
- ob.svg = svg_file
-
- svg_file.close
+ ob.svg = svg
end
success = if (action == 'create' and opts[:query]['id'])
Modified: branches/biocat/test/fixtures/workflow_versions.yml (2651 => 2652)
--- branches/biocat/test/fixtures/workflow_versions.yml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/test/fixtures/workflow_versions.yml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -5,8 +5,6 @@
version: 1
contributor_id: 1
contributor_type: User
- image:
- svg:
title: Get Dilbert
unique_name: get_dilbert
body: Gets todays dilbert cartoon
@@ -22,8 +20,6 @@
version: 1
contributor_id: 2
contributor_type: User
- image:
- svg:
title: Conditional branch choice
unique_name: branch_choice
body: Does something, probably chooses a branch based on a condition...
Modified: branches/biocat/test/fixtures/workflows.yml (2651 => 2652)
--- branches/biocat/test/fixtures/workflows.yml 2011-07-12 13:29:57 UTC (rev 2651)
+++ branches/biocat/test/fixtures/workflows.yml 2011-07-13 10:33:59 UTC (rev 2652)
@@ -3,8 +3,6 @@
id: 1
contributor_id: 1
contributor_type: User
- image:
- svg:
title: Get Dilbert
unique_name: get_dilbert
body: Gets todays dilbert cartoon
@@ -19,8 +17,6 @@
id: 2
contributor_id: 2
contributor_type: User
- image:
- svg:
title: Conditional branch choice
unique_name: branch_choice
body: Does something, probably chooses a branch based on a condition...