资源说明:Port of the Juggernaut js lib to jQuery (from prototype)
#{h params[:chat_input]} "
end
render :nothing => true
end
end
The index.html.erb
<%= javascript_include_tag :defaults, :juggernaut %>
<%= juggernaut %>
<%= form_remote_tag(
:url => { :action => :send_data },
:complete => "$('chat_input').value = ''" ) %>
<%= text_field_tag( 'chat_input', '', { :size => 20, :id => 'chat_input'} ) %>
<%= submit_tag "Add" %>
Juggernaut-jQuery ================= =CONTACT DETAILS Author: Alex MacCaw jQuery port: David Palm, dvdplm@gmail.com E-Mail Address: info@alexmaccaw.co.uk 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.1 or edge * json gem (gem install json) * EventMachine gem (gem install eventmachine) * juggernaut gem (gem install juggernaut) * jQuery 1.2.6 =============================================== INSTALLATION =============================================== 1. From your Rails Dir: If you have prototype installed in public/javascripts, juggernaut-jquery will not install the new javascript files script/plugin install git://github.com/dvdplm/juggernaut-jquery.git 2. Make sure to include the appropriate JavaScripts in your views/layouts in the header of your views <%= javascript_include_tag :defaults, :juggernaut %> 3. Add this to your view/layout head: <%= juggernaut %> 4. Make sure the juggernaut gem is installed (gem install juggernaut) 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', "
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。