messy application.haml file i know, but now the sockets only update pages which want their data
This commit is contained in:
parent
94de043862
commit
fd5d7c63ad
3 changed files with 19 additions and 19 deletions
1
Gemfile
1
Gemfile
|
|
@ -32,6 +32,7 @@ end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem "nifty-generators"
|
gem "nifty-generators"
|
||||||
|
gem "ruby-debug"
|
||||||
end
|
end
|
||||||
|
|
||||||
group :deployment do
|
group :deployment do
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
%html
|
%html
|
||||||
%head
|
%head
|
||||||
%title
|
%title
|
||||||
= yield(:title) || "Untitled"
|
= yield(:title) || "diaspora"
|
||||||
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
||||||
|
|
||||||
= stylesheet_link_tag "blueprint/screen", :media => 'screen'
|
= stylesheet_link_tag "blueprint/screen", :media => 'screen'
|
||||||
|
|
@ -29,13 +29,14 @@
|
||||||
|
|
||||||
ws = new WebSocket("ws://#{request.host}:8080/");
|
ws = new WebSocket("ws://#{request.host}:8080/");
|
||||||
ws.onmessage = function(evt) {
|
ws.onmessage = function(evt) {
|
||||||
$("#stream").prepend($(evt.data).fadeIn("fast"));
|
var obj = jQuery.parseJSON(evt.data);
|
||||||
};
|
if((location.href.indexOf(obj['class']) != -1 ) || (location.pathname == '/')) {
|
||||||
|
$("#stream").prepend($(obj['html']).fadeIn("fast"));
|
||||||
|
};
|
||||||
|
}
|
||||||
ws.onclose = function() { debug("socket closed"); };
|
ws.onclose = function() { debug("socket closed"); };
|
||||||
ws.onopen = function() {
|
ws.onopen = function() {
|
||||||
debug("connected...");
|
debug("connected...");
|
||||||
//ws.send("hello server");
|
|
||||||
// ws.send("hello again");
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -55,16 +56,16 @@
|
||||||
|
|
||||||
// wait for the DOM to be loaded
|
// wait for the DOM to be loaded
|
||||||
// bind 'myForm' and provide a simple callback function
|
// bind 'myForm' and provide a simple callback function
|
||||||
$('#new_status_message').ajaxForm(function() {
|
$('#new_status_message').ajaxForm(function() {
|
||||||
alert("Thank you for your comment!");
|
alert("Thank you for your comment!");
|
||||||
});
|
});
|
||||||
$('#new_bookmark').ajaxForm(function() {
|
$('#new_bookmark').ajaxForm(function() {
|
||||||
alert("Thank you for your comment!");
|
alert("Thank you for your comment!");
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#new_blog').ajaxForm(function() {
|
$('#new_blog').ajaxForm(function() {
|
||||||
alert("Thank you for your comment!");
|
alert("Thank you for your comment!");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
%body
|
%body
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,7 @@ module WebSocket
|
||||||
}
|
}
|
||||||
#this should get folded into message queue i think?
|
#this should get folded into message queue i think?
|
||||||
def self.update_clients(object)
|
def self.update_clients(object)
|
||||||
|
n = @view.render(:partial => @view.type_partial(object), :locals => {:post => object})
|
||||||
n = @view.render(:partial => @view.type_partial(object), :locals => {:post => object})
|
@channel.push({:class =>object.class.to_s.underscore.pluralize, :html => n}.to_json) if @channel
|
||||||
@channel.push(n) if @channel
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue