tap-server 0.1.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.
@@ -0,0 +1,112 @@
1
+ var Tap = {
2
+ App: {},
3
+ Schema: {},
4
+ };
5
+
6
+ Tap.App = {
7
+ /* Performs a tail update to target at the specified interval as long as
8
+ * checkbox is checked. A tail update posts to action and inserts the
9
+ * response at the bottom of target.
10
+ */
11
+ tail: function(action, checkbox, target, interval) {
12
+ if($(checkbox).checked) {
13
+ new Ajax.Request(action, {
14
+ method: 'post',
15
+ parameters: {
16
+ pos: $(target).innerHTML.length
17
+ },
18
+ onSuccess: function(transport) {
19
+ new Insertion.Bottom(target, transport.responseText);
20
+ },
21
+ onFailure: function(transport) {
22
+ alert(transport.responseText);
23
+ $(checkbox).checked = false;
24
+ }
25
+ });
26
+
27
+ var update = "Tap.App.tail('" + action + "', '" + checkbox + "', '" + target + "', " + interval + ");"
28
+ setTimeout(update, interval);
29
+ }
30
+ },
31
+
32
+ /* Performs a info update to target at the specified interval as long as
33
+ * checkbox is checked. An info update posts to action and replaces the
34
+ * inner html of target with the response.
35
+ */
36
+ info: function(action, checkbox, target, interval) {
37
+ if($(checkbox).checked) {
38
+ new Ajax.Request(action, {
39
+ method: 'post',
40
+ onSuccess: function(transport) {
41
+ $(target).update(transport.responseText);
42
+ },
43
+ onFailure: function(transport) {
44
+ alert(transport.responseText);
45
+ $(checkbox).checked = false;
46
+ }
47
+ });
48
+
49
+ var update = "Tap.App.info('" + action + "', '" + checkbox + "', '" + target + "', " + interval + ");"
50
+ setTimeout(update, interval);
51
+ }
52
+ },
53
+ };
54
+
55
+ Tap.Schema = {
56
+ /* Collects schema parameters in the specified element (ie source and target
57
+ * nodes that are checked, and the currently selected tasc, etc.). These
58
+ * parameters are used by the server to determine how to respond to actions
59
+ * on a form.
60
+ */
61
+ parameters: function(id) {
62
+ // Lookup elements
63
+ element = document.getElementById(id)
64
+ nodes = element.select('.node');
65
+ manifests = element.select('.manifest');
66
+
67
+ // Determine the indicies of source and target nodes
68
+ sources = []
69
+ targets = []
70
+ for (i=0;i<nodes.length;i++) {
71
+ source = nodes[i].getElementsByClassName('source_checkbox')[0];
72
+ if(source.checked) {
73
+ source.checked = false;
74
+ sources.push(i);
75
+ };
76
+
77
+ target = nodes[i].getElementsByClassName('target_checkbox')[0];
78
+ if(target.checked) {
79
+ target.checked = false;
80
+ targets.push(i);
81
+ };
82
+ };
83
+
84
+ // Determine tascs selected by manifests
85
+ tascs = []
86
+ for (i=0;i<manifests.length;i++) {
87
+ manifest = manifests[i];
88
+ tascs.push(manifest.value);
89
+ manifest.value = "";
90
+ };
91
+
92
+ parameters = {
93
+ index: nodes.length,
94
+ sources: sources,
95
+ targets: targets,
96
+ tascs: tascs
97
+ };
98
+ return parameters;
99
+ },
100
+
101
+ /* Performs an update to the specified element. Update posts to action with
102
+ * the Schema.parameters for element and inserts the response at the bottom
103
+ * of the element.
104
+ */
105
+ update: function(id, action) {
106
+ new Ajax.Updater(id, action, {
107
+ method: 'post',
108
+ insertion: Insertion.Bottom,
109
+ parameters: Tap.Schema.parameters(id)
110
+ });
111
+ },
112
+ };
@@ -0,0 +1,6 @@
1
+ /*
2
+ Tap Styles
3
+ */
4
+ form {
5
+ border: black solid thin;
6
+ }
data/tap.yml ADDED
File without changes
data/views/404.erb ADDED
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <title>404</title>
3
+ <body>
4
+ <pre>
5
+ # 404 Error: Could not handle request.
6
+ <%= req.env.reject {|key, value| key =~ /^(tap|rack)\./ }.to_yaml %>
7
+ </pre>
8
+ </body>
9
+ </html>
data/views/500.erb ADDED
@@ -0,0 +1,7 @@
1
+ <html>
2
+ <title>500</title>
3
+ <body>
4
+ # 500 Error handling request: <%= error.message %></br>
5
+ # <%= error.backtrace.join("<br/># ") %>
6
+ </body>
7
+ </html>
@@ -0,0 +1,44 @@
1
+ <div id="branding">
2
+ <h1><a href="<%= Tap::WEBSITE %>">Tap (<ins>T</ins>ask <ins>Ap</ins>plication) <%= Tap::VERSION %> </a></h1>
3
+ </div>
4
+
5
+ <div id="content_main">
6
+ <dl id="envs" class="manifest">
7
+ <% env.each do |current| %>
8
+ <dt class="key"><%= env_names[current] %> (<%= current.root.root %>)</dt>
9
+ <dd class="value">
10
+ <% controllers = current.controllers.build %>
11
+ <% unless controllers.empty? %>
12
+ <dl id="controllers" class="manifest">
13
+ <!-- controllers manifest -->
14
+ <dt class="key">controllers</dt>
15
+ <dd class="value">
16
+ <ol>
17
+ <% controllers.minimap.each do |(name, obj)| %>
18
+ <% path = obj.kind_of?(Tap::Support::Constant) ? obj.require_path : name %>
19
+ <li><a href="/<%= env_names[current] %>%3A<%= name %>"><%= name %></a> (<%= current.root.relative_filepath(:root, path) || path %>)</li>
20
+ <% end %>
21
+ </ol>
22
+ </dd>
23
+ </dl>
24
+ <% end %>
25
+
26
+ <% tascs = current.tasks.build %>
27
+ <% unless tascs.empty? %>
28
+ <dl id="tascs" class="manifest">
29
+ <!-- tasks manifest -->
30
+ <dt class="key">tasks</dt>
31
+ <dd class="value">
32
+ <ol>
33
+ <% tascs.minimap.each do |(name, obj)| %>
34
+ <% path = obj.kind_of?(Tap::Support::Constant) ? obj.require_path : name %>
35
+ <li><a href="/schema?nodes[0][0]=<%= env_names[current] %>%3A<%= name %>"><%= name %></a> (<%= current.root.relative_filepath(:root, path) || path %>)</li>
36
+ <% end %>
37
+ </ol>
38
+ </dd>
39
+ </dl>
40
+ <% end %>
41
+ </dd>
42
+ <% end %>
43
+ </dl>
44
+ </div>
@@ -0,0 +1,8 @@
1
+ <% id = app.hash %>
2
+ <% update_info = "Tap.App.info('/app/info', 'update-#{id}', 'info-#{id}', 1000);" %>
3
+ <div class="info">
4
+ <input class="update-" id="update-<%= id %>" type="checkbox" <%= update ? "checked='true' " : "" %>onchange="<%= update_info %>" />
5
+ <a href="/app/info">update</a>
6
+ <span class="info" id="info-<%= id %>"><%= content %></span>
7
+ </div>
8
+ <script type="text/javascript"><%= update ? update_info : "" %></script>
@@ -0,0 +1,8 @@
1
+ <% update_tail = "Tap.App.tail('/app/tail/#{id}', 'update-#{id}', 'content-#{id}', 1000);" %>
2
+ <div class="tail" id="tail-<%= id %>">
3
+ <input class="update" id="update-<%= id %>" type="checkbox" <%= update ? "checked='true' " : "" %>onchange="<%= update_tail %>" />
4
+ <a href="/app/tail/<%= id %>">update</a>
5
+ <span class="path" id="path-<%= id %>"><%= path %></span>
6
+ <pre class="content" id="content-<%= id %>"><%= content %></pre>
7
+ </div>
8
+ <script type="text/javascript"><%= update ? update_tail : "" %></script>
data/views/layout.erb ADDED
@@ -0,0 +1,11 @@
1
+ <html>
2
+ <head>
3
+ <title>Tap (Task Application)</title>
4
+ <link rel="stylesheet" type="text/css" href="/stylesheets/tap.css" />
5
+ <script src="/javascripts/prototype.js"></script>
6
+ <script src="/javascripts/tap.js"></script>
7
+ </head>
8
+ <body>
9
+ <%= content %>
10
+ </body>
11
+ </html>
@@ -0,0 +1,4 @@
1
+ <input name="argv[]" type="hidden" value="<%= switch %>" />
2
+ <input name="argv[]" type="text" value="<%= value %>" />
3
+ <span><%= key %></span>:
4
+ <span><%= config[:desc].to_s %></span>
@@ -0,0 +1,3 @@
1
+ <input name="argv[]" type="checkbox" value="<%= switch %>" <%= value ? 'checked="true"' : '' %> />
2
+ <span><%= key %></span>:
3
+ <span><%= config[:desc].to_s %></span>
@@ -0,0 +1,6 @@
1
+ <!-- note switches should be more like a radio button, hide
2
+ the other when selected, so that both are allowed... or
3
+ just present the opposite of the default... Currently they DO NOT WORK-->
4
+ <input name="argv[]" type="checkbox" value="<%= switch %>" <%= value ? 'checked="true"' : '' %> />
5
+ <span><%= key %></span>:
6
+ <span><%= config[:desc].to_s %></span>
@@ -0,0 +1,27 @@
1
+ <% configurations.each_pair do |key, config| %>
2
+ <li class="config">
3
+ <% if config.is_nest? %>
4
+ <span class="name"><%= key %></span>:
5
+ <span class="desc"><%= config[:desc].to_s %></span>
6
+ <ul class="nested_config">
7
+ <%= render("configurations.erb", :locals => {
8
+ :configurations => config.default(false).delegates,
9
+ :values => values[key],
10
+ :nest => "#{nest}#{nest.empty? ? '' : ':'}#{key}",
11
+ :index => index}) %>
12
+ </ul>
13
+ <% else %>
14
+ <% template = case config[:type] %>
15
+ <% when :switch then 'switch' %>
16
+ <% when :flag then 'flag' %>
17
+ <% else 'default' %>
18
+ <% end %>
19
+ <%= render("config/#{template}.erb", :locals => {
20
+ :key => key,
21
+ :config => config,
22
+ :switch => "--#{nest}#{nest.empty? ? '' : ':'}#{key.to_s.gsub('_', '-')}",
23
+ :value => values[key],
24
+ :index => index}) %>
25
+ </li>
26
+ <% end %>
27
+ <% end %>
@@ -0,0 +1,4 @@
1
+ [<% nodes.each do |node| %>
2
+ <% index = schema.index(node) %>
3
+ <a href="#node_<%= index %>"><%= index %></a>
4
+ <% end %>]
@@ -0,0 +1,47 @@
1
+ <% task, args = instantiate(*node.argv) %>
2
+ <% tasc = task.class %>
3
+ <span class="class"><%= tasc %></span>:
4
+ <span class="summary"><%= tasc.manifest.subject %></span>
5
+ <pre><%= tasc.manifest.wrap %></pre>
6
+
7
+ <!-- tasc identifier -->
8
+ <input name="argv[]" type="hidden" value="--" />
9
+ <input name="argv[]" type="hidden" value="<%= node.argv[0] %>" />
10
+
11
+ <ul>
12
+ <!-- inputs -->
13
+ <% attributes = node.input_join ? "disabled='true' ": " " %>
14
+ <% tasc.args.arguments.each do |argument| %>
15
+ <li class="input">
16
+ <input name="argv[]" <%= attributes %>value="<%= args.shift %>" />
17
+ <span><%= argument %></span>
18
+ </li>
19
+ <% end %>
20
+ <!-- for extra args... should be limited to *arg -->
21
+ <% args << '' %>
22
+ <% args.each do |arg| %>
23
+ <li class="input">
24
+ <input name="argv[]" <%= attributes %>value="<%= arg %>" />
25
+ <span>...</span>
26
+ </li>
27
+ <% end %>
28
+
29
+ <!-- configurations -->
30
+ <%= render("configurations.erb", :locals => {
31
+ :configurations => tasc.configurations,
32
+ :values => task.config,
33
+ :nest => "",
34
+ :index => index}) %>
35
+
36
+ <!-- options -->
37
+ <li class="options">
38
+ <input name="argv[]" type="hidden" value="--name" />
39
+ <input name="argv[]" value="<%= task.name %>" />
40
+ <span>Name</span>
41
+ </li>
42
+
43
+ <!--
44
+ <input class="globalize" name="nodes[<%= index %>][2]" type="checkbox" value="--*<%= index %>" />
45
+ <span class="name">Globalize</span> -->
46
+
47
+ </ul>
@@ -0,0 +1,3 @@
1
+ # This workflow may be saved to a file and loaded
2
+ # at a later time, or go back to run it now.
3
+ <%= schema.dump.to_yaml %>
@@ -0,0 +1,30 @@
1
+ <form id="update_<%= id %>" class="update_form" enctype="multipart/form-data" method="post" action="/schema/update/<%= id %>">
2
+ <span>round <%= round %></span>
3
+ <input name="round" type="hidden" value="<%= round %>">
4
+ <ol>
5
+ <% nodes.each do |node| %>
6
+ <% index = schema.index(node) %>
7
+ <li>
8
+ <input name="outputs[]" value="<%= index %>" type="checkbox" />
9
+ <a href="#node_<%= index %>"><%= index %></a>
10
+ <input name="inputs[]" value="<%= index %>" type="checkbox" />
11
+ <%= render('join.erb', :locals => {:schema => schema, :id => id, :nodes => node.parents}) %>
12
+ <%= render('join.erb', :locals => {:schema => schema, :id => id, :nodes => node.children}) %>
13
+ </li>
14
+ <% end %>
15
+ </ol>
16
+ <ul>
17
+ <% server.env.minimap.each do |(env_name, env)| %>
18
+ <% env.tasks.build.minimap.each do |(name, const)| %>
19
+ <% lookup = "#{env_name}:#{name}" %>
20
+ <li>
21
+ <input name="nodes[]" value="<%= lookup %>" type="checkbox"><%= lookup %></input>
22
+ </li>
23
+ <% end %>
24
+ <% end %>
25
+ </ul>
26
+ <input class="update_action" type="radio" name="action" value="add" checked="true">add</input>
27
+ <input class="update_action" type="radio" name="action" value="remove">remove</input>
28
+ <input class="update_action" type="radio" name="action" value="echo">echo</input>
29
+ <input id="update_form_submit" type="submit" value="Update" />
30
+ </form>
@@ -0,0 +1,28 @@
1
+ <% globals = schema.globals %>
2
+ <% unless globals.empty? %>
3
+ <%= render 'round.erb', :locals => {:schema => schema, :nodes => globals, :round => nil, :id => id} %>
4
+ <% end %>
5
+ <% index = 0 %>
6
+ <% schema.natural_rounds.each do |nodes| %>
7
+ <%= render 'round.erb', :locals => {:schema => schema, :nodes => nodes, :round => index, :id => id} %>
8
+ <% index += 1 %>
9
+ <% end %>
10
+ <%= render 'round.erb', :locals => {:schema => schema, :nodes => [], :round => index, :id => id} %>
11
+
12
+ <form id="submit_form_<%= id %>" class="submit_form" enctype="multipart/form-data" method="post" action="/schema/submit/<%= id %>">
13
+ <ol id="schema_<%= id %>" class="schema">
14
+ <% schema.nodes.each_with_index do |node, index| %>
15
+ <li id="node_<%= index %>" class="node">
16
+ <%= render('node.erb', :locals => {:id => id, :node => node, :index => index} ) %>
17
+ </li>
18
+ <% end %>
19
+ </ol>
20
+ <% schema.dump.select {|obj| !obj.kind_of?(Array) }.each do |str| %>
21
+ <input name="argv[]" type="hidden" value="--<%= str %>" />
22
+ <% end %>
23
+ <input class="submit_form_action" type="radio" name="action" value="save" checked="true">save</input>
24
+ <input class="submit_form_action" type="radio" name="action" value="preview">preview</input>
25
+ <input class="submit_form_action" type="radio" name="action" value="echo">echo</input>
26
+ <input class="submit_form_action" type="radio" name="action" value="run">run</input>
27
+ <input id="submit_form_submit" type="submit" value="Submit" />
28
+ </form>
@@ -0,0 +1 @@
1
+ <%= _result.dump %>
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tap-server
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Simon Chiang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-02-17 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: tap
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.12.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rack
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.1
34
+ version:
35
+ description:
36
+ email: simon.a.chiang@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README
43
+ - MIT-LICENSE
44
+ - History
45
+ files:
46
+ - cmd/server.rb
47
+ - controllers/app_controller.rb
48
+ - controllers/schema_controller.rb
49
+ - lib/tap/controller.rb
50
+ - lib/tap/server.rb
51
+ - lib/tap/server_error.rb
52
+ - lib/tap/tasks/echo.rb
53
+ - lib/tap/tasks/server.rb
54
+ - public/javascripts/prototype.js
55
+ - public/javascripts/tap.js
56
+ - public/stylesheets/tap.css
57
+ - tap.yml
58
+ - views/404.erb
59
+ - views/500.erb
60
+ - views/app_controller/index.erb
61
+ - views/app_controller/info.erb
62
+ - views/app_controller/tail.erb
63
+ - views/layout.erb
64
+ - views/schema_controller/config/default.erb
65
+ - views/schema_controller/config/flag.erb
66
+ - views/schema_controller/config/switch.erb
67
+ - views/schema_controller/configurations.erb
68
+ - views/schema_controller/join.erb
69
+ - views/schema_controller/node.erb
70
+ - views/schema_controller/preview.erb
71
+ - views/schema_controller/round.erb
72
+ - views/schema_controller/schema.erb
73
+ - views/tap/tasks/echo/result.html
74
+ - README
75
+ - MIT-LICENSE
76
+ - History
77
+ has_rdoc: true
78
+ homepage: http://tap.rubyforge.org
79
+ post_install_message:
80
+ rdoc_options:
81
+ - --main
82
+ - README
83
+ - -S
84
+ - -N
85
+ - --title
86
+ - Tap Server
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: "0"
94
+ version:
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: "0"
100
+ version:
101
+ requirements: []
102
+
103
+ rubyforge_project: tap
104
+ rubygems_version: 1.3.1
105
+ signing_key:
106
+ specification_version: 2
107
+ summary: A web interface for tap.
108
+ test_files: []
109
+