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,60 @@
|
|
1
|
+
class RioProxyController < ApplicationController
|
2
|
+
ssl_allowed :javascripts, :sounds, :stylesheets, :stylesheet_concat if defined? SslRequirement
|
3
|
+
|
4
|
+
def javascripts
|
5
|
+
if m = params[:path].last.match(/(.*)_concat\.jst/)
|
6
|
+
app = m[1]
|
7
|
+
render :text => RioCompressor.concat_templates_for_app(app, params[:path])
|
8
|
+
elsif m = params[:path].last.match(/(.*)_concat\.js/)
|
9
|
+
app = m[1]
|
10
|
+
if app == "rio"
|
11
|
+
render :text => RioCompressor.concat_scripts_for_rio
|
12
|
+
elsif app == "rio_development"
|
13
|
+
render :text => RioCompressor.concat_scripts_for_rio_development
|
14
|
+
elsif app == "prototype"
|
15
|
+
render :text => RioCompressor.concat_scripts_for_prototype
|
16
|
+
else
|
17
|
+
render :text => RioCompressor.concat_script_functions_for_app(app, params[:path])
|
18
|
+
end
|
19
|
+
else
|
20
|
+
file_to_render = File.join(Rio::ROOT, "public", "javascripts", File.join(params[:path]))
|
21
|
+
extension = params[:path].last.split('.').last || 'js'
|
22
|
+
render :file => file_to_render, :content_type => Mime::Type.lookup_by_extension(extension).to_s
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def sounds
|
27
|
+
file_to_render = File.join(Rio::ROOT, "public", "sounds", File.join(params[:path]))
|
28
|
+
extension = params[:path].last.split('.').last || 'js'
|
29
|
+
render :file => file_to_render, :content_type => Mime::Type.lookup_by_extension(extension).to_s
|
30
|
+
end
|
31
|
+
|
32
|
+
def images
|
33
|
+
file_to_render = File.join(Rio::ROOT, "public", "images", File.join(params[:path]))
|
34
|
+
extension = params[:path].last.split('.').last || 'png'
|
35
|
+
render :file => file_to_render, :content_type => Mime::Type.lookup_by_extension(extension).to_s
|
36
|
+
end
|
37
|
+
|
38
|
+
def stylesheets
|
39
|
+
if m = params[:path].last.match(/(.*)_concat\.css/)
|
40
|
+
app = m[1]
|
41
|
+
render :text => RioCompressor.concat_stylesheets_for_app(app, params[:path][0..-2] + ["apps"] + [params[:path][-1]]), :content_type => Mime::Type.lookup_by_extension("css").to_s
|
42
|
+
else
|
43
|
+
file_to_render = File.join(Rio::ROOT, "public", "stylesheets", File.join(params[:path]))
|
44
|
+
if (file_to_render.match(/\.css$/))
|
45
|
+
render :file => file_to_render, :content_type => Mime::Type.lookup_by_extension("css").to_s
|
46
|
+
else
|
47
|
+
render :text => "Not a css file"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def stylesheet_concat
|
53
|
+
content = params[:files].map do |f|
|
54
|
+
app_path = File.join(RAILS_ROOT, "public", "stylesheets", f + ".css")
|
55
|
+
rio_path = File.join(Rio::ROOT, "public", "stylesheets", f + ".css")
|
56
|
+
File.open(File.exists?(app_path) ? app_path : rio_path).read
|
57
|
+
end
|
58
|
+
render :text => content.join("\n\n"), :content_type => Mime::Type.lookup_by_extension("css").to_s
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class RioPushController < ApplicationController
|
2
|
+
session :cookie_only => false, :only => :subscribe
|
3
|
+
|
4
|
+
def subscribe
|
5
|
+
client_id = params[:client_id].to_i
|
6
|
+
channels = params[:channels] || []
|
7
|
+
if(client_id == 0)
|
8
|
+
# client 0 is the server
|
9
|
+
render :text => "AUTHORIZED"
|
10
|
+
elsif(channels.length != 1)
|
11
|
+
render :text => "FAILED", :status => 500
|
12
|
+
else
|
13
|
+
channel = channels.first
|
14
|
+
model = channel.split(".")[0].constantize
|
15
|
+
id = channel.split(".")[1].to_i
|
16
|
+
|
17
|
+
if (model.authorize_broadcast(id, client_id))
|
18
|
+
render :text => "AUTHORIZED"
|
19
|
+
else
|
20
|
+
render :text => "UNAUTHORIZED", :status => 401
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def broadcast
|
26
|
+
channel = params[:channel]
|
27
|
+
model_name = channel.split(".")[0]
|
28
|
+
model = model_name.constantize
|
29
|
+
id = channel.split(".")[1].to_i
|
30
|
+
user_id = current_user.id
|
31
|
+
|
32
|
+
if (model.authorize_broadcast(id, user_id))
|
33
|
+
|
34
|
+
message_json = ActiveSupport::JSON.decode(params[:message])
|
35
|
+
message = "rio.models." + model_name + ".receiveBroadcast(" + message_json.to_json + ")"
|
36
|
+
|
37
|
+
Rio::Push.send_to_channel(message, channel)
|
38
|
+
|
39
|
+
render :text => "PASSED", :status => 200
|
40
|
+
else
|
41
|
+
render :text => "UNAUTHORIZED", :status => 500
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_connection
|
46
|
+
render :text => Rio::Push.show_connected_clients.detect {|c| c["session_id"] == session.session_id} ? "CONNECTED" : "NOT_CONNECTED"
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ActionController
|
2
|
+
module Routing #:nodoc:
|
3
|
+
class RouteSet #:nodoc:
|
4
|
+
alias_method :draw_without_rio_routes, :draw
|
5
|
+
def draw
|
6
|
+
draw_without_rio_routes do |map|
|
7
|
+
map.connect 'rio/fixtures', :controller => 'rio_spec', :action => 'fixtures' unless RAILS_ENV == "production"
|
8
|
+
map.connect 'rio/specs', :controller => 'rio_spec', :action => 'specs' unless RAILS_ENV == "production"
|
9
|
+
map.connect 'rio/file', :controller => 'rio_file', :action => 'write' if RAILS_ENV == "development"
|
10
|
+
map.connect 'rio/stylesheets', :controller => 'rio_proxy', :action => 'stylesheet_concat'
|
11
|
+
yield map
|
12
|
+
map.connect 'javascripts/*path', :controller => 'rio_proxy', :action => 'javascripts' if RAILS_ENV == "development" or RAILS_ENV == "test"
|
13
|
+
map.connect 'sounds/*path', :controller => 'rio_proxy', :action => 'sounds' if RAILS_ENV == "development"
|
14
|
+
map.connect 'images/*path', :controller => 'rio_proxy', :action => 'images'
|
15
|
+
map.connect 'stylesheets/*path', :controller => 'rio_proxy', :action => 'stylesheets'
|
16
|
+
map.connect 'push/subscribe', :controller => 'rio_push', :action => 'subscribe'
|
17
|
+
map.connect 'push/broadcast', :controller => 'rio_push', :action => 'broadcast'
|
18
|
+
map.connect 'push/test_connection', :controller => 'rio_push', :action => 'test_connection'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
class RioSpecController < ApplicationController
|
2
|
+
def initialize
|
3
|
+
@file_utils = FileDependencies.new(File.join(RAILS_ROOT, 'public', 'javascripts', 'specs'))
|
4
|
+
@rio_file_utils = FileDependencies.new(File.join(Rio::ROOT, "public", "javascripts", "specs"))
|
5
|
+
end
|
6
|
+
|
7
|
+
def specs
|
8
|
+
render :text => ("{" + (spec_entries(@file_utils) + spec_entries(@rio_file_utils)).join(",") + "}")
|
9
|
+
end
|
10
|
+
|
11
|
+
def fixtures
|
12
|
+
render :json => "{ #{(dir(@file_utils, 'fixtures') + dir(@rio_file_utils, 'fixtures')).join(",")} }"
|
13
|
+
end
|
14
|
+
|
15
|
+
def spec_entries utils
|
16
|
+
utils.entries.reject do |entry|
|
17
|
+
entry == 'fixtures' or entry.starts_with?('.')
|
18
|
+
end.map do |entry|
|
19
|
+
dir(utils, entry)
|
20
|
+
end.flatten
|
21
|
+
end
|
22
|
+
|
23
|
+
def dir utils, dir_path
|
24
|
+
utils.entries(dir_path).reject do |entry|
|
25
|
+
# REQ: Skip anything that start with '.'
|
26
|
+
entry.starts_with?('.')
|
27
|
+
end.reject do |entry|
|
28
|
+
# REQ: Skip files that don't end with '.js'
|
29
|
+
utils.file?(entry) and not entry.ends_with?('.js')
|
30
|
+
end.map do |entry|
|
31
|
+
child_path = File.join(dir_path, entry)
|
32
|
+
if(utils.directory?(child_path))
|
33
|
+
dir(utils, child_path)
|
34
|
+
else
|
35
|
+
file(utils, child_path)
|
36
|
+
end
|
37
|
+
end.flatten
|
38
|
+
end
|
39
|
+
|
40
|
+
def file(utils, file_path)
|
41
|
+
"\"#{strip_ex file_path}\": function(){ return \"#{escape_special_characters(utils.read(file_path).gsub("\n", ""))}\" }"
|
42
|
+
end
|
43
|
+
|
44
|
+
def escape_special_characters s
|
45
|
+
s.gsub(/["]/, '\\\"').gsub(/\\n/, '\\\\\\n').gsub(/\\t/, '\\\\\\t')
|
46
|
+
end
|
47
|
+
|
48
|
+
def strip_ex s
|
49
|
+
s[0..(s.rindex('.')-1)]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class FileDependencies
|
54
|
+
def initialize root_directory
|
55
|
+
@root_directory = root_directory
|
56
|
+
end
|
57
|
+
|
58
|
+
def entries *path
|
59
|
+
Dir.entries(File.join(@root_directory, *path))
|
60
|
+
end
|
61
|
+
def directory? path
|
62
|
+
File.directory?(File.join(@root_directory, path))
|
63
|
+
end
|
64
|
+
def file? path
|
65
|
+
not self.directory?(path)
|
66
|
+
end
|
67
|
+
def read path
|
68
|
+
File.read(File.join(@root_directory, path))
|
69
|
+
end
|
70
|
+
end
|
data/lib/riojs.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "rio/rio_compressor"
|
2
|
+
require "rio/rio_file_controller"
|
3
|
+
require "rio/rio_on_rails"
|
4
|
+
require "rio/path"
|
5
|
+
require "rio/rio_proxy_controller"
|
6
|
+
require "rio/rio_push_controller"
|
7
|
+
require "rio/rio_routes"
|
8
|
+
require "rio/rio_spec_controller"
|
9
|
+
require "rio/juggernaut"
|
10
|
+
|
11
|
+
ActionView::Base.send(:include, Rio::Helpers)
|
12
|
+
ActionController::Base.send(:extend, Rio::ActionControllerExtensions)
|
13
|
+
ActionController::Base.send(:include, Rio::ApplicationControllerExtensions)
|
14
|
+
ActiveRecord::Base.send(:include, Rio::ActiveRecordExtensions)
|
data/lib/tasks/rio.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require "packr"
|
2
|
+
require "rio/path"
|
3
|
+
require "rio/autospec"
|
4
|
+
require "rio/rio_compressor"
|
5
|
+
|
6
|
+
ROOT = RAILS_ROOT
|
7
|
+
RIO_ROOT = Rio::ROOT
|
8
|
+
|
9
|
+
JS_ROOT = File.join(ROOT, "public", "javascripts")
|
10
|
+
RIO_JS_ROOT = File.join(RIO_ROOT, "public", "javascripts")
|
11
|
+
|
12
|
+
|
13
|
+
namespace :js do
|
14
|
+
|
15
|
+
desc "Minify javascripts and templates for production environment"
|
16
|
+
task :min => :environment do
|
17
|
+
RioCompressor.minify_boot
|
18
|
+
RioCompressor.apps.each do |app|
|
19
|
+
RioCompressor.minify_scripts(RioCompressor.scripts_for_app(app, ["apps", app + ".js"]), File.join(JS_ROOT, "apps", "compressed", app + ".js"))
|
20
|
+
|
21
|
+
RioCompressor.minify_stylesheets(app, ["apps", app + ".build"], File.join(ROOT, "public", "stylesheets", "compressed", app + ".css"))
|
22
|
+
|
23
|
+
RioCompressor.minify_templates(app, ["apps", app + ".build"], File.join(JS_ROOT, "apps", "compressed", app + ".jst"))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def entries_to_delete(directory, save = [])
|
28
|
+
return [] unless File.exist?(File.join(JS_ROOT, directory))
|
29
|
+
Dir.entries(File.join(JS_ROOT, directory)).reject do |entry|
|
30
|
+
entry.match /\.build$/ or entry.match /\.jst$/ or entry.match /^\./ or entry == "compressed" or save.include?(entry)
|
31
|
+
end.map { |entry| File.join(directory, entry) }
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "[ONLY USE IN PRODUCTION] Prepares for JS deployment, by minifying then removing all non-minified and non-prototype javascript files."
|
35
|
+
task :deploy => :min do
|
36
|
+
FileUtils.cp(File.join(RIO_JS_ROOT, "lib", "boot.js"), File.join(JS_ROOT, "lib"))
|
37
|
+
FileUtils.cp(File.join(RIO_JS_ROOT, "lib", "event.simulate.js"), File.join(JS_ROOT, "lib"))
|
38
|
+
FileUtils.cp_r(File.join(RIO_JS_ROOT, "prototype"), File.join(JS_ROOT))
|
39
|
+
|
40
|
+
to_remove = (
|
41
|
+
["models"] +
|
42
|
+
entries_to_delete("components") +
|
43
|
+
entries_to_delete("pages") +
|
44
|
+
entries_to_delete("apps") +
|
45
|
+
entries_to_delete("lib", ["boot.js", "environment.js", "ZeroClipboard.swf", "swfupload.swf", "juggernaut.swf", "selenium_extensions.js", "event.simulate.js", "expressinstall.swf"])
|
46
|
+
).map do |entry|
|
47
|
+
File.join(JS_ROOT, entry)
|
48
|
+
end
|
49
|
+
FileUtils.rm_rf(to_remove)
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Start the rio javascript autospec server"
|
53
|
+
task :autospec do
|
54
|
+
AutoSpec.run
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "Start the juggernaut server"
|
59
|
+
task :juggernaut do
|
60
|
+
`juggernaut -c config/juggernaut.yml`
|
61
|
+
end
|
62
|
+
|
63
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,144 @@
|
|
1
|
+
rio.Application.require("components/box");
|
2
|
+
|
3
|
+
rio.components.Accordion = rio.Component.create(rio.components.Box, "Accordion", {
|
4
|
+
requireCss: "accordion",
|
5
|
+
attrReaders: ["panes", "accordionPanes"],
|
6
|
+
attrAccessors: [["selectedPaneIndex", 0]],
|
7
|
+
methods: {
|
8
|
+
initialize: function() {
|
9
|
+
if (!this.getAccordionPanes()) {
|
10
|
+
this._accordionPanes = this.getPanes().map(function(pane) {
|
11
|
+
var accordionPane = new rio.components.AccordionPane({
|
12
|
+
header: pane.header,
|
13
|
+
body: pane.body,
|
14
|
+
onSelect: pane.onSelect
|
15
|
+
});
|
16
|
+
|
17
|
+
|
18
|
+
return accordionPane;
|
19
|
+
}.bind(this));
|
20
|
+
} else if (!Object.isArray(this.getAccordionPanes())) {
|
21
|
+
this._accordionPanes = [this.getAccordionPanes()];
|
22
|
+
}
|
23
|
+
|
24
|
+
this.getAccordionPanes().each(function(accordionPane) {
|
25
|
+
accordionPane.bind("selected", function(selected) {
|
26
|
+
if (selected) {
|
27
|
+
this.setSelectedPaneIndex(this.getAccordionPanes().indexOf(accordionPane));
|
28
|
+
}
|
29
|
+
}.bind(this));
|
30
|
+
}.bind(this));
|
31
|
+
|
32
|
+
this.resize.bind(this).defer();
|
33
|
+
},
|
34
|
+
|
35
|
+
buildHtml: function() {
|
36
|
+
var accordionHtml = this.boxHtml();
|
37
|
+
this.getAccordionPanes().each(function(ap) { return accordionHtml.insert(ap.html()); });
|
38
|
+
accordionHtml.addClassName("accordion");
|
39
|
+
|
40
|
+
this.bind("selectedPaneIndex", function(index) {
|
41
|
+
var toShow = this.getAccordionPanes()[index];
|
42
|
+
var toHide = this.getAccordionPanes().detect(function(ap) { return ap.getSelected() && ap != toShow; });
|
43
|
+
|
44
|
+
if (!toHide) {
|
45
|
+
toShow.bodyHtml().show();
|
46
|
+
toShow.setSelected(true);
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
|
50
|
+
this.getAccordionPanes().each(function(ap) { ap.setSelected(false); });
|
51
|
+
|
52
|
+
toShow.setSelected(true);
|
53
|
+
toShow.bodyHtml().show();
|
54
|
+
toHide.bodyHtml().hide();
|
55
|
+
|
56
|
+
// (function() {
|
57
|
+
// var effects = [new Effect.BlindDown(toShow.bodyHtml(), {
|
58
|
+
// duration: 0.5,
|
59
|
+
// sync: true,
|
60
|
+
// // transition: Effect.Transitions.sinoidal
|
61
|
+
// })];
|
62
|
+
// if (toHide) {
|
63
|
+
// effects.push(new Effect.BlindUp(toHide.bodyHtml(), {
|
64
|
+
// duration: 0.5,
|
65
|
+
// sync: true,
|
66
|
+
// // transition: Effect.Transitions.sinoidal
|
67
|
+
// }));
|
68
|
+
// }
|
69
|
+
// new Effect.Parallel(effects, {
|
70
|
+
// duration: 0.5,
|
71
|
+
// queue: {
|
72
|
+
// position: 'end',
|
73
|
+
// scope: 'accordionAnimation'
|
74
|
+
// },
|
75
|
+
// afterUpdate: function() {
|
76
|
+
// }.bind(this),
|
77
|
+
// afterFinish: function() {
|
78
|
+
// toShow.setSelected(true);
|
79
|
+
// toHide.setSelected(false);
|
80
|
+
// this.resize();
|
81
|
+
// }.bind(this)
|
82
|
+
// });
|
83
|
+
//
|
84
|
+
// }).bind(this).defer();
|
85
|
+
}.bind(this));
|
86
|
+
|
87
|
+
Element.observe(window, "resize", this.resize.bind(this));
|
88
|
+
|
89
|
+
return accordionHtml;
|
90
|
+
},
|
91
|
+
|
92
|
+
resize: function() {
|
93
|
+
this.getAccordionPanes().each(function(pane) {
|
94
|
+
pane.setBodyHeight(this.bodyHeight());
|
95
|
+
}.bind(this));
|
96
|
+
},
|
97
|
+
|
98
|
+
bodyHeight: function() {
|
99
|
+
var bodyHeight = this.html().getHeight();
|
100
|
+
var headersHeight = this.getAccordionPanes().inject(0, function(acc, pane) {
|
101
|
+
return acc + pane.getHeaderHeight();
|
102
|
+
}.bind(this));
|
103
|
+
return bodyHeight - headersHeight;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
});
|
107
|
+
|
108
|
+
rio.components.AccordionPane = rio.Component.create(rio.components.Base, "AccordionPane", {
|
109
|
+
attrReaders: ["header", "body", ["onSelect", Prototype.emptyFunction]],
|
110
|
+
attrAccessors: [["selected", false]],
|
111
|
+
attrHtmls: ["header", "body"],
|
112
|
+
methods: {
|
113
|
+
buildHtml: function() {
|
114
|
+
return rio.Tag.div([this.headerHtml(), this.bodyHtml()], { className: "pane" });
|
115
|
+
},
|
116
|
+
|
117
|
+
buildHeaderHtml: function() {
|
118
|
+
var headerHtml = rio.Tag.h1(this.getHeader(), { className: "paneHeader" });
|
119
|
+
this.bind("selected", function(selected) {
|
120
|
+
headerHtml[(selected ? "addClassName" : "removeClassName")]("selected");
|
121
|
+
if (selected) {
|
122
|
+
this.getOnSelect()();
|
123
|
+
}
|
124
|
+
}.bind(this));
|
125
|
+
headerHtml.observe("click", function() { this.setSelected(true); }.bind(this));
|
126
|
+
return headerHtml;
|
127
|
+
},
|
128
|
+
|
129
|
+
buildBodyHtml: function() {
|
130
|
+
var bodyHtml = rio.Tag.div(this.getBody(), { className: "paneBody" });
|
131
|
+
if (this.getSelected()) { bodyHtml.show(); } else { bodyHtml.hide(); }
|
132
|
+
return bodyHtml;
|
133
|
+
},
|
134
|
+
|
135
|
+
getHeaderHeight: function() {
|
136
|
+
return this.headerHtml().totalHeight();
|
137
|
+
},
|
138
|
+
|
139
|
+
setBodyHeight: function(height) {
|
140
|
+
this.bodyHtml().style.height = height;
|
141
|
+
}
|
142
|
+
}
|
143
|
+
});
|
144
|
+
|