rbbt-rest 1.4.13 → 1.5.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: 0f6369a018efc715d4d43812781989fc9c81e0be
4
- data.tar.gz: fd448c6fb71b1b145a2eb03291e2a55b9266677e
3
+ metadata.gz: 373227cb24541cc0b77e52a7228c1e8b4f7dafc8
4
+ data.tar.gz: f4fcde8a61a88c37f99e4e3ab64cc2b413eba217
5
5
  SHA512:
6
- metadata.gz: 805eaf6fbefae98774f067f47ab2da03fe14f041772017cc602151ccce5b64368954fb627210a4b4645f74b446e2fc0cc3ced93ffe43319980a8ada0d3c7bb5b
7
- data.tar.gz: fadc91b35639e826b830b68cbef1a40f793ba2291256361869bdaf65464f1a995524703dd6ac6d70e6f888bc4a3735b8646453c0cbd55b906eee9ac785a36958
6
+ metadata.gz: f1f78d6a708dee3e21eea2cfe7825d951babf1bb6f226322a33fd1ad36245787344e205bd45c2b5730bb0d471f33c579c834052b12e32e05f585440b6dcc4f42
7
+ data.tar.gz: 1fb872b28cffc3bf7b656fbde9318fb201193bdcf811390327524d277cd15ad8dc3826befde3bea35d76f5372375a501bcf92f52ec0d3240cac804b5b1e0b696
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ begin
15
15
  gem.add_dependency('rake')
16
16
  gem.add_dependency('sinatra')
17
17
  gem.add_dependency('modular-scale')
18
- gem.add_dependency('zurb-foundation')
18
+ #gem.add_dependency('zurb-foundation')
19
19
  gem.add_dependency('compass')
20
20
  gem.add_dependency('json')
21
21
  gem.add_dependency('haml')
@@ -31,7 +31,7 @@ module RbbtRESTHelpers
31
31
  @layout = false if @layout.nil? and @ajax
32
32
  @layout = true if @layout.nil? and not @ajax
33
33
  @layout = false if @layout == "false"
34
- @layout = true if @layout == "true"
34
+ @layout = true if @layout == "true"
35
35
 
36
36
  @format = consume_parameter(:_format)
37
37
  @format = :html if @format.nil?
@@ -56,14 +56,14 @@ module RbbtRESTHelpers
56
56
  template_file = template_file.find if template_file.respond_to? :find
57
57
  if layout_file
58
58
  Tilt::HamlTemplate.new(layout_file, :filename => layout_file, :ugly => production?).render(self, locals) do
59
+ Log.debug{ "Rendering #{template_file} with layout" }
59
60
  cache(cache, locals.merge(:_template_file => template_file, :user => user).merge(cache_options)) do
60
- Log.debug{ "Rendering #{template_file} with layout" }
61
61
  Tilt::HamlTemplate.new(template_file, :filename => template_file, :ugly => production?).render(self, locals)
62
62
  end
63
63
  end
64
64
  else
65
+ Log.debug{ "Rendering #{template_file} without layout" }
65
66
  cache(cache, locals.merge(:_template_file => template_file, :user => user).merge(cache_options)) do
66
- Log.debug{ "Rendering #{template_file} without layout" }
67
67
  Tilt::HamlTemplate.new(template_file, :filename => template_file, :ugly => production?).render(self, locals)
68
68
  end
69
69
  end
@@ -196,12 +196,16 @@ module RbbtRESTHelpers
196
196
  end
197
197
  end
198
198
 
199
- def reveal(text, id = nil, &block)
199
+ def reveal(text, id = nil, options = nil, &block)
200
200
  id ||= "rbbt_reveal_" << (rand * 10000).to_i.to_s
201
201
 
202
202
  content_html = capture_haml(&block)
203
203
 
204
- str = html_tag('a', text.to_s, :href => "#", "data-reveal-id" => 'modal1', 'attr-reveal_id' => id, 'class' => 'rbbt_reveal_trigger') <<
204
+ options = {} if options.nil?
205
+ options = {:href => "#", "data-reveal-id" => 'modal1', 'attr-reveal_id' => id}.merge(options)
206
+ options[:class] ||= ''
207
+ options[:class] << ' rbbt_reveal_trigger'
208
+ str = html_tag('a', text.to_s, options) <<
205
209
  "\n" <<
206
210
  html_tag('div', "\n" << content_html << "\n", :id => id, 'class' => 'rbbt_reveal_content') <<
207
211
  "\n"
@@ -100,6 +100,7 @@ Ratio
100
100
  Size
101
101
  size
102
102
  Matches
103
+ Quality
103
104
  EOF
104
105
  ).split("\n")
105
106
 
@@ -37,11 +37,15 @@ module Sinatra
37
37
  end
38
38
 
39
39
  app.get '/login' do
40
- "<form class='login' method='POST' action='/login'>" +
41
- "<label for='login_name'>Name: </label>" +
42
- "<input id='login_name' type='text' name='user'>" +
43
- "<label for='login_pass'>Pass: </label>" +
44
- "<input id 'login_pass' type='password' name='pass'>" +
40
+ "<form class='login ui form' method='POST' action='/login'>" +
41
+ "<div class='ui field'>" +
42
+ "<label for='login_name' class='ui label'>Name: </label>" +
43
+ "<input id='login_name' class='ui input' type='text' name='user'>" +
44
+ "</div>" +
45
+ "<div class='ui field'>" +
46
+ "<label for='login_pass' class='ui label'>Pass: </label>" +
47
+ "<input id='login_pass' class='ui input' type='password' name='pass'>" +
48
+ "</div>" +
45
49
  "<input type='submit'>" +
46
50
  "</form>"
47
51
  end
@@ -63,7 +63,7 @@ module EntityRESTHelpers
63
63
  locals[:description] = description
64
64
  locals = locals.merge(form_options)
65
65
 
66
- html_tag :div, partial_render('partials/form', locals), {:class => 'action_parameters'}.merge(action_options)
66
+ html_tag :div, partial_render('partials/form', locals), {:class => 'action_parameters ui raised segment'}.merge(action_options)
67
67
  end
68
68
 
69
69
  def page_type(path = nil)
@@ -49,9 +49,7 @@ module Entity
49
49
  link_params = include_entity_params ? entity_link_params : {}
50
50
 
51
51
  %w(class style title).each do |at|
52
- attributes[at.to_sym] = options.delete(at.to_sym) ||
53
- options.delete(at.to_s) ||
54
- nil
52
+ attributes[at.to_sym] = options.delete(at.to_sym) || options.delete(at.to_s) || nil
55
53
  end
56
54
 
57
55
  attributes[:class] = attributes[:class].split(" ") if String === attributes[:class]
@@ -122,6 +120,7 @@ module Entity
122
120
  #return self.tap{|a| a.extend AnnotatedArray}.collect{|e| e.link(text, options) } if Array === self
123
121
  return self.collect{|e| e.link(text, options) } if Array === self
124
122
  return self.split(";").collect{|e| self.annotate(e).link(text, options) } * ", " if self.include? ";"
123
+ return nil if self.empty?
125
124
 
126
125
  klasses = self.klasses
127
126
  klasses << 'entity'
@@ -183,7 +182,8 @@ module Entity
183
182
 
184
183
  attributes, link_params = process_link_options(options)
185
184
 
186
- attributes[:class] = klasses
185
+ attributes[:class] ||= ''
186
+ attributes[:class] << klasses
187
187
  attributes[:href] = Entity::REST.entity_list_url(id, entity_type.to_s)
188
188
 
189
189
  attributes[:title] = id
@@ -205,7 +205,8 @@ module Entity
205
205
 
206
206
  attributes, link_params = process_link_options({:title => [action, id] * ": " }.merge(options), false)
207
207
 
208
- attributes[:class] = klasses
208
+ attributes[:class] ||= ''
209
+ attributes[:class] << klasses
209
210
  attributes[:href] = Entity::REST.entity_list_action_url(id, entity_type.to_s, action, link_params)
210
211
 
211
212
  attributes[:title] = id if attributes[:title].nil?
@@ -142,7 +142,7 @@ module Sinatra
142
142
  cache_control :public, :max_age => 360000 if production?
143
143
 
144
144
  cache("css: #{File.basename(file)}", :_template_file => file, :_send_file => true, :cache_type => production? ? :synchronous : :none) do
145
- Log.debug{ "Rendering stylesheets" }
145
+ Log.debug{ "Rendering stylesheet: #{ file }" }
146
146
  render_sass(file)
147
147
  end
148
148
  end
@@ -40,3 +40,4 @@
40
40
 
41
41
  #content, #modal
42
42
  +large_menus
43
+
@@ -18,27 +18,3 @@
18
18
  .find.hide(hide-title="Find")
19
19
  = partial_render('layout/top_menu/finder')
20
20
 
21
- //:sass
22
- // .dl_menu
23
- // dt
24
- // display: inline-block
25
- // float: left
26
- //
27
- // body
28
- // margin-top: 0 !important
29
- // #top_bar
30
- // .reload
31
- // float: right
32
- //
33
- //#top_bar.ui.fixed.main.menu.dl_menu
34
- // .title.item= $title
35
- //
36
- // %dl.favourites.left.menu.ui.blue
37
- // %dt.item(data-tab='entities') Entities
38
- // %dd.en
39
- // %dt.item(data-tab='lists') Lists
40
- // %dl
41
- //
42
- // .reload.item
43
- // %i.spinner.icon
44
- //
@@ -24,6 +24,8 @@ $.ajax = function(url, options){
24
24
  url = options['url'];
25
25
  }
26
26
 
27
+ url = add_parameter(url, '_layout', 'false')
28
+ options['url'] = url
27
29
  options["crossDomain"] = true
28
30
 
29
31
  add_ajax(url);
@@ -158,6 +160,7 @@ function replace_object(object, href, embedd, complete){
158
160
 
159
161
  function replace_link(link){
160
162
  var href = $(link).attr('href');
163
+ href = add_parameter(href, '_layout','false')
161
164
 
162
165
  replace_object(link, href);
163
166
  }
@@ -220,6 +223,8 @@ function capture_embedded_form(object){
220
223
  url = url.replace(/\?.*/, '?' + params);
221
224
  }
222
225
 
226
+ url = add_parameter(url, '_layout', 'false')
227
+
223
228
  embedded.attr('target-href', url).attr('form-params', params)
224
229
 
225
230
  update_embedded(embedded);
@@ -15,6 +15,9 @@ function update_rbbt(){
15
15
  $('#top_menu .favourites').favourites('update_list_selects').favourites('update_map_selects')
16
16
  $('#top_bar .favourites').favourites('update_list_selects').favourites('update_map_selects')
17
17
 
18
+ $('.ui.accordion').accordion();
19
+ $('.ui.checkbox').checkbox();
20
+
18
21
  start_deferred()
19
22
  fit_content()
20
23
  }
@@ -84,7 +84,7 @@ function require_js(url, success){
84
84
  if ($.inArray(url, required_js) >= 0){
85
85
  if (typeof success == 'function'){ success.call() }
86
86
  }else{
87
- var _success = function(){ if (typeof success == 'function'){ success.call() }; required_js.push(url); }
87
+ var _success = function(){ required_js.push(url); if (typeof success == 'function'){ success.call() }; }
88
88
  $.ajax({url: url, cache:cache, dataType:'script', async: async, success: _success} ).fail(function(jqxhr, settings, exception){ console.log('Failed to load ' + url) })
89
89
  }
90
90
  }
@@ -60,7 +60,7 @@ $.widget("rbbt.action_controller", {
60
60
  },
61
61
 
62
62
  _toogle_track: function(){
63
- if (this.element.find('ul.controls > li.url.bookmarked').length > 0){
63
+ if (this.element.find('.controls > .url.bookmarked').length > 0){
64
64
  this._untrack(this._url());
65
65
  }else{
66
66
  this._track();
@@ -71,34 +71,33 @@ $.widget("rbbt.action_controller", {
71
71
  var tool = this
72
72
  var controller = tool.element;
73
73
 
74
- controller.on('click', '> ul.actions li', function(e){ tool._activate_action(this); return false});
75
- controller.on('click', '> ul.controls > li.reload', function(e){ tool._reload_action(this); return false});
76
- controller.on('click', '> ul.controls > li.parameters', function(e){ tool._display_parameters(this); return false});
77
- controller.on('click', '> ul.controls > li.description', function(e){ tool._display_description(this); return false});
78
- controller.on('click', '> ul.controls > li.pin', function(e){ tool._toggle_pin(this); return false});
79
- controller.on('click', '> ul.controls > li.url', function(e){ tool._toogle_track(this); return false});
80
- $('#top_menu .user ul.jobs').on('click', 'a.remove_element', function(){
74
+ controller.on('click', '> .actions .button', function(e){ tool._activate_action(this); return false});
75
+ controller.on('click', '> .controls > .reload', function(e){ tool._reload_action(this); return false});
76
+ controller.on('click', '> .controls > .parameters', function(e){ tool._display_parameters(this); return false});
77
+ controller.on('click', '> .controls > .description', function(e){ tool._display_description(this); return false});
78
+ controller.on('click', '> .controls > .pin', function(e){ tool._toggle_pin(this); return false});
79
+ controller.on('click', '> .controls > .url', function(e){ tool._toogle_track(this); return false});
80
+ $('#top_menu .user .jobs').on('click', 'a.remove_element', function(){
81
81
  var link = $(this).next('a')
82
82
  tool._untrack(link.attr('href'))
83
83
  })
84
84
 
85
85
  this.options.controller = controller
86
- this.options.action_controls = controller.find('> ul.controls')
87
- this.options.action_list = controller.find('> ul.actions')
86
+ this.options.action_controls = controller.find('> .controls')
87
+ this.options.action_list = controller.find('> .actions')
88
88
 
89
89
  this.options.complete = function(jqXHR, textStatus){
90
90
  var action_controller = tool.options.controller
91
- var action_list_item = action_controller.find('li.loading, li.active')
91
+ var action_list_item = action_controller.find('.actions > .loading, .actions > .active')
92
92
  var action_div = action_controller.next('.action_loader');
93
93
 
94
94
  if (jqXHR.status == 202){
95
95
  if (action_div.attr('reload-attempts') != '0'){
96
96
  action_controller.removeClass('active').addClass('loading');
97
- action_list_item.removeClass('active').addClass('loading');
98
97
 
99
98
  var response = $(jqXHR.responseText)
100
99
  var stat = response.find('span.status').html()
101
- var message = response.find('ul.step_messages li:first').html()
100
+ var message = response.find('.step_messages li:first').html()
102
101
 
103
102
  if (undefined === message){
104
103
  action_div.html("<span class='loading'>Loading [" + stat + "] ...</span>");
@@ -107,25 +106,25 @@ $.widget("rbbt.action_controller", {
107
106
  };
108
107
  }
109
108
  }else{
110
- action_controller.removeClass('loading').addClass('active');
111
- action_list_item.removeClass('loading').addClass('active');
109
+ action_controller.removeClass('loading').removeClass('disabled');
110
+ action_list_item.removeClass('loading').removeClass('disabled');
112
111
 
113
- action_controller.find('ul.controls > li.reload').addClass('active');
112
+ action_controller.find('.controls > .reload').removeClass('disabled');
114
113
  }
115
114
 
116
115
  var action_div = action_controller.next('.action_loader').first();
117
- action_controller.find('ul.controls > li.url').addClass('active');
116
+ action_controller.find('.controls > .url').removeClass('disabled');
118
117
  if (action_div.find('> .action_card > .action_parameters').length > 0){
119
- action_controller.find('ul.controls > li.parameters').addClass('active');
120
- action_controller.find('ul.controls > li.pin').addClass('active');
118
+ action_controller.find('.controls > .parameters').removeClass('disabled');
119
+ action_controller.find('.controls > .pin').removeClass('disabled');
121
120
  }else{
122
- action_controller.find('ul.controls > li.parameters').removeClass('active');
123
- action_controller.find('ul.controls > li.pin').removeClass('active');
121
+ action_controller.find('.controls > .parameters').addClass('disabled');
122
+ action_controller.find('.controls > .pin').addClass('disabled');
124
123
  }
125
124
  if (action_div.find('> .action_card > .action_description').length > 0){
126
- action_controller.find('ul.controls > li.description').addClass('active');
125
+ action_controller.find('.controls > .description').addClass('disabled');
127
126
  }else{
128
- action_controller.find('ul.controls > li.description').removeClass('active');
127
+ action_controller.find('.controls > .description').addClass('disabled');
129
128
  }
130
129
  }
131
130
 
@@ -135,24 +134,26 @@ $.widget("rbbt.action_controller", {
135
134
 
136
135
  _update_flag: function(){
137
136
  if ($.inArray(this._url(), this.options.bookmarked) != -1){
138
- $(this.element).find('> ul.controls > li.url').addClass('bookmarked')
137
+ $(this.element).find('> .controls > .url').addClass('bookmarked')
139
138
  }else{
140
- $(this.element).find('> ul.controls > li.url').removeClass('bookmarked')
139
+ $(this.element).find('> .controls > .url').removeClass('bookmarked')
141
140
  }
142
141
  },
143
142
 
144
143
  _activate_action: function(e){
145
144
  var action_list_item = $(e)
146
- var action_list = action_list_item.parent('ul.actions');
145
+ var action_list = action_list_item.parent('.actions');
147
146
  var link = action_list_item.find('> a')
147
+ link = action_list_item
148
+
148
149
 
149
150
  this._load_action(link);
150
151
 
151
152
  var action = link.html()
152
153
  if (this.options.saved[action] !== undefined){
153
- $(this.element).find('> ul.controls > li.pin').addClass('saved')
154
+ $(this.element).find('> .controls > .pin').addClass('saved')
154
155
  }else{
155
- $(this.element).find('> ul.controls > li.pin').removeClass('saved')
156
+ $(this.element).find('> .controls > .pin').removeClass('saved')
156
157
  }
157
158
 
158
159
  this._update_flag()
@@ -164,22 +165,22 @@ $.widget("rbbt.action_controller", {
164
165
 
165
166
  _unpin_parameters: function(){
166
167
  var controller = $(this.element)
167
- var action = controller.find('ul.actions li.active a').first().html()
168
+ var action = controller.find('.actions .active a').first().html()
168
169
  this.options.saved[action] = undefined
169
- controller.find('> ul.controls > li.pin').removeClass('saved')
170
+ controller.find('> .controls > .pin').removeClass('saved')
170
171
  },
171
172
 
172
173
  _pin_parameters: function(){
173
174
  var controller = $(this.element)
174
- var action = $(this.element).find('ul.actions li.active a').first().html()
175
+ var action = $(this.element).find('.actions .active a').first().html()
175
176
  var loader = $(this.element).next('.action_loader').first();
176
177
  this.options.saved[action] = loader.attr('form-params')
177
- controller.find('> ul.controls > li.pin').addClass('saved')
178
+ controller.find('> .controls > .pin').addClass('saved')
178
179
  this._dump()
179
180
  },
180
181
 
181
182
  _toggle_pin: function(){
182
- var action = $(this.element).find('ul.actions li.active a').first().html()
183
+ var action = $(this.element).find('.actions .active a').first().html()
183
184
 
184
185
  if (this.options.saved[action] != undefined){
185
186
  this._unpin_parameters();
@@ -213,7 +214,7 @@ $.widget("rbbt.action_controller", {
213
214
  _reload_action: function(e){
214
215
  if(! $(e).hasClass('active')){ return false}
215
216
  var action_list_item = $(e);
216
- var action_list = action_list_item.parent('ul.controls');
217
+ var action_list = action_list_item.parent('.controls');
217
218
  var action_controller = action_list.parent('.action_controller');
218
219
  var action_div = action_controller.next('.action_loader').first();
219
220
 
@@ -261,11 +262,13 @@ $.widget("rbbt.action_controller", {
261
262
  },
262
263
 
263
264
  _load_action: function(link){
264
- var action_list_item = link.parent('li');
265
- var action_list = action_list_item.parent('ul');
265
+ var action_list_item = link.parent('.button');
266
+ action_list_item = link
267
+ var action_list = action_list_item.parent('.menu');
266
268
  var action_controller = action_list.parents('.action_controller').first();
267
269
  var action_div = action_controller.next('.action_loader');
268
270
  var href = link.attr('href')
271
+ href = add_parameter(href, '_layout', 'false')
269
272
 
270
273
  var action = link.html()
271
274
  var saved = this.options.saved[action]
@@ -277,11 +280,12 @@ $.widget("rbbt.action_controller", {
277
280
 
278
281
  if( ! action_div.hasClass('reloading') ) {
279
282
  action_div.removeClass('active');
280
- action_controller.find('ul.controls > li.reload').removeClass('active');
281
- action_controller.find('ul.controls > li.parameters').removeClass('active');
282
- action_list.find('li').removeClass('active').removeClass('loading');
283
- action_list_item.addClass('loading');
283
+ action_controller.find('.controls > .reload').removeClass('active');
284
+ action_controller.find('.controls > .parameters').removeClass('active');
285
+ action_list.find('.button').removeClass('active').removeClass('loading');
286
+ action_list_item.addClass('active');
284
287
  action_controller.addClass('loading');
288
+
285
289
  replace_object(action_div, href, true, this.options.complete);
286
290
 
287
291
  return false
@@ -26,7 +26,7 @@ function favourite_type_ul(entities){
26
26
  }
27
27
 
28
28
  function favourite_list_type_ul(type, lists){
29
- var type_ul = $('<ul>').addClass('lists')
29
+ var type_ul = $('<ul>').addClass('lists').addClass('clean_list')
30
30
  for (var list in lists){
31
31
  var list = lists[list];
32
32
  var link = list_link(type, list)
@@ -28,10 +28,10 @@ body.on('click', 'a.compare_list', function(){
28
28
  var list_id = page_entity_list();
29
29
 
30
30
  var type_ul = favourite_list_type_ul(type, lists).addClass("list_comparison")
31
- var buttons = $('<ul class="list_comparison_buttons">')
32
- buttons.append('<li><a class="intersect_lists" href="#">Intersect</a></li>')
33
- buttons.append('<li><a class="remove_list" href="#">Remove</a></li>')
34
- buttons.append('<li><a class="add_list" href="#">Add</a></li>')
31
+ var buttons = $('<div class="list_comparison_buttons ui buttons">')
32
+ buttons.append('<a class="intersect_lists ui compact button" href="#">Intersect</a>')
33
+ buttons.append('<a class="remove_list ui compact button" href="#">Remove</a>')
34
+ buttons.append('<a class="add_list ui compact button" href="#">Add</a>')
35
35
  type_ul.find('li').prepend(buttons)
36
36
 
37
37
  $('#modal').modal('show', type_ul);
@@ -10,10 +10,10 @@ $.widget("rbbt.modal", {
10
10
 
11
11
  var title = $('<div>').addClass('title')
12
12
  if (modal_title !== undefined){ title.html(modal_title) }
13
- var controls = $('<div>').addClass('controls')
14
- controls.append($('<a>').addClass('toggle_favourite').append($('<i>').addClass('ui icon star right')))
15
- controls.append($('<a>').addClass('link-reveal-modal').append($('<i>').addClass('ui icon arrow right')))
16
- controls.append($('<a>').addClass('close-reveal-modal').append($('<i>').addClass('ui icon close right')))
13
+ var controls = $('<div>').addClass('controls ui buttons')
14
+ controls.append($('<a>').addClass('toggle_favourite ui button').append($('<i>').addClass('ui icon star right')))
15
+ controls.append($('<a>').addClass('link-reveal-modal ui button').append($('<i>').addClass('ui icon arrow right')))
16
+ controls.append($('<a>').addClass('close-reveal-modal ui button').append($('<i>').addClass('ui icon close right')))
17
17
 
18
18
  var header = $('<div>').addClass('header').append(title).append(controls)
19
19
 
@@ -99,7 +99,7 @@ $.widget("rbbt.table", {
99
99
 
100
100
  //{{{ Pagination
101
101
  //
102
- table.on('click', 'tfoot > tr > th > ul.table_pagination > li.num > a:not(.active)', function(link){
102
+ table.on('click', 'tfoot > tr > th > .table_pagination > .num > a:not(.active)', function(link){
103
103
  var link = $(this)
104
104
 
105
105
  var stat = tool._status()
@@ -109,7 +109,7 @@ $.widget("rbbt.table", {
109
109
  return false
110
110
  })
111
111
 
112
- table.on('click', 'tfoot > tr > th > ul.table_pagination > li.arrow > a.prev', function(link){
112
+ table.on('click', 'tfoot > tr > th > .table_pagination > .arrow > a.prev', function(link){
113
113
  var stat = tool._status()
114
114
 
115
115
  if (stat.num > 1){ stat.num = stat.num - 1 }
@@ -119,9 +119,9 @@ $.widget("rbbt.table", {
119
119
  return false
120
120
  })
121
121
 
122
- table.on('click', 'tfoot > tr > th > ul.table_pagination > li.arrow > a.next', function(evt){
122
+ table.on('click', 'tfoot > tr > th > .table_pagination > .arrow > a.next', function(evt){
123
123
  var stat = tool._status();
124
- var last = parseInt($(this).parents('ul.table_pagination').first().find('li.num').last().find('a').html())
124
+ var last = parseInt($(this).parents('.table_pagination').first().find('.num').last().find('a').html())
125
125
 
126
126
  if (stat.num < last){ stat.num = stat.num + 1 }
127
127
 
@@ -130,7 +130,7 @@ $.widget("rbbt.table", {
130
130
  return false
131
131
  })
132
132
 
133
- table.on('click', 'tfoot > tr > th > ul.table_pagination > li.all', function(link){
133
+ table.on('click', 'tfoot > tr > th > .table_pagination > .all', function(link){
134
134
  var stat = tool._status()
135
135
 
136
136
  tool._update(stat.url, '', stat.size, stat.field, stat.filter)
@@ -9,4 +9,5 @@
9
9
 
10
10
  %ul.step_messages.clean_list
11
11
  - job.messages.reverse.each do |line|
12
+ - next if line.nil? or line.strip.empty?
12
13
  %li= line
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.4.13
4
+ version: 1.5.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: 2015-01-14 00:00:00.000000000 Z
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: zurb-foundation
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: compass
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -173,10 +159,6 @@ extra_rdoc_files:
173
159
  files:
174
160
  - LICENSE
175
161
  - Rakefile
176
- - lib/rbbt/rest/client.rb
177
- - lib/rbbt/rest/client/adaptor.rb
178
- - lib/rbbt/rest/client/get.rb
179
- - lib/rbbt/rest/client/step.rb
180
162
  - lib/rbbt/rest/common/cache.rb
181
163
  - lib/rbbt/rest/common/forms.rb
182
164
  - lib/rbbt/rest/common/locate.rb
@@ -1,56 +0,0 @@
1
- require 'rest_client'
2
- require 'json'
3
- require 'rbbt/workflow'
4
- require 'rbbt/workflow/step'
5
- require 'rbbt/util/misc'
6
-
7
- require 'rbbt/rest/client/get'
8
- require 'rbbt/rest/client/adaptor'
9
- require 'rbbt/rest/client/step'
10
-
11
- class WorkflowRESTClient
12
- include Workflow
13
-
14
- attr_accessor :url, :name, :exec_exports, :asynchronous_exports, :synchronous_exports
15
-
16
- def initialize(url, name)
17
- Log.debug{ "Loading remote workflow #{ name }: #{ url }" }
18
- @url, @name = url, name
19
- init_remote_tasks
20
- end
21
-
22
- def to_s
23
- name
24
- end
25
-
26
- def job(task, name, inputs)
27
- task_info = task_info(task)
28
- fixed_inputs = {}
29
- input_types = task_info[:input_types]
30
-
31
- inputs.each do |k,v|
32
- k = k.to_sym
33
- if TSV === v
34
- fixed_inputs[k] = v.to_s
35
- else
36
- case input_types[k].to_sym
37
- when :tsv, :array, :file, :text
38
- fixed_inputs[k] = (String === v and Open.exists?(v)) ? Open.open(v) : v
39
- else
40
- fixed_inputs[k] = v
41
- end
42
- end
43
- end
44
-
45
- RemoteStep.new(url, task, name, fixed_inputs, task_info[:result_type], task_info[:result_description], @exec_exports.include?(task))
46
- end
47
-
48
- def load_id(id)
49
- task, name = id.split("/")
50
- step = RemoteStep.new url, task, nil
51
- step.name = name
52
- step.result_type = task_info(task)[:result_type]
53
- step.result_description = task_info(task)[:result_description]
54
- step
55
- end
56
- end
@@ -1,66 +0,0 @@
1
- class WorkflowRESTClient
2
-
3
- def workflow_description
4
- WorkflowRESTClient.get_raw(File.join(url, 'description'))
5
- end
6
-
7
- def documentation
8
- @documention ||= IndiferentHash.setup(WorkflowRESTClient.get_json(File.join(url, "documentation"),{}))
9
- end
10
-
11
- def task_info(task)
12
- @task_info ||= {}
13
- @task_info[task]
14
-
15
- if @task_info[task].nil?
16
- task_info = WorkflowRESTClient.get_json(File.join(url, task.to_s, 'info'))
17
- task_info = WorkflowRESTClient.fix_hash(task_info)
18
-
19
- task_info[:result_type] = task_info[:result_type].to_sym
20
- task_info[:export] = task_info[:export].to_sym
21
- task_info[:input_types] = WorkflowRESTClient.fix_hash(task_info[:input_types], true)
22
- task_info[:inputs] = task_info[:inputs].collect{|input| input.to_sym }
23
-
24
- @task_info[task] = task_info
25
- end
26
- @task_info[task]
27
- end
28
-
29
- def exported_tasks
30
- (@asynchronous_exports + @synchronous_exports + @exec_exports).compact.flatten
31
- end
32
-
33
- def tasks
34
- @tasks ||= Hash.new do |hash,task_name|
35
- info = task_info(task_name)
36
- task = Task.setup info do |*args|
37
- raise "This is a remote task"
38
- end
39
- task.name = task_name.to_sym
40
- hash[task_name] = task
41
- end
42
- end
43
-
44
- def load_tasks
45
- exported_tasks.each{|name| tasks[name]}
46
- nil
47
- end
48
-
49
- def task_dependencies
50
- @task_dependencies ||= Hash.new do |hash,task|
51
- hash[task] = if exported_tasks.include? task
52
- WorkflowRESTClient.get_json(File.join(url, task.to_s, 'dependencies'))
53
- else
54
- []
55
- end
56
- end
57
- end
58
-
59
- def init_remote_tasks
60
- task_exports = WorkflowRESTClient.get_json(url)
61
- @asynchronous_exports = task_exports["asynchronous"].collect{|task| task.to_sym }
62
- @synchronous_exports = task_exports["synchronous"].collect{|task| task.to_sym }
63
- @exec_exports = task_exports["exec"].collect{|task| task.to_sym }
64
- nil
65
- end
66
- end
@@ -1,96 +0,0 @@
1
- class WorkflowRESTClient
2
- def self.fix_hash(hash, fix_values = false)
3
- fixed = {}
4
- hash.each do |key, value|
5
- fixed[key.to_sym] = case value
6
- when TrueClass
7
- value
8
- when FalseClass
9
- value
10
- when Hash
11
- fix_hash(value)
12
- when (fix_values and String )
13
- value.to_sym
14
- when IO
15
- value.read
16
- when TSV::Dumper
17
- value.stream
18
- when Step
19
- stream = get_stream(value)
20
- stream || value.load
21
- else
22
- value
23
- end
24
- end
25
- fixed
26
- end
27
-
28
- def self.capture_exception
29
- begin
30
- yield
31
- rescue Exception => e
32
- raise e unless e.respond_to? :response
33
- begin
34
- klass, message = e.response.to_s.split " => "
35
- klass = Kernel.const_get klass
36
- raise klass.new message
37
- rescue
38
- raise e
39
- end
40
- raise $!
41
- end
42
- end
43
-
44
- def self.get_raw(url, params = {})
45
- Log.debug{ "RestClient get_raw: #{ url } - #{Misc.fingerprint params}" }
46
- params = params.merge({ :_format => 'raw' })
47
- capture_exception do
48
- Misc.insist(2, 0.5) do
49
- RestClient.get(URI.encode(url), :params => params)
50
- end
51
- end
52
- end
53
-
54
- def self.post_jobname(url, params = {})
55
- Log.debug{ "RestClient post_jobname: #{ url } - #{Misc.fingerprint params}" }
56
- params = params.merge({ :_format => 'jobname' })
57
-
58
- capture_exception do
59
- RestClient.post(URI.encode(url), params)
60
- end
61
- end
62
-
63
- def self.get_json(url, params = {})
64
- Log.debug{ "RestClient get_json: #{ url } - #{Misc.fingerprint params }" }
65
- params = params.merge({ :_format => 'json' })
66
-
67
- res = capture_exception do
68
- RestClient.get(URI.encode(url), :params => params)
69
- end
70
-
71
- begin
72
- JSON.parse(res)
73
- rescue
74
- res
75
- end
76
- end
77
-
78
- def self.post_json(url, params = {})
79
- if url =~ /_cache_type=:exec/
80
- JSON.parse(Open.open(url, :nocache => true))
81
- else
82
- params = params.merge({ :_format => 'json' })
83
-
84
- res = capture_exception do
85
- RestClient.post(URI.encode(url), params)
86
- end
87
-
88
- begin
89
- JSON.parse(res)
90
- rescue
91
- res
92
- end
93
- end
94
- end
95
-
96
- end
@@ -1,164 +0,0 @@
1
- class WorkflowRESTClient
2
- class RemoteStep < Step
3
-
4
- attr_accessor :url, :base_url, :task, :base_name, :inputs, :result_type, :result_description, :is_exec
5
-
6
- def self.get_streams(inputs)
7
- inputs.each do |k,v|
8
- if Step === v
9
- stream = v.get_stream
10
- inputs[k] = stream || v.load
11
- end
12
- end
13
- end
14
- def initialize(base_url, task = nil, base_name = nil, inputs = nil, result_type = nil, result_description = nil, is_exec = false)
15
- @base_url, @task, @base_name, @inputs, @result_type, @result_description, @is_exec = base_url, task, base_name, inputs, result_type, result_description, is_exec
16
- @mutex = Mutex.new
17
- RemoteStep.get_streams @inputs
18
- end
19
-
20
- def name
21
- return nil if @is_exec
22
- (Array === @url ? @url.first : @url).split("/").last
23
- end
24
-
25
- def task_name
26
- (Array === @url ? @url.first : @url).split("/")[-2]
27
- end
28
-
29
- def info(check_lock=false)
30
- @info ||= begin
31
- init_job unless url
32
- info = WorkflowRESTClient.get_json(File.join(url, 'info'))
33
- info = WorkflowRESTClient.fix_hash(info)
34
- info[:status] = info[:status].to_sym if String === info[:status]
35
- info
36
- end
37
- end
38
-
39
- def status
40
- begin
41
- info[:status]
42
- ensure
43
- @info = nil
44
- end
45
- end
46
-
47
- def done?
48
- @done || status.to_s == 'done'
49
- end
50
-
51
- def files
52
- WorkflowRESTClient.get_json(File.join(url, 'files'))
53
- end
54
-
55
- def file(file)
56
- WorkflowRESTClient.get_raw(File.join(url, 'file', file))
57
- end
58
-
59
- #{{{ MANAGEMENT
60
-
61
- def init_job(cache_type = :asynchronous)
62
- @name ||= Persist.memory("RemoteSteps", :jobname => @name, :inputs => inputs) do
63
- WorkflowRESTClient.post_jobname(File.join(base_url, task.to_s), inputs.merge(:jobname => @name||@base_name, :_cache_type => cache_type))
64
- end
65
- @url = File.join(base_url, task.to_s, @name)
66
- nil
67
- end
68
-
69
- def load_res(res, result_type = nil)
70
- result_type ||= self.result_type
71
- case result_type
72
- when :string
73
- res
74
- when :boolean
75
- res == "true"
76
- when :tsv
77
- TSV.open(StringIO.new(res))
78
- when :annotations
79
- Annotated.load_tsv(TSV.open(StringIO.new(res)))
80
- when :array
81
- res.split("\n")
82
- else
83
- JSON.parse res
84
- end
85
- end
86
-
87
- def get
88
- params ||= {}
89
- params = params.merge(:_format => [:string, :boolean, :tsv, :annotations,:array].include?(result_type.to_sym) ? :raw : :json )
90
- Misc.insist 3, rand(2) + 1 do
91
- begin
92
- WorkflowRESTClient.get_raw(url, params)
93
- rescue
94
- Log.exception $!
95
- raise $!
96
- end
97
- end
98
- end
99
-
100
- def load
101
- params = {}
102
- load_res get
103
- end
104
-
105
- def exec_job
106
- res = WorkflowRESTClient.capture_exception do
107
- RestClient.post(URI.encode(File.join(base_url, task.to_s)), inputs.merge(:_cache_type => :exec, :_format => [:string, :boolean, :tsv, :annotations].include?(result_type) ? :raw : :json))
108
- end
109
- load_res res, result_type == :array ? :json : result_type
110
- end
111
-
112
- def fork
113
- init_job(:asynchronous)
114
- end
115
-
116
- def running?
117
- ! %w(done error aborted).include? status.to_s
118
- end
119
-
120
- def path
121
- url
122
- end
123
-
124
- def run(noload = false)
125
- @mutex.synchronize do
126
- @result ||= begin
127
- if @is_exec
128
- exec_job
129
- else
130
- init_job(:synchronous)
131
- self.load
132
- end
133
- end
134
- end
135
- noload ? path : @result
136
- end
137
-
138
- def exec(*args)
139
- exec_job
140
- end
141
-
142
- def join
143
- return if self.done?
144
- self.load
145
- self
146
- end
147
-
148
- def recursive_clean
149
- begin
150
- inputs[:_update] = :recursive_clean
151
- rescue Exception
152
- end
153
- self
154
- end
155
-
156
- def clean
157
- begin
158
- inputs[:_update] = :clean
159
- rescue Exception
160
- end
161
- self
162
- end
163
- end
164
- end