rbbt-rest 1.4.10 → 1.4.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbbt/rest/client/step.rb +1 -1
  3. data/lib/rbbt/rest/common/cache.rb +2 -1
  4. data/lib/rbbt/rest/common/forms.rb +6 -6
  5. data/lib/rbbt/rest/common/locate.rb +25 -2
  6. data/lib/rbbt/rest/common/misc.rb +23 -7
  7. data/lib/rbbt/rest/common/render.rb +1 -3
  8. data/lib/rbbt/rest/common/table.rb +52 -3
  9. data/lib/rbbt/rest/main.rb +21 -5
  10. data/lib/rbbt/rest/web_tool.rb +1 -0
  11. data/lib/rbbt/rest/workflow.rb +20 -1
  12. data/lib/rbbt/rest/workflow/jobs.rb +3 -1
  13. data/lib/rbbt/rest/workflow/render.rb +17 -3
  14. data/share/views/compass/_app.sass +17 -0
  15. data/share/views/compass/app.sass +1 -17
  16. data/share/views/compass/finder.sass +7 -7
  17. data/share/views/compass/grid_system.sass +1 -9
  18. data/share/views/compass/layout.sass +2 -2
  19. data/share/views/compass/rbbt/table.sass +1 -0
  20. data/share/views/compass/screen_sizes.sass +16 -0
  21. data/share/views/compass/top_menu.sass +1 -0
  22. data/share/views/entity_partials/action_card.haml +2 -2
  23. data/share/views/entity_partials/entity_card.haml +10 -4
  24. data/share/views/entity_partials/entity_list_card.haml +7 -2
  25. data/share/views/entity_partials/entity_map_card.haml +1 -1
  26. data/share/views/error.haml +16 -12
  27. data/share/views/form.haml +2 -2
  28. data/share/views/help.haml +3 -3
  29. data/share/views/help/UI.haml +156 -163
  30. data/share/views/help/entity.haml +3 -3
  31. data/share/views/help/workflow.haml +1 -1
  32. data/share/views/job_result/job_control.haml +3 -2
  33. data/share/views/job_result/tsv.haml +17 -12
  34. data/share/views/layout.haml +18 -43
  35. data/share/views/layout/coda.haml +40 -0
  36. data/share/views/layout/footer.haml +0 -0
  37. data/share/views/layout/top_menu/finder.haml +1 -1
  38. data/share/views/partials/form.haml +1 -1
  39. data/share/views/partials/table.haml +1 -1
  40. data/share/views/public/js/app.js +4 -4
  41. data/share/views/public/js/defer.js +26 -0
  42. data/share/views/public/js/helpers.js +8 -1
  43. data/share/views/public/js/rbbt/actions.js +2 -2
  44. data/share/views/public/js/rbbt/hide.js +12 -8
  45. data/share/views/public/js/rbbt/menu.js +2 -1
  46. data/share/views/public/js/rbbt/modal.js +5 -2
  47. data/share/views/public/js/rbbt/reveal.js +7 -5
  48. data/share/views/wait.haml +1 -1
  49. metadata +7 -3
  50. data/share/views/public/js/deffer.js +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7238b912c301e0c3359e037b1c067332a8f6b413
4
- data.tar.gz: 502e447f4643efa03d48f63d22cc356e8c320623
3
+ metadata.gz: 79c5f4dab3cb27a5c2a52674a04fb02bf8257417
4
+ data.tar.gz: eb2d80aa0d553528c8556d56a47df3fbffabd185
5
5
  SHA512:
6
- metadata.gz: 5bc4bfcecac880d3855f412135959b0a4b4ae66e24e6f5368be23c00a5f6a21d33c76d95f38842a9f9b0b5dd8b28a60e6b7fec09d9536c1aa9b8ed293cfbe37c
7
- data.tar.gz: d9ed1bf96e0e8c7c9c52ff30b9921b1512cdc6dad883aa6ce5d57dcf4772b483600e8ffabd69975438bd51ebd7676e02fc65b63c1c9770358394c6c4c4092caa
6
+ metadata.gz: 25e607bce141f788bb50288933599d26f7563c6812df719e9d161624c1c5fb1cb1a7417010af2209a27b83e536017210749816480bb769c87a99cc595279f742
7
+ data.tar.gz: 6105e96305d4e1b71068ef30874576e41f2f04d73f5797bd826dec2940600cb84845e98d7d1a7132533d7d597b1e681d87eeb5f544057ed94ea20184a54e2d63
@@ -26,7 +26,7 @@ class WorkflowRESTClient
26
26
  (Array === @url ? @url.first : @url).split("/")[-2]
27
27
  end
28
28
 
29
- def info
29
+ def info(check_lock=false)
30
30
  @info ||= begin
31
31
  init_job unless url
32
32
  info = WorkflowRESTClient.get_json(File.join(url, 'info'))
@@ -28,7 +28,7 @@ module RbbtRESTHelpers
28
28
  orig_name = name
29
29
  name += "_" << Misc.hash2md5(params) if params.any?
30
30
 
31
- path = settings.cache_dir[name].find
31
+ path = params[:cache_file] || settings.cache_dir[name].find
32
32
  task = Task.setup(:name => orig_name, :result_type => :string, &block)
33
33
 
34
34
  step = Step.new(path, task, nil, nil, self)
@@ -128,6 +128,7 @@ module RbbtRESTHelpers
128
128
  step.run
129
129
  else
130
130
  step.fork
131
+ step.soft_grace
131
132
  end
132
133
  end
133
134
 
@@ -16,7 +16,7 @@ module RbbtRESTHelpers
16
16
  end
17
17
 
18
18
  def file_or_text_area(id, name, value, tsv = false)
19
- text_area_string = tsv ? "or use the text area bellow (you may use ',' intead of tabs)" : "or use the text area bellow"
19
+ text_area_string = tsv ? "or use the text area below (you may use ',' intead of tabs)" : "or use the text area below"
20
20
 
21
21
  html_tag("input", nil, :type => "file", :id => (id.nil? ? nil : id + "__" + "param_file"), :name => name.to_s + "__" + "param_file") +
22
22
  html_tag("span", text_area_string, :class => "file_or_text_area") +
@@ -75,8 +75,8 @@ module RbbtRESTHelpers
75
75
  end
76
76
 
77
77
  input_label(id, name, description, default, extra) +
78
- html_tag("input", nil, :type => :hidden, :name => name.to_s + "_checkbox_false", :value => "false") +
79
- html_tag("input", nil, :type => :checkbox, :checked => check_true, :name => name, :value => "true", :id => id)
78
+ html_tag("input", nil, :type => :checkbox, :checked => check_true, :name => name, :value => "true", :id => id) +
79
+ html_tag("input", nil, :type => :hidden, :name => name.to_s + "_checkbox_false", :value => "false")
80
80
 
81
81
  when :string, :float, :integer, :hidden
82
82
  value = current.nil? ? default : current
@@ -94,7 +94,7 @@ module RbbtRESTHelpers
94
94
  when :string
95
95
  nil
96
96
  when :float
97
- "any"
97
+ "0.1"
98
98
  when :integer
99
99
  1
100
100
  end
@@ -107,10 +107,10 @@ module RbbtRESTHelpers
107
107
  value = value * "\n" if Array === value
108
108
 
109
109
  if no_file
110
- input_label(id, name, description, default, extra) +
110
+ input_label(id, name, description, nil, extra) +
111
111
  html_tag("textarea", value || "" , :name => name, :id => id )
112
112
  else
113
- input_label(id, name, description, default, extra) +
113
+ input_label(id, name, description, nil, extra) +
114
114
  file_or_text_area(id, name, value, type == :tsv)
115
115
  end
116
116
 
@@ -10,7 +10,7 @@ module RbbtRESTHelpers
10
10
  end
11
11
 
12
12
  def template_resources
13
- [Rbbt.www.views.find(:lib)] + RbbtRESTHelpers.template_resources
13
+ [Rbbt.www.views] + RbbtRESTHelpers.template_resources
14
14
  end
15
15
 
16
16
  def locate_template_from_resource(resource, template)
@@ -26,6 +26,29 @@ module RbbtRESTHelpers
26
26
  raise TemplateMissing, "Template #{ template } not found"
27
27
  end
28
28
 
29
+ #{{{ TEMPLATE
30
+
31
+ def self.file_resources
32
+ @file_resources ||= template_resources
33
+ end
34
+
35
+ def file_resources
36
+ [Rbbt.www.views] + RbbtRESTHelpers.file_resources
37
+ end
38
+
39
+ def locate_file_from_resource(resource, file)
40
+ resource[file]
41
+ end
42
+
43
+ def locate_file(file)
44
+ file_resources.each do |resource|
45
+ path = locate_file_from_resource(resource, file)
46
+ return path if path.exists?
47
+ end
48
+
49
+ raise TemplateMissing, "File #{ file } not found"
50
+ end
51
+
29
52
  #{{{ SASS
30
53
 
31
54
  def self.add_sass_load_path(path)
@@ -37,7 +60,7 @@ module RbbtRESTHelpers
37
60
  end
38
61
 
39
62
  def sass_resources
40
- RbbtRESTHelpers.sass_resources
63
+ [Rbbt.www.views.compass] + RbbtRESTHelpers.sass_resources
41
64
  end
42
65
 
43
66
  def locate_sass_from_resource(resource, template)
@@ -221,16 +221,32 @@ module RbbtRESTHelpers
221
221
  end
222
222
 
223
223
  require 'haml'
224
- module Haml::Filters::DefferJS
224
+ module Haml::Filters::DeferJS
225
225
  include Haml::Filters::Base
226
226
 
227
227
  def render(text)
228
- deffer_text =<<-EOF
229
- :javascript
230
- deffer(function(){
231
- #{text.gsub(/^/," ")}
232
- })
228
+ defer_text =<<-EOF
229
+ %script(defer)
230
+ :plain
231
+ defer(function(){
232
+ #{text.gsub(/^/," ")}
233
+ })
233
234
  EOF
234
- Haml::Engine.new(deffer_text).to_html # gfm method defined elsewhere
235
+ Haml::Engine.new(defer_text).to_html
236
+ end
237
+ end
238
+
239
+ require 'haml'
240
+ module Haml::Filters::Documentation
241
+ include Haml::Filters::Base
242
+
243
+ def render(text)
244
+ doc_text =<<-EOF
245
+ %section.documentation#{ text.gsub(/\s/,'').length < 80 * 10 ? '.short' : ''}
246
+ :markdown
247
+ #{text.gsub(/^/," ")}
248
+ EOF
249
+
250
+ Haml::Engine.new(doc_text).to_html
235
251
  end
236
252
  end
@@ -34,6 +34,7 @@ module RbbtRESTHelpers
34
34
 
35
35
  def wait_on(job, layout = nil)
36
36
  3.times do
37
+ raise RbbtRESTHelpers::Retry if job.done? or job.error?
37
38
  sleep 1
38
39
  end
39
40
 
@@ -54,18 +55,15 @@ module RbbtRESTHelpers
54
55
  layout_file = layout_file.find if layout_file.respond_to? :find
55
56
  template_file = template_file.find if layout_file.respond_to? :find
56
57
  if layout_file
57
- #Haml::Engine.new(Open.read(layout_file), :filename => layout_file, :ugly => production?).render(self, locals) do
58
58
  Tilt::HamlTemplate.new(layout_file, :filename => layout_file, :ugly => production?).render(self, locals) do
59
59
  cache(cache, locals.merge(:_template_file => template_file, :user => user).merge(cache_options)) do
60
60
  Log.debug{ "Rendering #{template_file} with layout" }
61
- #Haml::Engine.new(Open.read(template_file), :filename => template_file, :ugly => production?).render(self, locals)
62
61
  Tilt::HamlTemplate.new(template_file, :filename => template_file, :ugly => production?).render(self, locals)
63
62
  end
64
63
  end
65
64
  else
66
65
  cache(cache, locals.merge(:_template_file => template_file, :user => user).merge(cache_options)) do
67
66
  Log.debug{ "Rendering #{template_file} without layout" }
68
- #Haml::Engine.new(Open.read(template_file), :filename => template_file, :ugly => production?).render(self, locals)
69
67
  Tilt::HamlTemplate.new(template_file, :filename => template_file, :ugly => production?).render(self, locals)
70
68
  end
71
69
  end
@@ -29,6 +29,50 @@ module Link
29
29
  end
30
30
  end
31
31
 
32
+ module Change
33
+ extend Entity
34
+
35
+ self.format =(<<-EOF
36
+ Change
37
+ EOF
38
+ ).split("\n")
39
+
40
+ def <=>(other)
41
+ self.scan(/\d+/).first.to_f <=> other.scan(/\d+/).first.to_f
42
+ end
43
+
44
+ def self.tsv_sort(v)
45
+ value = v.last
46
+ if Array === value
47
+ value.first.scan(/\d+/).first.to_f
48
+ else
49
+ value.scan(/\d+/).first.to_f
50
+ end
51
+ end
52
+ end
53
+
54
+ module Location
55
+ extend Entity
56
+
57
+ self.format =(<<-EOF
58
+ Location
59
+ EOF
60
+ ).split("\n")
61
+
62
+ def <=>(other)
63
+ self.to_s.split(":").first.to_f <=> other.to_s.split(":").first.to_f
64
+ end
65
+
66
+ def self.tsv_sort(v)
67
+ value = v.last
68
+ if Array === value
69
+ value.first.to_s.split(":").first.to_f
70
+ else
71
+ value.to_s.split(":").first.to_f
72
+ end
73
+ end
74
+ end
75
+
32
76
  module NumericValue
33
77
  extend Entity
34
78
 
@@ -51,6 +95,10 @@ adjusted.p.value
51
95
  adjusted.p.values
52
96
  Rank
53
97
  rank
98
+ Counts
99
+ Ratio
100
+ Size
101
+ size
54
102
  EOF
55
103
  ).split("\n")
56
104
 
@@ -128,7 +176,7 @@ module RbbtRESTHelpers
128
176
 
129
177
  num = num.to_i
130
178
  size = size.to_i
131
- max = object.size / size + 1
179
+ max = (object.size / size) + 1
132
180
 
133
181
  num = max if num > max
134
182
  num = - max if num < - max
@@ -178,7 +226,7 @@ module RbbtRESTHelpers
178
226
 
179
227
  case
180
228
  when value =~ /^([<>]=?)(.*)/
181
- tsv = tsv.select(key, invert){|k| k = k.first if Array === k; (k.nil? or k.empty?) ? false : k.to_f.send($1, $2.to_f)}
229
+ tsv = tsv.select(key, invert){|k| k = k.first if Array === k; (k.nil? or (String === k and k.empty?)) ? false : k.to_f.send($1, $2.to_f)}
182
230
  when value =~ /^\/(.+)\/.{0,2}\s*$/
183
231
  tsv = tsv.select({key => Regexp.new($1)}, invert)
184
232
  when (value =~ /^\d+$/ and tsv.type == :double or tsv.type == :flat)
@@ -286,7 +334,8 @@ module RbbtRESTHelpers
286
334
  url = remove_GET_param(url, "_")
287
335
  end
288
336
 
289
- table_class = []
337
+ table_class = options[:table_class] || []
338
+ table_class = [table_class] unless Array === table_class
290
339
  table_class << 'wide responsive' if tsv.fields.length > 4
291
340
 
292
341
  options[:url] = url
@@ -31,11 +31,6 @@ module Sinatra
31
31
 
32
32
  attr_accessor :ajax, :layout, :format, :size, :update, :cache_type, :_, :profile
33
33
 
34
- if production?
35
- set :haml, { :ugly => true }
36
- set :clean_trace, true
37
- set :static_cache_control , [:public, {:max_age => 360000}]
38
- end
39
34
 
40
35
  enable :cross_origin
41
36
  set :allow_origin, :any
@@ -44,9 +39,18 @@ module Sinatra
44
39
  set :max_age, "1728000"
45
40
  set :allow_headers, ['URI']
46
41
 
42
+ if production?
43
+ set :haml, { :ugly => true }
44
+ set :clean_trace, true
45
+ set :static_cache_control , [:public, {:max_age => 360000}]
46
+ else
47
+ set :static_cache_control , [:public, {:max_age => 0}]
48
+ end
49
+
47
50
  before do
48
51
  method = request.request_method
49
52
  method_color = case method
53
+
50
54
  when "GET"
51
55
  :cyan
52
56
  when "POST"
@@ -179,6 +183,18 @@ module Sinatra
179
183
 
180
184
  halt 500, [e.class.to_s, e.message] * " => " << "\n\n" << (e.backtrace * "\n").gsub('`',"'")
181
185
  end
186
+
187
+ get '/fonts/*' do
188
+ filename = params[:splat].first
189
+ file = File.join(FontAwesome::Sass.fonts_path, filename)
190
+ send_file file
191
+ end
192
+
193
+ get '/opt/*' do
194
+ filename = params[:splat].first
195
+ file = locate_file(Path.setup('public/opt')[filename])
196
+ send_file file.find
197
+ end
182
198
 
183
199
  require 'rbbt/rest/monitor'
184
200
  register Sinatra::RbbtRESTMonitor
@@ -2,6 +2,7 @@
2
2
  module Sinatra
3
3
  module RbbtToolHelper
4
4
  def tool(toolname, options = {})
5
+ options[:id] ||= toolname.to_s + "_#{rand(10000)}"
5
6
  partial_render("tools/#{toolname}", options)
6
7
  end
7
8
  end
@@ -217,7 +217,26 @@ module Sinatra
217
217
 
218
218
  job = workflow.load_id(File.join(task, job))
219
219
 
220
- send_file job.file(filename)
220
+ require 'mimemagic'
221
+ path = job.file(filename)
222
+ mime = nil
223
+ Open.open(path) do |io|
224
+ begin
225
+ mime = MimeMagic.by_path(io)
226
+ if mime.nil?
227
+ io.rewind
228
+ mime = MimeMagic.by_magic(io)
229
+ end
230
+ if mime.nil?
231
+ io.rewind
232
+ mime = "text/tab-separated-values" if io.gets =~ /^#/ and io.gets.include? "\t"
233
+ end
234
+ rescue Exception
235
+ Log.exception $!
236
+ end
237
+ end
238
+ content_type mime if mime
239
+ send_file path
221
240
  end
222
241
 
223
242
  delete "/#{workflow.to_s}/:task/:job" do
@@ -98,6 +98,8 @@ module WorkflowRESTHelpers
98
98
  end
99
99
 
100
100
  def show_result(job, workflow, task)
101
+ return show_result_html nil, workflow, task, job.name, job if @fragment
102
+
101
103
  case format.to_sym
102
104
  when :html
103
105
  show_result_html job.load, workflow, task, job.name, job
@@ -196,7 +198,7 @@ module WorkflowRESTHelpers
196
198
  content_type :text
197
199
  job.name
198
200
  else
199
- job.grace
201
+ job.soft_grace
200
202
  redirect job_url
201
203
  end
202
204
  rescue Exception
@@ -6,6 +6,7 @@ module WorkflowRESTHelpers
6
6
  def workflow_render(template, workflow = nil, task = nil, params = {})
7
7
  workflow = consume_parameter(:workflow, params) if workflow.nil?
8
8
  task = consume_parameter(:task, params) if workflow.nil?
9
+ job = consume_parameter(:job, params) if job.nil?
9
10
 
10
11
  template_file = locate_workflow_template(template, workflow, task)
11
12
 
@@ -13,9 +14,22 @@ module WorkflowRESTHelpers
13
14
  locals[:workflow] = workflow if workflow
14
15
  locals[:task] = task if task
15
16
 
16
- layout_file = layout ? locate_template("layout") : nil
17
-
18
- render(template_file, locals, layout_file)
17
+ if layout
18
+ layout_file = workflow.libdir.www.views[workflow.to_s]["layout.haml"] if workflow.libdir
19
+ layout_file = locate_template("layout") unless layout_file and layout_file.exists?
20
+ else
21
+ layout_file = nil
22
+ end
23
+
24
+ if job
25
+ locals[:job] = job
26
+ @step = job
27
+ cache_type = execution_type(workflow, task)
28
+ cache_file = job.file('html')
29
+ render(template_file, locals, layout_file, [task,workflow,job.name] * "-", :cache_type => cache_type, :cache_file => cache_file)
30
+ else
31
+ render(template_file, locals, layout_file)
32
+ end
19
33
  end
20
34
 
21
35
  def workflow_partial(template, workflow = nil, task = nil, params = {})
@@ -0,0 +1,17 @@
1
+ @import "_normalize"
2
+ @import "_rbbt"
3
+
4
+ @import "style"
5
+
6
+ @import "user"
7
+ @import "entity_card"
8
+ @import "workflow"
9
+ @import "finder"
10
+ @import "favourites"
11
+ @import "actions"
12
+ @import "top_menu"
13
+ @import "help"
14
+ @import "figure"
15
+ @import "monitor"
16
+ @import "layout"
17
+