From 5cf2e3c3eaeb3e35918c18d216d98cea779a5592 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 28 Jun 2010 14:47:23 -0700 Subject: [PATCH] commiting so i can pull --- app/controllers/comments_controller.rb | 3 +++ app/views/comments/_comments.html.haml | 2 +- app/views/comments/_new_comment.html.haml | 10 +++++----- config/initializers/socket.rb | 17 +++++++++-------- lib/message_handler.rb | 10 +++++----- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 0a31a4604..785f20320 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -4,6 +4,9 @@ class CommentsController < ApplicationController def create target = Post.first(:id => params[:comment][:post_id]) text = params[:comment][:text] + puts params.inspect + + if current_user.comment text, :on => target render :text => "Woo!" else diff --git a/app/views/comments/_comments.html.haml b/app/views/comments/_comments.html.haml index 374f585e5..50af21178 100644 --- a/app/views/comments/_comments.html.haml +++ b/app/views/comments/_comments.html.haml @@ -1,5 +1,5 @@ %div.comments - = render "comments/new_comment", :post => post + /= render "comments/new_comment", :post => post %ul.comment_set - for comment in post.comments = render "comments/comment", :comment => comment diff --git a/app/views/comments/_new_comment.html.haml b/app/views/comments/_new_comment.html.haml index b377602e3..7cfc43756 100644 --- a/app/views/comments/_new_comment.html.haml +++ b/app/views/comments/_new_comment.html.haml @@ -1,6 +1,6 @@ -= form_for Comment.new, :remote => true do |f| - = f.error_messages += form_tag("/comments",:remote => true, :class =>"new_comment", :id => "new_comment") do %p - = f.text_field :text, :value => "dislike!" - = f.hidden_field :post_id, :value => post.id - = f.submit 'comment', :class => 'button' + = text_field_tag "comment_text", 'dislike!', :size => 30, :name => 'comment[text]' + = hidden_field_tag "comment_post_id", "#{post.id}", :name => "comment[post_id]" + = submit_tag 'comment', :id => "comment_submit", :name => "commit" + diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index a6e9a6aa1..b55c3e185 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -10,6 +10,7 @@ module WebSocket class << @view include ApplicationHelper include Rails.application.routes.url_helpers + include ActionView::Helpers::FormTagHelper end end @@ -30,14 +31,14 @@ module WebSocket end def self.view_hash(object) - #begin - # puts "I be working hard" - v = WebSocket.view_for(object) - #puts view.inspect - #rescue - # puts "in failzord " + view.inspect - # raise "i suck" - #end + begin + puts "I be working hard" + v = WebSocket.view_for(object) + puts v.inspect + rescue + puts "in failzord " + v .inspect + raise "i suck" + end {:class =>object.class.to_s.underscore.pluralize, :html => v} end diff --git a/lib/message_handler.rb b/lib/message_handler.rb index 6fb15dfbe..8a7845e4f 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -1,7 +1,3 @@ -# require 'addressable/uri' -# require 'eventmachine' -# require 'em-http' - class MessageHandler NUM_TRIES = 3 @@ -17,6 +13,9 @@ class MessageHandler def add_post_request(destinations, body) + puts "yay" + puts destinations.inspect + puts body.inspect destinations.each{|dest| @queue.push(Message.new(:post, dest, body))} end @@ -25,7 +24,7 @@ class MessageHandler case query.type when :post http = EventMachine::HttpRequest.new(query.destination).post :timeout => TIMEOUT, :body =>{:xml => query.body} - http.callback {puts query.inspect; process} + http.callback {puts query.body; process} when :get http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT http.callback {send_to_seed(query, http.response); process} @@ -34,6 +33,7 @@ class MessageHandler end http.errback { + puts query.destination + " failed!" query.try_count +=1 @queue.push query unless query.try_count >= NUM_TRIES process