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
|
||||
gem "nifty-generators"
|
||||
gem "ruby-debug"
|
||||
end
|
||||
|
||||
group :deployment do
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
%html
|
||||
%head
|
||||
%title
|
||||
= yield(:title) || "Untitled"
|
||||
= yield(:title) || "diaspora"
|
||||
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
||||
|
||||
= stylesheet_link_tag "blueprint/screen", :media => 'screen'
|
||||
|
|
@ -29,13 +29,14 @@
|
|||
|
||||
ws = new WebSocket("ws://#{request.host}:8080/");
|
||||
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.onopen = function() {
|
||||
debug("connected...");
|
||||
//ws.send("hello server");
|
||||
// ws.send("hello again");
|
||||
};
|
||||
});
|
||||
|
||||
|
|
@ -55,16 +56,16 @@
|
|||
|
||||
// wait for the DOM to be loaded
|
||||
// bind 'myForm' and provide a simple callback function
|
||||
$('#new_status_message').ajaxForm(function() {
|
||||
alert("Thank you for your comment!");
|
||||
});
|
||||
$('#new_bookmark').ajaxForm(function() {
|
||||
alert("Thank you for your comment!");
|
||||
});
|
||||
|
||||
$('#new_blog').ajaxForm(function() {
|
||||
alert("Thank you for your comment!");
|
||||
});
|
||||
$('#new_status_message').ajaxForm(function() {
|
||||
alert("Thank you for your comment!");
|
||||
});
|
||||
$('#new_bookmark').ajaxForm(function() {
|
||||
alert("Thank you for your comment!");
|
||||
});
|
||||
|
||||
$('#new_blog').ajaxForm(function() {
|
||||
alert("Thank you for your comment!");
|
||||
});
|
||||
});
|
||||
|
||||
%body
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ module WebSocket
|
|||
}
|
||||
#this should get folded into message queue i think?
|
||||
def self.update_clients(object)
|
||||
|
||||
n = @view.render(:partial => @view.type_partial(object), :locals => {:post => object})
|
||||
@channel.push(n) if @channel
|
||||
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
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue