Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
6e1ed78861
7 changed files with 81 additions and 32 deletions
|
|
@ -3,6 +3,7 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class CommentsController < ApplicationController
|
||||
include ApplicationHelper
|
||||
before_filter :authenticate_user!
|
||||
|
||||
respond_to :html
|
||||
|
|
@ -15,7 +16,14 @@ class CommentsController < ApplicationController
|
|||
@comment = current_user.comment(text, :on => target) if target
|
||||
if @comment
|
||||
Rails.logger.info("event=comment_create user=#{current_user.inspect} status=success comment=#{@comment.inspect}")
|
||||
render :nothing => true, :status => 201
|
||||
|
||||
respond_to do |format|
|
||||
format.js{ render :json => { :post_id => @comment.post_id,
|
||||
:comment_id => @comment.id,
|
||||
:html => render_to_string(:partial => type_partial(@comment), :locals => {:post => @comment, :current_user => current_user})},
|
||||
:status => 201 }
|
||||
format.html{ render :nothing => true, :status => 201 }
|
||||
end
|
||||
else
|
||||
render :nothing => true, :status => 401
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,9 +26,18 @@ class StatusMessagesController < ApplicationController
|
|||
for photo in photos
|
||||
current_user.dispatch_post(photo, :to => params[:status_message][:to])
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js{ render :json => { :post_id => @status_message.id,
|
||||
:html => render_to_string(:partial => 'shared/stream_element', :locals => {:post => @status_message, :current_user => current_user})},
|
||||
:status => 201 }
|
||||
format.html{ respond_with @status_message }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.js{ render :status => 401 }
|
||||
end
|
||||
end
|
||||
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,13 +23,14 @@ module SocketsHelper
|
|||
Rails.logger.error("web socket view rendering failed for object #{object.inspect}.")
|
||||
raise e
|
||||
end
|
||||
action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)}
|
||||
action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)}
|
||||
action_hash.merge! opts
|
||||
if object.is_a? Photo
|
||||
action_hash[:photo_hash] = object.thumb_hash
|
||||
end
|
||||
|
||||
if object.is_a? Comment
|
||||
action_hash[:comment_id] = object.id
|
||||
action_hash[:my_post?] = (object.post.person.owner.id == uid)
|
||||
action_hash[:notification] = notification(object)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
%li.comment
|
||||
%li.comment{:data=>{:guid=>post.id}}
|
||||
= person_image_link(post.person)
|
||||
.content
|
||||
.from
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
$(document).ready(function(){
|
||||
var $stream = $(".stream");
|
||||
var $publisher = $("#publisher");
|
||||
// expand all comments on page load
|
||||
$(".stream:not('.show')").find('.comments').each(function(index) {
|
||||
var comments = $(this);
|
||||
|
|
@ -51,6 +52,22 @@ $(document).ready(function(){
|
|||
}
|
||||
});
|
||||
|
||||
$(".new_status_message").bind('ajax:success', function(data, json, xhr){
|
||||
json = $.parseJSON(json);
|
||||
WebSocketReceiver.addPostToStream(json['post_id'],json['html']);
|
||||
});
|
||||
$(".new_status_message").bind('ajax:failure', function(data, html, xhr){
|
||||
alert('failed to post message!');
|
||||
});
|
||||
|
||||
$(".new_comment").live('ajax:success', function(data, json, xhr){
|
||||
json = $.parseJSON(json);
|
||||
WebSocketReceiver.processComment(json['post_id'],json['comment_id'],json['html'],false);
|
||||
});
|
||||
$(".new_comment").live('ajax:failure', function(data, html, xhr){
|
||||
alert('failed to post message!');
|
||||
});
|
||||
|
||||
});//end document ready
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ var WebSocketReceiver = {
|
|||
WebSocketReceiver.processRetraction(obj['post_id']);
|
||||
|
||||
}else if (obj['class']=="comments"){
|
||||
WebSocketReceiver.processComment(obj['post_id'], obj['html'], {'notification':obj['notification'], 'mine?':obj['mine?'], 'my_post?':obj['my_post?']})
|
||||
WebSocketReceiver.processComment(obj['post_id'], obj['comment_id'], obj['html'], {'notification':obj['notification'], 'mine?':obj['mine?'], 'my_post?':obj['my_post?']})
|
||||
|
||||
}else{
|
||||
WebSocketReceiver.processPost(obj['class'], obj['html'], obj['aspect_ids'])
|
||||
WebSocketReceiver.processPost(obj['class'], obj['post_id'], obj['html'], obj['aspect_ids'])
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -62,44 +62,50 @@ var WebSocketReceiver = {
|
|||
}
|
||||
},
|
||||
|
||||
processComment: function(post_id, html, opts){
|
||||
post = $("*[data-guid='"+post_id+"']'");
|
||||
$('.comments li:last', post ).before(
|
||||
$(html).fadeIn("fast", function(){})
|
||||
);
|
||||
toggler = $('.show_post_comments', post);
|
||||
processComment: function(postId, commentId, html, opts){
|
||||
|
||||
if(toggler.length > 0){
|
||||
toggler.html(
|
||||
toggler.html().replace(/\d+/,$('.comments', post)[0].childElementCount -1)
|
||||
if( $(".comment[data-guid='"+commentId+"']").length == 0 ){
|
||||
|
||||
post = $("*[data-guid='"+postId+"']'");
|
||||
$('.comments li:last', post ).before(
|
||||
$(html).fadeIn("fast", function(){})
|
||||
);
|
||||
toggler = $('.show_post_comments', post);
|
||||
|
||||
if( !$(".comments", post).is(':visible') ){
|
||||
toggler.click();
|
||||
if(toggler.length > 0){
|
||||
toggler.html(
|
||||
toggler.html().replace(/\d+/,$('.comments', post)[0].childElementCount -1)
|
||||
);
|
||||
|
||||
if( !$(".comments", post).is(':visible') ){
|
||||
toggler.click();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !opts['mine?'] && opts['my_post?']) {
|
||||
WebSocketReceiver.processNotification(opts['notification']);
|
||||
if( !opts['mine?'] && opts['my_post?']) {
|
||||
WebSocketReceiver.processNotification(opts['notification']);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
processPost: function(className, html, aspectIds){
|
||||
processPost: function(className, postId, html, aspectIds){
|
||||
if(WebSocketReceiver.onPageForAspects(aspectIds)){
|
||||
if( $("#no_posts").is(":visible") ){
|
||||
$("#no_posts").fadeOut(400, WebSocketReceiver.addPostToStream(html)).hide();
|
||||
$("#no_posts").fadeOut(400, WebSocketReceiver.addPostToStream(postId, html)).hide();
|
||||
} else {
|
||||
WebSocketReceiver.addPostToStream(html);
|
||||
WebSocketReceiver.addPostToStream(postId, html);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addPostToStream: function(html){
|
||||
$("#main_stream:not('.show')").prepend(
|
||||
$(html).fadeIn("fast", function(){
|
||||
$("#main_stream").find("label").first().inFieldLabels();
|
||||
})
|
||||
);
|
||||
addPostToStream: function(postId, html){
|
||||
if( $(".message[data-guid='"+postId+"']").length == 0 ){
|
||||
$("#main_stream:not('.show')").prepend(
|
||||
$(html).fadeIn("fast", function(){
|
||||
$("#main_stream").find("label").first().inFieldLabels();
|
||||
})
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
onPageForClass: function(className){
|
||||
|
|
|
|||
|
|
@ -159,8 +159,9 @@ header
|
|||
:background
|
||||
:color #000
|
||||
|
||||
:border
|
||||
:radius 5px
|
||||
:-webkit-border-radius 5px
|
||||
:-moz-border-radius 5px
|
||||
:border-radius 5px
|
||||
|
||||
:position absolute
|
||||
:display inline
|
||||
|
|
@ -688,6 +689,8 @@ li.message .from .right
|
|||
:-moz-border-radius 3px
|
||||
:border-radius 3px
|
||||
|
||||
:max-width 100%
|
||||
|
||||
img
|
||||
:z-index 2
|
||||
:position relative
|
||||
|
|
@ -1261,7 +1264,10 @@ ul#settings_nav
|
|||
:color rgb(250,250,250)
|
||||
:border 1px solid #ddd
|
||||
:padding 11px
|
||||
|
||||
:-webkit-border-radius 4px
|
||||
:-moz-border-radius 4px
|
||||
:border-radius 4px
|
||||
|
||||
h2,h3
|
||||
:border
|
||||
|
|
@ -1954,6 +1960,8 @@ h3,h4
|
|||
:color #ccc
|
||||
|
||||
:-webkit-border-radius 10px
|
||||
:-moz-border-radius 10px
|
||||
:border-radius 10px
|
||||
|
||||
:width 15px
|
||||
:max-width 12px
|
||||
|
|
|
|||
Loading…
Reference in a new issue