diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb
index 5fa140597..4282b8964 100644
--- a/app/controllers/dev_utilities_controller.rb
+++ b/app/controllers/dev_utilities_controller.rb
@@ -37,6 +37,8 @@ def warzombie
def zombiefriendaccept
render :nothing => true
+ set_profile_photo
+
Request.all.each{|r|
current_user.accept_and_respond(r.id, current_user.groups.first.id)
}
@@ -54,4 +56,15 @@ def warzombie
file.write(seed_num_hash.to_yaml)
file.close
end
+
+ def set_profile_photo
+ album = current_user.post(:album, :name => "Profile Photos")
+
+ backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i
+ username = backer_info[backer_number]['username'].gsub(/ /,'').downcase
+ photo = current_user.post(:photo, :album_id => album.id,
+ :user_file => "public/images/users/#{username}.jpg")
+
+ current_user.update_profile(:image_url => photo.url)
+ end
end
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index aa0e618ef..b0b4eaea7 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -3,8 +3,10 @@ class GroupsController < ApplicationController
def index
@posts = current_user.visible_posts(:by_members_of => :all).paginate :page => params[:page], :order => 'created_at DESC'
- @group = :all
@friends = current_user.friends
+
+ @groups = current_user.groups.find_all_by_id(params[:group_ids]) if params[:group_ids]
+ @groups ||= current_user.groups
end
def create
diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb
index cdb2b5c2e..2d5ae315a 100644
--- a/app/controllers/sockets_controller.rb
+++ b/app/controllers/sockets_controller.rb
@@ -9,7 +9,7 @@ class SocketsController < ApplicationController
def outgoing(uid,object,opts={})
@_request = ActionDispatch::Request.new({})
- Diaspora::WebSocket.push_to_user(uid, action_hash(uid, object, :group_id => opts[:group_id]))
+ Diaspora::WebSocket.push_to_user(uid, action_hash(uid, object, opts))
end
end
diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb
index 3cacb1a55..d5cd07d51 100644
--- a/app/controllers/status_messages_controller.rb
+++ b/app/controllers/status_messages_controller.rb
@@ -6,16 +6,12 @@ class StatusMessagesController < ApplicationController
@status_message = current_user.post(:status_message, params[:status_message])
if @status_message.created_at
- flash[:notice] = "Successfully created status message."
+ render :nothing => true
else
- render :action => 'new'
+ redirect_to root_url
end
end
- def new
- @status_message = StatusMessage.new
- end
-
def destroy
@status_message = StatusMessage.where(:id => params[:id]).first
@status_message.destroy
diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb
index d4765feb7..3ac42f740 100644
--- a/app/helpers/sockets_helper.rb
+++ b/app/helpers/sockets_helper.rb
@@ -13,8 +13,8 @@ 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, :group_id => opts[:group_id] , :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
elsif object.is_a? StatusMessage
diff --git a/app/models/user.rb b/app/models/user.rb
index 7f3eeddf4..4d718ccc0 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -80,10 +80,10 @@ class User
group.save
target_people = target_people | group.people
}
+
+ post.socket_to_uid(id, :group_ids => groups.map{|g| g.id}) if post.respond_to?(:socket_to_uid)
post.push_to( target_people )
- post.socket_to_uid(id) if post.respond_to?(:socket_to_uid)
-
self.raw_visible_posts << post
self.save
post
diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml
index 282a07624..5305547cb 100644
--- a/app/views/js/_websocket_js.haml
+++ b/app/views/js/_websocket_js.haml
@@ -9,7 +9,8 @@
//Attach onmessage to websocket
ws.onmessage = function(evt) {
var obj = jQuery.parseJSON(evt.data);
- debug("got a " + obj['class'] + " for group " + obj['group_id']);
+ console.log(obj)
+ debug("got a " + obj['class'] + " for groups " + obj['group_ids']);
if (obj['class']=="retractions"){
processRetraction(obj['post_id']);
@@ -19,10 +20,8 @@
}else if (obj['class']=='photos' && onPageForClass('albums')){
processPhotoInAlbum(obj['photo_hash'])
- }else if (obj['class']=='status_messages'){
- processStatusMessage(obj['class'], obj['html'], obj['status_message_hash'], obj['group_id'], obj['mine?'])
}else{
- processPost(obj['class'], obj['html'], obj['group_id'], obj['mine?'])
+ processPost(obj['class'], obj['html'], obj['group_ids'])
}
@@ -33,69 +32,68 @@
debug("connected...");
};
- function processRetraction(post_id){
- $('#' + post_id ).fadeOut(500, function(){
- $(this).remove;
- });
- }
- function processComment(post_id, html){
- post = $('#' + post_id)[0]
- $(' .comment_set li:last', post ).before(
- $(html).fadeIn("fast", function(){})
- );
- toggler = $('.show_post_comments', post)
- toggler.html(
- toggler.html().replace(/\d/,$('.comment_set', post)[0].childElementCount -1));
- }
-
- function processPost(className, html, groupId, mineBool){
- if(mineBool || onPageForClass(className) || onPageForGroup(groupId)){
- $("#stream").prepend(
- $(html).fadeIn("fast", function(){
- $("#stream label:first").inFieldLabels();
- })
- );
- }
- }
-
- function processStatusMessage(className, html, messageHash, groupId, mineBool){
- processPost(className, html, groupId, mineBool);
- console.log(messageHash)
- if(messageHash['mine?']){
- updateMyLatestStatus(messageHash);
- }
- }
-
- function updateMyLatestStatus(messageHash){
- $("#latest_message").text(messageHash['text']);
- $("#latest_message_time").text(' - just now');
- }
-
- function processPhotoInAlbum(photoHash){
- if (location.href.indexOf(photoHash['album_id']) == -1){
- return ;
- }
- html = "
"
- $("#thumbnails").append( $(html) )
- $("#"+ photoHash['id'] + " img").load( function() {
- $(this).fadeIn("slow");
- });
- }
-
- function onPageForClass(className){
- return ((location.href.indexOf(className) != -1 ) || (location.pathname == '/')) && onPageOne();
- }
-
- function onPageForGroup(groupId){
- return (location.href.indexOf(groupId) != -1 )
- }
-
- function onPageOne() {
- var c = document.location.search.charAt(document.location.search.length-1);
- return ((c =='') || (c== '1'));
- }
});
+ function processRetraction(post_id){
+ $('#' + post_id ).fadeOut(500, function(){
+ $(this).remove;
+ });
+ }
+
+ function processComment(post_id, html){
+ post = $('#' + post_id)[0]
+ $(' .comment_set li:last', post ).before(
+ $(html).fadeIn("fast", function(){})
+ );
+ toggler = $('.show_post_comments', post)
+ toggler.html(
+ toggler.html().replace(/\d/,$('.comment_set', post)[0].childElementCount -1));
+ }
+
+ function processPost(className, html, groupIds){
+ if(onPageForGroups(groupIds)){
+ $("#stream").prepend(
+ $(html).fadeIn("fast", function(){
+ $("#stream label:first").inFieldLabels();
+ })
+ );
+ }
+ }
+
+ function processPhotoInAlbum(photoHash){
+ if (location.href.indexOf(photoHash['album_id']) == -1){
+ return ;
+ }
+ html = ""
+ $("#thumbnails").append( $(html) )
+ $("#"+ photoHash['id'] + " img").load( function() {
+ $(this).fadeIn("slow");
+ });
+ }
+
+ function onPageForClass(className){
+ return ((location.href.indexOf(className) != -1 ) || (location.pathname == '/')) && onPageOne();
+ }
+
+ function onPageForGroups(groupIds){
+ if(location.pathname == '/' && onPageOne()){
+ return true
+ }
+ var found = false;
+ $.each(groupIds, function(index, value) {
+ if(onPageForGroup(value)){ found = true };
+ });
+ return found;
+ }
+
+ function onPageForGroup(groupId){
+ return (location.href.indexOf(groupId) != -1 )
+ }
+
+ function onPageOne() {
+ var c = document.location.search.charAt(document.location.search.length-1);
+ return ((c =='') || (c== '1'));
+ }
diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml
index 427f97289..a2aaba4e9 100644
--- a/app/views/shared/_group_nav.haml
+++ b/app/views/shared/_group_nav.haml
@@ -1,9 +1,10 @@
#friend_pictures
- for friend in @friends
= person_image_link(friend)
- = link_to (image_tag 'add_friend_button.png'), "#add_request_pane", :id => 'add_request_button'
- unless @group == :all
+ = link_to (image_tag 'add_friend_button.png'), "#add_request_pane", :id => 'add_request_button'
+
.yo{:style => 'display:none'}
#add_request_pane
= render "requests/new_request"
diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml
index 59fdbbfb7..da57beff7 100644
--- a/app/views/shared/_publisher.haml
+++ b/app/views/shared/_publisher.haml
@@ -3,8 +3,8 @@
= form_for StatusMessage.new, :remote => true do |f|
= f.error_messages
- .span-15.last
- .span-2.last
+ .span-15
+ .span-2
.user_image
= owner_image_tag
.span-13.last
@@ -12,8 +12,7 @@
%label{:for => "status_message_message"} Message
= f.text_area :message, :rows => 2
- .span-3.last
-
+ .span-3
%ul.group_selector
going to...
- for group in current_user.groups
diff --git a/app/views/status_messages/new.html.haml b/app/views/status_messages/new.html.haml
deleted file mode 100644
index 2e9c88474..000000000
--- a/app/views/status_messages/new.html.haml
+++ /dev/null
@@ -1,13 +0,0 @@
-- title "New Status Message"
-
-= form_for @status_message, :remote => true do |f|
- = f.error_messages
- %p
- = f.label :message
- %br
- = f.text_field :message
- %p
- = f.submit
-
-
-%p= link_to "Back to List", status_messages_path
diff --git a/config/app_config.yml b/config/app_config.yml
index 1eee9376c..db81e9ddc 100644
--- a/config/app_config.yml
+++ b/config/app_config.yml
@@ -1,6 +1,6 @@
development:
debug: false
- socket_debug : false
+ socket_debug : true
socket_port: 8080
pubsub_server: 'https://pubsubhubbub.appspot.com/'
diff --git a/config/routes.rb b/config/routes.rb
index f2b4ebd80..1f3efbbbd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,7 +1,7 @@
Diaspora::Application.routes.draw do
resources :people, :only => [:index, :show, :destroy]
resources :users, :except => [:create, :new]
- resources :status_messages, :except => [:index]
+ resources :status_messages, :only => [:create, :destroy, :show]
resources :comments, :except => [:index]
resources :requests, :except => [:edit, :update]
resources :photos, :except => [:index]
diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb
index bc5039aa1..f8fe0dc97 100644
--- a/db/seeds/backer.rb
+++ b/db/seeds/backer.rb
@@ -19,10 +19,12 @@ def create
:password => "#{username+backer_info[backer_number]['pin'].to_s}",
:person => Person.new(
:email => "#{username}@#{username}.joindiaspora.com",
- :profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'] ),
+ :profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'],
+ :image_url => "http://#{username}.joindiaspora.com/images/users/#{username}.jpg"),
:url=> "http://#{username}.joindiaspora.com/")
)
user.person.save
+
user.group(:name => "Presidents")
end
diff --git a/lib/diaspora/websocket.rb b/lib/diaspora/websocket.rb
index d3ca511bb..3eb41ed45 100644
--- a/lib/diaspora/websocket.rb
+++ b/lib/diaspora/websocket.rb
@@ -10,7 +10,7 @@ module Diaspora
end
def self.subscribe(uid, ws)
- Rails.logger.debug "Subscribing socket to #{User.first(:id => uid).email}"
+ Rails.logger.debug "Subscribing socket to #{uid}"
self.ensure_channel(uid)
@channels[uid][0].subscribe{ |msg| ws.send msg }
@channels[uid][1] += 1
@@ -32,7 +32,8 @@ module Diaspora
module Socketable
def socket_to_uid(id, opts={})
- SocketsController.new.outgoing(id, self, :group_id => opts[:group_id])
+ puts "#{id}, #{self}, #{opts}"
+ SocketsController.new.outgoing(id, self, opts)
end
def unsocket_from_uid id
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 24faf671b..34cfe4904 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -319,18 +319,27 @@ label {
height: 50px;
padding-left: 10px; }
#publisher ul.group_selector {
+ float: left;
padding: 0;
margin: 0;
- width: 150px;
+ width: auto;
+ z-index: 10;
+ position: absolute;
+ height: auto;
+ overflow: visible;
list-style: none; }
#publisher ul.group_selector > li {
- z-index: 10;
+ height: auto;
+ font-size: smaller;
+ padding: 2px;
display: none;
background-color: white; }
#publisher ul.group_selector > li:active {
background-color: yellow; }
#publisher ul.group_selector:hover li {
display: block; }
+ #publisher .button {
+ margin-left: 100px; }
#image_picker .small_photo {
height: 100px;
diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass
index 3e14cab06..b603e790e 100644
--- a/public/stylesheets/sass/application.sass
+++ b/public/stylesheets/sass/application.sass
@@ -397,14 +397,21 @@ label
:left 10px
ul.group_selector
+ :float left
:padding 0
:margin 0
- :width 150px
+ :width auto
+ :z-index 10
+ :position absolute
+ :height auto
+ :overflow visible
:list
:style none
> li
- :z-index 10
+ :height auto
+ :font-size smaller
+ :padding 2px
:display none
:background
:color #fff
@@ -415,6 +422,9 @@ label
&:hover li
:display block
+
+ .button
+ :margin-left 100px
#image_picker
diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb
index ad4d00e2b..64869df86 100644
--- a/spec/models/person_spec.rb
+++ b/spec/models/person_spec.rb
@@ -144,5 +144,18 @@ describe Person do
it 'should search by email exactly' do
Person.by_webfinger(@friend_one.email).should == @friend_one
end
+
+ describe 'wall posting' do
+ it 'should be able to post on another persons wall' do
+
+ #user2 is in user's group, user is in group2 on user
+ friend_users(@user, @group, @user2, @group2)
+
+ @user.person.post_to_wall(:person => @user2.person, :message => "youve got a great smile")
+ @user.person.wall_posts.count.should == 1
+
+ end
+ end
+
end
end