rbbt-rest 1.7.14 → 1.7.15

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: ce8c4aa907a83faab847c02de0a07aa2a762c8d2
4
- data.tar.gz: f59aa870c35fe2616b67c2d8cc8ed7e2e77aa136
3
+ metadata.gz: d7bb233c1577c8a190d0bcdacd86f8014620de6f
4
+ data.tar.gz: 6989d8b3be1b51a817022fa35ee2f8124ff5dc87
5
5
  SHA512:
6
- metadata.gz: 5c4e572157f16516c0c2545e35a5a0848cbc52e9dca8daa543f3ba598dcb05bdc351249ff0fe034ab9aee8fe13ef45fe11d5efa5fa795be3ae1dcdef0def3e31
7
- data.tar.gz: 06dee8abc4d12ca0a63807d18843f43177c2c97dc71c3a7f8dfde44ab4cbac5a90e5e0cb5a7b4058078771b5c6587872083a47712e843ef356c2c06f4f205642
6
+ metadata.gz: 9963a51751edb4971bd7c87309010299f7f1f449c4e5a29bec3cf59e402919816ed648dd84fae44d779e204924c2e8eeea01c3f33f472c7f507e746417909a96
7
+ data.tar.gz: 6e0a31491b8046ca5e2dc34b799772a88c9547592c66627fe1c076bc30a66aeffb654d77b3ccc941ef13fcf02809e020189f447cbd167760288ee7d8d2240eb1
@@ -222,7 +222,14 @@ module RbbtRESTHelpers
222
222
  end
223
223
 
224
224
  def remove_GET_param(url, param)
225
- url.gsub(/&?#{param}=[^&]+/,'').sub(/\?$/, '')
225
+ if Array === param
226
+ param.each do |p|
227
+ url = remove_GET_param(url, p)
228
+ end
229
+ url
230
+ else
231
+ url.gsub(/&?#{param}=[^&]+/,'').sub(/\?$/, '')
232
+ end
226
233
  end
227
234
 
228
235
  def add_GET_param(url, param, value)
@@ -174,27 +174,37 @@ module RbbtRESTHelpers
174
174
  text ||= filename
175
175
 
176
176
  filename = Misc.sanitize_filename(filename)
177
- f = settings.file_dir[filename].find
177
+
178
+ if @step
179
+ url = add_GET_param(remove_GET_param(@fullpath, ["_update", "_"]), "_fragment", "html_resources/#{ filename }")
180
+ f = @step.file(:html_resources)[filename].find
181
+ else
182
+ url = "/files/#{ filename }"
183
+ f = settings.file_dir[filename].find
184
+ end
185
+
178
186
  FileUtils.mkdir_p(File.dirname(f))
187
+
179
188
  yield(f)
180
189
 
190
+
181
191
  type ||= :link
182
192
  case type
183
193
  when :image
184
- "<img src='/files/#{ filename }' alt='#{text}' class='file_resource'/>"
194
+ "<img src='#{url}' alt='#{text}' class='file_resource'/>"
185
195
  when :link
186
- "<a href='/files/#{ filename }' class='file_resource'>#{ text }</a>"
196
+ "<a href='#{url}' class='file_resource'>#{ text }</a>"
187
197
  when :linked_image
188
- "<a href='/files/#{ filename }' class='file_resource' target='_blank'><img src='/files/#{ filename }' class='file_resource'/></a>"
198
+ "<a href='#{url}' class='file_resource' target='_blank'><img src='#{url}' class='file_resource'/></a>"
189
199
  when :zoomable_image
190
200
  id = options[:id] || Misc.digest(filename)
191
201
  width, height= [600, 600]
192
- "<div class='zoomable_image'><img id='#{id}' style='width:#{width}px; height:#{height}px' rel='/files/#{ filename }' src='/files/#{ filename }' class='file_resource'/></div>"
202
+ "<div class='zoomable_image'><img id='#{id}' style='width:#{width}px; height:#{height}px' rel='#{url}' src='#{url}' class='file_resource'/></div>"
193
203
  when :mapped_image
194
204
  mapid = options[:mapid] || options[:id] + '_map'
195
205
  width, height= [300, 300]
196
206
  mapfile = f.sub(/\.[^.]+$/, '.html')
197
- "<div class='mapped_image'>#{Open.read(mapfile)}<img class='has_map' usemap='##{mapid}' rel='/files/#{ filename }' src='/files/#{ filename }' class='file_resource'/></div>"
207
+ "<div class='mapped_image'>#{Open.read(mapfile)}<img class='has_map' usemap='##{mapid}' rel='#{url}' src='#{url}' class='file_resource'/></div>"
198
208
  else
199
209
  raise "Type not understood: #{ type }"
200
210
  end
@@ -7,11 +7,14 @@ require 'rbbt/rest/knowledge_base/query'
7
7
  require 'rbbt/rest/knowledge_base/helpers'
8
8
  require 'rbbt/rest/knowledge_base/locate'
9
9
  require 'rbbt/rest/knowledge_base/render'
10
+ require "sinatra/multi_route"
10
11
 
11
12
  module Sinatra
12
13
  module RbbtRESTKnowledgeBase
13
14
  def self.registered(base)
14
15
  base.module_eval do
16
+ register Sinatra::MultiRoute
17
+
15
18
  include RbbtRESTHelpers
16
19
  include KnowledgeBaseRESTHelpers
17
20
 
@@ -221,7 +221,7 @@ module Sinatra
221
221
  file = locate_file(Path.setup('public')[filename])
222
222
  send_file file.find
223
223
  end
224
-
224
+
225
225
  require 'rbbt/rest/monitor'
226
226
  register Sinatra::RbbtRESTMonitor
227
227
  end
@@ -50,9 +50,9 @@
50
50
  - field = header ? header[i] : nil
51
51
  - val = table_value(value, field, :list_id => list_id, :unnamed => unnamed, :entity_options => entity_options, :span => span)
52
52
  - case val.to_s
53
- - when 'true'
53
+ - when 'true', 'Yes', 'yes'
54
54
  %td.true= val.to_s
55
- - when 'false'
55
+ - when 'false', 'No', 'no'
56
56
  %td.false= val.to_s
57
57
  - else
58
58
  %td= Float === val ? "%.5g" % val : val.to_s
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.14
4
+ version: 1.7.15
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-01-21 00:00:00.000000000 Z
11
+ date: 2016-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake