Merge branch 'master' of github.com:diaspora/diaspora_rails

This commit is contained in:
ilya 2010-06-28 21:32:18 -04:00
commit 0fa11806ba
8 changed files with 25 additions and 19 deletions

View file

@ -3,7 +3,7 @@ module StatusMessagesHelper
def my_latest_message
message = StatusMessage.my_newest
unless message.nil?
return message.message + " " + how_long_ago(message)
return message.message + " - " + how_long_ago(message)
else
return "No message to display."
end

View file

@ -37,8 +37,7 @@ class Post
protected
def send_to_view
self.reload
WebSocket.update_clients(self)
WebSocket.update_clients(self)
end

View file

@ -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

View file

@ -1,6 +1,5 @@
= form_tag("/comments",:remote => true, :class =>"new_comment", :id => "new_comment") do
= form_tag("/comments", :remote => true, :class =>"new_comment", :id => "new_comment-#{post.id}") do
%p
= 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"
= submit_tag 'comment', :id => "comment_submit_#{post.id}", :name => "commit"

View file

@ -8,7 +8,7 @@
= stylesheet_link_tag "blueprint/screen", :media => 'screen'
= stylesheet_link_tag "application"
/= javascript_include_tag"http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"
/= 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 'tiny_mce/tiny_mce.js'
@ -30,6 +30,7 @@
ws = new WebSocket("ws://#{request.host}:8080/");
ws.onmessage = function(evt) {
var obj = jQuery.parseJSON(evt.data);
debug("got a " + obj['class']);
if((location.href.indexOf(obj['class']) != -1 ) || (location.pathname == '/')) {
$("#stream").prepend($(obj['html']).fadeIn("fast"));
};

View file

@ -5,20 +5,26 @@ module WebSocket
EM.next_tick {
EM.add_timer(0.1) do
@channel = EM::Channel.new
puts @channel.inspect
@view = ActionView::Base.new(ActionController::Base.view_paths, {})
class << @view
include ApplicationHelper
include Rails.application.routes.url_helpers
include ActionController::RequestForgeryProtection::ClassMethods
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::UrlHelper
def protect_against_forgery?
false
end
end
end
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug =>false) do |ws|
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug =>true) do |ws|
ws.onopen {
sid = @channel.subscribe { |msg| ws.send msg }
ws.onmessage { |msg|}#@channel.push msg; puts msg}
ws.onmessage { |msg| }#@channel.push msg; puts msg}
ws.onclose { @channel.unsubscribe(sid) }
}
@ -33,12 +39,15 @@ module WebSocket
begin
puts "I be working hard"
v = WebSocket.view_for(object)
puts v.inspect
rescue
puts "in failzord " + v .inspect
raise "i suck"
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

View file

@ -13,9 +13,6 @@ 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
@ -24,7 +21,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.body; process}
http.callback {process}
when :get
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
http.callback {send_to_seed(query, http.response); process}

View file

@ -30,6 +30,7 @@ $(document).ready(function(){
$('#bookmark_title').click(clearForm);
$('#bookmark_link').click(clearForm);
$('#debug_more').hide();
function clearForm(){
$(this).val("");