Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
diaspora
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Milan
diaspora
Commits
6e1ed788
Commit
6e1ed788
authored
Nov 22, 2010
by
zhitomirskiyi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:diaspora/diaspora
parents
e84ce559
26a11f7a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
81 additions
and
32 deletions
+81
-32
app/controllers/comments_controller.rb
app/controllers/comments_controller.rb
+9
-1
app/controllers/status_messages_controller.rb
app/controllers/status_messages_controller.rb
+11
-2
app/helpers/sockets_helper.rb
app/helpers/sockets_helper.rb
+2
-1
app/views/comments/_comment.html.haml
app/views/comments/_comment.html.haml
+1
-1
public/javascripts/stream.js
public/javascripts/stream.js
+17
-0
public/javascripts/web-socket-receiver.js
public/javascripts/web-socket-receiver.js
+31
-25
public/stylesheets/sass/application.sass
public/stylesheets/sass/application.sass
+10
-2
No files found.
app/controllers/comments_controller.rb
View file @
6e1ed788
...
...
@@ -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
...
...
app/controllers/status_messages_controller.rb
View file @
6e1ed788
...
...
@@ -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
...
...
app/helpers/sockets_helper.rb
View file @
6e1ed788
...
...
@@ -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
...
...
app/views/comments/_comment.html.haml
View file @
6e1ed788
...
...
@@ -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
...
...
public/javascripts/stream.js
View file @
6e1ed788
...
...
@@ -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
...
...
public/javascripts/web-socket-receiver.js
View file @
6e1ed788
...
...
@@ -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
(
toggler
.
length
>
0
){
toggler
.
html
(
toggler
.
html
().
replace
(
/
\d
+/
,
$
(
'
.comments
'
,
post
)[
0
].
childElementCount
-
1
)
);
if
(
!
$
(
"
.comments
"
,
post
).
is
(
'
:visible
'
)
){
toggler
.
click
();
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
){
...
...
public/stylesheets/sass/application.sass
View file @
6e1ed788
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment