rbbt-rest 1.1.5 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/rbbt/rest/common/cache.rb +33 -14
- data/lib/rbbt/rest/common/locate.rb +8 -6
- data/lib/rbbt/rest/common/misc.rb +4 -0
- data/lib/rbbt/rest/common/render.rb +14 -4
- data/lib/rbbt/rest/common/resources.rb +1 -1
- data/lib/rbbt/rest/common/table.rb +37 -7
- data/lib/rbbt/rest/entity.rb +5 -3
- data/lib/rbbt/rest/entity/favourites.rb +4 -1
- data/lib/rbbt/rest/entity/helpers.rb +12 -0
- data/lib/rbbt/rest/entity/rest.rb +6 -2
- data/lib/rbbt/rest/helpers.rb +7 -0
- data/lib/rbbt/rest/knowledge_base.rb +338 -0
- data/lib/rbbt/rest/knowledge_base/helpers.rb +57 -0
- data/lib/rbbt/rest/main.rb +16 -3
- data/share/views/compass/_rbbt.sass +11 -0
- data/share/views/compass/actions.sass +48 -24
- data/share/views/compass/app.sass +72 -50
- data/share/views/compass/colors.sass +3 -229
- data/share/views/compass/entity_card.sass +44 -108
- data/share/views/compass/favourites.sass +17 -72
- data/share/views/compass/finder.sass +30 -0
- data/share/views/compass/foundation.sass +79 -0
- data/share/views/compass/functions.sass +27 -0
- data/share/views/compass/help.sass +3 -0
- data/share/views/compass/layout.sass +132 -0
- data/share/views/compass/rbbt/form.sass +84 -0
- data/share/views/compass/rbbt/fragment.sass +7 -0
- data/share/views/compass/rbbt/menu.sass +189 -0
- data/share/views/compass/rbbt/reveal.sass +46 -0
- data/share/views/compass/rbbt/table.sass +169 -0
- data/share/views/compass/skeleton.sass +2 -0
- data/share/views/compass/skeleton/_dependencies.sass +151 -0
- data/share/views/compass/skeleton/_functions.sass +4 -0
- data/share/views/compass/skeleton/_mixins.sass +25 -0
- data/share/views/compass/skeleton/_vars.sass +72 -0
- data/share/views/compass/skeleton/base.sass +333 -0
- data/share/views/compass/skeleton/layout.sass +51 -0
- data/share/views/compass/skeleton/skeleton.sass +105 -0
- data/share/views/compass/solarized.sass +56 -0
- data/share/views/compass/style.sass +2 -116
- data/share/views/compass/theme.sass +57 -44
- data/share/views/compass/top_menu.sass +121 -0
- data/share/views/compass/user.sass +7 -0
- data/share/views/compass/variables.sass +7 -0
- data/share/views/compass/workflow.sass +6 -14
- data/share/views/entity_partials/action_controller.haml +7 -4
- data/share/views/entity_partials/entity_card.haml +10 -5
- data/share/views/entity_partials/entity_list.haml +4 -7
- data/share/views/entity_partials/entity_list_card.haml +10 -3
- data/share/views/entity_partials/entity_map_card.haml +2 -2
- data/share/views/entity_partials/list_container.haml +31 -26
- data/share/views/error.haml +5 -7
- data/share/views/help.haml +75 -31
- data/share/views/help/entity.haml +191 -193
- data/share/views/help/workflow.haml +59 -63
- data/share/views/job_result.haml +23 -26
- data/share/views/layout.haml +41 -61
- data/share/views/layout/top_menu.haml +19 -0
- data/share/views/layout/top_menu/favourites.haml +45 -0
- data/share/views/layout/top_menu/finder.haml +4 -0
- data/share/views/layout/top_menu/user.haml +15 -0
- data/share/views/public/js/_ajax_replace.js +17 -5
- data/share/views/public/js/_ellipsis.js +7 -9
- data/share/views/public/js/app.js +50 -2
- data/share/views/public/js/foundation/foundation.abide.js +194 -0
- data/share/views/public/js/foundation/foundation.alerts.js +52 -0
- data/share/views/public/js/foundation/foundation.clearing.js +516 -0
- data/share/views/public/js/foundation/foundation.cookie.js +74 -0
- data/share/views/public/js/foundation/foundation.dropdown.js +177 -0
- data/share/views/public/js/foundation/foundation.forms.js +533 -0
- data/share/views/public/js/foundation/foundation.interchange.js +280 -0
- data/share/views/public/js/foundation/foundation.joyride.js +850 -0
- data/share/views/public/js/foundation/foundation.js +440 -0
- data/share/views/public/js/foundation/foundation.magellan.js +135 -0
- data/share/views/public/js/foundation/foundation.orbit.js +412 -0
- data/share/views/public/js/foundation/foundation.placeholder.js +179 -0
- data/share/views/public/js/foundation/foundation.reveal.js +330 -0
- data/share/views/public/js/foundation/foundation.section.js +400 -0
- data/share/views/public/js/foundation/foundation.tooltips.js +208 -0
- data/share/views/public/js/foundation/foundation.topbar.js +300 -0
- data/share/views/public/js/foundation/index.js +18 -0
- data/share/views/public/js/helpers.js +33 -2
- data/share/views/public/js/jquery-ui.js +313 -0
- data/share/views/public/js/rbbt/actions.js +264 -0
- data/share/views/public/js/{_dom_update.js → rbbt/dom_update.js} +0 -0
- data/share/views/public/js/rbbt/favourites.js +425 -0
- data/share/views/public/js/rbbt/fragment.js +13 -0
- data/share/views/public/js/rbbt/hide.js +60 -0
- data/share/views/public/js/rbbt/list.js +117 -0
- data/share/views/public/js/{maps.js → rbbt/map.js} +3 -2
- data/share/views/public/js/rbbt/menu.js +22 -0
- data/share/views/public/js/rbbt/modal.js +96 -0
- data/share/views/public/js/{entities.js → rbbt/page_type.js} +12 -9
- data/share/views/public/js/rbbt/reveal.js +19 -0
- data/share/views/public/js/rbbt/table.js +283 -0
- data/share/views/public/js/{workflow.js → rbbt/workflow.js} +0 -0
- data/share/views/tasks.haml +14 -15
- data/share/views/wait.haml +11 -12
- metadata +62 -33
- data/share/views/compass/_foundation_setup.sass +0 -74
- data/share/views/compass/dom.sass +0 -32
- data/share/views/compass/footer.sass +0 -4
- data/share/views/compass/form.sass +0 -41
- data/share/views/compass/fragment.sass +0 -8
- data/share/views/compass/list_container.sass +0 -34
- data/share/views/compass/lists.sass +0 -33
- data/share/views/compass/offcanvas.sass +0 -66
- data/share/views/compass/responsive_table.sass +0 -80
- data/share/views/compass/reveal.sass +0 -31
- data/share/views/compass/style_mixins.sass +0 -42
- data/share/views/compass/table.sass +0 -63
- data/share/views/compass/tabs.sass +0 -81
- data/share/views/compass/topbar.sass +0 -25
- data/share/views/compass/web-fonts.sass +0 -77
- data/share/views/layout/favourites.haml +0 -46
- data/share/views/layout/header.haml +0 -44
- data/share/views/public/js/_fix_tablesorter_science.js +0 -38
- data/share/views/public/js/_foundation.js +0 -42
- data/share/views/public/js/actions.js +0 -108
- data/share/views/public/js/base.js +0 -121
- data/share/views/public/js/favourites.js +0 -441
- data/share/views/public/js/lists.js +0 -117
- data/share/views/public/js/offcanvas.js +0 -35
- data/share/views/public/js/reveal.js +0 -48
- data/share/views/public/js/tables.js +0 -314
- data/share/views/public/js/tabs.js +0 -7
data/lib/rbbt/rest/helpers.rb
CHANGED
@@ -40,5 +40,12 @@ module Sinatra
|
|
40
40
|
end
|
41
41
|
bed
|
42
42
|
end
|
43
|
+
|
44
|
+
def format_name(name)
|
45
|
+
parts = name.split("_")
|
46
|
+
hash = parts.pop
|
47
|
+
clean_name = parts * "_"
|
48
|
+
"<span class='name' jobname='#{ name }'>#{ clean_name }</span><span class='hash'>#{ hash }</span>"
|
49
|
+
end
|
43
50
|
end
|
44
51
|
end
|
@@ -0,0 +1,338 @@
|
|
1
|
+
require 'rbbt'
|
2
|
+
require 'rbbt/workflow'
|
3
|
+
require 'sinatra/base'
|
4
|
+
|
5
|
+
require 'rbbt/knowledge_base'
|
6
|
+
require 'rbbt/rest/knowledge_base/helpers'
|
7
|
+
|
8
|
+
module Sinatra
|
9
|
+
module RbbtRESTKnowledgeBase
|
10
|
+
def self.registered(base)
|
11
|
+
base.module_eval do
|
12
|
+
helpers KnowledgeBaseRESTHelpers
|
13
|
+
|
14
|
+
get '/knowledge_base/:name/:database/entity_children/:entity' do
|
15
|
+
name = consume_parameter :name
|
16
|
+
database = consume_parameter :database
|
17
|
+
entity = consume_parameter :entity
|
18
|
+
|
19
|
+
kb = get_knowledge_base name
|
20
|
+
found = kb.identify database, entity
|
21
|
+
raise ParameterException, "Entity #{entity} was not found" unless found
|
22
|
+
|
23
|
+
list = kb.children(database, found).target_entity
|
24
|
+
|
25
|
+
case @format
|
26
|
+
when :json
|
27
|
+
content_type "application/json"
|
28
|
+
halt 200, prepare_entities_for_json(list).to_json
|
29
|
+
when :html
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
post '/knowledge_base/:name/:database/entity_list_children/' do
|
34
|
+
name = consume_parameter :name
|
35
|
+
database = consume_parameter :database
|
36
|
+
entities = consume_parameter :entities
|
37
|
+
|
38
|
+
raise ParameterException, "No 'entities' provided" if entities.nil?
|
39
|
+
|
40
|
+
entities = entities.split("|")
|
41
|
+
|
42
|
+
kb = get_knowledge_base name
|
43
|
+
|
44
|
+
children = {}
|
45
|
+
entities.each do |entity|
|
46
|
+
found = kb.identify database, entity
|
47
|
+
next if found.nil?
|
48
|
+
children[entity] = kb.children(database, found).target_entity
|
49
|
+
end
|
50
|
+
case @format
|
51
|
+
when :json
|
52
|
+
content_type "application/json"
|
53
|
+
halt 200, prepare_entities_for_json(children).to_json
|
54
|
+
when :html
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
post '/knowledge_base/:name/:database/entity_collection_children' do
|
59
|
+
name = consume_parameter :name
|
60
|
+
database = consume_parameter :database
|
61
|
+
entities = consume_parameter :entities
|
62
|
+
|
63
|
+
raise ParameterException, "No 'entities' provided" if entities.nil?
|
64
|
+
|
65
|
+
entities = JSON.parse(entities)
|
66
|
+
|
67
|
+
kb = get_knowledge_base name
|
68
|
+
|
69
|
+
entities.each do |type,list|
|
70
|
+
list.each do |entity|
|
71
|
+
found = kb.identify database, entity
|
72
|
+
next if found.nil?
|
73
|
+
targets = kb.children(database, found).target_entity
|
74
|
+
next if targets.nil? or targets.empty?
|
75
|
+
target_type = kb.target database
|
76
|
+
children[target_type] ||= []
|
77
|
+
children[target_type].concat targets
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
case @format
|
82
|
+
when :json
|
83
|
+
content_type "application/json"
|
84
|
+
halt 200, prepare_entities_for_json(children).to_json
|
85
|
+
when :html
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Neighbours
|
90
|
+
|
91
|
+
get '/knowledge_base/:name/:database/entity_neighbours/:entity' do
|
92
|
+
name = consume_parameter :name
|
93
|
+
database = consume_parameter :database
|
94
|
+
entity = consume_parameter :entity
|
95
|
+
|
96
|
+
kb = get_knowledge_base name
|
97
|
+
found = kb.identify database, entity
|
98
|
+
raise ParameterException, "Entity #{entity} was not found" unless found
|
99
|
+
|
100
|
+
list = kb.neighbours(database, found).values.select{|list| list and list.any?}.first
|
101
|
+
list = list.target_entity if list.respond_to? :target_entity
|
102
|
+
list ||= []
|
103
|
+
|
104
|
+
case @format
|
105
|
+
when :json
|
106
|
+
content_type "application/json"
|
107
|
+
halt 200, prepare_entities_for_json(list).to_json
|
108
|
+
when :html
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
post '/knowledge_base/:name/:database/entity_list_neighbours/' do
|
113
|
+
name = consume_parameter :name
|
114
|
+
database = consume_parameter :database
|
115
|
+
entities = consume_parameter :entities
|
116
|
+
|
117
|
+
raise ParameterException, "No 'entities' provided" if entities.nil?
|
118
|
+
|
119
|
+
entities = entities.split("|")
|
120
|
+
|
121
|
+
kb = get_kb name
|
122
|
+
|
123
|
+
children = {}
|
124
|
+
entities.each do |entity|
|
125
|
+
found = kb.identify database, entity
|
126
|
+
next if found.nil?
|
127
|
+
matches = kb.neighbours(database, found).values.select{|list| list and list.any?}.first
|
128
|
+
next if matches.nil? or matches.empty?
|
129
|
+
children[entity] = matches.target_entity
|
130
|
+
end
|
131
|
+
case @format
|
132
|
+
when :json
|
133
|
+
content_type "application/json"
|
134
|
+
halt 200, prepare_entities_for_json(children).to_json
|
135
|
+
when :html
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
post '/knowledge_base/:name/:database/entity_collection_neighbours' do
|
140
|
+
name = consume_parameter :name
|
141
|
+
database = consume_parameter :database
|
142
|
+
entities = consume_parameter :entities
|
143
|
+
|
144
|
+
raise ParameterException, "No 'entities' provided" if entities.nil?
|
145
|
+
|
146
|
+
entities = JSON.parse(entities)
|
147
|
+
|
148
|
+
kb = get_kb name
|
149
|
+
|
150
|
+
neighbours = {}
|
151
|
+
entities.each do |type,list|
|
152
|
+
list.each do |entity|
|
153
|
+
|
154
|
+
found = kb.identify_source database, entity
|
155
|
+
if found.nil?
|
156
|
+
reverse = true
|
157
|
+
found = kb.identify_target database, entity
|
158
|
+
else
|
159
|
+
reverse = false
|
160
|
+
end
|
161
|
+
next if found.nil?
|
162
|
+
|
163
|
+
matches = kb.neighbours(database, found)[reverse ? :parents : :children]
|
164
|
+
next if matches.nil? or matches.empty?
|
165
|
+
targets = matches.target
|
166
|
+
|
167
|
+
entity_type = reverse ? kb.source_type(database) : kb.target_type(database)
|
168
|
+
neighbours[entity_type] ||= []
|
169
|
+
neighbours[entity_type].concat targets
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
neighbours.each{|type, list| list.uniq!}
|
174
|
+
|
175
|
+
case @format
|
176
|
+
when :json
|
177
|
+
content_type "application/json"
|
178
|
+
halt 200, prepare_entities_for_json(neighbours).to_json
|
179
|
+
when :html
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
#{{{ OLD
|
184
|
+
|
185
|
+
get '/knowledge_base/entity/:name/:database/:entity' do
|
186
|
+
name = consume_parameter :name
|
187
|
+
|
188
|
+
database = consume_parameter :database
|
189
|
+
entity = consume_parameter :entity
|
190
|
+
|
191
|
+
kb = get_kb name
|
192
|
+
found = kb.identify database, entity
|
193
|
+
raise ParameterException, "Entity #{entity} was not found" unless found
|
194
|
+
|
195
|
+
list = kb.neighbours(database, found).values.select{|l| l.any?}.first.target_entity
|
196
|
+
|
197
|
+
case @format
|
198
|
+
when :json
|
199
|
+
content_type "application/json"
|
200
|
+
halt 200, list_json(list || [])
|
201
|
+
when :html
|
202
|
+
template_render('entity_partials/entity_list', :list => list)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
get '/knowledge_base/entities/:name/:database' do
|
207
|
+
name = consume_parameter :name
|
208
|
+
database = consume_parameter :database
|
209
|
+
entities = consume_parameter(:entities).split("|")
|
210
|
+
|
211
|
+
kb = get_kb name
|
212
|
+
|
213
|
+
entity_neighbours = {}
|
214
|
+
entities.each do |entity|
|
215
|
+
found = kb.identify database, entity
|
216
|
+
next unless found
|
217
|
+
list = kb.neighbours(database, found).values.select{|l| l.any?}.first.target_entity
|
218
|
+
entity_neighbours[entity] = list
|
219
|
+
end
|
220
|
+
|
221
|
+
case @format
|
222
|
+
when :json
|
223
|
+
content_type "application/json"
|
224
|
+
hash = {}
|
225
|
+
entity_neighbours.each do |entity, list|
|
226
|
+
hash[entity] = list_hash(list)
|
227
|
+
end
|
228
|
+
halt 200, hash.to_json
|
229
|
+
when :html
|
230
|
+
template_render('entity_partials/entity_list', :list => list)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
get '/knowledge_base/entity/:name/:entity' do
|
235
|
+
name = consume_parameter :name
|
236
|
+
database = consume_parameter :database
|
237
|
+
entity = consume_parameter :entity
|
238
|
+
|
239
|
+
kb = get_kb name
|
240
|
+
|
241
|
+
lists = {}
|
242
|
+
kb.all_databases.collect do |database|
|
243
|
+
found = kb.identify database, entity
|
244
|
+
next unless found
|
245
|
+
matches = kb.neighbours(database, found).values.select{|l| l.any?}.first
|
246
|
+
next if matches.nil?
|
247
|
+
lists[database] = matches.target_entity
|
248
|
+
end
|
249
|
+
|
250
|
+
case @format
|
251
|
+
when :json
|
252
|
+
content_type "application/json"
|
253
|
+
halt 200, lists.each{|database,entities| lists[database] = list_hash(entities || []) }.to_json
|
254
|
+
when :html
|
255
|
+
template_render('knowledge_base_partials/knowledge_base_matches', :matches => lists, :knowledge_base => kb)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
#{{{ Hash
|
260
|
+
|
261
|
+
post '/knowledge_base/associations' do
|
262
|
+
knowledge_base = consume_parameter :knowledge_base
|
263
|
+
knowledge_base = get_knowledge_base(knowledge_base)
|
264
|
+
|
265
|
+
namespace = consume_parameter :namespace
|
266
|
+
|
267
|
+
databases = consume_parameter(:databases) || consume_parameter(:database)
|
268
|
+
databases = databases.nil? ? knowledge_base.all_databases : databases.split("|")
|
269
|
+
|
270
|
+
entities = consume_parameter :entities
|
271
|
+
entities = JSON.parse(entities)
|
272
|
+
|
273
|
+
subset = {}
|
274
|
+
databases.each do |database|
|
275
|
+
subset[database] = knowledge_base.subset(database, entities)
|
276
|
+
end
|
277
|
+
|
278
|
+
case @format
|
279
|
+
when :json
|
280
|
+
content_type "application/json"
|
281
|
+
halt 200, subset.each{|database,entities| subset[database] = list_hash(entities || []) }.to_json
|
282
|
+
when :html
|
283
|
+
template_render('entity_partials/associations', :matches => matches, :entities => entities)
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
post '/knowledge_base/neighbours' do
|
288
|
+
knowledge_base = consume_parameter :knowledge_base
|
289
|
+
knowledge_base = get_knowledge_base(knowledge_base)
|
290
|
+
|
291
|
+
namespace = consume_parameter :namespace
|
292
|
+
|
293
|
+
database = consume_parameter(:database)
|
294
|
+
|
295
|
+
entities = consume_parameter :entities
|
296
|
+
entities = JSON.parse(entities)
|
297
|
+
|
298
|
+
all_neighbours = {}
|
299
|
+
entities.collect{|source_type,list|
|
300
|
+
list.each do |entity|
|
301
|
+
|
302
|
+
target_type = knowledge_base.target_type(database)
|
303
|
+
source_type = knowledge_base.source_type(database)
|
304
|
+
|
305
|
+
neighbours = knowledge_base.neighbours(database, entity)
|
306
|
+
|
307
|
+
children = neighbours[:children]
|
308
|
+
if children.any?
|
309
|
+
all_neighbours[target_type] ||= []
|
310
|
+
all_neighbours[target_type].concat children.target
|
311
|
+
end
|
312
|
+
|
313
|
+
parents = neighbours[:parents]
|
314
|
+
if parents and parents.any?
|
315
|
+
all_neighbours[source_type] ||= []
|
316
|
+
all_neighbours[source_type].concat parents.target
|
317
|
+
end
|
318
|
+
end
|
319
|
+
}
|
320
|
+
|
321
|
+
case @format
|
322
|
+
when :json
|
323
|
+
content_type "application/json"
|
324
|
+
halt 200, [].to_json if all_neighbours.empty?
|
325
|
+
entities = {}
|
326
|
+
all_neighbours.each do |type,list|
|
327
|
+
entities[type] = list
|
328
|
+
end
|
329
|
+
|
330
|
+
halt 200, all_neighbours.to_json
|
331
|
+
when :html
|
332
|
+
template_render('entity_partials/neighbours', :matches => matches, :neighbours => all_neighbours)
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'rbbt/util/misc'
|
2
|
+
require 'rbbt/knowledge_base'
|
3
|
+
|
4
|
+
module KnowledgeBaseRESTHelpers
|
5
|
+
class << self
|
6
|
+
attr_accessor :knowledge_base_dir, :knowledge_bases
|
7
|
+
end
|
8
|
+
|
9
|
+
self.knowledge_base_dir = "var/knowledge_base"
|
10
|
+
|
11
|
+
def prepare_entities_for_json(entities)
|
12
|
+
case entities
|
13
|
+
when AnnotatedArray
|
14
|
+
list_hash(entities)
|
15
|
+
when Array
|
16
|
+
entities.inject([]){|acc,e| acc << prepare_entities_for_json(e); acc }
|
17
|
+
when Hash
|
18
|
+
hash = {}
|
19
|
+
entities.each do |key,values|
|
20
|
+
hash[key] = prepare_entities_for_json(values)
|
21
|
+
end
|
22
|
+
hash
|
23
|
+
when String
|
24
|
+
entities
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_kb(name)
|
29
|
+
@knowledge_bases ||= IndiferentHash.setup({})
|
30
|
+
case name
|
31
|
+
when :genomics, "genomics"
|
32
|
+
@knowledge_bases[name] ||= Genomics.knowledge_base
|
33
|
+
else
|
34
|
+
@knowledge_bases[name] ||= KnowledgeBase.new File.join(KnowledgeBaseRESTHelpers.knowledge_base_dir, name)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_knowledge_base(name, namespace = nil)
|
39
|
+
@knowledge_bases ||= IndiferentHash.setup({})
|
40
|
+
@knowledge_bases[name] ||= begin
|
41
|
+
kb = case
|
42
|
+
when [:genomics, "genomics"].include?(name)
|
43
|
+
Genomics.knowledge_base
|
44
|
+
when (Misc.path_relative_to(settings.cache_dir, name) and File.exists?(name))
|
45
|
+
KnowledgeBase.new name
|
46
|
+
when KnowledgeBase.registry.include?(name)
|
47
|
+
KnowledgeBase.registry[name]
|
48
|
+
when Study.studies.include?(name)
|
49
|
+
Study.setup(name).knowledge_base
|
50
|
+
else
|
51
|
+
KnowledgeBase.new File.join(KnowledgeBaseRESTHelpers.knowledge_base_dir, name)
|
52
|
+
end
|
53
|
+
|
54
|
+
namespace ? kb.version(namespace) : kb
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/rbbt/rest/main.rb
CHANGED
@@ -42,7 +42,7 @@ module Sinatra
|
|
42
42
|
set :allow_headers, ['URI']
|
43
43
|
|
44
44
|
before do
|
45
|
-
Log.info("
|
45
|
+
Log.info("#{request.request_method} #{request.ip}: " << request.path_info << ". Params: " << Misc.fingerprint(params))
|
46
46
|
process_common_parameters
|
47
47
|
|
48
48
|
if profile
|
@@ -51,6 +51,7 @@ module Sinatra
|
|
51
51
|
end
|
52
52
|
|
53
53
|
after do
|
54
|
+
Log.info("#{request.request_method} #{request.ip}: " << request.path_info << ". Params: " << Misc.fingerprint(params) << "[#{response.status}]")
|
54
55
|
|
55
56
|
if profile
|
56
57
|
result = RubyProf.stop
|
@@ -71,11 +72,12 @@ module Sinatra
|
|
71
72
|
send_file file
|
72
73
|
end
|
73
74
|
|
74
|
-
get %r{/js/(.*)(.js)?} do
|
75
|
+
get %r{/js-find/(.*)(.js)?} do
|
75
76
|
name = consume_parameter(:captures).first
|
76
77
|
|
77
78
|
script_file = locate_javascript(name)
|
78
79
|
|
80
|
+
content_type 'text/javascript', :charset => 'utf-8'
|
79
81
|
cache_control :public, :max_age => 360000 if production?
|
80
82
|
send_file script_file
|
81
83
|
end
|
@@ -93,7 +95,7 @@ module Sinatra
|
|
93
95
|
Log.debug("Rendering stylesheets")
|
94
96
|
renderer = Sass::Engine.new(Open.read(file), :filename => file,
|
95
97
|
:style => production? ? :compressed : nil,
|
96
|
-
:debug_info =>
|
98
|
+
:debug_info => development? ? true : false)
|
97
99
|
renderer.render
|
98
100
|
end
|
99
101
|
end
|
@@ -102,6 +104,13 @@ module Sinatra
|
|
102
104
|
template_render('main', params, 'main', :cache_type => :asynchronous)
|
103
105
|
end
|
104
106
|
|
107
|
+
get '/main/*' do |file|
|
108
|
+
template = File.join 'main', file
|
109
|
+
name = template.gsub(/\//,' - ')
|
110
|
+
template_render(template, params, name, :cache_type => :asynchronous)
|
111
|
+
end
|
112
|
+
|
113
|
+
|
105
114
|
get '/help/?:section?' do
|
106
115
|
if params[:section]
|
107
116
|
section = params[:section]
|
@@ -118,6 +127,10 @@ module Sinatra
|
|
118
127
|
Open.read(File.join(settings.permalink_dir, params[:id]))
|
119
128
|
end
|
120
129
|
end
|
130
|
+
|
131
|
+
error RbbtRESTHelpers::TemplateMissing do |e|
|
132
|
+
halt 404, e.message
|
133
|
+
end
|
121
134
|
end
|
122
135
|
end
|
123
136
|
end
|