There are no reviews yet. Be the first to send feedback to the community and the maintainers!
Notice! This repo has now been deprecated - please see: http://github.com/maccman/juggernaut Juggernaut =========== =CONTACT DETAILS Author: Alex MacCaw E-Mail Address: [email protected] License: MIT Website: http://juggernaut.rubyforge.org Blog: http://www.eribium.org =DESCRIPTION The Juggernaut plugin for Ruby on Rails aims to revolutionize your Rails app by letting the server initiate a connection and push data to the client. In other words your app can have a real time connection to the server with the advantage of instant updates. Although the obvious use of this is for chat, the most exciting prospect for me is collaborative cms and wikis. What Happens: 1. Client A opens socket connection to the socket server 2. Client B makes Ajax call to Rails 3. Rails sends message to the socket server 4. Socket server broadcasts message to clients Juggernaut Features: * Allows a real time connection with a client - Rails can literally push javascript in real time to the client which is then evaluated. * Push server - written in Ruby. * Integrated, as a plugin, into Rails. * Subscribers can subscribe to multiple channels, and broadcasters can broadcast to multiple channels. * Subscribers can provide a 'unique_id' and broadcasters can send data to specific clients. * Add and remove channels at runtime * Uses Flash 8 - installed on more than 98% of computers. * Supports all the major browsers (uses ExternalInterface): Firefox 1+, IE 6+ and Safari 2+. Requirements: * Rails 2.0.2 or edge * json gem (gem install json) * EventMachine gem (gem install eventmachine) * juggernaut gem (gem install juggernaut) =============================================== INSTALLATION =============================================== 1. From your Rails Dir: script/plugin install git://github.com/maccman/juggernaut_plugin.git 2. Make sure to include the appropriate JavaScripts in your views/layouts in the header of your views <%= javascript_include_tag 'prototype', :juggernaut %> 3. Add this to your view/layout head: <%= juggernaut %> 4. Make sure the juggernaut gem is installed (gem install maccman-juggernaut -s http://gems.github.com ) and run: juggernaut -g juggernaut.yml juggernaut -c juggernaut.yml 5. Run script/server and visit the Jugged up page. 6. Then, to send data to juggernaut, execute this in the console: Juggernaut.send_to_all("alert('hi from juggernaut')") Usage To demonstrate Juggernaut I'll walk you through building a simple chat. Start the push server going by running: juggernaut -g juggernaut.yml juggernaut -c juggernaut.yml The chat controller: class ChatController < ApplicationController def index end def send_data render :juggernaut do |page| page.insert_html :top, 'chat_data', "<li>#{h params[:chat_input]}</li>" end render :nothing => true end end The index.html.erb <html> <head> <%= javascript_include_tag :defaults, :juggernaut %> <%= juggernaut %> </head> <body> <%= form_remote_tag( :url => { :action => :send_data }, :complete => "$('chat_input').value = ''" ) %> <%= text_field_tag( 'chat_input', '', { :size => 20, :id => 'chat_input'} ) %> <%= submit_tag "Add" %> </form> <ul id="chat_data" style="list-style:none"> </ul> </body> </html> Start the webserver going with: ruby script/server Try it and see what you think. If it doesn't work please visit the faq. Other ways of rendering to juggernaut: render :juggernaut do |page| page.alert('hi') end render_juggernaut(:action => 'whatever') =============================================== More usage information, examples and support =============================================== === Channel Usage === <%= juggernaut(:channels => ['one', 'two', 'three']) %> render :juggernaut => {:type => :send_to_channels, :channels => ['one']} do |page| page.alert('hi') end Client id usage: <%= juggernaut(:client_id => session[:user_id]) %> render :juggernaut => {:type => :send_to_clients, :client_ids => [1, 2, 3]} do |page| page.alert('hi') end Other juggernaut render options: OPTION_TYPE PARAMS :send_to_all :send_to_channels :channels :send_to_channel :channel :send_to_client :client_id :send_to_clients :client_ids :send_to_client_on_channel :client_id, :channel :send_to_clients_on_channel :client_ids, :channel :send_to_client_on_channels :client_id, :channels :send_to_clients_on_channels :client_ids, :channels You can also call these methods directly on the Juggernaut class: Juggernaut.send_to_clients('data', [1,2,3]) For authentication options and callbacks see the juggernaut.yml configuration file. Usage and examples: http://ncavig.com/blog/ Support and forums: http://groups.google.com/group/Juggernaut-for-Rails?hl=en === Getting remote clients to connect === Firstly you will need to configure juggernaut_hosts.yml in your Rails app to point to the proper IP of the push server (rather than 127.0.0.1). For example: :hosts: - :port: 5001 :host: 129.168.0.2 :environment: :production Ok, remote clients that visit pages on this server (once you restart it) will connect to the proper push server IP. BUT, if you're using IP based authentication (recommended) you'll find that the broadcast authentication fails. You'll need to add the Rails IP to juggernaut.yml, like so: :allowed_ips: - 127.0.0.1 - 192.168.0.4 # IP of the Rails app =============================================== Jquery =============================================== To get Juggernaut working with Jquery (Prototype is used by default) follow the tutorial above with the following differences. >>Javascripts You must have jquery.js (version 1.2.6 tested) and the jquery-json plugin (http://www.jdempster.com/wp-content/uploads/2007/08/jquery.json.js) in the /javascripts directory. You need the jquerynaut.js file in the /javascripts/juggernaut directory (found in /lib in the media directory) >>The chat controller: class ChatController < ApplicationController def index end def send_data render :juggernaut do |page| page["#chat_data"].prepend "<li>#{h params[:chat_input]}</li>" end render :nothing => true end end >>The index.html.erb <html> <head> <%= javascript_include_tag 'jquery', 'json', 'juggernaut/juggernaut', 'juggernaut/jquerynaut', 'juggernaut/swfobject' %> <%= juggernaut %> </head> <body> <form action="/chat/send_data" method="get"> <div style="margin:0;padding:0"> <input id="chat_input" name="chat_input" size="20" type="text" value="" /> <input name="commit" type="submit" value="Add" /> </form> <script> $(document).ready(function(){ $('form').submit(function(){ $.get('/chat/send_data', { chat_input: $('#chat_input').val() } ) return false; }) }) </script> <ul id="chat_data" style="list-style:none"></ul> </body> </html> =============================================== Troubleshooting =============================================== Check out the support forums on google groups: http://groups.google.com/group/Juggernaut-for-Rails
juggernaut
[DEPRECATED] Realtime server push with node.js, WebSockets and Cometmonocle
Link and news sharingabba
A/B testing frameworkholla
Holla! - Rich JavaScript Applicationjquery.magicmove
Animate DOM transitions.bowline
Ruby/JS GUI and Binding framework (deprecated)stylo
Spine/CoffeeScript example GUI designersaasy
Rails SaaS and SSO solutiongfx
CSS3 3D animation librarynestful
Simple Ruby HTTP/REST client with a sane APIace
Sinatra for Nodesupermodel
Ruby in-memory modelsacts_as_recommendable
Collaborative Filtering for Railsbook-assets
Files for the O'Reilly book JavaScript Web Applicationsgo
gotrevi
An opinionated Sinatra app generatorflarevideo
HTML5 & Flash Video Playerspine.todos
A Backbone alternative ideahermes
Messaging re-inventedmotivation
New Chrome tab page showing your agespine.contacts
Spine demo contact managersprockets-commonjs
Adds CommonJS support to Sprocketsmacgap-rb
Generator for MacGapsinatra-blog
A example Sinatra blogheadsup
A simple Heads Up displaycatapult
A Sprockets/Rack build toolremail
RESTful email for Railsspine.rails3
Sample app demonstrating Spine and Rails integrationbowline-twitter
Bowline Twitter clientwysiwyg
sinatra-pubsub
Push & Streaming for Sinatra.push-mac
stitch-rb
Stitch ported to Rubydhash
Compare image similarity with a dhash101-school
AI generated coursesichabod
Headless JavaScript testing with WebKitcolorcanvas
roauth
*Simple* Ruby OAuth librarypush
juggernaut_gem
Realtime Railsspine.mobile
Spine Mobile Frameworksuper.js
Simple JavaScript framework for building RIAs (with jQuery)oped
Email based diaryremail-engine
RESTful email for Rails - see http://github.com/maccman/remailsyncro
Synchronize state across remote clients.spine.mobile.currency
Spine Mobile currency convertor examplesourcemap
Ruby library for using Source Mapssuperapp
JavaScript state machine and class abstraction for building RIAs (deprecated! - use http://github.com/maccman/super.js)sprockets-source-url
Adds @sourceURL support to Sprocketsspine.infinite
Infinite scrolling with Spine & Railsbowline-desktop
wxWidgets/Ruby/Webkit framework for Bowline appsymockup
UI mockups using HTML and CSSsupermodel-js
SuperModel in JavaScript (deprecated! - use http://github.com/maccman/super.js)zombies
A Facebook/Spine game.quora2
Redesigning Quora's interface, turning it into a JavaScript web application powered by Spine.spine.mobile.contacts
Example Spine Mobile Apphumanapi
request-profile
API to access autocomplete datagwo
Rails plugin integrating Google Web Optimizer for AB testscft
jquery.upload.js
Upload files using Ajaxspine.realtime
Realtime Spine app with Railsrbyte
Byte compile Ruby 1.9.1 files and "require" support for loading compiled files.phonegap
Gem for building PhoneGap appssegment-hooks
Trigger arbitrary JavaScript from Segment.com eventsspine.mobile.workout
Spine Mobile Workouts Examplerestful_email
AppEngine that provides a RESTful interface to sending emails (decrep - use http://github.com/maccman/remail)csbook
statster
Merb Web Analyticsrack-modulr
Use CommonJS modules in your Rack/Rails applicationsblossom
Demonstration chat appdtwitter
Distributed Twittercanonical
Rails plugin providing helper for canonical URLsjquery.drop.js
jQuery lib abstracting the drag/drop APIalexmaccaw
Portfolioomniauth-humanapi
OmniAuth strategy for HumanAPI.the-managers-handbook
syncro-js
JavaScript library for Syncroless-rb
Less using ExecJSspine.tutorials
Spine tutorials (DEPRECATED - use http://spinejs.com)bowline-bundler
Specialized version of the Bundler gem for Bowline appsserveup
gdata
Recent clone of http://code.google.com/p/gdata-ruby-util (with Ruby 1.9 support)package-jquery
package-jquery-ui
jquery.tmpl
jQuery.tmpl for Hemnode-twitter-stream
Twitter Streaming API Library for Node.jscounterman
monocle-assets
jlink
jQuery data binding library - bind objects to HTML elementscloudflare-r2-edge
super.todos
Port of Backbone.js Todos to Superjeco
jQuery extension to ecoinvoices
Test Spine applike-detector
bp-p2p
Browser Plus P2Prenoir
Simple Canvas physics engine using Verlet Integrationhnv2
Hacker News V2elb-nginx-vhosts
socialmod
Ruby/Python/PHP client libsLove Open Source and this site? Check out how you can help us