class Object
Public Instance Methods
cannot_inline(port, index = [])
click to toggle source
# File lib/generators/templates/callbacks/render_callbacks.rb, line 51 def cannot_inline(port, index = []) "Sorry but we cannot show this type of content in the browser. Please " + link_to("download it", port.path(index)) + " to view it on " + "your local machine." end
cannot_inline_tp_default(port, index = [])
click to toggle source
# File lib/taverna_player/render_callbacks.rb, line 34 def cannot_inline_tp_default(port, index = []) "Sorry but we cannot show this type of content in the browser. Please " + link_to("download it", port.path(index)) + " to view it on " + "your local machine." end
empty_port(port, _)
click to toggle source
Rendering an empty port has no need of the index parameter.
# File lib/generators/templates/callbacks/render_callbacks.rb, line 58 def empty_port(port, _) "<div><empty port></div>" end
empty_tp_default(port, _)
click to toggle source
# File lib/taverna_player/render_callbacks.rb, line 40 def empty_tp_default(port, _) "<div><empty port></div>" end
format_text(port, index = [])
click to toggle source
These methods are the default renderer callbacks that Taverna Player uses. If you customize (or add to) the methods in this file you must register them in the Taverna Player initializer. These methods will not override the defaults automatically.
Each method MUST accept two parameters:
* The first (port) is the port to be rendered. * The second (index) is the index into the port. For singleton ports this will be the empty list.
Note that you can use most of the ActiveView Helpers here as global methods but the image_tag() method does not work as explained below.
# File lib/generators/templates/callbacks/render_callbacks.rb, line 26 def format_text(port, index = []) # Use CodeRay to format text so that newlines are respected. content = CodeRay.scan(port.value(index), :text).div(:css => :class) # Use auto_link to turn URI-like text into links. auto_link(content, :html => { :target => '_blank' }, :sanitize => false) end
format_text_tp_default(port, index = [])
click to toggle source
# File lib/taverna_player/render_callbacks.rb, line 13 def format_text_tp_default(port, index = []) content = CodeRay.scan(port.value(index), :text).div(:css => :class) auto_link(content, :html => { :target => '_blank' }, :sanitize => false) end
format_xml(port, index = [])
click to toggle source
# File lib/generators/templates/callbacks/render_callbacks.rb, line 34 def format_xml(port, index = []) # Make sure XML is indented consistently. out = String.new REXML::Document.new(port.value(index)).write(out, 1) CodeRay.scan(out, :xml).div(:css => :class, :line_numbers => :table) end
format_xml_tp_default(port, index = [])
click to toggle source
# File lib/taverna_player/render_callbacks.rb, line 18 def format_xml_tp_default(port, index = []) out = String.new REXML::Document.new(port.value(index)).write(out, 1) CodeRay.scan(out, :xml).div(:css => :class, :line_numbers => :table) end
list_port(port, index = [], types = nil)
click to toggle source
Rendering a list port requires recursion. In this implementation an extra parameter (types) is added to drive the recursion; we can't just keep track of depth because we need to know the length of each sub-list - and types can be used to pass that through for us.
# File lib/generators/templates/callbacks/render_callbacks.rb, line 66 def list_port(port, index = [], types = nil) types = port.metadata[:type] if types.nil? content = "<ol>" i = 0 types.each do |type| if type.is_a?(Array) content += "<li><br />" + list_port(port, index + [i], type) + "</li>" else content += "<li>(#{type})<p>" + TavernaPlayer.port_renderer.render(port, index + [i]) + "</p></li>" end i += 1 end content += "</ol>" end
list_tp_default(port, index = [], types = nil)
click to toggle source
# File lib/taverna_player/render_callbacks.rb, line 44 def list_tp_default(port, index = [], types = nil) types = port.metadata[:type] if types.nil? content = "<ol>" i = 0 types.each do |type| if type.is_a?(Array) content += "<li><br />" + list_tp_default(port, index + [i], type) + "</li>" else content += "<li>(#{type})<p>" + TavernaPlayer.port_renderer.render(port, index + [i]) + "</p></li>" end i += 1 end content += "</ol>" end
player_post_run_callback(run)
click to toggle source
# File lib/generators/templates/callbacks/worker_callbacks.rb, line 18 def player_post_run_callback(run) w = TavernaPlayer::Workflow.find(run.workflow_id) puts "Post-run callback called for run '#{run.name}' of workflow '#{w.id}'" end
player_pre_run_callback(run)
click to toggle source
# File lib/generators/templates/callbacks/worker_callbacks.rb, line 13 def player_pre_run_callback(run) w = TavernaPlayer::Workflow.find(run.workflow_id) puts "Pre-run callback called for run '#{run.name}' of workflow '#{w.id}'" end
player_run_cancelled_callback(run)
click to toggle source
# File lib/generators/templates/callbacks/worker_callbacks.rb, line 23 def player_run_cancelled_callback(run) w = TavernaPlayer::Workflow.find(run.workflow_id) puts "Run-cancelled callback called for run '#{run.name}' of workflow '#{w.id}'" end
player_run_failed_callback(run)
click to toggle source
# File lib/generators/templates/callbacks/worker_callbacks.rb, line 28 def player_run_failed_callback(run) w = TavernaPlayer::Workflow.find(run.workflow_id) puts "Run-failed callback called for run '#{run.name}' of workflow '#{w.id}'" end
show_image(port, index = [])
click to toggle source
# File lib/generators/templates/callbacks/render_callbacks.rb, line 41 def show_image(port, index = []) # Can't use image_tag() here because the image doesn't really exist (it's in # a zip file, really) and this confuses the Rails asset pipeline. tag("img", :src => port.path(index)) end
show_image_tp_default(port, index = [])
click to toggle source
# File lib/taverna_player/render_callbacks.rb, line 24 def show_image_tp_default(port, index = []) # Can't use image_tag() here because the image doesn't really exist (it's in # a zip file, really) and this confuses the Rails asset pipeline. tag("img", :src => port.path(index)) end
workflow_error(port, index = [])
click to toggle source
# File lib/generators/templates/callbacks/render_callbacks.rb, line 47 def workflow_error(port, index = []) link_to("This output is a workflow error.", port.path(index)) end
workflow_error_tp_default(port, index = [])
click to toggle source
# File lib/taverna_player/render_callbacks.rb, line 30 def workflow_error_tp_default(port, index = []) link_to("This output is a workflow error.", port.path(index)) end