Sha256: 405dbb16ff0b41e16c9b9afabb1c77af0929a9582b801e0eaefb8e5ce4c87364

Contents?: true

Size: 1.71 KB

Versions: 5

Compression:

Stored size: 1.71 KB

Contents

require 'rbbt/util/open'

require 'haml'
module WorkflowRESTHelpers

  def workflow_render(template, workflow = nil, task = nil, params = {})
    workflow = consume_parameter(:workflow, params) if workflow.nil?
    task     = consume_parameter(:task, params) if workflow.nil?
    job      = consume_parameter(:job, params) if job.nil?

    template_file = locate_workflow_template(template, workflow, task)

    locals = params.dup
    locals[:workflow] = workflow if workflow
    locals[:task]     = task if task

    if layout
      layout_file = workflow.libdir.www.views[workflow.to_s]["layout.haml"] if workflow.libdir
      layout_file = locate_template("layout") unless layout_file and layout_file.exists?
    else
      layout_file = nil
    end

    if job 
      locals[:job] = job 
      @step = job
      cache_type = execution_type(workflow, task)
      server_key = $app_name
      html_dir = job.file('.html')
      FileUtils.mkdir_p html_dir.find unless File.exists? html_dir.find
      cache_file = html_dir[server_key]
      render(template_file, locals, layout_file, [task,workflow,job.name] * "-", :cache_type => cache_type, :cache_file => cache_file)
    else
      render(template_file, locals, layout_file, [workflow, task, template_file].compact * "-", :cache_type => :async )
    end
  end

  def workflow_partial(template, workflow = nil, task = nil, params = {})
    workflow = consume_parameter(:workflow, params) if workflow.nil?
    task     = consume_parameter(:task, params) if workflow.nil?

    template_file = locate_workflow_template(template, workflow, task)

    locals = params.dup
    locals[:workflow] = workflow if workflow
    locals[:task]     = task if task

    render_partial(template_file, locals)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rbbt-rest-1.8.28 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.27 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.26 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.25 lib/rbbt/rest/workflow/render.rb
rbbt-rest-1.8.23 lib/rbbt/rest/workflow/render.rb