diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 31b14138f..be9535559 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -9,7 +9,7 @@ = stylesheet_link_tag "blueprint/screen", :media => 'screen' = stylesheet_link_tag "application" /= javascript_include_tag"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" - = javascript_include_tag 'jquery142', 'rails', 'view' + = javascript_include_tag 'jquery142', 'rails', 'view', 'google' = javascript_include_tag 'tiny_mce/tiny_mce.js' diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index 701cc0502..22086046d 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -1,23 +1,14 @@ require 'em-websocket' require 'eventmachine' - +require 'lib/socket_render' module WebSocket EM.next_tick { EM.add_timer(0.1) do @channel = EM::Channel.new puts @channel.inspect - #this should really be a controller - @view = ActionView::Base.new(ActionController::Base.view_paths, {}) + include SocketRenderer - class << @view - include ApplicationHelper - include Rails.application.routes.url_helpers - include ActionController::RequestForgeryProtection::ClassMethods - def protect_against_forgery? - false - end - end end EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug =>true) do |ws| @@ -32,26 +23,8 @@ module WebSocket } def self.update_clients(object) - @channel.push(WebSocket.view_hash(object).to_json) if @channel + @channel.push(SocketRenderer.view_hash(object).to_json) if @channel end - def self.view_hash(object) - begin - puts "I be working hard" - v = WebSocket.view_for(object) - puts v.inspect - - rescue Exception => e - puts "in failzord " + v.inspect - puts object.inspect - puts e.message - raise e - end - puts "i made it here" - {:class =>object.class.to_s.underscore.pluralize, :html => v} - end - - def self.view_for(object) - @view.render @view.type_partial(object), :post => object - end + end diff --git a/public/javascripts/google.js b/public/javascripts/google.js new file mode 100644 index 000000000..2ea0010bb --- /dev/null +++ b/public/javascripts/google.js @@ -0,0 +1,14 @@ + diff --git a/spec/lib/web_socket_spec.rb b/spec/lib/web_socket_spec.rb index 55e383a73..4613dc98a 100644 --- a/spec/lib/web_socket_spec.rb +++ b/spec/lib/web_socket_spec.rb @@ -2,18 +2,4 @@ require File.dirname(__FILE__) + '/../spec_helper' -describe WebSocket do - it 'should prepare a view along with an objects class in json' do - - EventMachine.run { - include WebSocket - user = Factory.create(:user) - post = Factory.create(:status_message) - - json = WebSocket.view_hash(post) - json.should include post.message - - EventMachine.stop - } - end -end \ No newline at end of file +