rbbt-rest 1.7.20 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a40ff490d992383fabd6576ad3b06df0c1a9e7c4
4
- data.tar.gz: d6ea9091bd3dca0e92f0628ef84b477a6e43f344
3
+ metadata.gz: 33b3e5b0e58772dc57de97948285d38035eccbec
4
+ data.tar.gz: a8b907196c822fed834fe8c7ef116b68a78ea74e
5
5
  SHA512:
6
- metadata.gz: 5b813d5e2dfe4bbd36b1676a569393f7903eb8f1eb14c9392ed583991fa22cbdfea40b63f910642c5cce50610040154925aa23987855ed7c0112d15b2881754c
7
- data.tar.gz: b70426b8a0d31ce739e551c23ca91ab6823aa2bc9b6036f31cf988b6327fd33bb15577ae6aef3c1c740288d46ba7139b53506df9cdb9eaad8ce8557c651aa03c
6
+ metadata.gz: 9b1b63cb4665226a0ece4345bec78f3cb74885ac003a1e3eb3d31f999f28060d49cc79cc490106752465af7d177b9b805c5f5ff3d7bd2a72a79509c5e7185073
7
+ data.tar.gz: e27f644d02bb2745e6295cb989ad4f0dfaf06dc59ed7d3f07bbe05f0049cd303560ec985819f53ddd3dc8a2ead90f1e18d413caa046001adeef6d96e5a758c2a
@@ -99,8 +99,12 @@ module RbbtRESTHelpers
99
99
  1
100
100
  end
101
101
 
102
- input_label(id, name, description, default, extra) +
103
- html_tag("input", nil, html_options.merge(:type => input_type, :name => name, :value => value, :id => id, :step => step))
102
+ if input_type == 'hidden'
103
+ html_tag("input", nil, html_options.merge(:type => input_type, :name => name, :value => value, :id => id, :step => step))
104
+ else
105
+ input_label(id, name, description, default, extra) +
106
+ html_tag("input", nil, html_options.merge(:type => input_type, :name => name, :value => value, :id => id, :step => step))
107
+ end
104
108
 
105
109
  when :tsv, :array, :text, :file
106
110
  value = current.nil? ? default : current
@@ -81,7 +81,7 @@ module RbbtRESTHelpers
81
81
  #{{{ JAVASCRIPT
82
82
 
83
83
  def self.javascript_resources
84
- @javascript_resources ||= [Rbbt.share.views.public.find(:lib), Rbbt.share.views.public.js.find(:lib)]
84
+ @javascript_resources ||= [Rbbt.share.views.public.find(:lib), Rbbt.share.views.public.js.find(:lib), Rbbt.share.views.public.plugins.find(:lib)]
85
85
  end
86
86
 
87
87
  def javascript_resources
@@ -103,4 +103,30 @@ module RbbtRESTHelpers
103
103
 
104
104
  raise TemplateMissing, "Script #{ script } not found"
105
105
  end
106
+
107
+ #{{{ CSS
108
+
109
+ def self.css_resources
110
+ @css_resources ||= [Rbbt.share.views.public.find(:lib), Rbbt.share.views.public.css.find(:lib), Rbbt.share.views.public.plugins.find(:lib)]
111
+ end
112
+
113
+ def css_resources
114
+ RbbtRESTHelpers.css_resources
115
+ end
116
+
117
+
118
+ def locate_css_from_resource(resource, script)
119
+ path = resource[script + '.css']
120
+ return path if path.exists?
121
+ resource[script]
122
+ end
123
+
124
+ def locate_css(script)
125
+ css_resources.each do |resource|
126
+ path = locate_css_from_resource(resource, script)
127
+ return path if path.exists?
128
+ end
129
+
130
+ raise TemplateMissing, "Script #{ script } not found"
131
+ end
106
132
  end
@@ -362,6 +362,7 @@ module Sinatra
362
362
  halt 200, TSV.open(file).to_json
363
363
  else
364
364
  map = Entity::Map.load_map(entity_type.split(":").first, column, map_id, user)
365
+ raise "Map not found: #{ map_id }" if map.nil?
365
366
  entity_map_render(map_id, entity_type.split(":").first, column)
366
367
  end
367
368
  end
@@ -386,7 +387,8 @@ module Sinatra
386
387
  column = Entity::REST.restore_element(params[:column])
387
388
  map_id = Entity::REST.restore_element(params[:map_id])
388
389
 
389
- map = Entity::Map.load_map(entity_type.split(":").first, column, map_id, user)
390
+ base_type = entity_type.split(":").first
391
+ map = Entity::Map.load_map(base_type, column, map_id, user)
390
392
 
391
393
  Entity::Map.save_map(entity_type, column, new_id, map, user)
392
394
 
@@ -402,15 +404,18 @@ module Sinatra
402
404
 
403
405
  entity_type = consume_parameter :entity_type
404
406
  column = consume_parameter :column
407
+ column2 = consume_parameter :column2
405
408
  entity_type = Entity::REST.restore_element(entity_type)
406
409
  column = Entity::REST.restore_element(column)
407
410
 
408
411
  file1 = Entity::Map.map_file(entity_type.split(":").first, column, map1, user)
409
412
  file1 = Entity::Map.map_file(entity_type.split(":").first, column, map1, nil) unless File.exists? file1
410
- tsv1 = TSV.open(file1)
413
+ raise "Map not found: #{ map1 }" unless File.exists? file1
414
+ tsv1 = TSV.open(file1)
411
415
 
412
- file2 = Entity::Map.map_file(entity_type.split(":").first, column, map2, user)
413
- file2 = Entity::Map.map_file(entity_type.split(":").first, column, map2, nil) unless File.exists? file2
416
+ file2 = Entity::Map.map_file(entity_type.split(":").first, column2, map2, user)
417
+ file2 = Entity::Map.map_file(entity_type.split(":").first, column2, map2, nil) unless File.exists? file2
418
+ raise "Map not found: #{ map2 } - #{ file2 }" unless File.exists? file2
414
419
  tsv2 = TSV.open(file2)
415
420
 
416
421
  tsv1.attach tsv2, :fields => tsv2.fields
@@ -8,6 +8,32 @@ module EntityRESTHelpers
8
8
  [Rbbt.share.views.find(:lib)] + EntityRESTHelpers.entity_resources
9
9
  end
10
10
 
11
+ #{{{ CHECKS
12
+
13
+ def reject_template(path,binding)
14
+ check_file = path.sub(/\.haml$/, '.check')
15
+
16
+ if Path === path
17
+ path.annotate check_file
18
+ return false unless check_file.exists?
19
+ else
20
+ return false unless File.exists?(check_file)
21
+ end
22
+
23
+ begin
24
+ code = Open.read(check_file)
25
+ accept = eval code, binding, check_file, 0
26
+ Log.debug{"Checking action template: #{path} - #{accept ? 'accepted' : 'rejected'}"}
27
+ return ! accept
28
+ rescue
29
+ Log.exception $!
30
+ iii path
31
+ ppp code
32
+ return true
33
+ end
34
+ false
35
+ end
36
+
11
37
  #{{{ ENTITY
12
38
 
13
39
  def locate_entity_template_from_resource(resource, entity)
@@ -54,59 +80,10 @@ module EntityRESTHelpers
54
80
 
55
81
  #{{{ ENTITY ACTION
56
82
 
57
- def find_all_entity_action_templates_from_resource(resource, entity)
58
- if entity == "Default"
59
- resource.entity["Default"].glob("*.haml").sort
60
- else
61
- entity.annotation_types.collect do |annotation|
62
- resource.entity[annotation].glob('*.haml')
63
- end.compact.flatten.sort
64
- end
65
- end
66
-
67
- def find_all_entity_action_templates(entity, check = false)
68
- paths = []
69
-
70
- if entity.respond_to? :dir and Path === entity.dir
71
- paths.concat find_all_entity_action_templates_from_resource(entity.dir.www.views, entity)
72
- end
73
-
74
- entity_resources.each do |resource|
75
- paths.concat find_all_entity_action_templates_from_resource(resource, entity)
76
- end
77
-
78
- entity_resources.each do |resource|
79
- paths.concat find_all_entity_action_templates_from_resource(resource, "Default")
80
- end
81
-
82
- if check
83
- paths = paths.reject do |path|
84
- check_file = path.sub(/\.haml$/, '.check')
85
- case
86
- when (path.basename == "edit.haml" or path.basename == 'new.haml')
87
- true
88
- when File.exists?(check_file)
89
- begin
90
- Log.debug{"Checking action template: #{path}"}
91
- code = File.read(check_file)
92
- accept = eval code
93
- not accept
94
- rescue
95
- Log.debug{"Error Checking action template #{path}: #{$!.message}"}
96
- true
97
- end
98
- else
99
- false
100
- end
101
- end
102
- end
103
-
104
- paths.collect{|file| file.basename.sub('.haml', '') }.uniq
105
- end
106
-
107
83
  def locate_entity_action_template_from_resource(resource, entity, action)
108
84
  if entity == "Default"
109
85
  path = resource.entity["Default"][action.to_s + ".haml"]
86
+ raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
110
87
  if path.exists?
111
88
  return path
112
89
  else
@@ -116,6 +93,7 @@ module EntityRESTHelpers
116
93
 
117
94
  entity.annotation_types.each do |annotation|
118
95
  path = resource.entity[annotation][action.to_s + ".haml"]
96
+ raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
119
97
  return path if path.exists?
120
98
  end
121
99
 
@@ -136,12 +114,56 @@ module EntityRESTHelpers
136
114
 
137
115
  entity_resources.each do |resource|
138
116
  path = locate_entity_action_template_from_resource(resource, "Default", action)
117
+ raise "This action was rejected: #{ action }" if reject_template(path,binding)
139
118
  return path if path and path.exists?
140
119
  end
141
120
 
142
121
  raise "Template not found for action #{action}: #{ entity } (#{entity.annotation_types * ", "})"
143
122
  end
144
123
 
124
+ def find_all_entity_action_templates_from_resource(resource, entity)
125
+ if entity == "Default"
126
+ resource.entity["Default"].glob("*.haml").sort
127
+ else
128
+ entity.annotation_types.collect do |annotation|
129
+ resource.entity[annotation].glob('*.haml')
130
+ end.compact.flatten.sort
131
+ end
132
+ end
133
+
134
+ def find_all_entity_action_templates(entity, check = false)
135
+ paths = []
136
+
137
+ if entity.respond_to? :dir and Path === entity.dir
138
+ paths.concat find_all_entity_action_templates_from_resource(entity.dir.www.views, entity)
139
+ end
140
+
141
+ entity_resources.each do |resource|
142
+ paths.concat find_all_entity_action_templates_from_resource(resource, entity)
143
+ end
144
+
145
+ entity_resources.each do |resource|
146
+ paths.concat find_all_entity_action_templates_from_resource(resource, "Default")
147
+ end
148
+
149
+ if check
150
+ paths = paths.reject do |path|
151
+ (path.basename == "edit.haml" or path.basename == 'new.haml')
152
+ end
153
+ end
154
+
155
+ actions = paths.collect{|file| file.basename.sub('.haml', '') }.uniq
156
+
157
+ actions.select! do |action|
158
+ begin
159
+ locate_entity_action_template(entity, action)
160
+ rescue Exception
161
+ false
162
+ end
163
+ end if check
164
+
165
+ actions
166
+ end
145
167
  #{{{ ENTITY LIST
146
168
 
147
169
  def locate_entity_list_template_from_resource(resource, list)
@@ -189,61 +211,11 @@ module EntityRESTHelpers
189
211
 
190
212
  #{{{ ENTITY LIST ACTION
191
213
 
192
- def find_all_entity_list_action_templates_from_resource(resource, entity)
193
-
194
- if entity == "Default"
195
- resource.entity_list["Default"].glob("*.haml").sort
196
- else
197
- entity.annotation_types.collect do |annotation|
198
- resource.entity_list[annotation].glob('*.haml')
199
- end.compact.flatten.sort
200
- end
201
- end
202
-
203
- def find_all_entity_list_action_templates(list, check = false)
204
- paths = []
205
-
206
- if list.respond_to? :dir and Path === list.dir
207
- paths.concat find_all_entity_list_action_templates_from_resource(list.dir.www.views, list)
208
- end
209
-
210
- entity_resources.each do |resource|
211
- paths.concat find_all_entity_list_action_templates_from_resource(resource, list)
212
- end
213
-
214
- entity_resources.each do |resource|
215
- paths.concat find_all_entity_list_action_templates_from_resource(resource, "Default")
216
- end
217
-
218
- if check
219
- paths = paths.reject do |path|
220
- check_file = path.sub(/\.haml$/, '.check')
221
- case
222
- when (path.basename == "edit.haml" or path.basename == 'new.haml')
223
- true
224
- when File.exists?(check_file)
225
- begin
226
- Log.debug{ "Checking action template: #{path}" }
227
- code = File.read(check_file)
228
- accept = eval code
229
- not accept
230
- rescue
231
- Log.debug{ "Error Checking action template #{path}: #{$!.message}" }
232
- true
233
- end
234
- else
235
- false
236
- end
237
- end
238
- end
239
-
240
- paths.collect{|file| file.basename.sub('.haml', '') }.uniq
241
- end
242
-
243
214
 
244
215
  def locate_entity_list_action_template_from_resource(resource, list, action)
245
216
  if list == "Default"
246
217
  path = resource.entity_list["Default"][action.to_s + ".haml"]
218
+ raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
247
219
  if path.exists?
248
220
  return path
249
221
  else
@@ -253,6 +225,7 @@ module EntityRESTHelpers
253
225
 
254
226
  list.annotation_types.each do |annotation|
255
227
  path = resource.entity_list[annotation][action.to_s + ".haml"]
228
+ raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
256
229
  return path if path.exists?
257
230
  end
258
231
 
@@ -279,6 +252,51 @@ module EntityRESTHelpers
279
252
  raise "Template not found for list #{ action } (#{list.annotation_types * ", "})"
280
253
  end
281
254
 
255
+ def find_all_entity_list_action_templates_from_resource(resource, entity)
256
+
257
+ if entity == "Default"
258
+ resource.entity_list["Default"].glob("*.haml").sort
259
+ else
260
+ entity.annotation_types.collect do |annotation|
261
+ resource.entity_list[annotation].glob('*.haml')
262
+ end.compact.flatten.sort
263
+ end
264
+ end
265
+
266
+ def find_all_entity_list_action_templates(list, check = false)
267
+ paths = []
268
+
269
+ if list.respond_to? :dir and Path === list.dir
270
+ paths.concat find_all_entity_list_action_templates_from_resource(list.dir.www.views, list)
271
+ end
272
+
273
+ entity_resources.each do |resource|
274
+ paths.concat find_all_entity_list_action_templates_from_resource(resource, list)
275
+ end
276
+
277
+ entity_resources.each do |resource|
278
+ paths.concat find_all_entity_list_action_templates_from_resource(resource, "Default")
279
+ end
280
+
281
+ if check
282
+ paths = paths.reject do |path|
283
+ (path.basename == "edit.haml" or path.basename == 'new.haml')
284
+ end
285
+ end
286
+
287
+ actions = paths.collect{|file| file.basename.sub('.haml', '') }.uniq
288
+
289
+ actions.select! do |action|
290
+ begin
291
+ locate_entity_list_action_template(list, action)
292
+ rescue Exception
293
+ false
294
+ end
295
+ end if check
296
+
297
+ actions
298
+ end
299
+
282
300
  #{{{ ENTITY MAP
283
301
 
284
302
  def locate_entity_map_template_from_resource(resource, type)
@@ -314,7 +332,7 @@ module EntityRESTHelpers
314
332
 
315
333
  #{{{ ENTITY MAP ACTION
316
334
 
317
- def find_all_entity_map_action_templates_from_resource(resource, map)
335
+ def locate_entity_map_action_template_from_resource(resource, map, action)
318
336
  field = map.key_field
319
337
 
320
338
  if map.entity_templates[field]
@@ -325,45 +343,26 @@ module EntityRESTHelpers
325
343
 
326
344
  annotation_types += ["Default"]
327
345
 
328
- annotation_types.collect do |annotation|
329
- resource.entity_map[annotation].glob('*.haml')
330
- end.compact.flatten
346
+ annotation_types.each do |annotation|
347
+ path = resource.entity_map[annotation][action.to_s + ".haml"]
348
+ raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
349
+ return path if path.exists?
350
+ end
351
+
352
+ nil
331
353
  end
332
354
 
333
- def find_all_entity_map_action_templates(map, check = false)
334
- paths = []
355
+ def locate_entity_map_action_template(map, action)
335
356
 
336
357
  entity_resources.each do |resource|
337
- paths.concat find_all_entity_map_action_templates_from_resource(resource, map)
338
- end
339
-
340
- if check
341
- paths = paths.reject do |path|
342
- check_file = path.sub(/\.haml$/, '.check')
343
- case
344
- when (path.basename == "edit.haml" or path.basename == 'new.haml')
345
- true
346
- when File.exists?(check_file)
347
- begin
348
- Log.debug{ "Checking action template: #{path}" }
349
- code = File.read(check_file)
350
- accept = eval code
351
- not accept
352
- rescue
353
- Log.debug{ "Error Checking action template #{path}: #{$!.message}" }
354
- true
355
- end
356
- else
357
- false
358
- end
359
- end
358
+ path = locate_entity_map_action_template_from_resource(resource, map, action)
359
+ return path if path and path.exists?
360
360
  end
361
361
 
362
- paths.collect{|file| file.basename.sub('.haml', '') }.uniq
362
+ raise "Template not found for map #{ action } (#{map.key_field * ", "})"
363
363
  end
364
364
 
365
-
366
- def locate_entity_map_action_template_from_resource(resource, map, action)
365
+ def find_all_entity_map_action_templates_from_resource(resource, map)
367
366
  field = map.key_field
368
367
 
369
368
  if map.entity_templates[field]
@@ -374,22 +373,36 @@ module EntityRESTHelpers
374
373
 
375
374
  annotation_types += ["Default"]
376
375
 
377
- annotation_types.each do |annotation|
378
- path = resource.entity_map[annotation][action.to_s + ".haml"]
379
- return path if path.exists?
380
- end
381
-
382
- nil
376
+ annotation_types.collect do |annotation|
377
+ resource.entity_map[annotation].glob('*.haml')
378
+ end.compact.flatten
383
379
  end
384
380
 
385
- def locate_entity_map_action_template(map, action)
381
+ def find_all_entity_map_action_templates(map, check = false)
382
+ paths = []
386
383
 
387
384
  entity_resources.each do |resource|
388
- path = locate_entity_map_action_template_from_resource(resource, map, action)
389
- return path if path and path.exists?
385
+ paths.concat find_all_entity_map_action_templates_from_resource(resource, map)
390
386
  end
391
387
 
392
- raise "Template not found for map #{ action } (#{map.key_field * ", "})"
388
+ if check
389
+ paths = paths.reject do |path|
390
+ (path.basename == "edit.haml" or path.basename == 'new.haml')
391
+ end
392
+ end
393
+
394
+ actions = paths.collect{|file| file.basename.sub('.haml', '') }.uniq
395
+
396
+ actions.select! do |action|
397
+ begin
398
+ locate_entity_map_action_template(map, action)
399
+ rescue Exception
400
+ false
401
+ end
402
+ end if check
403
+
404
+ actions
393
405
  end
394
406
 
407
+
395
408
  end
@@ -14,11 +14,11 @@ module Entity
14
14
  #{{{ MISC
15
15
 
16
16
  def self.clean_element(elem)
17
- elem.gsub('/', '--').gsub('%', 'o-o')
17
+ elem.gsub('/', '-..-').gsub('%', 'o-o').gsub('[','(.-(').gsub(']',').-)')
18
18
  end
19
19
 
20
20
  def self.restore_element(elem)
21
- CGI.unescape(CGI.unescape(elem.gsub('--', '/').gsub('o-o', '%')))
21
+ CGI.unescape(CGI.unescape(elem.gsub('-..-', '/').gsub('o-o', '%').gsub('(.-(','[').gsub(').-)',']')))
22
22
  end
23
23
 
24
24
  def entity_link_params
@@ -27,7 +27,10 @@ module Sinatra
27
27
 
28
28
  RbbtRESTHelpers.add_sass_load_path path.compass if path.compass.exists?
29
29
 
30
- RbbtRESTHelpers.javascript_resources.unshift path.public.js if path.public.js.exists?
30
+ RbbtRESTHelpers.javascript_resources.unshift path.public.js if path.public.js.exists?
31
+ RbbtRESTHelpers.css_resources.unshift path.public.css if path.public.css.exists?
32
+ RbbtRESTHelpers.javascript_resources.unshift path.public.plugins if path.public.plugins.exists?
33
+ RbbtRESTHelpers.css_resources.unshift path.public.plugins if path.public.plugins.exists?
31
34
  RbbtRESTHelpers.sass_resources.unshift path.compass if path.compass.exists?
32
35
  end
33
36
 
@@ -140,6 +143,17 @@ module Sinatra
140
143
  send_file script_file
141
144
  end
142
145
 
146
+ get %r{/css-find/(.*)(.css)?} do
147
+ name = consume_parameter(:captures).first
148
+
149
+ script_file = locate_css(name)
150
+
151
+ content_type 'text/css', :charset => 'utf-8' if script_file =~ /\.js$/
152
+ cache_control :public, :max_age => 360000 if production?
153
+ send_file script_file
154
+ end
155
+
156
+
143
157
  get '/stylesheets/*' do
144
158
  name = consume_parameter :splat
145
159
 
@@ -47,3 +47,6 @@ a.entity
47
47
 
48
48
  table > caption
49
49
  max-width: 60em
50
+
51
+ .filters + p
52
+ margin-top: 2em
@@ -14,13 +14,13 @@
14
14
  .info.ui.compact.segment
15
15
  .meta
16
16
  .map_management.ui.buttons
17
- = reveal "Rename", nil, :class => 'ui small button' do
18
- %form.rename
17
+ = reveal "Rename", nil, :class => 'ui small button rename_map' do
18
+ %form.rename_map
19
19
  %label New name
20
20
  %input(name='rename' value=map_id)
21
21
  %input(type='submit')
22
22
 
23
- - if %w(pvalue p.value p-value pvalues p.values p-values qvalue q.value q-value qvalues q.values q-values).include? map.fields.first.downcase.gsub(/\s/,'')
23
+ - if (%w(pvalue p.value p-value pvalues p.values p-values qvalue q.value q-value qvalues q.values q-values) & map.fields.first.downcase.split(/\s+/)).any? and map.fields.first.downcase !~ /score$/
24
24
  - url = add_GET_param(@fullpath, '_format', 'pvalue_score')
25
25
  %a.ui.small.button(href=url) Pvalue score
26
26
 
@@ -40,15 +40,19 @@
40
40
  - if NumericValue == Entity.formats[map.fields.first] or (map.entity_templates[map.fields.first] and map.entity_templates[map.fields.first].annotation_types.include? NumericValue)
41
41
  - $page_entity_base_type = page_entity_base_type
42
42
  - $page_entity_map_column = page_entity_map_column
43
- = reveal :rank_products, nil, :title => "Rank Product", :class => 'ui small button' do
43
+ = reveal "Rank products", nil, :class => 'ui small button rank_product' do
44
44
  = action_parameters nil, :class => 'rank_products' do
45
45
  - input :map, :select, "Select map to use", nil, :html_options => {:class => 'favourite_maps', :type => $page_entity_base_type, :column => $page_entity_map_column}
46
46
 
47
+ = reveal "Compare plot", nil, :class => 'ui small button plot' do
48
+ = action_parameters nil, :class => 'plot' do
49
+ - input :map, :select, "Select map to use", nil, :html_options => {:class => 'favourite_maps', :type => $page_entity_base_type, :column => $page_entity_map_column}
50
+
47
51
 
48
52
 
49
53
  .content
50
54
  .description
51
- = table :class => 'ui collapsing table' do
55
+ = table :class => 'ui collapsing table', :table_id => map_id do
52
56
  - map
53
57
  - if card.action_controller
54
58
  .actions
@@ -11,6 +11,7 @@
11
11
 
12
12
  var known_types = #{Entity::REST::REST_ENTITIES.collect{|m| m.to_s}.to_json}
13
13
 
14
+ -#
14
15
  function gene_name(name){
15
16
  return new Entity({type: "Gene", id: name, name: name, format: "Associated Gene Name", info: { organism: "Hsa/feb2014" }})
16
17
  }
@@ -16,10 +16,10 @@
16
16
  :markdown
17
17
  Filters can be specified in several ways:
18
18
 
19
- - *String of text*: perfect match (e.g. `Cancer`)
20
- - *Regular expression*: flexible match (e.g. `/(bladder|breast)\s+cancer/i`)
21
- - *Numeric comparison*: lower of grater than (e.g. `< 0.1` or `>= 2`)
22
- - *Names*: for entities with names, such as genes or pathways; regular expression accepted (e.g. `:name: SF3B1` or `:name: /CDK\d/`)
23
- - *Length*: for lists (e.g. `:length: > 2`)
24
- - *Negation*: Any of the rules above can be negated by prepending the `!` character (e.g. `!:name:/^IG/`)
19
+ - *String of text*: perfect match (e.g. `'Cancer'`)
20
+ - *Regular expression*: flexible match (e.g. `'/(bladder|breast)\s+cancer/i'`)
21
+ - *Numeric comparison*: lower of grater than (e.g. `'< 0.1'` or `'>= 2'`)
22
+ - *Names*: for entities having 'human-friendly' names, such as genes or pathways; regular expression accepted (e.g. `':name: SF3B1'` or `':name: /CDK\d/'`)
23
+ - *Length*: for lists (e.g. `':length: > 2'`)
24
+ - *Negation*: Any of the rules above can be negated by prepending the `!` character (e.g. `'!:name:/^IG/'`)
25
25
 
@@ -37,11 +37,11 @@ function remove_parameter(url, parameter){
37
37
  }
38
38
 
39
39
  function clean_element(elem){
40
- return elem.replace(/\//g, '--').replace(/%/g,'o-o')
40
+ return elem.replace(/\//g, '-..-').replace(/%/g,'o-o').replace(/\[/g,'(.-(').replace(/\]/g,').-)')
41
41
  }
42
42
 
43
43
  function restore_element(elem){
44
- return unescape(elem.replace(/--/g, '/').replace(/o-o/g,'%'));
44
+ return unescape(elem.replace(/-\.\.-/g, '/').replace(/o-o/g,'%')).replace(/\(\.-\(/g,'[').replace(/\)\.-\)/g,']');
45
45
  }
46
46
 
47
47
  function parse_parameters(params){
@@ -70,7 +70,7 @@ function require_js(url, success, script){
70
70
  }
71
71
  }else{
72
72
  var async = true;
73
- if (undefined === production) production = false
73
+ if (typeof production == 'undefined') production = false
74
74
  var cache = production;
75
75
 
76
76
  if (undefined === success){
@@ -79,12 +79,14 @@ function require_js(url, success, script){
79
79
  async = true;
80
80
  }
81
81
 
82
- url = url.replace('/js/', '/js-find/')
82
+ url = url.replace('^/js/', '/js-find/')
83
83
 
84
84
  if ($.inArray(url, required_js) >= 0){
85
85
  if (typeof success == 'function'){ success.call(script) }
86
86
  }else{
87
- var _success = function(){ required_js.push(url); if (typeof success == 'function'){ success.call(script) }; }
87
+ var _success = function(script_text){ required_js.push(url); console.log("Required and loaded JS: " + url); if (typeof success == 'function'){ success(script) }; }
88
+ if (typeof rbbt.proxy != 'undefined')
89
+ url = rbbt.proxy + url
88
90
  $.ajax({url: url, cache:cache, dataType:'script', async: async, success: _success} ).fail(function(jqxhr, settings, exception){ console.log('Failed to load ' + url) })
89
91
  }
90
92
  }
@@ -142,7 +142,11 @@ FavouriteLists.get = function(){
142
142
  }
143
143
 
144
144
  FavouriteLists.deserialize = function(data){
145
- data = JSON.parse(data)
145
+ try{
146
+ data = JSON.parse(data)
147
+ }catch(err){
148
+ data = {}
149
+ }
146
150
  favourite_lists = {}
147
151
 
148
152
  forHash(data, function(type, type_data){
@@ -39,6 +39,7 @@ rbbt.plots.aes.map_aesthetic = function(aes, mapper, map_obj){
39
39
  return map_obj(aes)
40
40
  }
41
41
  }
42
+
42
43
  rbbt.plots.aes.get_properties = function(list, rules){
43
44
  if (undefined === rules) rules == []
44
45
  if (undefined === list.properties) list.properties = {}
@@ -190,6 +191,17 @@ rbbt.plots.aes.set_aes = function(list, aes_rules){
190
191
  if (undefined === property && name == 'code') property = list.codes
191
192
  if (undefined === property) return
192
193
 
193
- list.aes[aes] = rbbt.plots.aes.map_aesthetic(property, mapper, mapper_obj)
194
+ var aes_values = rbbt.plots.aes.map_aesthetic(property, mapper, mapper_obj)
195
+
196
+ if (undefined === list.aes[aes]){
197
+ list.aes[aes] = aes_values
198
+ }else{
199
+ for(i in aes_values){
200
+ var v = aes_values[i]
201
+ if (undefined !== v){
202
+ list.aes[aes][i] = v
203
+ }
204
+ }
205
+ }
194
206
  })
195
207
  }
@@ -110,7 +110,6 @@ rbbt.plots.graph.view_cytoscapejs = function(graph_model, elem, style, layout, e
110
110
 
111
111
  var deferred = m.deferred()
112
112
 
113
- console.log(graph_model)
114
113
  rbbt.plots.graph.update(graph_model).then(function(updated_model){
115
114
  var cy_model = rbbt.plots.graph.build_cytoscapejs(updated_model)
116
115
 
@@ -121,7 +121,7 @@ body.on('click', '.edit_list input[type=submit]', function(){
121
121
 
122
122
  if (undefined !== format){ entity_type = entity_type + ':' + clean_element(format) }
123
123
 
124
- var url = '/entity_list/' + entity_type + '/' + new_list_id
124
+ var url = '/entity_list/' + clean_element(entity_type) + '/' + clean_element(new_list_id )
125
125
 
126
126
  get_ajax({url: url, type: 'POST', async: false, data: {annotations: JSON.stringify(annotations), entities: entities}}, function(){ window.location = url })
127
127
 
@@ -1,18 +1,116 @@
1
1
  function entity_map(type, column, id, complete){
2
2
  var url = "/entity_map" + '/' + clean_element(type) + '/' + clean_element(column) + '/' + clean_element(id);
3
- return get_ajax({url: url, async: false, method: "GET", data: {_format: 'json'}}, complete)
3
+ return rbbt.ajax({url: url, async: false, method: "GET", data: {_format: 'json'}}, complete)
4
4
  }
5
5
 
6
+ $('body').on('click', '#modal form.rename_map input[type=submit]', function(){
7
+ console.log(1)
8
+ var map = rbbt.page.map();
9
+ var map_id = map.id
10
+
11
+ var submit = $(this);
12
+ var input = submit.closest('form').find('input[name=rename]')
13
+ var new_name = input.val();
14
+ var entity_type = map.type
15
+ var column = map.column
16
+ url = '/entity_map/rename/'+ clean_element(entity_type) + '/'+ clean_element(column) +'/' + clean_element(map_id) + '?new_name=' + clean_element(new_name)
17
+ window.location = url
18
+ return false
19
+ })
20
+
6
21
  $('body').on('click', '.rank_products form input[type=submit]', function(){
7
- var map1 = page_entity_map();
22
+ var map = rbbt.page.map();
23
+ var map1 = map.id;
8
24
 
9
25
  var input = $(this);
10
26
  var select = input.closest('form').find('select')
11
27
  var map2 = select.val();
12
- var entity_type = page_entity_base_type()
13
- var column = page_entity_map_column()
14
- url = "/entity_map/rank_products?map1=" + clean_element(map1) + "&map2=" + clean_element(map2) + '&entity_type=' + entity_type + "&column=" + column
28
+ var entity_type = map.type
29
+ var column = map.column
30
+ var column2 = select.find('option:selected').attr('attr-column')
31
+ url = "/entity_map/rank_products?map1=" + clean_element(map1) + "&map2=" + clean_element(map2) + '&entity_type=' + entity_type + "&column=" + column + "&column2=" + column2
15
32
  window.location = url
16
33
  return false
17
34
  })
18
35
 
36
+ $('body').on('click', '.plot form input[type=submit]', function(){
37
+ var map = rbbt.page.map();
38
+ var map1 = map.id;
39
+
40
+ var input = $(this);
41
+ var select = input.closest('form').find('select')
42
+ var map2 = select.val();
43
+ var entity_type = map.type
44
+ var column = map.column
45
+ var column2 = select.find('option:selected').attr('attr-column')
46
+
47
+ m.sync([entity_map(entity_type,column,map1), entity_map(entity_type,column2, map2)]).then(function(res){
48
+ var modal = $('#modal')
49
+ var container = $('<div>').addClass('plot_container')
50
+
51
+ var res1, res2
52
+ res1 = res[0]
53
+ res2 = res[1]
54
+
55
+ var tmp_data = []
56
+ forHash(res1,function(k,v1){
57
+ var v2 = res2[k]
58
+ if (undefined !== v2)
59
+ tmp_data.push([v1,v2,k])
60
+ })
61
+ tmp_data = tmp_data.sort(function(a,b){ return a[0] - b[0] })
62
+
63
+ var data = []
64
+ var keys = []
65
+
66
+ for(i in tmp_data){
67
+ var k,v1,v2
68
+ v1 = tmp_data[i][0]
69
+ v2 = tmp_data[i][1]
70
+ k = tmp_data[i][2]
71
+
72
+ keys.push(k)
73
+ data.push([v1,v2])
74
+ }
75
+
76
+ require_js('https://code.highcharts.com/highcharts.js', function(){
77
+ container.highcharts({
78
+ title: {
79
+ text: map1 + ' vs. ' + map2,
80
+ x: -20 //center
81
+ },
82
+ subtitle: {
83
+ text: 'Comparison plot',
84
+ x: -20
85
+ },
86
+ xAxis: {
87
+ title: {
88
+ text: map1 + ': ' + column
89
+ },
90
+ },
91
+ yAxis: {
92
+ title: {
93
+ text: map2 + ': ' + column2
94
+ },
95
+ },
96
+ legend: {
97
+ layout: 'vertical',
98
+ align: 'right',
99
+ verticalAlign: 'middle',
100
+ borderWidth: 0
101
+ },
102
+ series: [{
103
+ name: 'Comparison',
104
+ data: data,
105
+ labels: keys,
106
+ }]
107
+ });
108
+
109
+ modal.find('.content').append(container)
110
+
111
+ })
112
+ })
113
+
114
+ return false
115
+ })
116
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.20
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-14 00:00:00.000000000 Z
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake