Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
33317aeeaf
17 changed files with 177 additions and 44 deletions
|
|
@ -52,7 +52,7 @@ class AlbumsController < ApplicationController
|
||||||
|
|
||||||
data = clean_hash(params[:album])
|
data = clean_hash(params[:album])
|
||||||
|
|
||||||
if @album.update_attributes data
|
if current_user.update_post( @album, data )
|
||||||
flash[:notice] = "Album #{@album.name} successfully edited."
|
flash[:notice] = "Album #{@album.name} successfully edited."
|
||||||
respond_with @album
|
respond_with @album
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ class PhotosController < ApplicationController
|
||||||
|
|
||||||
data = clean_hash(params)
|
data = clean_hash(params)
|
||||||
|
|
||||||
if @photo.update_attributes data[:photo]
|
if current_user.update_post( @photo, data[:photo] )
|
||||||
flash[:notice] = "Photo successfully updated."
|
flash[:notice] = "Photo successfully updated."
|
||||||
respond_with @photo
|
respond_with @photo
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,12 @@ class User
|
||||||
post
|
post
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_post( post, post_hash = {} )
|
||||||
|
if self.owns? post
|
||||||
|
post.update_attributes(post_hash)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def validate_aspect_permissions(aspect_ids)
|
def validate_aspect_permissions(aspect_ids)
|
||||||
aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId
|
aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
= f.error_messages
|
= f.error_messages
|
||||||
%p
|
%p
|
||||||
%label{:for => "status_message_message"} Message
|
%label{:for => "status_message_message"} Message
|
||||||
= f.text_area :message, :rows => 2
|
= f.text_area :message, :rows => 2, :value => params[:prefill]
|
||||||
|
|
||||||
%ul.aspect_selector{ :style => "display:none;"}
|
%ul.aspect_selector{ :style => "display:none;"}
|
||||||
going to...
|
going to...
|
||||||
|
|
|
||||||
27
app/views/shared/_reshare.haml
Normal file
27
app/views/shared/_reshare.haml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
-# licensed under the Affero General Public License version 3. See
|
||||||
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
$(".reshare_button").toggle(function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
$(this).parent(".reshare_pane").children(".reshare_box").fadeIn(200);
|
||||||
|
}, function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$(this).parent(".reshare_pane").children(".reshare_box").fadeOut(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
.reshare_pane
|
||||||
|
%span.reshare_button
|
||||||
|
= link_to "Reshare", "#"
|
||||||
|
|
||||||
|
%ul.reshare_box
|
||||||
|
- for aspect in current_user.aspects_with_post( post.id )
|
||||||
|
|
||||||
|
%li.currently_sharing= aspect.name
|
||||||
|
|
||||||
|
- for aspect in current_user.aspects
|
||||||
|
- unless aspect.posts.include? post
|
||||||
|
%li.aspect_to_share= link_to aspect, :controller => "aspects", :action => "show", :id => aspect.id, :prefill => post.message
|
||||||
|
|
@ -17,8 +17,10 @@
|
||||||
\--
|
\--
|
||||||
= link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
|
= link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
|
||||||
|
|
||||||
= render "comments/comments", :post => post
|
= render "comments/comments", :post => post
|
||||||
|
|
||||||
- if current_user.owns?(post)
|
- if current_user.owns?(post)
|
||||||
.destroy_link
|
.destroy_link
|
||||||
= link_to 'Delete', status_message_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "delete"
|
= link_to 'Delete', status_message_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "delete"
|
||||||
|
= render "shared/reshare", :post => post, :current_user => current_user
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ end
|
||||||
|
|
||||||
if File.exist? "#{Rails.root}/config/app_config.yml"
|
if File.exist? "#{Rails.root}/config/app_config.yml"
|
||||||
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml"
|
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml"
|
||||||
all_envs = load_config_yaml "#{Rails.root}/config/app_config_example.yml" unless all_envs
|
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example" unless all_envs
|
||||||
else
|
else
|
||||||
puts "WARNING: No config/app_config.yml found! Look at config/app_config_example.yml for help."
|
puts "WARNING: No config/app_config.yml found! Look at config/app_config.yml.example for help."
|
||||||
all_envs = load_config_yaml "#{Rails.root}/config/app_config_example.yml"
|
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example"
|
||||||
end
|
end
|
||||||
|
|
||||||
if all_envs[Rails.env.to_s]
|
if all_envs[Rails.env.to_s]
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
Diaspora::Application.routes.draw do
|
Diaspora::Application.routes.draw do
|
||||||
resources :people, :only => [:index, :show, :destroy]
|
resources :people, :only => [:index, :show, :destroy]
|
||||||
resources :users, :except => [:create, :new, :show]
|
resources :users, :except => [:create, :new, :show]
|
||||||
resources :status_messages, :only => [:create, :destroy, :show]
|
resources :status_messages
|
||||||
resources :comments, :except => [:index]
|
resources :comments, :except => [:index]
|
||||||
resources :requests, :except => [:edit, :update]
|
resources :requests, :except => [:edit, :update]
|
||||||
resources :photos, :except => [:index]
|
resources :photos, :except => [:index]
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ def create
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_app_config username
|
def set_app_config username
|
||||||
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml')))
|
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example')))
|
||||||
current_config[Rails.env.to_s] ||= {}
|
current_config[Rails.env.to_s] ||= {}
|
||||||
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
|
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
|
||||||
current_config['default']['pod_url'] = "#{username}.joindiaspora.com"
|
current_config['default']['pod_url'] = "#{username}.joindiaspora.com"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
require 'config/environment'
|
require 'config/environment'
|
||||||
|
|
||||||
def set_app_config username
|
def set_app_config username
|
||||||
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml')))
|
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example')))
|
||||||
current_config[Rails.env.to_s] ||= {}
|
current_config[Rails.env.to_s] ||= {}
|
||||||
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
|
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
|
||||||
current_config['default']['pod_url'] = "#{username}.joindiaspora.com"
|
current_config['default']['pod_url'] = "#{username}.joindiaspora.com"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
require 'config/environment'
|
require 'config/environment'
|
||||||
|
|
||||||
def set_app_config username
|
def set_app_config username
|
||||||
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml')))
|
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example')))
|
||||||
current_config[Rails.env.to_s] ||= {}
|
current_config[Rails.env.to_s] ||= {}
|
||||||
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
|
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
|
||||||
current_config['default']['pod_url'] = "#{username}.joindiaspora.com"
|
current_config['default']['pod_url'] = "#{username}.joindiaspora.com"
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,12 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$("#publisher textarea").keydown( function(e) {
|
||||||
|
if (e.shiftKey && e.keyCode == 13) {
|
||||||
|
$("#publisher form").submit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});//end document ready
|
});//end document ready
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,41 @@ li.message {
|
||||||
li.message .content div.info .time a {
|
li.message .content div.info .time a {
|
||||||
color: #666666; }
|
color: #666666; }
|
||||||
|
|
||||||
|
.reshare_pane {
|
||||||
|
margin-left: 5px;
|
||||||
|
margin-right: 5px;
|
||||||
|
display: inline;
|
||||||
|
position: relative; }
|
||||||
|
.reshare_pane ul.reshare_box {
|
||||||
|
width: 150px;
|
||||||
|
display: none;
|
||||||
|
z-index: 10;
|
||||||
|
position: absolute;
|
||||||
|
margin-top: 5px;
|
||||||
|
padding: 0;
|
||||||
|
background-color: #fafafa;
|
||||||
|
list-style: none;
|
||||||
|
border: 5px solid #666666;
|
||||||
|
-webkit-box-shadow: 0 0 5px #666666;
|
||||||
|
-moz-box-shadow: 0 0 5px #666666;
|
||||||
|
text-shadow: 0 2px white;
|
||||||
|
color: black; }
|
||||||
|
.reshare_pane ul.reshare_box > li {
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 8px;
|
||||||
|
padding-right: 15px;
|
||||||
|
border-top: 1px solid white;
|
||||||
|
border-bottom: 1px solid #cccccc; }
|
||||||
|
.reshare_pane ul.reshare_box > li:first-child {
|
||||||
|
border-top: none; }
|
||||||
|
.reshare_pane ul.reshare_box > li:last-child {
|
||||||
|
border-bottom: none; }
|
||||||
|
.reshare_pane ul.reshare_box > li a {
|
||||||
|
display: block;
|
||||||
|
height: 100%; }
|
||||||
|
.reshare_pane ul.reshare_box > li a:hover {
|
||||||
|
background-color: #eeeeee; }
|
||||||
|
|
||||||
form {
|
form {
|
||||||
position: relative;
|
position: relative;
|
||||||
font-size: 120%;
|
font-size: 120%;
|
||||||
|
|
@ -270,6 +305,9 @@ ul.comment_set {
|
||||||
.destroy_link a, .request_button a {
|
.destroy_link a, .request_button a {
|
||||||
color: #999999;
|
color: #999999;
|
||||||
font-weight: normal; }
|
font-weight: normal; }
|
||||||
|
.destroy_link a:hover, .request_button a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
background: none; }
|
||||||
|
|
||||||
.destroy_link {
|
.destroy_link {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
||||||
|
|
@ -225,6 +225,59 @@ li.message
|
||||||
a
|
a
|
||||||
:color #666
|
:color #666
|
||||||
|
|
||||||
|
.reshare_pane
|
||||||
|
:margin
|
||||||
|
:left 5px
|
||||||
|
:right 5px
|
||||||
|
:display inline
|
||||||
|
:position relative
|
||||||
|
|
||||||
|
ul.reshare_box
|
||||||
|
:width 150px
|
||||||
|
:display none
|
||||||
|
:z-index 10
|
||||||
|
:position absolute
|
||||||
|
:margin
|
||||||
|
:top 5px
|
||||||
|
:padding 0
|
||||||
|
|
||||||
|
:background
|
||||||
|
:color #fafafa
|
||||||
|
|
||||||
|
:list
|
||||||
|
:style none
|
||||||
|
|
||||||
|
:border 5px solid #666
|
||||||
|
:-webkit-box-shadow 0 0 5px #666
|
||||||
|
:-moz-box-shadow 0 0 5px #666
|
||||||
|
|
||||||
|
:text-shadow 0 2px #fff
|
||||||
|
:color #000
|
||||||
|
|
||||||
|
> li
|
||||||
|
:font
|
||||||
|
:weight bold
|
||||||
|
|
||||||
|
:padding 8px
|
||||||
|
:right 15px
|
||||||
|
:border
|
||||||
|
:top 1px solid #fff
|
||||||
|
:bottom 1px solid #ccc
|
||||||
|
|
||||||
|
&:first-child
|
||||||
|
:border
|
||||||
|
:top none
|
||||||
|
&:last-child
|
||||||
|
:border
|
||||||
|
:bottom none
|
||||||
|
a
|
||||||
|
:display block
|
||||||
|
:height 100%
|
||||||
|
|
||||||
|
&:hover
|
||||||
|
:background
|
||||||
|
:color #eee
|
||||||
|
|
||||||
|
|
||||||
form
|
form
|
||||||
:position relative
|
:position relative
|
||||||
|
|
@ -360,6 +413,10 @@ ul.comment_set
|
||||||
:color #999
|
:color #999
|
||||||
:font
|
:font
|
||||||
:weight normal
|
:weight normal
|
||||||
|
&:hover
|
||||||
|
:text
|
||||||
|
:decoration underline
|
||||||
|
:background none
|
||||||
|
|
||||||
.destroy_link
|
.destroy_link
|
||||||
:display none
|
:display none
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,16 @@ describe User do
|
||||||
aspect1.posts.count.should be 1
|
aspect1.posts.count.should be 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#update_post' do
|
||||||
|
let!(:album) { user.post(:album, :name => "Profile Photos", :to => aspect.id) }
|
||||||
|
|
||||||
|
it 'should update fields' do
|
||||||
|
update_hash = { :name => "Other Photos" }
|
||||||
|
user.update_post( album, update_hash )
|
||||||
|
album.name.should == "Other Photos"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'dispatching' do
|
context 'dispatching' do
|
||||||
|
|
|
||||||
|
|
@ -7,54 +7,41 @@
|
||||||
require File.dirname(__FILE__) + '/../spec_helper'
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
describe User do
|
describe User do
|
||||||
before do
|
let(:user) { Factory(:user) }
|
||||||
@user = Factory.create(:user)
|
let(:aspect) { user.aspect(:name => 'heroes') }
|
||||||
@aspect = @user.aspect(:name => 'heroes')
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#diaspora_handle' do
|
describe '#diaspora_handle' do
|
||||||
it 'uses the pod config url to set the diaspora_handle' do
|
it 'uses the pod config url to set the diaspora_handle' do
|
||||||
@user.diaspora_handle.should == @user.username + "@example.org"
|
user.diaspora_handle.should == user.username + "@example.org"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'profiles' do
|
||||||
|
|
||||||
describe 'profiles' do
|
|
||||||
it 'should be able to update their profile and send it to their friends' do
|
it 'should be able to update their profile and send it to their friends' do
|
||||||
Factory.create(:person)
|
updated_profile = { :profile => {
|
||||||
|
:first_name => 'bob',
|
||||||
|
:last_name => 'billytown',
|
||||||
|
:image_url => "http://clown.com"} }
|
||||||
|
|
||||||
updated_profile = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clown.com"}}
|
user.update_profile(updated_profile).should be true
|
||||||
|
user.profile.image_url.should == "http://clown.com"
|
||||||
@user.update_profile(updated_profile).should == true
|
|
||||||
@user.profile.image_url.should == "http://clown.com"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'aspects' do
|
context 'aspects' do
|
||||||
it 'should delete an empty aspect' do
|
let(:user2) { Factory(:user) }
|
||||||
@user.aspects.include?(@aspect).should == true
|
let(:aspect2) { user2.aspect(:name => 'stuff') }
|
||||||
@user.drop_aspect(@aspect)
|
|
||||||
@user.reload
|
|
||||||
|
|
||||||
@user.aspects.include?(@aspect).should == false
|
it 'should delete an empty aspect' do
|
||||||
|
user.drop_aspect(aspect)
|
||||||
|
user.aspects.include?(aspect).should == false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not delete an aspect with friends' do
|
it 'should not delete an aspect with friends' do
|
||||||
user2 = Factory.create(:user)
|
friend_users(user, Aspect.find_by_id(aspect.id), user2, Aspect.find_by_id(aspect2.id))
|
||||||
aspect2 = user2.aspect(:name => 'stuff')
|
aspect.reload
|
||||||
user2.reload
|
proc{user.drop_aspect(aspect)}.should raise_error /Aspect not empty/
|
||||||
aspect2.reload
|
user.aspects.include?(aspect).should == true
|
||||||
|
|
||||||
friend_users(@user, Aspect.find_by_id(@aspect.id), user2, Aspect.find_by_id(aspect2.id))
|
|
||||||
@aspect.reload
|
|
||||||
|
|
||||||
@user.aspects.include?(@aspect).should == true
|
|
||||||
|
|
||||||
proc{@user.drop_aspect(@aspect)}.should raise_error /Aspect not empty/
|
|
||||||
|
|
||||||
@user.reload
|
|
||||||
@user.aspects.include?(@aspect).should == true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue