Top Level Namespace
Defined Under Namespace
Modules: Paperclip, TavernaPlayer
Instance Method Summary collapse
- #cannot_inline(port, index = []) ⇒ Object
- #cannot_inline_tp_default(port, index = []) ⇒ Object
-
#empty_port(port, _) ⇒ Object
Rendering an empty port has no need of the index parameter.
- #empty_tp_default(port, _) ⇒ Object
-
#format_text(port, index = []) ⇒ Object
These methods are the default renderer callbacks that Taverna Player uses.
-
#format_text_tp_default(port, index = []) ⇒ Object
—————————————————————————— Copyright © 2013 The University of Manchester, UK.
- #format_xml(port, index = []) ⇒ Object
- #format_xml_tp_default(port, index = []) ⇒ Object
-
#list_port(port, index = [], types = nil) ⇒ Object
Rendering a list port requires recursion.
- #list_tp_default(port, index = [], types = nil) ⇒ Object
- #player_post_run_callback(run) ⇒ Object
-
#player_pre_run_callback(run) ⇒ Object
—————————————————————————— Copyright © 2013, 2014 The University of Manchester, UK.
- #player_run_cancelled_callback(run) ⇒ Object
- #player_run_failed_callback(run) ⇒ Object
- #show_image(port, index = []) ⇒ Object
- #show_image_tp_default(port, index = []) ⇒ Object
- #workflow_error(port, index = []) ⇒ Object
- #workflow_error_tp_default(port, index = []) ⇒ Object
Instance Method Details
#cannot_inline(port, index = []) ⇒ Object
51 52 53 54 55 |
# 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 = []) ⇒ Object
34 35 36 37 38 |
# 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, _) ⇒ Object
Rendering an empty port has no need of the index parameter.
58 59 60 |
# File 'lib/generators/templates/callbacks/render_callbacks.rb', line 58 def empty_port(port, _) "<div><empty port></div>" end |
#empty_tp_default(port, _) ⇒ Object
40 41 42 |
# File 'lib/taverna_player/render_callbacks.rb', line 40 def empty_tp_default(port, _) "<div><empty port></div>" end |
#format_text(port, index = []) ⇒ Object
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.
26 27 28 29 30 31 32 |
# 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 = []) ⇒ Object
Copyright © 2013 The University of Manchester, UK.
BSD Licenced. See LICENCE.rdoc for details.
Taverna Player was developed in the BioVeL project, funded by the European Commission 7th Framework Programme (FP7), through grant agreement number 283359.
Author: Robert Haines
13 14 15 16 |
# 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 = []) ⇒ Object
34 35 36 37 38 39 |
# 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 = []) ⇒ Object
18 19 20 21 22 |
# 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) ⇒ Object
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.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/generators/templates/callbacks/render_callbacks.rb', line 66 def list_port(port, index = [], types = nil) types = port.[: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) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/taverna_player/render_callbacks.rb', line 44 def list_tp_default(port, index = [], types = nil) types = port.[: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) ⇒ Object
18 19 20 21 |
# 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) ⇒ Object
Copyright © 2013, 2014 The University of Manchester, UK.
BSD Licenced. See LICENCE.rdoc for details.
Taverna Player was developed in the BioVeL project, funded by the European Commission 7th Framework Programme (FP7), through grant agreement number 283359.
Author: Robert Haines
13 14 15 16 |
# 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) ⇒ Object
23 24 25 26 |
# 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) ⇒ Object
28 29 30 31 |
# 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 = []) ⇒ Object
41 42 43 44 45 |
# 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 = []) ⇒ Object
24 25 26 27 28 |
# 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 = []) ⇒ Object
47 48 49 |
# 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 = []) ⇒ Object
30 31 32 |
# 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 |