rbbt-views 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rbbt/workflow/rest.rb +142 -57
- data/lib/rbbt/workflow/rest/auth.rb +3 -2
- data/lib/rbbt/workflow/rest/client.rb +4 -1
- data/lib/rbbt/workflow/rest/email.rb +23 -0
- data/lib/rbbt/workflow/rest/entity.rb +87 -62
- data/lib/rbbt/workflow/rest/helpers.rb +38 -0
- data/lib/rbbt/workflow/rest/render.rb +532 -153
- data/lib/rbbt/workflow/rest/util.rb +81 -104
- data/share/views/compass/_base.sass +0 -3
- data/share/views/compass/app.sass +0 -103
- data/share/views/compass/compass.config +5 -5
- data/share/views/compass/layout.sass +133 -0
- data/share/views/compass/main.sass +28 -5
- data/share/views/entity/GOTerm.haml +15 -0
- data/share/views/entity/Gene.haml +7 -0
- data/share/views/entity/GenomicMutation.haml +10 -0
- data/share/views/entity/KeggPathway.haml +13 -0
- data/share/views/entity/MutatedIsoform.haml +43 -0
- data/share/views/entity/NCIBioCartaPathways.haml +9 -0
- data/share/views/entity/NCINaturePathways.haml +9 -0
- data/share/views/entity/NCIReactomePathways.haml +9 -0
- data/share/views/entity/PfamDomain.haml +1 -0
- data/share/views/entity_list/Default.haml +10 -0
- data/share/views/form.haml +2 -54
- data/share/views/front.haml +1 -0
- data/share/views/job_list.haml +1 -1
- data/share/views/js/app.js +122 -68
- data/share/views/layout.haml +28 -22
- data/share/views/partials/_form.haml +36 -0
- data/share/views/partials/_job_control.haml +8 -8
- data/share/views/partials/_result_table.haml +12 -40
- data/share/views/partials/_result_table_controls.haml +36 -28
- data/share/views/partials/_table.haml +39 -0
- data/share/views/public/favicon.gif +0 -0
- data/share/views/public/plugins/jmol/CHANGES.txt +11124 -0
- data/share/views/public/plugins/jmol/COPYRIGHT.txt +73 -0
- data/share/views/public/plugins/jmol/ChimeToJmol.jar +0 -0
- data/share/views/public/plugins/jmol/Jmol.jar +0 -0
- data/share/views/public/plugins/jmol/Jmol.js +1711 -0
- data/share/views/public/plugins/jmol/JmolApplet.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_Console.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_Minimize.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_Popup.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_ReadersCifPdb.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_ReadersMolXyz.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_ReadersMore.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_ReadersQuantum.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_ReadersSimple.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_ReadersXml.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_ReadersXtal.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_ShapeBio.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_ShapeSpecial.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_ShapeSurface.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_Smiles.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_Symmetry.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_ar.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_bs.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_ca.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_cs.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_da.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_de.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_el.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_en_GB.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_es.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_et.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_fi.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_fr.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_fy.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_hu.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_hy.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_id.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_it.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_jv.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_ko.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_ms.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_nb.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_nl.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_oc.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_pl.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_pt.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_pt_BR.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_ru.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_sl.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_sv.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_ta.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_te.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_tr.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_uk.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_zh_CN.jar +0 -0
- data/share/views/public/plugins/jmol/JmolApplet0_i18n_zh_TW.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_Console.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_Minimize.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_MultiTouch.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_Popup.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersCifPdb.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersMolXyz.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersMore.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersQuantum.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersSimple.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersXml.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersXtal.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_ShapeBio.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_ShapeSpecial.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_ShapeSurface.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_Smiles.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_Symmetry.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_ar.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_bs.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_ca.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_cs.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_da.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_de.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_el.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_en_GB.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_es.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_et.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_fi.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_fr.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_fy.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_hu.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_hy.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_id.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_it.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_jv.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_ko.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_ms.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_nb.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_nl.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_oc.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_pl.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_pt.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_pt_BR.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_ru.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_sl.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_sv.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_ta.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_te.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_tr.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_uk.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_zh_CN.jar +0 -0
- data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_zh_TW.jar +0 -0
- data/share/views/public/plugins/jmol/JmolData.jar +0 -0
- data/share/views/public/plugins/jmol/LEAME.txt +217 -0
- data/share/views/public/plugins/jmol/LICENSE.txt +504 -0
- data/share/views/public/plugins/jmol/README.txt +203 -0
- data/share/views/public/plugins/jmol/jmol +22 -0
- data/share/views/public/plugins/jmol/jmol.bat +5 -0
- data/share/views/public/plugins/jmol/jmol.mac +0 -0
- data/share/views/public/plugins/jmol/jmol.sh +39 -0
- data/share/views/public/plugins/jquery/js/jquery.form.js +980 -0
- data/share/views/result.haml +2 -2
- metadata +139 -6
- data/share/views/workflow_list.haml +0 -5
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
module RbbtHTMLHelpers
|
3
|
+
def input(type, name, options = {})
|
4
|
+
id, hide, value, klass, default, description = Misc.process_options options, :id, :hide, :value, :class, :default, :description
|
5
|
+
str = "<div class='form_input' id='#{ id }'>"
|
6
|
+
|
7
|
+
if hide
|
8
|
+
str << "<input #{"id='#{ id }'" if id} type='hidden' name='#{ name }' #{"class='#{ klass }'" if klass} #{"value='#{ value }'" if value}/>" << '</div>' << "\n"
|
9
|
+
return str
|
10
|
+
end
|
11
|
+
|
12
|
+
case type
|
13
|
+
when :boolean
|
14
|
+
not_value = ! value
|
15
|
+
str << "<label #{"for='#{ id }" if id}'><span class='input_name'>#{ name }</span>#{": <span class='input_description'>#{ description }</span>" if description}</label>" << "\n"
|
16
|
+
str << "<input type='radio' id='input_#{id}_true' name='#{ name }' value='true' #{"checked='true'" if value}>" << "\n"
|
17
|
+
str << "<label type='radio_option radio_true' for='input_#{id}_true' name='#{ name }'>true</label>" << "\n"
|
18
|
+
str << "<input type='radio' id='input_#{id}_false' name='#{ name }' value='false' #{"checked='false'" if not value}>" << "\n"
|
19
|
+
str << "<label type='radio_option radio_false' for='input_#{id}_false' name='#{ name }'>false</label>" << "\n"
|
20
|
+
str << "</div>"
|
21
|
+
str
|
22
|
+
when :string, :float, :integer
|
23
|
+
str << "<label #{"for='#{ id }" if id}'><span class='input_name'>#{ name }</span>#{": <span class='input_description'>#{ description }</span>" if description}#{": <span class='input_default'>(Default: #{ default })</span>" if default}</label>" << "\n"
|
24
|
+
str << "<input #{"class='#{klass ? klass : "#{ name } #{ type }" }'"} #{"id='#{ id }'" if id} name='#{ name }' #{"value='#{ value }'" if value}/>" << "\n"
|
25
|
+
str << "</div>"
|
26
|
+
str
|
27
|
+
when :tsv, :array, :text
|
28
|
+
str << "<label #{"for='#{ id }" if id}'><span class='input_name'>#{ name }</span>#{": <span class='input_description'>#{ description }</span>" if description}#{": <span class='input_default'>(Default: #{ default })</span>" if default}</label>" << "\n"
|
29
|
+
str << "<p>"
|
30
|
+
str << "<input type='file' #{"class='#{klass ? klass : "#{ name } #{ type }" }'"} #{"id='input_#{ id }_tsv_file'" if id} name='#{ name }_param_file' #{"value='#{ value }'" if value}/>" << "\n"
|
31
|
+
str << "<span class='tsv_textarea_note note'>(or use text area bellow)</span>"
|
32
|
+
str << "</p>"
|
33
|
+
str << "<textarea #{"class='#{klass ? klass : "#{ name } #{ type }" }'"} name='#{ name }' #{"id='input_#{ id }'" if id}></textarea>"
|
34
|
+
str << "</div>"
|
35
|
+
str
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,209 +1,588 @@
|
|
1
|
-
require 'rbbt/
|
1
|
+
require 'rbbt/entity'
|
2
|
+
|
3
|
+
module RbbtHTMLHelpers
|
4
|
+
PAGESIZE = 25
|
5
|
+
|
6
|
+
def self.locate_file(workflow, task, file)
|
7
|
+
file = case
|
8
|
+
when file =~ /\.[a-z]{2,4}$/
|
9
|
+
file
|
10
|
+
when file =~ /(.*)\/$/
|
11
|
+
$1
|
12
|
+
else
|
13
|
+
file + '.haml'
|
14
|
+
end
|
15
|
+
|
16
|
+
webapp_dir_views = Rbbt.www.views.find(:lib, Sinatra::Application.root)
|
17
|
+
workflow_dir_views = (workflow.nil? or workflow.libdir.nil?) ? nil : workflow.libdir.www.views
|
18
|
+
global_views = Rbbt.share.views
|
19
|
+
|
20
|
+
# workflow = workflow.to_s unless workflow.nil? or String === workflow
|
21
|
+
|
22
|
+
path = case
|
23
|
+
when webapp_dir_views[workflow][task][file].exists?
|
24
|
+
webapp_dir_views[workflow][task][file]
|
25
|
+
when webapp_dir_views[task][file].exists?
|
26
|
+
webapp_dir_views[task][file]
|
27
|
+
when webapp_dir_views[workflow][file].exists?
|
28
|
+
webapp_dir_views[workflow][file]
|
29
|
+
when webapp_dir_views[file].exists?
|
30
|
+
webapp_dir_views[file]
|
31
|
+
|
32
|
+
when (not workflow_dir_views.nil? and workflow_dir_views[workflow][task][file].exists?)
|
33
|
+
workflow_dir_views[workflow][task][file]
|
34
|
+
when (not workflow_dir_views.nil? and workflow_dir_views[task][file].exists?)
|
35
|
+
workflow_dir_views[task][file]
|
36
|
+
when (not workflow_dir_views.nil? and workflow_dir_views[workflow][file].exists?)
|
37
|
+
workflow_dir_views[workflow][file]
|
38
|
+
when (not workflow_dir_views.nil? and workflow_dir_views[file].exists?)
|
39
|
+
workflow_dir_views[file]
|
40
|
+
|
41
|
+
when global_views[workflow][task][file].exists?
|
42
|
+
global_views[workflow][task][file]
|
43
|
+
when global_views[task][file].exists?
|
44
|
+
global_views[task][file]
|
45
|
+
when global_views[workflow][file].exists?
|
46
|
+
global_views[workflow][file]
|
47
|
+
when global_views[file].exists?
|
48
|
+
global_views[file]
|
49
|
+
else
|
50
|
+
raise "File not found: #{[workflow, task, file].compact * ", "}"
|
51
|
+
end
|
52
|
+
|
53
|
+
Log.debug "File #{[workflow, task, file].collect{|v| "'#{ v }'"} * ", "} located at #{ path }"
|
54
|
+
path
|
55
|
+
end
|
2
56
|
|
3
|
-
|
4
|
-
|
57
|
+
def locate_file(workflow, task, file)
|
58
|
+
RbbtHTMLHelpers.locate_file(workflow, task, file)
|
59
|
+
end
|
5
60
|
|
6
|
-
PAGESIZE = 25
|
7
61
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
size ||= PAGESIZE
|
15
|
-
[field, num, size]
|
62
|
+
def parse_page(page)
|
63
|
+
field, num, size = page.split("~").values_at 0, 1, 2
|
64
|
+
if num.nil?
|
65
|
+
num = field
|
66
|
+
field = "key"
|
16
67
|
end
|
68
|
+
size ||= PAGESIZE
|
69
|
+
[field, num, size]
|
70
|
+
end
|
17
71
|
|
18
|
-
|
19
|
-
|
72
|
+
def paginate(object, page = nil, just_keys = false)
|
73
|
+
return object unless TSV === object and not page.nil?
|
20
74
|
|
21
|
-
|
22
|
-
|
23
|
-
field, num, size = parse_page(page)
|
75
|
+
return object if page == "all" or page.nil?
|
76
|
+
field, num, size = parse_page(page)
|
24
77
|
|
25
|
-
|
78
|
+
entity = Entity.formats[field]
|
26
79
|
|
27
|
-
|
28
|
-
|
29
|
-
|
80
|
+
num = num.to_i
|
81
|
+
size = size.to_i
|
82
|
+
max = object.size / size + 1
|
30
83
|
|
31
|
-
|
32
|
-
|
84
|
+
num = max if num > max
|
85
|
+
num = - max if num < - max
|
33
86
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
87
|
+
if entity and entity.respond_to? :tsv_sort
|
88
|
+
object.page(num, size, field, just_keys, &entity.method(:tsv_sort))
|
89
|
+
else
|
90
|
+
object.page(num, size, field, just_keys)
|
39
91
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
curried_proc = Proc.new{|entity|
|
55
|
-
filter_proc.call(query, type, options.merge(:tsv => result, :field => field), entity)
|
56
|
-
}
|
57
|
-
end
|
58
|
-
rows = rows.select field => curried_proc
|
92
|
+
end
|
93
|
+
|
94
|
+
def process_result(result, options)
|
95
|
+
rows = result
|
96
|
+
|
97
|
+
if options.include? :_filter and not options[:_filter].nil?
|
98
|
+
field, query = options[:_filter].split("~")
|
99
|
+
|
100
|
+
entity = Entity.formats[field]
|
101
|
+
|
102
|
+
if entity and entity.respond_to?(:filter)
|
103
|
+
filter_proc = entity.method :filter
|
104
|
+
if filter_proc.respond_to? :curry
|
105
|
+
curried_proc = filter_proc.curry(query, field, options.merge(:tsv => result, :field => field))
|
59
106
|
else
|
60
|
-
|
107
|
+
curried_proc = Proc.new{|entity|
|
108
|
+
filter_proc.call(query, field, options.merge(:tsv => result, :field => field), entity)
|
109
|
+
}
|
61
110
|
end
|
111
|
+
rows = rows.select field => curried_proc
|
112
|
+
else
|
113
|
+
rows = rows.select field => Regexp.new(query)
|
62
114
|
end
|
115
|
+
end
|
63
116
|
|
64
|
-
|
117
|
+
total = rows.size
|
65
118
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
if keys
|
70
|
-
rows = keys.zip(rows.values_at *keys)
|
71
|
-
end
|
119
|
+
options[:_page] = "1" if rows.size > 100 and options[:_page].nil?
|
120
|
+
if options.include?(:_page) and not options[:_page].nil?
|
121
|
+
keys = paginate(rows, options[:_page], true)
|
72
122
|
|
123
|
+
if keys
|
124
|
+
rows = keys.zip(rows.values_at *keys)
|
73
125
|
end
|
74
126
|
|
75
|
-
[rows, total]
|
76
127
|
end
|
77
128
|
|
78
|
-
|
79
|
-
|
129
|
+
[rows, total]
|
130
|
+
end
|
131
|
+
|
132
|
+
#def workflow_render(file, workflow = nil, task = nil, locals = {}, &block)
|
133
|
+
def workflow_render(file, *args, &block)
|
134
|
+
locals = Hash === args.last ? args.pop : {}
|
135
|
+
|
136
|
+
case args.length
|
137
|
+
when 0
|
138
|
+
workflow = locals[:workflow]
|
139
|
+
task = locals[:task]
|
140
|
+
when 1
|
141
|
+
workflow = args.shift
|
142
|
+
task = locals[:task]
|
143
|
+
when 2
|
144
|
+
workflow = args.shift
|
145
|
+
task = args.shift
|
146
|
+
end
|
80
147
|
|
81
|
-
|
82
|
-
|
148
|
+
size = locals.delete(:_size) || locals.delete("_size") || :normal
|
149
|
+
|
150
|
+
case size.to_sym
|
151
|
+
when :normal
|
152
|
+
path = locate_file(workflow, task, file)
|
153
|
+
when :small
|
154
|
+
begin
|
155
|
+
path = locate_file(workflow, task, file + '.small')
|
156
|
+
rescue
|
157
|
+
Log.debug $!.message
|
83
158
|
path = locate_file(workflow, task, file)
|
84
|
-
when :small
|
85
|
-
begin
|
86
|
-
path = locate_file(workflow, task, file + '.small')
|
87
|
-
rescue
|
88
|
-
Log.debug $!.message
|
89
|
-
path = locate_file(workflow, task, file)
|
90
|
-
end
|
91
159
|
end
|
160
|
+
end
|
92
161
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
headers "AJAX-URL" => request.env["REQUEST_URI"]
|
162
|
+
layout = locals[:_layout]
|
163
|
+
layout = false if locals[:_xhr] and layout.nil?
|
164
|
+
layout = true if layout.nil?
|
97
165
|
|
98
|
-
|
166
|
+
locals = Misc.add_defaults locals, :workflow => workflow, :task => task
|
99
167
|
|
100
|
-
|
168
|
+
renderer = Haml::Engine.new(path.read)
|
101
169
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
109
|
-
else
|
110
|
-
renderer.render(self, locals, &block)
|
170
|
+
case
|
171
|
+
when (not layout)
|
172
|
+
renderer.render(self, locals, &block)
|
173
|
+
when (not block_given?)
|
174
|
+
workflow_render("layout", workflow, task, locals) do
|
175
|
+
renderer.render(self, locals)
|
111
176
|
end
|
177
|
+
else
|
178
|
+
renderer.render(self, locals, &block)
|
112
179
|
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def workflow_partial(file, *args)
|
183
|
+
locals = Hash === args.last ? args.pop : {}
|
184
|
+
|
185
|
+
case args.length
|
186
|
+
when 0
|
187
|
+
workflow = locals[:workflow]
|
188
|
+
task = locals[:task]
|
189
|
+
when 1
|
190
|
+
workflow = args.shift
|
191
|
+
task = locals[:task]
|
192
|
+
when 2
|
193
|
+
workflow = args.shift
|
194
|
+
task = args.shift
|
195
|
+
end
|
196
|
+
|
197
|
+
workflow_render(file, workflow, task, locals.merge(:_layout => false))
|
198
|
+
end
|
113
199
|
|
114
|
-
|
115
|
-
|
200
|
+
def workflow_render_result(result, *args)
|
201
|
+
options = Hash === args.last ? args.pop : {}
|
202
|
+
|
203
|
+
case args.length
|
204
|
+
when 0
|
205
|
+
workflow = options[:workflow]
|
206
|
+
task = options[:task]
|
207
|
+
when 1
|
208
|
+
workflow = args.shift
|
209
|
+
task = options[:task]
|
210
|
+
when 2
|
211
|
+
workflow = args.shift
|
212
|
+
task = args.shift
|
116
213
|
end
|
117
214
|
|
118
|
-
def workflow_render_result(workflow, task_name, result, options = {})
|
119
|
-
format = options[:_format]
|
120
|
-
page = options[:_page]
|
121
215
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
216
|
+
format = options[:_format]
|
217
|
+
page = options[:_page]
|
218
|
+
|
219
|
+
case
|
220
|
+
when format.to_sym == :raw
|
221
|
+
content_type "text/plain"
|
222
|
+
if Array === result
|
223
|
+
result * "\n"
|
224
|
+
else
|
225
|
+
result.to_s
|
226
|
+
end
|
227
|
+
when format.to_sym == :json
|
228
|
+
content_type "application/json"
|
229
|
+
if TSV === result
|
230
|
+
result = paginate(result, page)
|
231
|
+
result.to_json
|
232
|
+
else
|
233
|
+
result.to_json
|
234
|
+
end
|
235
|
+
when format.to_sym == :html
|
236
|
+
content_type "text/html"
|
237
|
+
options = Misc.add_defaults options, workflow.task_info(task)
|
238
|
+
options = Misc.add_defaults options, :result => result, :workflow => workflow, :task => task
|
239
|
+
workflow_render("result", workflow, task, options)
|
240
|
+
else
|
241
|
+
raise "Unkonwn format: #{format}"
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def entity_render(type, locals, &block)
|
246
|
+
type, format = type.split ":"
|
247
|
+
|
248
|
+
size = locals.delete(:_size) || locals.delete("_size") || :normal
|
249
|
+
|
250
|
+
workflow = WorkflowREST.workflows.last
|
251
|
+
|
252
|
+
entity = locals[:entity]
|
253
|
+
|
254
|
+
entity_class = case
|
255
|
+
when Entity.formats.include?(format)
|
256
|
+
Entity.formats[format]
|
257
|
+
when Entity.formats.include?(type)
|
258
|
+
Entity.formats[type]
|
259
|
+
else
|
260
|
+
nil
|
261
|
+
end
|
262
|
+
|
263
|
+
path = case
|
264
|
+
when (entity.respond_to? :template and not entity.template.nil?)
|
265
|
+
entity.template
|
266
|
+
when (entity_class.respond_to? :template and not entity_class.template.nil?)
|
267
|
+
entity_class.template
|
268
|
+
else
|
269
|
+
path = nil
|
270
|
+
|
271
|
+
[format, type].compact.each do |file|
|
272
|
+
break unless path.nil?
|
273
|
+
begin
|
274
|
+
case size.to_sym
|
275
|
+
when :normal
|
276
|
+
file = File.join('entity', file + '.haml')
|
277
|
+
path = locate_file(workflow, nil, file)
|
278
|
+
when :small
|
279
|
+
begin
|
280
|
+
file_small = File.join('entity', file + '.small.haml')
|
281
|
+
path = locate_file(workflow, nil, file_small)
|
282
|
+
rescue
|
283
|
+
Log.debug $!.message
|
284
|
+
file = File.join('entity', file + '.haml')
|
285
|
+
path = locate_file(workflow, nil, file)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
rescue
|
289
|
+
next
|
290
|
+
end
|
291
|
+
end
|
292
|
+
raise "Template not found for type, format: #{[type, format] * ", "}" if path.nil?
|
293
|
+
|
294
|
+
path
|
295
|
+
end
|
296
|
+
|
297
|
+
if entity_class
|
298
|
+
entity_class.setup(entity, *locals.values_at(*entity_class.annotations).collect{|v|
|
299
|
+
case v
|
300
|
+
when "false"
|
301
|
+
false
|
302
|
+
when "true"
|
303
|
+
true
|
127
304
|
else
|
128
|
-
|
305
|
+
v
|
129
306
|
end
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
307
|
+
})
|
308
|
+
entity.format = format if entity.respond_to? :format
|
309
|
+
end
|
310
|
+
|
311
|
+
layout = locals[:_layout]
|
312
|
+
layout = false if locals[:_xhr] and layout.nil?
|
313
|
+
layout = true if layout.nil?
|
314
|
+
|
315
|
+
renderer = Haml::Engine.new(path.read)
|
316
|
+
|
317
|
+
case
|
318
|
+
when (not layout)
|
319
|
+
renderer.render(self, locals, &block)
|
320
|
+
when (not block_given?)
|
321
|
+
workflow_render("layout", nil, nil, locals) do
|
322
|
+
renderer.render(self, locals)
|
323
|
+
end
|
324
|
+
else
|
325
|
+
renderer.render(self, locals, &block)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
def entity_action_render(type, action, locals, &block)
|
330
|
+
type, format = type.split ":"
|
331
|
+
|
332
|
+
size = locals.delete(:_size) || locals.delete("_size") || :normal
|
333
|
+
|
334
|
+
workflow = WorkflowREST.workflows.last
|
335
|
+
|
336
|
+
entity = locals[:entity]
|
337
|
+
|
338
|
+
entity_class = case
|
339
|
+
when Entity.formats.include?(format)
|
340
|
+
Entity.formats[format]
|
341
|
+
when Entity.formats.include?(type)
|
342
|
+
Entity.formats[type]
|
343
|
+
else
|
344
|
+
nil
|
345
|
+
end
|
346
|
+
|
347
|
+
path = case
|
348
|
+
when (entity.respond_to? :action_template and Hash === entity.action_template and not entity.action_template[action].nil?)
|
349
|
+
entity.action_template[action]
|
350
|
+
when (entity_class.respond_to? :action_template and Hash === entity_class.action_template and not entity_class.action_template[action].nil?)
|
351
|
+
entity_class.action_template[action]
|
352
|
+
else
|
353
|
+
path = nil
|
354
|
+
|
355
|
+
[format, type].compact.each do |file|
|
356
|
+
break unless path.nil?
|
357
|
+
file = File.join(file, action)
|
358
|
+
begin
|
359
|
+
case size.to_sym
|
360
|
+
when :normal
|
361
|
+
file = File.join('entity', file + '.haml')
|
362
|
+
path = locate_file(workflow, nil, file)
|
363
|
+
when :small
|
364
|
+
begin
|
365
|
+
file_small = File.join('entity', file + '.small.haml')
|
366
|
+
path = locate_file(workflow, nil, file_small)
|
367
|
+
rescue
|
368
|
+
Log.debug $!.message
|
369
|
+
file = File.join('entity', file + '.haml')
|
370
|
+
path = locate_file(workflow, nil, file)
|
371
|
+
end
|
372
|
+
end
|
373
|
+
rescue
|
374
|
+
next
|
375
|
+
end
|
376
|
+
end
|
377
|
+
raise "Action Template not found for type, format, action: #{[type, format, action] * ", "}" if path.nil?
|
378
|
+
path
|
379
|
+
end
|
380
|
+
|
381
|
+
if entity_class
|
382
|
+
entity_class.setup(entity, *locals.values_at(*entity_class.annotations).collect{|v|
|
383
|
+
case v
|
384
|
+
when "false"
|
385
|
+
false
|
386
|
+
when "true"
|
387
|
+
true
|
135
388
|
else
|
136
|
-
|
389
|
+
v
|
137
390
|
end
|
138
|
-
|
139
|
-
|
140
|
-
options = Misc.add_defaults options, workflow.task_info(task_name)
|
141
|
-
options = Misc.add_defaults options, :result => result, :workflow => workflow, :task_name => task_name
|
142
|
-
workflow_render(workflow, task_name, "result", options)
|
143
|
-
else
|
144
|
-
raise "Unkonwn format: #{format}"
|
145
|
-
end
|
391
|
+
})
|
392
|
+
entity.format = format if entity.respond_to? :format
|
146
393
|
end
|
147
394
|
|
148
|
-
|
149
|
-
|
395
|
+
layout = locals[:_layout]
|
396
|
+
layout = false if locals[:_xhr] and layout.nil?
|
397
|
+
layout = true if layout.nil?
|
150
398
|
|
151
|
-
|
399
|
+
renderer = Haml::Engine.new(path.read)
|
152
400
|
|
153
|
-
|
154
|
-
|
401
|
+
case
|
402
|
+
when (not layout)
|
403
|
+
renderer.render(self, locals, &block)
|
404
|
+
when (not block_given?)
|
405
|
+
workflow_render("layout", nil, nil, locals) do
|
406
|
+
renderer.render(self, locals)
|
407
|
+
end
|
408
|
+
else
|
409
|
+
renderer.render(self, locals, &block)
|
410
|
+
end
|
411
|
+
end
|
155
412
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
413
|
+
def entity_list_render(type, locals, &block)
|
414
|
+
type, format = type.split ":"
|
415
|
+
|
416
|
+
size = locals.delete(:_size) || locals.delete("_size") || :normal
|
417
|
+
|
418
|
+
workflow = WorkflowREST.workflows.last
|
419
|
+
|
420
|
+
list = locals[:list] = Entity::REST.load_list(locals[:id])
|
421
|
+
|
422
|
+
entity_class = case
|
423
|
+
when Entity.formats.include?(format)
|
424
|
+
Entity.formats[format]
|
425
|
+
when Entity.formats.include?(type)
|
426
|
+
Entity.formats[type]
|
427
|
+
else
|
428
|
+
nil
|
429
|
+
end
|
430
|
+
|
431
|
+
path = case
|
432
|
+
when (list.respond_to? :list_template and not list.list_template.nil?)
|
433
|
+
list.list_template
|
434
|
+
when (entity_class.respond_to? :list_template and not entity_class.list_template.nil?)
|
435
|
+
entity_class.list_template
|
436
|
+
else
|
437
|
+
path = nil
|
438
|
+
|
439
|
+
[format, type].compact.each do |file|
|
440
|
+
break unless path.nil?
|
441
|
+
begin
|
442
|
+
case size.to_sym
|
443
|
+
when :normal
|
444
|
+
file = File.join('entity_list', file + '.haml')
|
445
|
+
path = locate_file(workflow, nil, file)
|
446
|
+
when :small
|
447
|
+
begin
|
448
|
+
file_small = File.join('entity_list', file + '.small.haml')
|
449
|
+
path = locate_file(workflow, nil, file_small)
|
450
|
+
rescue
|
451
|
+
Log.debug $!.message
|
452
|
+
file = File.join('entity_list', file + '.haml')
|
453
|
+
path = locate_file(workflow, nil, file)
|
454
|
+
end
|
455
|
+
end
|
456
|
+
rescue
|
457
|
+
next
|
458
|
+
end
|
459
|
+
end
|
460
|
+
raise "List Template not found for type, format: #{[type, format] * ", "}" if path.nil?
|
461
|
+
path
|
462
|
+
end
|
463
|
+
|
464
|
+
if entity_class
|
465
|
+
entity_class.setup(list, *locals.values_at(*entity_class.annotations).collect{|v|
|
466
|
+
case v
|
467
|
+
when "false"
|
468
|
+
false
|
469
|
+
when "true"
|
470
|
+
true
|
471
|
+
else
|
472
|
+
v
|
179
473
|
end
|
474
|
+
})
|
475
|
+
list.format = format if list.respond_to? :format
|
476
|
+
end
|
180
477
|
|
181
|
-
|
182
|
-
|
478
|
+
layout = locals[:_layout]
|
479
|
+
layout = false if locals[:_xhr] and layout.nil?
|
480
|
+
layout = true if layout.nil?
|
183
481
|
|
184
|
-
|
185
|
-
|
186
|
-
|
482
|
+
renderer = Haml::Engine.new(path.read)
|
483
|
+
|
484
|
+
case
|
485
|
+
when (not layout)
|
486
|
+
renderer.render(self, locals, &block)
|
487
|
+
when (not block_given?)
|
488
|
+
workflow_render("layout", nil, nil, locals) do
|
489
|
+
renderer.render(self, locals)
|
187
490
|
end
|
491
|
+
else
|
492
|
+
renderer.render(self, locals, &block)
|
493
|
+
end
|
494
|
+
end
|
188
495
|
|
189
|
-
|
190
|
-
|
496
|
+
|
497
|
+
|
498
|
+
def entity_list_action_render(type, action, locals, &block)
|
499
|
+
type, format = type.split ":"
|
500
|
+
|
501
|
+
size = locals.delete(:_size) || locals.delete("_size") || :normal
|
502
|
+
|
503
|
+
workflow = WorkflowREST.workflows.last
|
504
|
+
|
505
|
+
list = locals[:list] = Entity::REST.load_list(locals[:id])
|
506
|
+
|
507
|
+
entity_class = case
|
508
|
+
when Entity.formats.include?(format)
|
509
|
+
Entity.formats[format]
|
510
|
+
when Entity.formats.include?(type)
|
511
|
+
Entity.formats[type]
|
512
|
+
else
|
513
|
+
nil
|
514
|
+
end
|
515
|
+
|
516
|
+
path = case
|
517
|
+
when (list.respond_to? :list_action_template and Hash === list.list_action_template and not list.list_action_template[action].nil?)
|
518
|
+
list.list_action_template[action]
|
519
|
+
when (entity_class.respond_to? :list_action_template and Hash === entity_class.list_action_template and not entity_class.list_action_template[action].nil?)
|
520
|
+
entity_class.list_action_template[action]
|
521
|
+
else
|
522
|
+
path = nil
|
523
|
+
|
524
|
+
[format, type].compact.each do |file|
|
525
|
+
break unless path.nil?
|
526
|
+
file = File.join(file, action)
|
527
|
+
begin
|
528
|
+
case size.to_sym
|
529
|
+
when :normal
|
530
|
+
file = File.join('entity_list', file + '.haml')
|
531
|
+
path = locate_file(workflow, nil, file)
|
532
|
+
when :small
|
533
|
+
begin
|
534
|
+
file_small = File.join('entity_list', file + '.small.haml')
|
535
|
+
path = locate_file(workflow, nil, file_small)
|
536
|
+
rescue
|
537
|
+
Log.debug $!.message
|
538
|
+
file = File.join('entity_list', file + '.haml')
|
539
|
+
path = locate_file(workflow, nil, file)
|
540
|
+
end
|
541
|
+
end
|
542
|
+
rescue
|
543
|
+
next
|
544
|
+
end
|
545
|
+
end
|
546
|
+
raise "List Template not found for type, format: #{[type, format] * ", "}" if path.nil?
|
547
|
+
path
|
548
|
+
end
|
549
|
+
|
550
|
+
if entity_class
|
551
|
+
entity_class.setup(list, *locals.values_at(*entity_class.annotations).collect{|v|
|
552
|
+
case v
|
553
|
+
when "false"
|
554
|
+
false
|
555
|
+
when "true"
|
556
|
+
true
|
557
|
+
else
|
558
|
+
v
|
559
|
+
end
|
560
|
+
})
|
561
|
+
list.format = format if list.respond_to? :format
|
562
|
+
end
|
191
563
|
|
192
|
-
|
564
|
+
layout = locals[:_layout]
|
565
|
+
layout = false if locals[:_xhr] and layout.nil?
|
566
|
+
layout = true if layout.nil?
|
193
567
|
|
194
|
-
|
568
|
+
renderer = Haml::Engine.new(path.read)
|
195
569
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
end
|
203
|
-
else
|
204
|
-
renderer.render(self, locals, &block)
|
570
|
+
case
|
571
|
+
when (not layout)
|
572
|
+
renderer.render(self, locals, &block)
|
573
|
+
when (not block_given?)
|
574
|
+
workflow_render("layout", nil, nil, locals) do
|
575
|
+
renderer.render(self, locals)
|
205
576
|
end
|
577
|
+
else
|
578
|
+
renderer.render(self, locals, &block)
|
206
579
|
end
|
580
|
+
|
581
|
+
end
|
582
|
+
end
|
207
583
|
|
584
|
+
module Sinatra
|
585
|
+
module SinatraRbbt
|
586
|
+
include RbbtHTMLHelpers
|
208
587
|
end
|
209
588
|
end
|