riojs 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +24 -0
- data/VERSION +1 -0
- data/bin/rio +5 -0
- data/generators/rio_app/USAGE +19 -0
- data/generators/rio_app/rio_app_generator.rb +40 -0
- data/generators/rio_app/templates/app.build +10 -0
- data/generators/rio_app/templates/app.css +0 -0
- data/generators/rio_app/templates/app.js +20 -0
- data/generators/rio_app/templates/app_view.html.erb +19 -0
- data/generators/rio_app/templates/fixture.js +4 -0
- data/generators/rio_app/templates/rio.html.erb +18 -0
- data/generators/rio_app/templates/rio_controller.rb +2 -0
- data/generators/rio_app/templates/spec.js +7 -0
- data/generators/rio_component/USAGE +13 -0
- data/generators/rio_component/rio_component_generator.rb +16 -0
- data/generators/rio_component/templates/component.css +0 -0
- data/generators/rio_component/templates/component.js +11 -0
- data/generators/rio_component/templates/fixture.js +3 -0
- data/generators/rio_component/templates/spec.js +6 -0
- data/generators/rio_model/USAGE +12 -0
- data/generators/rio_model/rio_model_generator.rb +21 -0
- data/generators/rio_model/templates/fixture.js +3 -0
- data/generators/rio_model/templates/model.js +9 -0
- data/generators/rio_model/templates/spec.js +6 -0
- data/generators/rio_page/USAGE +14 -0
- data/generators/rio_page/rio_page_generator.rb +16 -0
- data/generators/rio_page/templates/fixture.js +3 -0
- data/generators/rio_page/templates/page.css +12 -0
- data/generators/rio_page/templates/page.js +12 -0
- data/generators/rio_page/templates/page.jst +64 -0
- data/generators/rio_page/templates/spec.js +6 -0
- data/generators/rio_resource/USAGE +20 -0
- data/generators/rio_resource/rio_resource_generator.rb +10 -0
- data/generators/rio_resource/templates/controller.rb +3 -0
- data/init.rb +4 -0
- data/install/config/juggernaut_hosts.yml +18 -0
- data/install/lib/tasks/rio.rake +1 -0
- data/install/script/rio_server +37 -0
- data/lib/rio/autospec.rb +86 -0
- data/lib/rio/install.rb +90 -0
- data/lib/rio/juggernaut.rb +212 -0
- data/lib/rio/path.rb +3 -0
- data/lib/rio/rio_compressor.rb +219 -0
- data/lib/rio/rio_file_controller.rb +16 -0
- data/lib/rio/rio_on_rails.rb +586 -0
- data/lib/rio/rio_proxy_controller.rb +60 -0
- data/lib/rio/rio_push_controller.rb +48 -0
- data/lib/rio/rio_routes.rb +24 -0
- data/lib/rio/rio_spec_controller.rb +70 -0
- data/lib/riojs.rb +14 -0
- data/lib/tasks/rio.rb +63 -0
- data/public/images/background-chiffon.png +0 -0
- data/public/images/button-gradient-overlay-down.png +0 -0
- data/public/images/button-gradient-overlay.png +0 -0
- data/public/images/icons/add.png +0 -0
- data/public/images/icons/error-big.png +0 -0
- data/public/images/icons/warning-big.png +0 -0
- data/public/images/rio-logo-big.png +0 -0
- data/public/images/rio-logo.png +0 -0
- data/public/images/splitter-handle-horizontal.png +0 -0
- data/public/images/splitter-handle-vertical.png +0 -0
- data/public/images/tab-bar-gradient-overlay.png +0 -0
- data/public/images/title-gradient-overlay.png +0 -0
- data/public/images/trash.gif +0 -0
- data/public/javascripts/components/accordion.js +144 -0
- data/public/javascripts/components/alert_box.js +59 -0
- data/public/javascripts/components/base.js +47 -0
- data/public/javascripts/components/box.js +63 -0
- data/public/javascripts/components/button.js +98 -0
- data/public/javascripts/components/checkbox.js +44 -0
- data/public/javascripts/components/container.js +265 -0
- data/public/javascripts/components/grid_view.js +107 -0
- data/public/javascripts/components/image.js +19 -0
- data/public/javascripts/components/input.js +171 -0
- data/public/javascripts/components/label.js +15 -0
- data/public/javascripts/components/lightbox.js +160 -0
- data/public/javascripts/components/link.js +43 -0
- data/public/javascripts/components/list_item.js +44 -0
- data/public/javascripts/components/list_view.js +192 -0
- data/public/javascripts/components/marquee.js +131 -0
- data/public/javascripts/components/menu.js +89 -0
- data/public/javascripts/components/notification.js +75 -0
- data/public/javascripts/components/overlay.js +134 -0
- data/public/javascripts/components/panel.js +146 -0
- data/public/javascripts/components/radio.js +46 -0
- data/public/javascripts/components/splitter.js +65 -0
- data/public/javascripts/components/tab_bar.js +64 -0
- data/public/javascripts/components/tab_panel.js +57 -0
- data/public/javascripts/components/textarea.js +223 -0
- data/public/javascripts/components/toggle_button.js +22 -0
- data/public/javascripts/components/tooltip.js +80 -0
- data/public/javascripts/lib/application.js +482 -0
- data/public/javascripts/lib/attr.js +760 -0
- data/public/javascripts/lib/benchmark.js +235 -0
- data/public/javascripts/lib/blank.html +39 -0
- data/public/javascripts/lib/boot.js +300 -0
- data/public/javascripts/lib/clipboard.js +96 -0
- data/public/javascripts/lib/collection_entity.js +46 -0
- data/public/javascripts/lib/component.js +129 -0
- data/public/javascripts/lib/console.js +75 -0
- data/public/javascripts/lib/console/apps/console.build +43 -0
- data/public/javascripts/lib/console/apps/console.js +28 -0
- data/public/javascripts/lib/console/blank.html +39 -0
- data/public/javascripts/lib/console/components/benchmark.js +196 -0
- data/public/javascripts/lib/console/components/console.js +352 -0
- data/public/javascripts/lib/console/components/dependencies_list.js +17 -0
- data/public/javascripts/lib/console/components/docs.js +66 -0
- data/public/javascripts/lib/console/components/playground.js +30 -0
- data/public/javascripts/lib/console/console.html +27 -0
- data/public/javascripts/lib/console/console_commands.js +287 -0
- data/public/javascripts/lib/console/console_commands.js.rej +21 -0
- data/public/javascripts/lib/console/console_mixin.js +22 -0
- data/public/javascripts/lib/console/docs/files.html +579 -0
- data/public/javascripts/lib/console/docs/index.html +323 -0
- data/public/javascripts/lib/console/docs/symbols/Object.html +291 -0
- data/public/javascripts/lib/console/docs/symbols/_global_.html +413 -0
- data/public/javascripts/lib/console/docs/symbols/rio.AIM.html +490 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Application.html +841 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Attr.html +1075 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Binding.html +272 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Component.html +419 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Cookie.html +543 -0
- data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask#initialize.html +270 -0
- data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask.html +391 -0
- data/public/javascripts/lib/console/docs/symbols/rio.JsTemplate.html +271 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Juggernaut.html +329 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Model.html +822 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Page.html +383 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Template.html +328 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Utils.html +617 -0
- data/public/javascripts/lib/console/docs/symbols/rio.html +506 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_components_base.js.html +54 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_application.js.html +490 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_attr.js.html +768 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_boot.js.html +308 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_clipboard.js.html +103 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_collection_entity.js.html +53 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_component.js.html +137 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_cookie.js.html +81 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_delayed_task.js.html +68 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_file.js.html +80 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_flash_detect.js.html +129 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_form.js.html +95 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_id.js.html +50 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_inflector.js.html +167 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_js_template.js.html +283 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_juggernaut.js.html +303 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_key_map.js.html +68 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_layout_manager.js.html +175 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_log.js.html +17 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_model.js.html +1074 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_page.js.html +246 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_parameters.js.html +66 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_protohack.js.html +305 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_push.js.html +12 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_rsh.js.html +659 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_swfobject.js.html +12 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_tag.js.html +60 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_template.js.html +64 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_theme.js.html +105 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_undo.js.html +142 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_utils.js.html +87 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_yaml.js.html +88 -0
- data/public/javascripts/lib/console/file-small.png +0 -0
- data/public/javascripts/lib/console/green-circle.png +0 -0
- data/public/javascripts/lib/console/loading.gif +0 -0
- data/public/javascripts/lib/console/pages/console_page.js +149 -0
- data/public/javascripts/lib/console/pages/console_page.jst +27 -0
- data/public/javascripts/lib/console/red-circle.png +0 -0
- data/public/javascripts/lib/cookie.js +74 -0
- data/public/javascripts/lib/delayed_task.js +61 -0
- data/public/javascripts/lib/dependencies.js +76 -0
- data/public/javascripts/lib/environment.js +30 -0
- data/public/javascripts/lib/event.simulate.js +137 -0
- data/public/javascripts/lib/expressinstall.swf +0 -0
- data/public/javascripts/lib/file.js +72 -0
- data/public/javascripts/lib/flash_detect.js +122 -0
- data/public/javascripts/lib/flashembed.min.js +16 -0
- data/public/javascripts/lib/form.js +88 -0
- data/public/javascripts/lib/id.js +43 -0
- data/public/javascripts/lib/inflector.js +160 -0
- data/public/javascripts/lib/instrumenter.js +106 -0
- data/public/javascripts/lib/js_template.js +275 -0
- data/public/javascripts/lib/jslint.js +4950 -0
- data/public/javascripts/lib/juggernaut.js +295 -0
- data/public/javascripts/lib/juggernaut.swf +0 -0
- data/public/javascripts/lib/key_map.js +60 -0
- data/public/javascripts/lib/layout_manager.js +167 -0
- data/public/javascripts/lib/model.js +1067 -0
- data/public/javascripts/lib/page.js +238 -0
- data/public/javascripts/lib/parameters.js +59 -0
- data/public/javascripts/lib/png_fix.js +75 -0
- data/public/javascripts/lib/protohack.js +297 -0
- data/public/javascripts/lib/push.js +5 -0
- data/public/javascripts/lib/rio.build +28 -0
- data/public/javascripts/lib/rio_development.build +5 -0
- data/public/javascripts/lib/rio_lint.js +66 -0
- data/public/javascripts/lib/rsh.js +651 -0
- data/public/javascripts/lib/spec.js +545 -0
- data/public/javascripts/lib/spec_runner.js +242 -0
- data/public/javascripts/lib/swfobject.js +5 -0
- data/public/javascripts/lib/tag.js +52 -0
- data/public/javascripts/lib/undo.js +134 -0
- data/public/javascripts/lib/utils.js +80 -0
- data/public/javascripts/lib/yaml.js +80 -0
- data/public/javascripts/pages/playground_page.js +15 -0
- data/public/javascripts/prototype/builder.js +146 -0
- data/public/javascripts/prototype/controls.js +1004 -0
- data/public/javascripts/prototype/dragdrop.js +1030 -0
- data/public/javascripts/prototype/effects.js +1137 -0
- data/public/javascripts/prototype/prototype.js +4320 -0
- data/public/javascripts/prototype/slider.js +283 -0
- data/public/javascripts/prototype/sound.js +67 -0
- data/public/javascripts/specs/components/box_spec.js +6 -0
- data/public/javascripts/specs/components/checkbox_spec.js +26 -0
- data/public/javascripts/specs/components/container_spec.js +6 -0
- data/public/javascripts/specs/components/input_spec.js +71 -0
- data/public/javascripts/specs/components/panel_spec.js +6 -0
- data/public/javascripts/specs/components/radio_spec.js +40 -0
- data/public/javascripts/specs/fixtures/components/box.js +3 -0
- data/public/javascripts/specs/fixtures/components/checkbox.js +9 -0
- data/public/javascripts/specs/fixtures/components/container.js +3 -0
- data/public/javascripts/specs/fixtures/components/input.js +12 -0
- data/public/javascripts/specs/fixtures/components/menu.js +19 -0
- data/public/javascripts/specs/fixtures/components/menu_item.js +18 -0
- data/public/javascripts/specs/fixtures/components/radio.js +11 -0
- data/public/javascripts/specs/lib/application_spec.js +281 -0
- data/public/javascripts/specs/lib/attr_spec.js +1514 -0
- data/public/javascripts/specs/lib/benchmark_spec.js +361 -0
- data/public/javascripts/specs/lib/collection_entity_spec.js +131 -0
- data/public/javascripts/specs/lib/component_spec.js +86 -0
- data/public/javascripts/specs/lib/form_spec.js +171 -0
- data/public/javascripts/specs/lib/id_spec.js +21 -0
- data/public/javascripts/specs/lib/instrumenter_spec.js +5 -0
- data/public/javascripts/specs/lib/js_template_spec.js +131 -0
- data/public/javascripts/specs/lib/key_map_spec.js +227 -0
- data/public/javascripts/specs/lib/model_spec.js +2268 -0
- data/public/javascripts/specs/lib/parameters_spec.js +94 -0
- data/public/javascripts/specs/lib/spec_spec.js +943 -0
- data/public/javascripts/specs/lib/undo_spec.js +105 -0
- data/public/javascripts/specs/lib/yaml_spec.js +127 -0
- data/public/sounds/basso.wav +0 -0
- data/public/sounds/purr.wav +0 -0
- data/public/stylesheets/components/accordion.css +24 -0
- data/public/stylesheets/components/alert_box.css +35 -0
- data/public/stylesheets/components/box.css +0 -0
- data/public/stylesheets/components/button.css +39 -0
- data/public/stylesheets/components/checkbox.css +9 -0
- data/public/stylesheets/components/container.css +3 -0
- data/public/stylesheets/components/grid_view.css +52 -0
- data/public/stylesheets/components/input.css +10 -0
- data/public/stylesheets/components/label.css +3 -0
- data/public/stylesheets/components/lightbox.css +31 -0
- data/public/stylesheets/components/link.css +4 -0
- data/public/stylesheets/components/list_view.css +23 -0
- data/public/stylesheets/components/marquee.css +29 -0
- data/public/stylesheets/components/menu.css +34 -0
- data/public/stylesheets/components/notification.css +52 -0
- data/public/stylesheets/components/overlay.css +8 -0
- data/public/stylesheets/components/panel.css +36 -0
- data/public/stylesheets/components/radio.css +9 -0
- data/public/stylesheets/components/splitter.css +35 -0
- data/public/stylesheets/components/tab_bar.css +59 -0
- data/public/stylesheets/components/tab_panel.css +15 -0
- data/public/stylesheets/components/textarea.css +11 -0
- data/public/stylesheets/components/tooltip.css +10 -0
- data/public/stylesheets/console.css +151 -0
- data/public/stylesheets/css_reset.css +55 -0
- metadata +343 -0
@@ -0,0 +1,196 @@
|
|
1
|
+
rio.Application.require("components/box");
|
2
|
+
|
3
|
+
rio.components.Benchmark = rio.Component.create(rio.components.Box, "Benchmark", {
|
4
|
+
require: ["components/button", "components/grid_view", "components/input", "components/label", "components/container", "components/checkbox"],
|
5
|
+
attrReaders: [],
|
6
|
+
attrAccessors: [],
|
7
|
+
attrEvents: [],
|
8
|
+
methods: {
|
9
|
+
|
10
|
+
buildHtml: function() {
|
11
|
+
this.loadBenchmarks();
|
12
|
+
|
13
|
+
var grid = new rio.components.GridView({
|
14
|
+
headerBackgroundColor: "#666",
|
15
|
+
headerFontWeight: 700,
|
16
|
+
headerColor: "#fff",
|
17
|
+
headerPadding: "3px 6px",
|
18
|
+
items: opener.rio.Benchmark.installations,
|
19
|
+
overflow: "hidden",
|
20
|
+
padding: 0,
|
21
|
+
columns: [
|
22
|
+
{
|
23
|
+
padding: 3,
|
24
|
+
width: 24,
|
25
|
+
align: "center",
|
26
|
+
renderer: function(item) {
|
27
|
+
return new rio.components.Checkbox({ checked: item.enabled });
|
28
|
+
}
|
29
|
+
},
|
30
|
+
{
|
31
|
+
header: "Object",
|
32
|
+
padding: 3,
|
33
|
+
renderer: function(item) {
|
34
|
+
var html = new rio.components.Label({ content: item.objectString });
|
35
|
+
item.enabled.bind(function(val) {
|
36
|
+
html[val ? "removeClassName" : "addClassName"]("benchmarkDisabled");
|
37
|
+
});
|
38
|
+
return html;
|
39
|
+
}
|
40
|
+
},
|
41
|
+
{
|
42
|
+
header: "Method",
|
43
|
+
padding: 3,
|
44
|
+
renderer: function(item) {
|
45
|
+
var html = new rio.components.Label({ content: item.methodName });
|
46
|
+
item.enabled.bind(function(val) {
|
47
|
+
html[val ? "removeClassName" : "addClassName"]("benchmarkDisabled");
|
48
|
+
});
|
49
|
+
return html;
|
50
|
+
}
|
51
|
+
},
|
52
|
+
{
|
53
|
+
header: "Invocations",
|
54
|
+
padding: 3,
|
55
|
+
renderer: function(item) {
|
56
|
+
var label = new rio.components.Label({ content: item.invocations });
|
57
|
+
var image = rio.Tag.img("", { src: "loading.gif", style: "margin-top: -2px; margin-bottom: -2px" });
|
58
|
+
opener.rio.Benchmark.started.bind(function(started) {
|
59
|
+
label[started ? "hide" : "show"]();
|
60
|
+
image[started ? "show" : "hide"]();
|
61
|
+
});
|
62
|
+
var enabled = rio.Tag.span([label, image]);
|
63
|
+
var disabled = rio.Tag.span("-", { className: "benchmarkDisabled" });
|
64
|
+
var html = rio.Tag.span([enabled, disabled]);
|
65
|
+
item.enabled.bind(function(val) {
|
66
|
+
enabled[val ? "show" : "hide"]();
|
67
|
+
disabled[val ? "hide" : "show"]();
|
68
|
+
});
|
69
|
+
return html;
|
70
|
+
}
|
71
|
+
},
|
72
|
+
{
|
73
|
+
header: "Time",
|
74
|
+
padding: 3,
|
75
|
+
renderer: function(item) {
|
76
|
+
var label = new rio.components.Label({ content: item.time });
|
77
|
+
var image = rio.Tag.img("", { src: "loading.gif", style: "margin-top: -2px; margin-bottom: -2px" });
|
78
|
+
opener.rio.Benchmark.started.bind(function(started) {
|
79
|
+
label[started ? "hide" : "show"]();
|
80
|
+
image[started ? "show" : "hide"]();
|
81
|
+
});
|
82
|
+
var enabled = rio.Tag.span([label, image]);
|
83
|
+
var disabled = rio.Tag.span("-", { className: "benchmarkDisabled" });
|
84
|
+
var html = rio.Tag.span([enabled, disabled]);
|
85
|
+
item.enabled.bind(function(val) {
|
86
|
+
enabled[val ? "show" : "hide"]();
|
87
|
+
disabled[val ? "hide" : "show"]();
|
88
|
+
});
|
89
|
+
return html;
|
90
|
+
}
|
91
|
+
},
|
92
|
+
{
|
93
|
+
width: 24,
|
94
|
+
align: "center",
|
95
|
+
renderer: function(item) {
|
96
|
+
var trash = new rio.components.Button({
|
97
|
+
imageSrc: "/images/trash.gif",
|
98
|
+
// onClick: item.uninstall.bind(item)
|
99
|
+
onClick: function() {
|
100
|
+
item.uninstall();
|
101
|
+
this.saveBenchmarks();
|
102
|
+
}.bind(this),
|
103
|
+
className: "benchmarkTrashCan"
|
104
|
+
});
|
105
|
+
return item.isRemovable() ? trash : rio.Tag.span("");
|
106
|
+
}.bind(this)
|
107
|
+
}
|
108
|
+
]
|
109
|
+
});
|
110
|
+
|
111
|
+
var startButton = new rio.components.Button({ text: "Start benchmarking", onClick: opener.rio.Benchmark.start.bind(opener.rio.Benchmark) });
|
112
|
+
var stopButton = new rio.components.Button({ text: "Stop benchmarking", onClick: opener.rio.Benchmark.stop.bind(opener.rio.Benchmark) });
|
113
|
+
|
114
|
+
opener.rio.Benchmark.started.bind(function(started) {
|
115
|
+
startButton.setEnabled(!started);
|
116
|
+
stopButton.setEnabled(started);
|
117
|
+
});
|
118
|
+
|
119
|
+
var buttonBar = rio.Tag.div([startButton, stopButton], { className: "benchmarkButtons" });
|
120
|
+
var addInput = new rio.components.Input({
|
121
|
+
placeHolderText: "Type benchmark target here and press enter (e.g. window.alert)",
|
122
|
+
width: "100%",
|
123
|
+
padding: "5px 8px",
|
124
|
+
fontSize: 16,
|
125
|
+
blurOnEnter: false,
|
126
|
+
onEnter: function() {
|
127
|
+
var val = addInput.html().value;
|
128
|
+
if (this.installBenchmark(val)) {
|
129
|
+
addInput.html().value = "";
|
130
|
+
addInput.setValue("");
|
131
|
+
addInput.setBackgroundColor("#fff");
|
132
|
+
this.saveBenchmarks();
|
133
|
+
} else {
|
134
|
+
addInput.setBackgroundColor("#faf0f0");
|
135
|
+
}
|
136
|
+
}.bind(this)
|
137
|
+
});
|
138
|
+
var installationBar = rio.Tag.div(addInput, { style: "overflow: hidden" });
|
139
|
+
|
140
|
+
var center = new rio.components.Container({ region: "center", items: [installationBar, grid], overflow: "auto" });
|
141
|
+
var south = new rio.components.Container({ region: "south", items: [buttonBar] });
|
142
|
+
|
143
|
+
return new rio.components.Container({ layout: true, items: [center, south], height: "100%", width: "100%" }).html();
|
144
|
+
},
|
145
|
+
|
146
|
+
installBenchmark: function(val) {
|
147
|
+
var match = val.match(/^(.*)\.(.*)$/);
|
148
|
+
if (match) {
|
149
|
+
var objectString = match[1];
|
150
|
+
try {
|
151
|
+
var object = opener.window.eval(objectString);
|
152
|
+
if (object) {
|
153
|
+
var methodName = match[2];
|
154
|
+
if (object[methodName] && Object.isFunction(object[methodName])) {
|
155
|
+
opener.rio.Benchmark.install(object, methodName, objectString);
|
156
|
+
return true;
|
157
|
+
}
|
158
|
+
}
|
159
|
+
} catch(e) {
|
160
|
+
}
|
161
|
+
}
|
162
|
+
return false;
|
163
|
+
},
|
164
|
+
|
165
|
+
loadBenchmarks: function() {
|
166
|
+
var savedBenchmarks = (rio.Cookie.get("_RIO_savedBenchmarks") || "").split("\n").reject(function(b) { return b.blank() });
|
167
|
+
savedBenchmarks.each(function(b) {
|
168
|
+
try {
|
169
|
+
this.installBenchmark(b);
|
170
|
+
} catch(e) {
|
171
|
+
// if it fails, who cares. Add a log here if you need to debug.
|
172
|
+
}
|
173
|
+
}.bind(this));
|
174
|
+
},
|
175
|
+
|
176
|
+
saveBenchmarks: function() {
|
177
|
+
var benchmarks = [];
|
178
|
+
opener.rio.Benchmark.getInstallations().each(function(i) {
|
179
|
+
if (i.isRemovable()) {
|
180
|
+
var benchmark = i.getObjectString() + "." + i.getMethodName();
|
181
|
+
if (this.installBenchmark(benchmark)) {
|
182
|
+
benchmarks.push(benchmark);
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}.bind(this));
|
186
|
+
rio.Cookie.set("_RIO_savedBenchmarks", benchmarks.join("\n"));
|
187
|
+
}
|
188
|
+
}
|
189
|
+
});
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
@@ -0,0 +1,352 @@
|
|
1
|
+
rio.Application.require("components/box");
|
2
|
+
|
3
|
+
rio.components.Console = rio.Component.create(rio.components.Box, "Console", {
|
4
|
+
require: ["lib/spec", "lib/spec_runner", "lib/rio_lint", "lib/file", "prototype/sound", "components/container", "lib/console/console_mixin", "lib/console/console_commands"],
|
5
|
+
attrReaders: [["promptHistory", []], "consoleLog", "prompt", "consoleHtmlWrapper"],
|
6
|
+
attrAccessors: [
|
7
|
+
["boundTo"],
|
8
|
+
["currentHistoryPoint", 0],
|
9
|
+
["halfTyped", ""],
|
10
|
+
["autospec", false],
|
11
|
+
["autocss", false]
|
12
|
+
],
|
13
|
+
attrEvents: ["navigateToPlayground"],
|
14
|
+
methods: {
|
15
|
+
initialize: function() {
|
16
|
+
this.loadFixtures();
|
17
|
+
this.setAutospec(opener.window.rio.environment.autospec);
|
18
|
+
this.setAutocss(opener.window.rio.environment.autocss);
|
19
|
+
|
20
|
+
this._promptHistory = (rio.Cookie.get("promptHistory") || "").split("\n");
|
21
|
+
},
|
22
|
+
|
23
|
+
buildHtml: function() {
|
24
|
+
this._consoleLog = rio.Tag.div("", { className: "log" });
|
25
|
+
this._consoleLog.observe("click", this.focus.bind(this));
|
26
|
+
this._prompt = rio.Tag.input("", { className: "prompt" });
|
27
|
+
var promptBox = rio.Tag.div([
|
28
|
+
rio.Tag.span(">>>", { className: "promptArrows" }),
|
29
|
+
this.getPrompt()
|
30
|
+
], { style: "position: relative;" });
|
31
|
+
|
32
|
+
this.getPrompt().observe("keypress", function(e) {
|
33
|
+
if (e.keyCode == Event.KEY_RETURN) {
|
34
|
+
this.executePrompt();
|
35
|
+
e.stop();
|
36
|
+
}
|
37
|
+
}.bindAsEventListener(this));
|
38
|
+
this.getPrompt().observe("keydown", function(e) {
|
39
|
+
if (e.keyCode == Event.KEY_UP || e.keyCode == 38) {
|
40
|
+
this.selectPreviousHistoryItem();
|
41
|
+
e.stop();
|
42
|
+
}
|
43
|
+
if (e.keyCode == Event.KEY_DOWN || e.keyCode == 40) {
|
44
|
+
this.selectNextHistoryItem();
|
45
|
+
e.stop();
|
46
|
+
}
|
47
|
+
}.bindAsEventListener(this));
|
48
|
+
|
49
|
+
var center = new rio.components.Container({ region: "center", items: [this._consoleLog] });
|
50
|
+
var south = new rio.components.Container({ region: "south", items: [promptBox], overflow: "hidden" });
|
51
|
+
|
52
|
+
return new rio.components.Container({ layout: true, items: [center, south], height: "100%", width: "100%" }).html();
|
53
|
+
},
|
54
|
+
|
55
|
+
focus: function() {
|
56
|
+
this.getPrompt().setFocus(true);
|
57
|
+
},
|
58
|
+
|
59
|
+
log: function(msg, className, prefix) {
|
60
|
+
prefix = (prefix === undefined) ? ">> " : prefix;
|
61
|
+
var logItem = rio.Tag.div(rio.Tag.pre([prefix, (msg == undefined ? "" : msg).toString()]), {
|
62
|
+
className: className || "logItem"
|
63
|
+
});
|
64
|
+
this.getConsoleLog().insert(logItem);
|
65
|
+
this.getConsoleLog().scrollTop = this.getConsoleLog().scrollHeight - this.getConsoleLog().getHeight() + 50;
|
66
|
+
},
|
67
|
+
|
68
|
+
logHtml: function(msg, className) {
|
69
|
+
var logItem = rio.Tag.div(msg, {
|
70
|
+
className: className || "logItem"
|
71
|
+
});
|
72
|
+
this.getConsoleLog().insert(logItem);
|
73
|
+
this.getConsoleLog().scrollTop = this.getConsoleLog().scrollHeight - this.getConsoleLog().getHeight() + 50;
|
74
|
+
},
|
75
|
+
|
76
|
+
skipAutotest: [
|
77
|
+
"/lib/console/components/console.js",
|
78
|
+
/* "/lib/spec.js", Not sure why this used to be skipped */
|
79
|
+
"/lib/boot.js"
|
80
|
+
],
|
81
|
+
|
82
|
+
skipAutoload: [
|
83
|
+
"/lib/boot.js"
|
84
|
+
],
|
85
|
+
|
86
|
+
touch: function(files) {
|
87
|
+
files.each(function(file) {
|
88
|
+
if (file.endsWith(".js") && !file.match(/\/specs\//) && !this.skipAutoload.include(file)) {
|
89
|
+
if (opener.rio.boot.loadedFiles.include(file.match(/\/?(.*)\.js/)[1])) {
|
90
|
+
opener.rio.File.execute("/javascripts" + file, { asynchronous: false });
|
91
|
+
}
|
92
|
+
if (rio.boot.loadedFiles.include(file.match(/\/?(.*)\.js/)[1])) {
|
93
|
+
rio.File.execute("/javascripts" + file, { asynchronous: false });
|
94
|
+
// rio.app.reboot();
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}.bind(this));
|
98
|
+
if (this.getAutocss()) {
|
99
|
+
files.select(function(f) {
|
100
|
+
return f.strip().toLowerCase().match(/.css$/);
|
101
|
+
}).each(function(f) {
|
102
|
+
var css = "/stylesheets" + f.strip().toLowerCase();
|
103
|
+
var found = false;
|
104
|
+
opener.window.$$("link").each(function(l) {
|
105
|
+
if (l.href.include("/rio/stylesheets?")) {
|
106
|
+
// l.href += "&" + Math.random();
|
107
|
+
// Don't do anything here, it's way too slow
|
108
|
+
} else {
|
109
|
+
var root = opener.window.location.protocol + "//" + opener.window.location.host;
|
110
|
+
var link = l.href.strip().toLowerCase();
|
111
|
+
var compare = link.startsWith(root) ? root + css : css;
|
112
|
+
if (link == compare || link.startsWith(compare + "?")) {
|
113
|
+
l.href = compare + "?" + Math.random();
|
114
|
+
found = true;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
});
|
118
|
+
// If we can't find the stylesheet but it's loaded, just reload all stylesheets
|
119
|
+
if (!found && opener.rio.preloadedStylesheets.include(css.match(/\/stylesheets\/(.*)\.css/)[1])) {
|
120
|
+
opener.rio.boot.loadedStylesheets.each(function(s) {
|
121
|
+
opener.Element.head().insert({
|
122
|
+
bottom: opener.rio.Tag.link("", {
|
123
|
+
href: "/stylesheets/" + s + ".css?" + Math.random(),
|
124
|
+
media: "screen",
|
125
|
+
rel: "stylesheet",
|
126
|
+
type: "text/css"
|
127
|
+
})
|
128
|
+
});
|
129
|
+
});
|
130
|
+
}
|
131
|
+
});
|
132
|
+
}
|
133
|
+
if (this.getAutospec()) {
|
134
|
+
var filesToTest = files.select(function(f) {
|
135
|
+
return f.strip().toLowerCase().match(/.jst?$/) && !this.skipAutotest.include(f);
|
136
|
+
}.bind(this)).map(function(f) {
|
137
|
+
var m;
|
138
|
+
if (m = f.match(/\/?(.*).jst/)) {
|
139
|
+
var allTemplatesList = opener.rio.JsTemplate._allTemplatesList;
|
140
|
+
var index = allTemplatesList.indexOf(m[1]);
|
141
|
+
if (index >= 0) {
|
142
|
+
allTemplatesList.splice(index, 1);
|
143
|
+
}
|
144
|
+
var page = opener.rio.pages[m[1].split("/").last().classize()];
|
145
|
+
page._templateApplied = false;
|
146
|
+
page.applyTemplate();
|
147
|
+
}
|
148
|
+
if (f.strip().toLowerCase().startsWith("/specs/fixtures/")) {
|
149
|
+
return f.strip().toLowerCase().match(/^\/specs\/fixtures\/(.*)\.js$/)[1];
|
150
|
+
} else if (f.strip().toLowerCase().startsWith("/specs/")) {
|
151
|
+
return f.strip().toLowerCase().match(/^\/specs\/(.*)_spec\.js$/)[1];
|
152
|
+
} else {
|
153
|
+
return f.strip().toLowerCase().match(/^\/?(.*).jst?$/)[1];
|
154
|
+
}
|
155
|
+
}).uniq();
|
156
|
+
|
157
|
+
filesToTest.each(function(f) {
|
158
|
+
this.runSpecs(f);
|
159
|
+
}.bind(this));
|
160
|
+
}
|
161
|
+
},
|
162
|
+
|
163
|
+
focus: function() {
|
164
|
+
this.getPrompt().focus();
|
165
|
+
},
|
166
|
+
|
167
|
+
consoleCommandFor: function(command) {
|
168
|
+
if (rio.ConsoleCommands[command]) { return rio.ConsoleCommands[command]; }
|
169
|
+
|
170
|
+
return Object.values(rio.ConsoleCommands).detect(function(c) {
|
171
|
+
return c.alias && c.alias.include(command);
|
172
|
+
});
|
173
|
+
},
|
174
|
+
|
175
|
+
_lastResults: null,
|
176
|
+
executePrompt: function() {
|
177
|
+
var prompt = this.getPrompt().value;
|
178
|
+
if (prompt.blank()) { return; }
|
179
|
+
|
180
|
+
this.setCurrentHistoryPoint(0);
|
181
|
+
this.setHalfTyped("");
|
182
|
+
this.getPromptHistory().push(prompt);
|
183
|
+
rio.Cookie.set("promptHistory", rio.Cookie.get("promptHistory") + "\n" + prompt);
|
184
|
+
this.getPrompt().clear();
|
185
|
+
|
186
|
+
var pathMatch;
|
187
|
+
|
188
|
+
var command = prompt.split(" ")[0].strip();
|
189
|
+
|
190
|
+
var consoleCommand = this.consoleCommandFor(command);
|
191
|
+
if (consoleCommand) {
|
192
|
+
try {
|
193
|
+
consoleCommand.action.bind(this, prompt)();
|
194
|
+
} catch(er) {
|
195
|
+
this.log(er, "errorLogItem", "> ");
|
196
|
+
}
|
197
|
+
return;
|
198
|
+
}
|
199
|
+
|
200
|
+
this.log(prompt, "userLogItem", ">>> ");
|
201
|
+
try {
|
202
|
+
var mixin = {};
|
203
|
+
Object.keys(rio.ConsoleMixin).each(function(key) {
|
204
|
+
mixin[key] = rio.ConsoleMixin[key].bind(this)();
|
205
|
+
}.bind(this));
|
206
|
+
|
207
|
+
var results;
|
208
|
+
with(mixin) {
|
209
|
+
if (this.getBoundTo()) {
|
210
|
+
results = opener.eval("(function() { return eval(\"" + prompt.gsub("\"", "\\\"") + "\"); }.bind(rio.console.window.rio.app.getCurrentPage().getConsole().getBoundTo()))()");
|
211
|
+
} else {
|
212
|
+
results = opener.eval(prompt);
|
213
|
+
}
|
214
|
+
}
|
215
|
+
this._lastResults = results;
|
216
|
+
|
217
|
+
this.log(results, "userLogItem", "");
|
218
|
+
} catch(e) {
|
219
|
+
this.log(e, "errorLogItem", "> ");
|
220
|
+
}
|
221
|
+
},
|
222
|
+
|
223
|
+
runSpecs: function(spec) {
|
224
|
+
try {
|
225
|
+
var startTime = new Date();
|
226
|
+
var context = {
|
227
|
+
examples: 0,
|
228
|
+
failures: 0,
|
229
|
+
pendings: 0
|
230
|
+
};
|
231
|
+
var stdout = function(msg, className) {
|
232
|
+
this.log(msg, className, " ");
|
233
|
+
}.bind(this);
|
234
|
+
|
235
|
+
var summarizer = function() {
|
236
|
+
Sound.play("/sounds/" + (context.failures > 0 ? "basso" : "purr") + ".wav");
|
237
|
+
var msg = context.examples + " " + rio.Utils.pluralize(context.examples, "example", "examples") + ", " +
|
238
|
+
context.failures + " " + rio.Utils.pluralize(context.failures, "failure", "failures");
|
239
|
+
if (context.pendings > 0) {
|
240
|
+
msg = msg + ", " + context.pendings + " pending";
|
241
|
+
}
|
242
|
+
var logClass = context.failures > 0 ? "summaryFailed" : (context.pendings > 0 ? "summaryPending" : "summaryPassed");
|
243
|
+
|
244
|
+
var time = (new Date().getTime() - startTime.getTime()) / 1000.0;
|
245
|
+
this.log("Completed in " + time + " seconds", "", "");
|
246
|
+
this.log(msg, logClass, "=> ");
|
247
|
+
}.bind(this);
|
248
|
+
|
249
|
+
if (!spec) {
|
250
|
+
rio.SpecRunner.runAll({
|
251
|
+
stdout: stdout,
|
252
|
+
env: opener,
|
253
|
+
context: context,
|
254
|
+
syntaxChecker: this.checkSyntax.bind(this),
|
255
|
+
onComplete: summarizer
|
256
|
+
});
|
257
|
+
} else {
|
258
|
+
rio.SpecRunner.run({
|
259
|
+
path: spec,
|
260
|
+
stdout: stdout,
|
261
|
+
env: opener,
|
262
|
+
context: context,
|
263
|
+
syntaxChecker: this.checkSyntax.bind(this),
|
264
|
+
onComplete: summarizer
|
265
|
+
});
|
266
|
+
}
|
267
|
+
} catch(e) {
|
268
|
+
this.log(e, "errorLogItem", "> ");
|
269
|
+
}
|
270
|
+
},
|
271
|
+
|
272
|
+
selectPreviousHistoryItem: function() {
|
273
|
+
if (this.getPromptHistory().size() == this.getCurrentHistoryPoint()) {return;}
|
274
|
+
if (this.getCurrentHistoryPoint() == 0) { this.setHalfTyped(this.getPrompt().value); }
|
275
|
+
this.setCurrentHistoryPoint(this.getCurrentHistoryPoint() + 1);
|
276
|
+
this.getPrompt().value = this.getPromptHistory()[this.getPromptHistory().size() - this.getCurrentHistoryPoint()];
|
277
|
+
},
|
278
|
+
|
279
|
+
selectNextHistoryItem: function() {
|
280
|
+
if (0 == this.getCurrentHistoryPoint()) {return;}
|
281
|
+
this.setCurrentHistoryPoint(this.getCurrentHistoryPoint() - 1);
|
282
|
+
if (this.getCurrentHistoryPoint() == 0) {
|
283
|
+
this.getPrompt().value = this.getHalfTyped();
|
284
|
+
} else {
|
285
|
+
this.getPrompt().value = this.getPromptHistory()[this.getPromptHistory().size() - this.getCurrentHistoryPoint()];
|
286
|
+
}
|
287
|
+
},
|
288
|
+
|
289
|
+
checkRioSyntax: function() {
|
290
|
+
var filesToIgnore = [
|
291
|
+
"lib/swfobject"
|
292
|
+
];
|
293
|
+
rio.File.open("../rio.build", {
|
294
|
+
onSuccess: function(content) {
|
295
|
+
var rioFiles = content.split("\n").map(function(file) { return file.strip(); }).reject(function(file) { return file.blank() || filesToIgnore.include(file); });
|
296
|
+
this.checkFilesSyntax(rioFiles);
|
297
|
+
}.bind(this)
|
298
|
+
});
|
299
|
+
},
|
300
|
+
|
301
|
+
checkProgramSyntax: function() {
|
302
|
+
this.checkFilesSyntax(opener.rio.boot.appScripts());
|
303
|
+
},
|
304
|
+
|
305
|
+
checkFilesSyntax: function(files) {
|
306
|
+
this.checkFileSyntax(files.first(), {
|
307
|
+
onComplete: function() {
|
308
|
+
if (files.size() > 1) {
|
309
|
+
this.checkFilesSyntax(files.without(files.first()));
|
310
|
+
}
|
311
|
+
}.bind(this)
|
312
|
+
});
|
313
|
+
},
|
314
|
+
|
315
|
+
checkFileSyntax: function(file, options) {
|
316
|
+
var onComplete = (options || {}).onComplete || Prototype.emptyFunction;
|
317
|
+
rio.RioLint.checkFileSyntax(file, {
|
318
|
+
onComplete: function(errors) {
|
319
|
+
this.logLintErrors(errors, file);
|
320
|
+
|
321
|
+
onComplete();
|
322
|
+
}.bind(this)
|
323
|
+
});
|
324
|
+
},
|
325
|
+
|
326
|
+
checkSyntax: function(content, fileName) {
|
327
|
+
var errors = rio.RioLint.checkSyntax(content, fileName);
|
328
|
+
this.logLintErrors(errors, fileName);
|
329
|
+
},
|
330
|
+
|
331
|
+
logLintErrors: function(errors, fileName) {
|
332
|
+
if (errors.empty()) {
|
333
|
+
this.log("Syntax valid: " + fileName, "passed");
|
334
|
+
} else {
|
335
|
+
errors.each(function(e) {
|
336
|
+
this.log(e, "warningLogItem", "- ");
|
337
|
+
}.bind(this));
|
338
|
+
}
|
339
|
+
},
|
340
|
+
|
341
|
+
loadFixtures: function() {
|
342
|
+
rio.SpecRunner.loadFixtures({ env: opener });
|
343
|
+
}
|
344
|
+
}
|
345
|
+
});
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|