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
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDEwYTAxNGNmZTM1OTk0MTIwM2JiZWRlOGM4NjVlNTE1M2M3MTE0MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzYzOGQ3M2E3NmRkMzkzMDBlYjMxNjdiYjNhMzFjOGMwZWFkZGFhZg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGZlZjJkMjdhZDIxOTVhZjBmOGRhOGFmMDY5Y2I5N2RhODFlM2RiYmE3YjI2
|
10
|
+
ODNhMjJjNTIwNmE2MzA2ZWZjMGFmNzQ2NzkwNmFhMTg4MTBhNTQxYTJiNDEx
|
11
|
+
NzEzNmJmMjRjNjljMDJkOGViOTQ4OWM3YWIwOWEyYmU3YzlkNzE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWNhNTk4MjJjZGMxOWE4MmE0MmExMzYyZGFjY2QwMWIyOGQzYzZiOWJkNDU1
|
14
|
+
MjkwNDIxNjFhMGQzNTgxYTM2MWNiMDdmZTllMWI0MDJjMTljMjY0ZWQ4ZTlk
|
15
|
+
ZTQ2ZmM0NzIwODQ3NDg1ZThjZDhlZjEwYmU0YTZjNDJiNjE0ZjQ=
|
@@ -19,6 +19,8 @@ module RbbtRESTHelpers
|
|
19
19
|
|
20
20
|
send_file = consume_parameter(:_send_file, params)
|
21
21
|
|
22
|
+
# Setup Step
|
23
|
+
|
22
24
|
check = [params[:_template_file]].compact
|
23
25
|
check += consume_parameter(:_cache_check, params) || []
|
24
26
|
check.flatten!
|
@@ -29,11 +31,14 @@ module RbbtRESTHelpers
|
|
29
31
|
task = Task.setup(:name => "Sinatra cache", :result_type => :string, &block)
|
30
32
|
|
31
33
|
step = Step.new(path, task, nil, nil, self)
|
34
|
+
last_modified File.mtime(step.path.find) if step.done?
|
32
35
|
|
33
36
|
halt 200, step.info.to_json if @format == :info
|
34
37
|
|
35
38
|
self.instance_variable_set("@step", step)
|
36
39
|
|
40
|
+
# Return fragment
|
41
|
+
|
37
42
|
if @fragment
|
38
43
|
fragment_file = step.file(@fragment)
|
39
44
|
if File.exists?(fragment_file)
|
@@ -73,6 +78,7 @@ module RbbtRESTHelpers
|
|
73
78
|
tsv.excel(excel_file, :name => @excel_use_name,:sort_by => @excel_sort_by, :sort_by_cast => @excel_sort_by_cast)
|
74
79
|
send_file excel_file, :type => 'application/vnd.ms-excel', :filename => 'table.xls'
|
75
80
|
else
|
81
|
+
cache_control :public, :max_age => 360000 if production?
|
76
82
|
send_file fragment_file
|
77
83
|
end
|
78
84
|
else
|
@@ -85,8 +91,9 @@ module RbbtRESTHelpers
|
|
85
91
|
end
|
86
92
|
end
|
87
93
|
|
94
|
+
# Clean/update job
|
88
95
|
|
89
|
-
if old_cache(path, check) or update == :reload
|
96
|
+
if old_cache(step.path, check) or update == :reload
|
90
97
|
begin
|
91
98
|
pid = step.info[:pid]
|
92
99
|
step.abort if pid and Misc.pid_exists? pid
|
@@ -97,6 +104,8 @@ module RbbtRESTHelpers
|
|
97
104
|
step.clean
|
98
105
|
end
|
99
106
|
|
107
|
+
# Issue
|
108
|
+
|
100
109
|
step.fork unless step.started?
|
101
110
|
|
102
111
|
step.join if cache_type == :synchronous or cache_type == :sync
|
@@ -108,31 +117,41 @@ module RbbtRESTHelpers
|
|
108
117
|
redirect to(url)
|
109
118
|
end
|
110
119
|
|
120
|
+
# Monitor
|
121
|
+
|
111
122
|
begin
|
112
|
-
|
113
|
-
|
114
|
-
error_for step, !@ajax
|
115
|
-
when :done
|
123
|
+
|
124
|
+
if step.done?
|
116
125
|
case
|
117
126
|
when @permalink
|
118
127
|
redirect to(permalink(step.path))
|
119
128
|
when send_file
|
120
129
|
send_file step.path
|
121
130
|
else
|
131
|
+
cache_control :public, :max_age => 360000 if production?
|
122
132
|
step.load
|
123
133
|
end
|
124
134
|
else
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
135
|
+
|
136
|
+
case step.status
|
137
|
+
when :error, :aborted
|
138
|
+
error_for step, !@ajax
|
139
|
+
|
140
|
+
else
|
141
|
+
# check for problems
|
142
|
+
if File.exists?(step.info_file) and Time.now - File.atime(step.info_file) > 60
|
143
|
+
Log.debug("Checking on #{step.info_file}")
|
144
|
+
running = step.running?
|
145
|
+
if FalseClass === running
|
146
|
+
Log.debug("Aborting zombie #{step.info_file}")
|
147
|
+
step.abort unless step.done?
|
148
|
+
raise RbbtRESTHelpers::Retry
|
149
|
+
end
|
150
|
+
FileUtils.touch(step.info_file)
|
132
151
|
end
|
133
|
-
|
152
|
+
|
153
|
+
wait_on step, false
|
134
154
|
end
|
135
|
-
wait_on step, false
|
136
155
|
end
|
137
156
|
rescue RbbtRESTHelpers::Retry
|
138
157
|
retry
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module RbbtRESTHelpers
|
2
2
|
attr_accessor :template_resources, :sass_resources, :javascript_resources, :plugin_resources
|
3
3
|
|
4
|
+
class TemplateMissing < StandardError; end
|
5
|
+
|
4
6
|
#{{{ TEMPLATE
|
5
7
|
|
6
8
|
def self.template_resources
|
@@ -21,7 +23,7 @@ module RbbtRESTHelpers
|
|
21
23
|
return path if path.exists?
|
22
24
|
end
|
23
25
|
|
24
|
-
raise "Template #{ template } not found"
|
26
|
+
raise TemplateMissing, "Template #{ template } not found"
|
25
27
|
end
|
26
28
|
|
27
29
|
#{{{ SASS
|
@@ -35,7 +37,7 @@ module RbbtRESTHelpers
|
|
35
37
|
end
|
36
38
|
|
37
39
|
def sass_resources
|
38
|
-
|
40
|
+
RbbtRESTHelpers.sass_resources
|
39
41
|
end
|
40
42
|
|
41
43
|
def locate_sass_from_resource(resource, template)
|
@@ -48,17 +50,17 @@ module RbbtRESTHelpers
|
|
48
50
|
return path if path.exists?
|
49
51
|
end
|
50
52
|
|
51
|
-
raise "Sass template #{ template } not found"
|
53
|
+
raise TemplateMissing, "Sass template #{ template } not found"
|
52
54
|
end
|
53
55
|
|
54
56
|
#{{{ JAVASCRIPT
|
55
57
|
|
56
58
|
def self.javascript_resources
|
57
|
-
@javascript_resources ||= [Rbbt.share.views.
|
59
|
+
@javascript_resources ||= [Rbbt.share.views.public.find(:lib), Rbbt.share.views.public.js.find(:lib)]
|
58
60
|
end
|
59
61
|
|
60
62
|
def javascript_resources
|
61
|
-
|
63
|
+
RbbtRESTHelpers.javascript_resources
|
62
64
|
end
|
63
65
|
|
64
66
|
|
@@ -74,6 +76,6 @@ module RbbtRESTHelpers
|
|
74
76
|
return path if path.exists?
|
75
77
|
end
|
76
78
|
|
77
|
-
raise "Script #{ script } not found"
|
79
|
+
raise TemplateMissing, "Script #{ script } not found"
|
78
80
|
end
|
79
81
|
end
|
@@ -17,10 +17,16 @@ module RbbtRESTHelpers
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def wait_on(job, layout = nil)
|
20
|
+
ddd "wait"
|
20
21
|
3.times do
|
21
22
|
sleep 1
|
22
|
-
raise RbbtRESTHelpers::Retry if job.done? or job.error?
|
23
23
|
end
|
24
|
+
ddd job.status
|
25
|
+
ddd job.done?
|
26
|
+
ddd job.error?
|
27
|
+
raise RbbtRESTHelpers::Retry if job.done? or job.error?
|
28
|
+
|
29
|
+
ddd "Render"
|
24
30
|
|
25
31
|
layout = @layout if layout.nil?
|
26
32
|
|
@@ -32,6 +38,8 @@ module RbbtRESTHelpers
|
|
32
38
|
end
|
33
39
|
|
34
40
|
def render(template_file, locals = {}, layout_file = nil, cache = nil, cache_options = {})
|
41
|
+
raise TemplateMissing, "Template #{ template_file } not found" unless template_file.exists?
|
42
|
+
raise TemplateMissing, "Template #{ layout_file } not found" unless layout_file.nil? or layout_file.exists?
|
35
43
|
if layout_file
|
36
44
|
Haml::Engine.new(Open.read(layout_file), :filename => layout_file, :ugly => production?).render(self, locals) do
|
37
45
|
cache(cache, locals.merge(:_template_file => template_file, :user => user).merge(cache_options)) do
|
@@ -63,13 +71,14 @@ module RbbtRESTHelpers
|
|
63
71
|
render(template_file, locals, nil, cache, cache_options)
|
64
72
|
end
|
65
73
|
|
66
|
-
def fragment(link = nil
|
74
|
+
def fragment(link = nil, &block)
|
75
|
+
fragment_code, link = [link.to_s, nil] if link and not link.to_s[0] == '<'
|
67
76
|
if block_given?
|
68
77
|
if defined? @step and cache_type == :asynchronous or cache_type == :async
|
69
|
-
fragment_code
|
78
|
+
fragment_code ||= (rand * 100000).to_i.to_s
|
70
79
|
fragment_file = @step.file(fragment_code)
|
71
80
|
|
72
|
-
pid = @step.child
|
81
|
+
pid = @step.child{
|
73
82
|
begin
|
74
83
|
res = capture_haml &block
|
75
84
|
Open.write(fragment_file, res)
|
@@ -82,6 +91,7 @@ module RbbtRESTHelpers
|
|
82
91
|
|
83
92
|
url = request.fullpath
|
84
93
|
url = remove_GET_param(url, "_update")
|
94
|
+
url = remove_GET_param(url, "_")
|
85
95
|
fragment_url = add_GET_param(url, "_fragment", fragment_code)
|
86
96
|
if link.nil?
|
87
97
|
html_tag('a', "", :href => fragment_url, :class => 'fragment')
|
@@ -134,13 +134,21 @@ module RbbtRESTHelpers
|
|
134
134
|
if filter and filter.to_s != "false"
|
135
135
|
filter.split(";;").each do |f|
|
136
136
|
key, value = f.split("~")
|
137
|
+
if value =~ /^!\s*(.*)/
|
138
|
+
value = $1
|
139
|
+
invert = true
|
140
|
+
else
|
141
|
+
invert = false
|
142
|
+
end
|
137
143
|
case
|
138
144
|
when value =~ /^([<>]=?)(.*)/
|
139
|
-
tsv = tsv.select(key){|k| k = k.first if Array === k; k.to_f.send($1, $2.to_f)}
|
140
|
-
when value =~ /^\/(.+)\/.{0,2}
|
141
|
-
tsv = tsv.select(key => Regexp.new($1))
|
145
|
+
tsv = tsv.select(key, invert){|k| k = k.first if Array === k; k.to_f.send($1, $2.to_f)}
|
146
|
+
when value =~ /^\/(.+)\/.{0,2}\s*$/
|
147
|
+
tsv = tsv.select({key => Regexp.new($1)}, invert)
|
148
|
+
when (value =~ /^\d+$/ and tsv.type == :double or tsv.type == :flat)
|
149
|
+
tsv = tsv.select({key => value.to_i}, invert)
|
142
150
|
else
|
143
|
-
tsv = tsv.select(key => value)
|
151
|
+
tsv = tsv.select({key => value}, invert)
|
144
152
|
end
|
145
153
|
end
|
146
154
|
end
|
@@ -188,6 +196,17 @@ module RbbtRESTHelpers
|
|
188
196
|
def self.save_tsv(tsv, path)
|
189
197
|
Open.write(path, tsv.to_s)
|
190
198
|
table_options = {:tsv_entity_options => tsv.entity_options}
|
199
|
+
if tsv.entity_templates and tsv.entity_templates.any?
|
200
|
+
table_options[:headers] ||= {}
|
201
|
+
tsv.entity_templates.each do |field,template|
|
202
|
+
next if table_options[:headers].include? field
|
203
|
+
info = template.info
|
204
|
+
info.delete :format
|
205
|
+
info.delete :annotation_types
|
206
|
+
info.delete :annotated_array
|
207
|
+
table_options[:headers][field] = [template.annotation_types.last.to_s, info]
|
208
|
+
end
|
209
|
+
end
|
191
210
|
Open.write(path + '.table_options', table_options.to_yaml )
|
192
211
|
end
|
193
212
|
|
@@ -197,7 +216,7 @@ module RbbtRESTHelpers
|
|
197
216
|
table_options = File.exists?(file + '.table_options') ? YAML.load_file(file + '.table_options') : {}
|
198
217
|
tsv.entity_options = table_options[:tsv_entity_options]
|
199
218
|
headers = table_options[:headers]
|
200
|
-
headers.each{|field,p| tsv.entity_templates[field] = Misc.prepare_entity("TEMPLATE", p.first, p.last) } unless headers.nil?
|
219
|
+
headers.each{|field,p| tsv.entity_templates[field] = Misc.prepare_entity("TEMPLATE", p.first, (tsv.entity_options || {}).merge(p.last)) } unless headers.nil?
|
201
220
|
|
202
221
|
[tsv, table_options]
|
203
222
|
end
|
@@ -237,6 +256,15 @@ module RbbtRESTHelpers
|
|
237
256
|
@table_headers = {}
|
238
257
|
end
|
239
258
|
|
259
|
+
if tsv.entity_templates and tsv.entity_templates.any?
|
260
|
+
options[:headers] ||= {}
|
261
|
+
tsv.entity_templates.each do |field,template|
|
262
|
+
next if options[:headers].include? field
|
263
|
+
next if template.nil?
|
264
|
+
options[:headers][field] = [template.annotation_types.last.to_s, template.info]
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
240
268
|
if @table_filters and @table_filters.any?
|
241
269
|
options[:filters] = @table_filters
|
242
270
|
@table_filters = {}
|
@@ -247,10 +275,12 @@ module RbbtRESTHelpers
|
|
247
275
|
|
248
276
|
total_size = tsv.size
|
249
277
|
if options[:page].nil? and total_size > PAGE_SIZE * 1.2
|
250
|
-
|
278
|
+
@page = "1"
|
279
|
+
else
|
280
|
+
@page = options[:page]
|
251
281
|
end
|
252
282
|
|
253
|
-
tsv2html(table_file)
|
283
|
+
tsv2html(table_file, options)
|
254
284
|
end
|
255
285
|
|
256
286
|
|
data/lib/rbbt/rest/entity.rb
CHANGED
@@ -22,6 +22,7 @@ require 'rbbt/rest/entity/entity_map_card'
|
|
22
22
|
require 'rbbt/rest/entity/action_card'
|
23
23
|
require 'rbbt/rest/entity/list_container'
|
24
24
|
require 'rbbt/rest/entity/action_controller'
|
25
|
+
require 'rbbt/rest/knowledge_base'
|
25
26
|
|
26
27
|
require 'rbbt/statistics/rank_product'
|
27
28
|
|
@@ -154,9 +155,10 @@ module Sinatra
|
|
154
155
|
|
155
156
|
raise "List file not found: #{ list_id }"
|
156
157
|
when :json
|
157
|
-
|
158
|
-
halt 200,
|
158
|
+
content_type "application/json"
|
159
|
+
halt 200, list_json(list)
|
159
160
|
when :info
|
161
|
+
content_type "application/json"
|
160
162
|
halt 200, list.info.to_json
|
161
163
|
when :list
|
162
164
|
content_type "text/plain"
|
@@ -475,7 +477,6 @@ module Sinatra
|
|
475
477
|
content_type "application/json"
|
476
478
|
|
477
479
|
favs = {}
|
478
|
-
|
479
480
|
favourite_entities.each{|type, list|
|
480
481
|
type_favs = {}
|
481
482
|
list.each do |entity|
|
@@ -486,6 +487,7 @@ module Sinatra
|
|
486
487
|
favs[type] = type_favs
|
487
488
|
}
|
488
489
|
|
490
|
+
cache_control :public, :max_age => 360000 if production?
|
489
491
|
favs.to_json
|
490
492
|
end
|
491
493
|
|
@@ -6,12 +6,14 @@ module EntityRESTHelpers
|
|
6
6
|
raise "You need to login to have favourites" unless authorized?
|
7
7
|
|
8
8
|
dir = Path.setup(File.join(settings.favourites_dir, user))
|
9
|
+
|
9
10
|
favourites = {}
|
10
11
|
dir.glob('**').each do |file|
|
11
12
|
type = File.basename(file)
|
12
13
|
entities = Annotated.load_tsv(TSV.open(file))
|
13
14
|
favourites[type] = entities
|
14
15
|
end
|
16
|
+
|
15
17
|
favourites
|
16
18
|
end
|
17
19
|
|
@@ -85,6 +87,8 @@ module EntityRESTHelpers
|
|
85
87
|
|
86
88
|
if (file = dir[entity_type]).exists?
|
87
89
|
lists = Open.read(file).split("\n")
|
90
|
+
ddd lists
|
91
|
+
ddd list
|
88
92
|
lists -= [list]
|
89
93
|
if lists.any?
|
90
94
|
Open.write(file, lists * "\n")
|
@@ -128,7 +132,6 @@ module EntityRESTHelpers
|
|
128
132
|
maps = [map]
|
129
133
|
Open.write(file, maps * "\n")
|
130
134
|
end
|
131
|
-
ddd favourite_entity_maps
|
132
135
|
end
|
133
136
|
|
134
137
|
def remove_favourite_entity_map(entity_type, column, map)
|
@@ -1,6 +1,18 @@
|
|
1
1
|
|
2
2
|
module EntityRESTHelpers
|
3
3
|
|
4
|
+
def list_hash(list)
|
5
|
+
return {:entities => list} unless list.respond_to? :base_entity
|
6
|
+
info = list.info
|
7
|
+
info.delete :annotation_types
|
8
|
+
info.delete :annotated_array
|
9
|
+
{:entities => list, :info => list.info, :entity_type => list.base_entity}
|
10
|
+
end
|
11
|
+
|
12
|
+
def list_json(list)
|
13
|
+
list_hash(list).to_json
|
14
|
+
end
|
15
|
+
|
4
16
|
def list(list, list_id = nil, text = nil)
|
5
17
|
partial_render('entity_partials/entity_list', :list => list, :list_id => list_id, :text => text)
|
6
18
|
end
|
@@ -37,7 +37,7 @@ module Entity
|
|
37
37
|
klasses = []
|
38
38
|
klasses << base_type.to_s if base_type
|
39
39
|
klasses << format if self.respond_to? :format and format
|
40
|
-
klasses.collect{|klass| klass.gsub(
|
40
|
+
klasses.collect{|klass| klass.gsub(/[^\w]/, '_') }
|
41
41
|
end
|
42
42
|
|
43
43
|
def entity_type
|
@@ -131,7 +131,11 @@ module Entity
|
|
131
131
|
attributes[:href] = Entity::REST.entity_url(self, entity_type.to_s, link_params)
|
132
132
|
attributes["attr-entity_id"] = self.to_s
|
133
133
|
|
134
|
-
|
134
|
+
begin
|
135
|
+
text = self.respond_to?(:name)? self.name || self : self if text.nil?
|
136
|
+
rescue
|
137
|
+
text = self
|
138
|
+
end
|
135
139
|
attributes[:title] = text if attributes[:title].nil?
|
136
140
|
|
137
141
|
Misc.html_tag('a', text, attributes)
|