ruote-kit 2.1.10 → 2.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG.txt +10 -0
  3. data/Gemfile +21 -5
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +132 -80
  6. data/Rakefile +4 -15
  7. data/TODO.txt +12 -0
  8. data/config.ru +22 -14
  9. data/lib/ruote-kit/application.rb +46 -22
  10. data/lib/ruote-kit/helpers/json_helpers.rb +280 -0
  11. data/lib/ruote-kit/helpers/link_helpers.rb +117 -0
  12. data/lib/ruote-kit/helpers/misc_helpers.rb +35 -0
  13. data/lib/ruote-kit/helpers/pagination_helpers.rb +30 -0
  14. data/lib/ruote-kit/helpers/render_helpers.rb +39 -92
  15. data/lib/ruote-kit/public/_ruote/images/favicon.ico +0 -0
  16. data/lib/ruote-kit/public/_ruote/images/ruote.png +0 -0
  17. data/lib/ruote-kit/public/_ruote/images/ruote_buttons.png +0 -0
  18. data/lib/ruote-kit/public/_ruote/javascripts/jquery-1.4.2.min.js +154 -0
  19. data/lib/ruote-kit/public/_ruote/javascripts/rk.js +40 -0
  20. data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo-editor.js +548 -0
  21. data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo.js +32 -1
  22. data/lib/ruote-kit/public/_ruote/stylesheets/reset.css +53 -0
  23. data/lib/ruote-kit/public/_ruote/stylesheets/rk.css +355 -16
  24. data/lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo-editor.css +108 -0
  25. data/lib/ruote-kit/resources/errors.rb +46 -43
  26. data/lib/ruote-kit/resources/expressions.rb +92 -35
  27. data/lib/ruote-kit/resources/participants.rb +53 -0
  28. data/lib/ruote-kit/resources/processes.rb +68 -36
  29. data/lib/ruote-kit/resources/schedules.rb +27 -0
  30. data/lib/ruote-kit/resources/workitems.rb +93 -31
  31. data/lib/ruote-kit/spec/ruote_helpers.rb +25 -16
  32. data/lib/ruote-kit/version.rb +3 -1
  33. data/lib/ruote-kit/views/_pagination.html.haml +38 -0
  34. data/lib/ruote-kit/views/_tree_editor.html.haml +52 -0
  35. data/lib/ruote-kit/views/error.html.haml +69 -0
  36. data/lib/ruote-kit/views/errors.html.haml +28 -12
  37. data/lib/ruote-kit/views/expression.html.haml +161 -30
  38. data/lib/ruote-kit/views/expressions.html.haml +26 -21
  39. data/lib/ruote-kit/views/http_error.html.haml +11 -0
  40. data/lib/ruote-kit/views/index.html.haml +4 -0
  41. data/lib/ruote-kit/views/layout.html.haml +52 -32
  42. data/lib/ruote-kit/views/participants.html.haml +79 -0
  43. data/lib/ruote-kit/views/process.html.haml +109 -42
  44. data/lib/ruote-kit/views/process_launched.html.haml +6 -2
  45. data/lib/ruote-kit/views/processes.html.haml +55 -24
  46. data/lib/ruote-kit/views/processes_new.html.haml +36 -0
  47. data/lib/ruote-kit/views/schedules.html.haml +42 -0
  48. data/lib/ruote-kit/views/workitem.html.haml +83 -29
  49. data/lib/ruote-kit/views/workitems.html.haml +42 -19
  50. data/lib/ruote-kit.rb +17 -88
  51. data/ruote-kit.gemspec +68 -80
  52. data/spec/it_has_an_engine.rb +69 -0
  53. data/spec/resources/errors_spec.rb +198 -270
  54. data/spec/resources/expressions_spec.rb +308 -52
  55. data/spec/resources/index_spec.rb +28 -16
  56. data/spec/resources/participants_spec.rb +102 -0
  57. data/spec/resources/processes_spec.rb +218 -104
  58. data/spec/resources/schedules_spec.rb +97 -0
  59. data/spec/resources/workitems_spec.rb +195 -100
  60. data/spec/ruote-kit_configure_spec.rb +32 -75
  61. data/spec/spec.opts +0 -1
  62. data/spec/spec_helper.rb +31 -92
  63. data/spec/webapp_helpers_spec.rb +309 -0
  64. metadata +87 -152
  65. data/lib/ruote-kit/configuration.rb +0 -83
  66. data/lib/ruote-kit/helpers/engine_helpers.rb +0 -24
  67. data/lib/ruote-kit/helpers/form_helpers.rb +0 -11
  68. data/lib/ruote-kit/helpers/launch_item_parser.rb +0 -59
  69. data/lib/ruote-kit/helpers/navigation_helpers.rb +0 -54
  70. data/lib/ruote-kit/helpers.rb +0 -9
  71. data/lib/ruote-kit/public/_ruote/images/bg.gif +0 -0
  72. data/lib/ruote-kit/public/_ruote/images/bg_button_left.gif +0 -0
  73. data/lib/ruote-kit/public/_ruote/images/bg_button_left_cancel.gif +0 -0
  74. data/lib/ruote-kit/public/_ruote/images/bg_button_left_submit.gif +0 -0
  75. data/lib/ruote-kit/public/_ruote/images/bg_button_right.gif +0 -0
  76. data/lib/ruote-kit/public/_ruote/javascripts/SimplyButtons.js +0 -191
  77. data/lib/ruote-kit/public/_ruote/javascripts/fluo-dial.js +0 -149
  78. data/lib/ruote-kit/public/_ruote/stylesheets/SimplyButtons.css +0 -226
  79. data/lib/ruote-kit/public/_ruote/stylesheets/base.css +0 -336
  80. data/lib/ruote-kit/public/_ruote/stylesheets/style.css +0 -393
  81. data/lib/ruote-kit/views/launch_process.html.haml +0 -19
  82. data/lib/ruote-kit/views/process_failed_to_launch.html.haml +0 -7
  83. data/lib/ruote-kit/views/resource_not_found.html.haml +0 -7
  84. data/spec/helpers/render_helpers_spec.rb +0 -214
  85. data/spec/ruote-kit_spec.rb +0 -4
  86. data/spec/views/expressions.html.haml_spec.rb +0 -31
  87. data/spec/views/launch_process.html.haml_spec.rb +0 -22
  88. data/spec/views/process.html.haml_spec.rb +0 -17
  89. data/spec/views/process_launched.html.haml_spec.rb +0 -16
  90. data/spec/views/processes.html.haml_spec.rb +0 -31
  91. data/spec/views/workitems.html.haml_spec.rb +0 -69
@@ -0,0 +1,69 @@
1
+
2
+ - # under the MIT license, see LICENSE.txt
3
+
4
+ %h1 error #{@error.fei.sid}
5
+
6
+ %table.details
7
+
8
+ %tr
9
+ %td
10
+ id
11
+ %td
12
+ = @error.fei.sid
13
+
14
+ %tr
15
+ %td
16
+ action / direction
17
+ %td
18
+ &= @error.action
19
+
20
+ %tr
21
+ %td
22
+ message
23
+ %td
24
+ &= @error.message
25
+
26
+ %tr
27
+ %td
28
+ trace
29
+ %td
30
+ %pre.trace{ :onclick => 'Rk.toggleNext(this);' } #{h(@error.trace[0, 80] + '...')}
31
+ %pre.trace{ :onclick => 'Rk.toggleNext(this);', :style => 'display: none;' } #{h(@error.trace)}
32
+
33
+ %tr
34
+ %td.no_border{ :colspan => 2 }
35
+  
36
+
37
+ %tr
38
+ %td
39
+ expression
40
+ %td
41
+ GET
42
+ = alink(:expressions, @error.fei.sid)
43
+ %span.explanation
44
+ you can re-apply the expression (and hopefully nuke the error) from there
45
+ %tr
46
+ %td
47
+ process
48
+ %td
49
+ GET
50
+ = alink(:processes, @error.wfid)
51
+ %tr
52
+ %td
53
+ errors of this process
54
+ %td
55
+ GET
56
+ = alink(:errors, @error.wfid)
57
+
58
+ %tr
59
+ %td.no_border{ :colspan => 2 }
60
+  
61
+ %tr
62
+ %td
63
+ %td
64
+ %form{ :method => 'POST' }
65
+ %input{ :type => 'hidden', :name => '_method', :value => 'delete' }
66
+ %input{ :type => 'submit', :value => "DELETE /_ruote/errors/#{@error.fei.sid}", :title => 'replay at this error' }
67
+ %span.explanation
68
+ replay at this error
69
+
@@ -1,18 +1,34 @@
1
1
 
2
- - @_uses_fluo = true
2
+ - # under the MIT license, see LICENSE.txt
3
3
 
4
- %h2 Errors
4
+ %h1 errors
5
5
 
6
- %ul
7
- - @errors.each do |error|
8
- %li #{error.fei.to_storage_id}
9
-
10
- %p  
6
+ = haml :_pagination, :layout => false
11
7
 
12
- %canvas#fluo
8
+ %table.list
9
+
10
+ %thead
11
+ %td
12
+ error
13
+ %td
14
+ process
15
+ %td
16
+ message
17
+ %td
18
+ at
19
+ %td
20
+ action
13
21
 
14
- :javascript
15
- //var proc_rep = #{process_tree( @process )};
16
- //Fluo.renderFlow( 'fluo', proc_rep );
17
- //Fluo.crop('fluo');
22
+ - @errors.each do |error|
23
+ %tr
24
+ %td
25
+ = alink(:errors, error.fei.sid)
26
+ %td
27
+ = alink(:errors, error.wfid)
28
+ %td
29
+ &= error.message
30
+ %td
31
+ = Time.parse(error.at).localtime.strftime('%Y/%m/%d %H:%M:%S')
32
+ %td
33
+ &= error.action
18
34
 
@@ -1,38 +1,169 @@
1
+
2
+ - # under the MIT license, see LICENSE.txt
3
+
1
4
  - @_uses_fluo = true
2
5
 
3
- %h2 Expression #{@expression.fei.wfid}/#{@expression.fei.expid}
4
-
5
- .options
6
- %ul.nolist
7
- %li.b5
8
- %form{ :method => 'post' }
9
- %input{ :type => 'hidden', :name => '_method', :value => 'delete' }
10
- = button "Cancel", "cancel force-block"
11
- %span.description DELETE /_ruote/expressions/#{@expression.fei.wfid}/#{@expression.fei.expid}
12
- %li.b5
13
- %form{ :method => 'post' }
14
- %input{ :type => 'hidden', :name => '_method', :value => 'delete' }
15
- %input{ :type => 'hidden', :name => '_kill', :value => '1' }
16
- = button "Kill", "cancel force-block"
17
- %span.description DELETE /_ruote/expressions/#{@expression.fei.wfid}/#{@expression.fei.expid}?_kill=1
18
-
19
- %ul.nolist
20
- %li id: #{@expression.fei.expid}
21
- %li class: #{@expression.class.name}
22
- %li name: #{@expression.respond_to?(:participant_name) ? @expression.participant_name : @expression.name}
23
- %li process: #{link_to @process}
24
- %li
25
- process expressions:
26
- %a{ :href => "/_ruote/expressions/#{@process.wfid}" } GET /_ruote/expressions/#{@process.wfid}
27
- - if @expression.parent
28
- %li parent expression: #{link_to_expression @expression.parent}
29
-
30
- %p  
6
+ %h1
7
+ expression
8
+ = @expression.fei.sid
31
9
 
32
10
  %canvas#fluo
33
11
 
12
+ %form{ :method => 'POST', :enctype => 'multipart/form-data', :accept_charset => 'UTF-8' }
13
+
14
+ %input#_method{ :type => 'hidden', :name => '_method', :value => 'DELETE' }
15
+ %input{ :type => 'hidden', :name => '_snowman', :value => '☃' }
16
+
17
+ %table.details
18
+
19
+ %tr
20
+ %td
21
+ fei
22
+ %td
23
+ &= @expression.fei.sid
24
+ %tr
25
+ %td
26
+ expid
27
+ %td
28
+ &= @expression.fei.expid
29
+ %tr
30
+ %td
31
+ expression
32
+ %td
33
+ &= @expression.tree.first
34
+ %tr
35
+ %td
36
+ expression class
37
+ %td
38
+ &= @expression.class.to_s
39
+ - if @expression.original_tree != @expression.tree
40
+ %tr
41
+ %td
42
+ original tree
43
+ %td
44
+ - ruby = Ruote::Parser.to_ruby(@expression.original_tree)
45
+ - rubyline = ruby.split("\n").first
46
+ - json = Rufus::Json.pretty_encode(@expression.original_tree)
47
+ %pre.pdef{ :onclick => 'Rk.toggleNext(this);' } #{rubyline}
48
+ %pre.pdef{ :onclick => 'Rk.toggleNext(this);', :style => 'display: none;' } #{ruby}
49
+ %pre.pdef{ :onclick => 'Rk.toggleNext(this);', :style => 'display: none;' } #{json}
50
+ %tr
51
+ %td
52
+ tree
53
+ %td
54
+ - ruby = Ruote::Parser.to_ruby(@expression.tree)
55
+ - rubyline = ruby.split("\n").first
56
+ - json = Rufus::Json.pretty_encode(@expression.tree)
57
+ %pre.pdef{ :onclick => 'Rk.toggleNext(this);' } #{rubyline}
58
+ %pre.pdef{ :onclick => 'Rk.toggleNext(this);', :style => 'display: none;' } #{ruby}
59
+ %pre.pdef{ :onclick => 'Rk.toggleNext(this);', :style => 'display: none;' } #{json}
60
+
61
+ - if sched = @process.schedules.find { |s| s['owner'] == @expression.fei }
62
+ %tr
63
+ %td
64
+ schedule
65
+ %td
66
+ &= sched['type']
67
+ - if sched['at']
68
+ at
69
+ = Time.parse(sched['at']).localtime.strftime('%Y/%m/%d %H:%M:%S')
70
+ %tr
71
+ %td.no_border{ :colspan => 2 }
72
+  
73
+
74
+ %tr
75
+ %td
76
+ process
77
+ %td
78
+ GET
79
+ = alink(:processes, @expression.fei.wfid)
80
+ %tr
81
+ %td
82
+ other expressions
83
+ %td
84
+ GET
85
+ = alink(:expressions, @expression.fei.wfid)
86
+ %tr
87
+ %td
88
+ stored workitem
89
+ %td
90
+ - if workitem = @process.stored_workitems.find { |wi| wi.fei == @expression.fei }
91
+ GET
92
+ = alink(:workitems, @expression.fei.sid)
93
+
94
+ %tr
95
+ %td.no_border{ :colspan => 2 }
96
+  
97
+
98
+ %tr
99
+ %td
100
+ cancel
101
+ %td
102
+ %input{ :type => 'submit', :value => 'cancel', :onclick => 'return confirm("really ?");' }
103
+ %span.description DELETE /_ruote/expressions/#{@expression.fei.sid}
104
+ %tr
105
+ %td
106
+ kill
107
+ %td
108
+ -#%input{ :type => 'hidden', :name => '_kill', :value => '1' }
109
+ %input{ :type => 'submit', :value => 'kill', :onclick => 'return confirm("really ?");' }
110
+ %span.description DELETE /_ruote/expressions/#{@expression.fei.sid}?_kill=1
111
+
112
+ %tr
113
+ %td.no_border{ :colspan => 2 }
114
+  
115
+
116
+ %tr{ :style => 'cursor: pointer;', :onclick => 'showReApply(this);' }
117
+ %td{ :colspan => 2 }
118
+ re-apply
119
+ %tr.re_apply
120
+ %td
121
+ fields
122
+ %td.no_padding
123
+ - fields = @expression.h.applied_workitem['fields']
124
+ - fields.delete('params')
125
+ %textarea{ :name => 'fields', :cols => 70, :rows => 7 } #{Rufus::Json.pretty_encode(fields)}
126
+ %tr.re_apply
127
+ %td
128
+ tree
129
+ %a.ruote_button.ruote_go_button{ :title => 'open process definition editor', :href => '', :onclick => 'showEditor(); return false;' }
130
+ %td.no_padding
131
+ - tree = @expression.tree
132
+ - tree = Rufus::Json.pretty_encode(tree)
133
+ - rows = tree.split("\n").size
134
+ %textarea#tree{ :name => 'tree', :cols => 70, :rows => rows } #{tree}
135
+ %tr.re_apply
136
+ %td
137
+ %td
138
+ -#%input{ :type => 'hidden', :name => '_method', :value => 'put' }
139
+ %input{ :type => 'submit', :value => 're-apply', :onclick => 'return confirmReApply();' }
140
+ %span.description PUT /_ruote/expressions/#{@expression.fei.sid}
141
+
142
+
34
143
  :javascript
35
- var proc_rep = #{process_tree( @process )};
36
- Fluo.renderFlow( 'fluo', proc_rep );
144
+
145
+ var proc_rep = #{process_tree(@process)};
146
+ Fluo.renderFlow('fluo', proc_rep);
37
147
  Fluo.crop('fluo');
38
148
  Fluo.highlight('fluo', '#{@expression.fei.expid}');
149
+ Fluo.resizeForMaxWidth('fluo', $('body').width() / 2.1);
150
+
151
+ $('.re_apply').hide();
152
+
153
+ function showReApply (elt) {
154
+ $(elt).hide();
155
+ $('.re_apply').show();
156
+ }
157
+
158
+ function confirmReApply () {
159
+
160
+ var r = confirm('really ?');
161
+ if (r) $('#_method')[0].value = 'PUT';
162
+
163
+ return r;
164
+ }
165
+
166
+ var tree = #{Rufus::Json.encode(@expression.tree)};
167
+
168
+ = haml :_tree_editor, :layout => false
169
+
@@ -1,30 +1,35 @@
1
+
2
+ - # under the MIT license, see LICENSE.txt
3
+
1
4
  - @_uses_fluo = true
2
5
 
3
- - unless @process
4
- %h2 Expressions
5
- .flash
6
- .message
7
- .notice
8
- %p Expressions are atomic pieces of process instances.
9
- %p Have a look at the <a href="/_ruote/processes">processes</a> and then follow their links to their set of expressions.
6
+ %h1 expressions for #{@process.wfid}
10
7
 
11
- - else
12
- %h2 Expressions for #{@process.wfid}
8
+ %canvas#fluo
13
9
 
14
- %ul.nested_list
15
- - @process.expressions.each do |expression|
16
- %li
17
- = link_to_expression expression
18
- %ul.nested_details
19
- %li id: #{expression.fei.expid}
20
- %li class: #{expression.class.name}
21
- %li name: #{expression.respond_to?(:participant_name) ? expression.participant_name : expression.name}
10
+ %table.list{ :style => 'width: auto;', :onmouseout => "Fluo.highlight('fluo')" }
11
+ %thead
12
+ %td fei
13
+ %td expid
14
+ %td exp
15
+ %td applied
22
16
 
23
- %p &nbsp;
24
17
 
25
- %canvas#fluo
18
+ - @process.expressions.each do |expression|
19
+ %tr{ :onmouseover => "Fluo.highlight('fluo', '#{expression.fei.expid}')" }
20
+ %td
21
+ = alink(:expressions, expression.fei.sid)
22
+ %td
23
+ &= expression.fei.expid
24
+ %td
25
+ &= expression.tree.first
26
+ %td
27
+ = Time.parse(expression.h.put_at).localtime.strftime('%Y/%m/%d %H:%M:%S')
26
28
 
27
29
  :javascript
28
- var proc_rep = #{process_tree( @process )};
29
- Fluo.renderFlow( 'fluo', proc_rep );
30
+
31
+ var proc_rep = #{process_tree(@process)};
32
+ Fluo.renderFlow('fluo', proc_rep);
30
33
  Fluo.crop('fluo');
34
+ Fluo.resizeForMaxWidth('fluo', $('body').width() / 2.1);
35
+
@@ -0,0 +1,11 @@
1
+
2
+ - # under the MIT license, see LICENSE.txt
3
+
4
+ %h1 #{@code} #{@message}
5
+
6
+ - if @trace
7
+ %pre.trace{ :onclick => 'Rk.toggleNext(this);' } #{h(@trace.first.split("\n").first + '...')}
8
+ %pre.trace{ :onclick => 'Rk.toggleNext(this);', :style => 'display: none;' } #{h(@trace.join("\n"))}
9
+
10
+ %a{ :href => "javascript:history.go(-1)" } back
11
+
@@ -1 +1,5 @@
1
+
2
+ - # under the MIT license, see LICENSE.txt
3
+
1
4
  %p Hello world
5
+
@@ -1,44 +1,64 @@
1
+
2
+ - # under the MIT license, see LICENSE.txt
3
+
1
4
  !!!
2
5
  %html
3
6
  %head
7
+
4
8
  %title ruote-kit
5
- %link{ :type => "text/css", :href => "/_ruote/stylesheets/base.css", :rel => "stylesheet" }
6
- %link{ :type => "text/css", :href => "/_ruote/stylesheets/style.css", :rel => "stylesheet" }
7
- %link{ :type => "text/css", :href => "/_ruote/stylesheets/SimplyButtons.css", :rel => "stylesheet" }
8
- %link{ :type => "text/css", :href => "/_ruote/stylesheets/rk.css", :rel => "stylesheet" }
9
- %script{ :type => "text/javascript", :src => "/_ruote/javascripts/SimplyButtons.js" }
9
+
10
+ %link{ :type => 'image/vnd.microsoft.icon', :href => '/_ruote/images/favicon.ico', :rel => 'icon' }
11
+
12
+ %link{ :type => 'text/css', :href => '/_ruote/stylesheets/reset.css', :rel => 'stylesheet' }
13
+ %link{ :type => 'text/css', :href => '/_ruote/stylesheets/rk.css', :rel => 'stylesheet' }
14
+
15
+ %script{ :type => 'text/javascript', :src => '/_ruote/javascripts/jquery-1.4.2.min.js' }
16
+ %script{ :type => 'text/javascript', :src => '/_ruote/javascripts/rk.js' }
17
+
10
18
  - if @_uses_fluo
11
- %script{ :type => "text/javascript", :src => "/_ruote/javascripts/ruote-fluo.js" }
12
- %script{ :type => "text/javascript", :src => "/_ruote/javascripts/fluo-dial.js" }
19
+ %script{ :type => 'text/javascript', :src => '/_ruote/javascripts/ruote-fluo.js' }
20
+ %script{ :type => 'text/javascript', :src => '/_ruote/javascripts/ruote-fluo-editor.js' }
21
+ %link{ :type => 'text/css', :href => '/_ruote/stylesheets/ruote-fluo-editor.css', :rel => 'stylesheet' }
22
+ - #%script{ :type => "text/javascript", :src => "/_ruote/javascripts/fluo-dial.js" }
13
23
 
14
- :javascript
15
- window.onload = function() { SimplyButtons.init(); }
16
24
  %body
17
25
  #container
26
+
18
27
  #header
19
- %h1 ruote-kit
20
- #user-navigation
21
- %ul
22
- %li
23
- %a{ :href => "/_ruote/processes/new" } Launch a new process
24
- #main-navigation
25
- %ul
26
- = navigate_to "Processes", "/_ruote/processes"
27
- = navigate_to "Expressions", "/_ruote/expressions"
28
- = navigate_to "Workitems", "/_ruote/workitems"
29
- .clear
30
- #wrapper
31
- #main
32
- .block
33
- .content
34
- .inner= yield
35
- #footer
36
- .block
37
- %p
38
- &copy; 2009 Kenneth Kalmer
28
+ #hlogo
29
+ %img{ :src => '/_ruote/images/ruote.png' }
30
+ #htext
31
+ #ruote_kit
32
+ ruote-kit
33
+ #main_navigation
34
+ = alink(:processes, :head, :text => 'processes')
35
+ |
36
+ = alink(:workitems, :head, :text => 'workitems')
39
37
  |
40
- %a{ :href => "http://www.opensourcery.co.za" } Blog
38
+ = alink(:errors, :head, :text => 'errors')
41
39
  |
42
- %a{ :href => "http://github.com/kennethkalmer/ruote-kit" } Source
40
+ = alink(:schedules, :head, :text => 'schedules')
43
41
  |
44
- %a{ :href => "http://ruote.rubyforge.org" } Powered by ruote
42
+ = alink(:participants, :text => 'participants')
43
+ ||
44
+ %a{ :href => '/_ruote/processes/new'} launch process
45
+ #hclear
46
+
47
+ #main
48
+ = yield
49
+
50
+ - unless request.path.match(/\/processes\/new/)
51
+ #as_json
52
+ %a{ :href => as_json, :title => 'same page, but as JSON' }
53
+ as JSON
54
+
55
+ #footer
56
+ %div
57
+ &copy; 2009-2010 Kenneth Kalmer
58
+ |
59
+ %a{ :href => 'http://www.opensourcery.co.za' } blog
60
+ |
61
+ %a{ :href => 'http://github.com/tosch/ruote-kit' } source
62
+ |
63
+ %a{ :href => 'http://ruote.rubyforge.org' } powered by ruote
64
+
@@ -0,0 +1,79 @@
1
+
2
+ - # under the MIT license, see LICENSE.txt
3
+
4
+ %h1 participants
5
+
6
+ .flash
7
+ .message
8
+ .notice
9
+ %p #{pluralize(@participants.size, 'participant')} registered
10
+
11
+ %form{ :method => 'POST', :enctype => 'multipart/form-data', :accept_charset => 'UTF-8' }
12
+
13
+ %input{ :type => 'hidden', :name => '_method', :value => 'PUT' }
14
+ %input{ :type => 'hidden', :name => '_snowman', :value => '&#9731;' }
15
+
16
+ %table.participants
17
+ %thead
18
+ %td
19
+ regex
20
+ %td
21
+ classname
22
+ %td
23
+ options
24
+ %td
25
+ &nbsp;
26
+
27
+ - @participants.each_with_index do |pa, i|
28
+ %tr
29
+ %td
30
+ %input.participant{ :type => :text, :value => pa.regex }
31
+ %td
32
+ %input.participant{ :type => :text, :style => 'width: 350px;', :value => pa.classname }
33
+ %td
34
+ %input.participant{ :type => :text, :style => 'width: 350px;', :value => Rufus::Json.encode(pa.options) }
35
+ %td
36
+ %a.ruote_button.ruote_minus_button{ :title => 'remove', :href => '', :onclick => 'remove(this); return false;' }
37
+ %a.ruote_button.ruote_up_button{ :title => 'move up', :href => '', :onclick => 'move(this, "up"); return false;' }
38
+ %a.ruote_button.ruote_down_button{ :title => 'move down', :href => '', :onclick => 'move(this, "down"); return false;' }
39
+ %a.ruote_button.ruote_copy_button{ :title => 'copy', :href => '', :onclick => 'copy(this); return false;' }
40
+
41
+ %input#put_button{ :type => 'submit', :value => 'PUT /_ruote/participants', :onclick => 'nameInputs(); return true;' }
42
+
43
+
44
+ :javascript
45
+
46
+ function nameInputs () {
47
+ $('tr').each(function (index) {
48
+ var inputs = $(this).children('td').map(function () {
49
+ return $(this).children('input')[0];
50
+ });
51
+ inputs[0].name = 'regex_' + index;
52
+ inputs[1].name = 'classname_' + index;
53
+ inputs[2].name = 'options_' + index;
54
+ });
55
+ }
56
+
57
+ function move (elt, direction) {
58
+ var tr = elt.parentNode.parentNode;
59
+ if (direction == 'up') {
60
+ var ps = tr.previousSibling;
61
+ if (! ps) return;
62
+ tr.parentNode.insertBefore(tr, ps);
63
+ }
64
+ else {
65
+ var ns = tr.nextSibling;
66
+ if (! ns) return;
67
+ tr.parentNode.insertBefore(ns, tr);
68
+ }
69
+ }
70
+ function copy (elt) {
71
+ var tr = elt.parentNode.parentNode;
72
+ var tr2 = tr.cloneNode(true);
73
+ tr.parentNode.insertBefore(tr2, tr);
74
+ }
75
+ function remove (elt) {
76
+ var tr = elt.parentNode.parentNode;
77
+ tr.parentNode.removeChild(tr);
78
+ }
79
+