Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
34cb15c423
39 changed files with 340 additions and 172 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -5,7 +5,7 @@
|
|||
*~
|
||||
.bundle
|
||||
db/*.sqlite3
|
||||
log/*.log
|
||||
log/*
|
||||
tmp/**/*
|
||||
Gemfile.lock
|
||||
gpg/diaspora-development/*.gpg
|
||||
|
|
|
|||
8
.pairs
Normal file
8
.pairs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
pairs:
|
||||
dg: Daniel Grippi; daniel
|
||||
rs: Raphael Sofaer; raphael
|
||||
iz: Ilya Zhitomirskiy; ilya
|
||||
ms: Maxwell Salzberg; maxwell
|
||||
email:
|
||||
prefix: pair
|
||||
domain: joindiaspora.com
|
||||
|
|
@ -42,14 +42,30 @@ class GroupsController < ApplicationController
|
|||
def update
|
||||
@group = Group.first(:id => params[:id])
|
||||
if @group.update_attributes(params[:group])
|
||||
flash[:notice] = "Successfully updated group."
|
||||
#flash[:notice] = "Successfully updated group."
|
||||
redirect_to @group
|
||||
else
|
||||
render :action => 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def move_person
|
||||
def move_friends
|
||||
pp params
|
||||
|
||||
params[:moves].each{ |move|
|
||||
move = move[1]
|
||||
unless current_user.move_friend(move)
|
||||
flash[:error] = "Group editing failed for friend #{Person.find_by_id( move[:friend_id] ).real_name}."
|
||||
redirect_to Group.first, :action => "edit"
|
||||
return
|
||||
end
|
||||
}
|
||||
|
||||
flash[:notice] = "Groups edited successfully."
|
||||
redirect_to Group.first, :action => "edit"
|
||||
|
||||
end
|
||||
def move_friend
|
||||
unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to])
|
||||
flash[:error] = "didn't work #{params.inspect}"
|
||||
end
|
||||
|
|
@ -59,5 +75,4 @@ class GroupsController < ApplicationController
|
|||
redirect_to Person.first(:id => params[:friend_id])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,11 +14,9 @@ class PeopleController < ApplicationController
|
|||
def show
|
||||
@person = current_user.visible_person_by_id(params[:id])
|
||||
@profile = @person.profile
|
||||
@person_groups = current_user.groups_with_person(@person)
|
||||
|
||||
|
||||
@groups_array = current_user.groups.collect{|x| [x.to_s, x.id]}
|
||||
|
||||
@groups_with_person = current_user.groups_with_person(@person)
|
||||
@groups_dropdown_array = current_user.groups.collect{|x| [x.to_s, x.id]}
|
||||
|
||||
@posts = Post.where(:person_id => @person.id, :_id.in => current_user.visible_post_ids).paginate :page => params[:page], :order => 'created_at DESC'
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ class PublicsController < ApplicationController
|
|||
Rails.logger.error("Received post #{params[:xml]} for nonexistent person #{params[:id]}")
|
||||
return
|
||||
end
|
||||
Rails.logger.debug "PublicsController has received: #{params[:xml]}"
|
||||
@user.receive params[:xml] if params[:xml]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,9 @@ class Comment
|
|||
verify_signature(post_creator_signature, post.person)
|
||||
end
|
||||
|
||||
def signature_valid?
|
||||
verify_signature(creator_signature, person)
|
||||
end
|
||||
|
||||
protected
|
||||
def sign_if_my_post
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class Group
|
|||
end
|
||||
|
||||
def posts_by_person_id( id )
|
||||
id = ensure_bson id
|
||||
id = id.to_id
|
||||
posts.detect{|x| x.person.id == id }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ class Person
|
|||
xml_accessor :email
|
||||
xml_accessor :url
|
||||
xml_accessor :profile, :as => Profile
|
||||
xml_reader :exported_key
|
||||
|
||||
|
||||
key :email, String, :unique => true
|
||||
|
|
@ -52,13 +53,17 @@ class Person
|
|||
end
|
||||
|
||||
def public_key_hash
|
||||
Base64.encode64 OpenSSL::Digest::SHA256.new(self.export_key).to_s
|
||||
Base64.encode64 OpenSSL::Digest::SHA256.new(self.exported_key).to_s
|
||||
end
|
||||
|
||||
def export_key
|
||||
def exported_key
|
||||
encryption_key.public_key.export
|
||||
end
|
||||
|
||||
def exported_key= new_key
|
||||
raise "Don't change a key" if serialized_key
|
||||
@serialized_key = new_key
|
||||
end
|
||||
|
||||
def owns?(post)
|
||||
self.id == post.person.id
|
||||
|
|
@ -77,6 +82,7 @@ class Person
|
|||
end
|
||||
|
||||
protected
|
||||
|
||||
def clean_url
|
||||
self.url ||= "http://localhost:3000/" if self.class == User
|
||||
if self.url
|
||||
|
|
@ -84,7 +90,9 @@ class Person
|
|||
self.url = self.url + '/' if self.url[-1,1] != '/'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_all_traces
|
||||
Post.all(:person_id => id).each{|p| p.delete}
|
||||
Album.all(:person_id => id).each{|p| p.delete}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,6 @@ class Photo < Post
|
|||
end
|
||||
|
||||
def thumb_hash
|
||||
{:thumb_url => image.url(:thumb_medium), :id => id, :album_id => album_id}
|
||||
{:thumb_url => url(:thumb_medium), :id => id, :album_id => album_id}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class Profile
|
|||
end
|
||||
|
||||
def person
|
||||
Person.first(:id => self.person_id)
|
||||
self._parent_document
|
||||
end
|
||||
|
||||
##this needs to go once we move to Salmon
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ class Request
|
|||
self.new(:destination_url => options[:to],
|
||||
:callback_url => person.receive_url,
|
||||
:person => person,
|
||||
:exported_key => person.export_key,
|
||||
:exported_key => person.exported_key,
|
||||
:group_id => options[:into])
|
||||
end
|
||||
|
||||
def reverse_for accepting_user
|
||||
self.person = accepting_user.person
|
||||
self.exported_key = accepting_user.export_key
|
||||
self.exported_key = accepting_user.exported_key
|
||||
self.destination_url = self.callback_url
|
||||
self.save
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@ class User
|
|||
key :friend_ids, Array
|
||||
key :pending_request_ids, Array
|
||||
key :visible_post_ids, Array
|
||||
key :visible_person_ids, Array
|
||||
|
||||
one :person, :class_name => 'Person', :foreign_key => :owner_id
|
||||
|
||||
many :friends, :in => :friend_ids, :class_name => 'Person'
|
||||
many :visible_people, :in => :visible_person_ids, :class_name => 'Person' # One of these needs to go
|
||||
many :pending_requests, :in => :pending_request_ids, :class_name => 'Request'
|
||||
many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post'
|
||||
|
||||
|
|
@ -48,10 +50,9 @@ class User
|
|||
to_group = self.group_by_id(opts[:to])
|
||||
if from_group && to_group
|
||||
posts_to_move = from_group.posts.find_all_by_person_id(friend.id)
|
||||
puts posts_to_move.inspect
|
||||
to_group.people << friend
|
||||
to_group.posts << posts_to_move
|
||||
from_group.person_ids.delete(ensure_bson(friend.id))
|
||||
from_group.person_ids.delete(friend.id.to_id)
|
||||
posts_to_move.each{ |x| from_group.post_ids.delete(x.id)}
|
||||
from_group.save
|
||||
to_group.save
|
||||
|
|
@ -166,7 +167,9 @@ class User
|
|||
def receive xml
|
||||
object = Diaspora::Parser.from_xml(xml)
|
||||
Rails.logger.debug("Receiving object:\n#{object.inspect}")
|
||||
raise "Signature was not valid on: #{object.inspect}" unless object.signature_valid?
|
||||
Rails.logger.debug("From: #{object.person.inspect}") if object.person
|
||||
raise "In receive for #{self.real_name}, signature was not valid on: #{object.inspect}" unless object.signature_valid?
|
||||
|
||||
if object.is_a? Retraction
|
||||
if object.type == 'Person' && object.signature_valid?
|
||||
|
||||
|
|
@ -181,7 +184,7 @@ class User
|
|||
}
|
||||
end
|
||||
elsif object.is_a? Request
|
||||
person = Diaspora::Parser.get_or_create_person_object_from_xml( xml )
|
||||
person = Diaspora::Parser.parse_or_find_person_from_xml( xml )
|
||||
person.serialized_key ||= object.exported_key
|
||||
object.person = person
|
||||
object.person.save
|
||||
|
|
@ -195,6 +198,14 @@ class User
|
|||
person.save
|
||||
|
||||
elsif object.is_a?(Comment)
|
||||
object.person = Diaspora::Parser.parse_or_find_person_from_xml( xml ).save if object.person.nil?
|
||||
self.visible_people << object.person
|
||||
self.save
|
||||
Rails.logger.debug("The person parsed from comment xml is #{object.person.inspect}") unless object.person.nil?
|
||||
object.person.save
|
||||
Rails.logger.debug("From: #{object.person.inspect}") if object.person
|
||||
raise "In receive for #{self.real_name}, signature was not valid on: #{object.inspect}" unless object.post.person == self.person || object.verify_post_creator_signature
|
||||
object.save
|
||||
dispatch_comment object unless owns?(object)
|
||||
object.socket_to_uid(id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
|
||||
else
|
||||
|
|
@ -237,7 +248,9 @@ class User
|
|||
def visible_person_by_id( id )
|
||||
id = id.to_id
|
||||
return self.person if id == self.person.id
|
||||
friends.detect{|x| x.id == id }
|
||||
result = friends.detect{|x| x.id == id }
|
||||
result = visible_people.detect{|x| x.id == id } unless result
|
||||
result
|
||||
end
|
||||
|
||||
def group_by_id( id )
|
||||
|
|
@ -260,7 +273,7 @@ class User
|
|||
end
|
||||
|
||||
def setup_person
|
||||
self.person.serialized_key ||= generate_key.export
|
||||
self.person.serialized_key ||= User.generate_key.export
|
||||
self.person.email ||= email
|
||||
self.person.save!
|
||||
end
|
||||
|
|
@ -269,9 +282,6 @@ class User
|
|||
self.groups.all.collect{|x| x.id}
|
||||
end
|
||||
protected
|
||||
def generate_key
|
||||
OpenSSL::PKey::RSA::generate 1024
|
||||
end
|
||||
|
||||
def self.generate_key
|
||||
OpenSSL::PKey::RSA::generate 1024
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class ImageUploader < CarrierWave::Uploader::Base
|
|||
end
|
||||
|
||||
version :thumb_small do
|
||||
process :resize_to_fill => [30,30]
|
||||
process :resize_to_fill => [50,50]
|
||||
end
|
||||
|
||||
version :thumb_medium do
|
||||
|
|
@ -24,7 +24,7 @@ class ImageUploader < CarrierWave::Uploader::Base
|
|||
end
|
||||
|
||||
version :thumb_large do
|
||||
process :resize_to_fill => [300,300]
|
||||
process :resize_to_fill => [200,200]
|
||||
end
|
||||
|
||||
version :scaled_full do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
- content_for :head do
|
||||
:javascript
|
||||
$(document).ready(function(){
|
||||
$("#add_album_button").fancybox();
|
||||
});
|
||||
|
||||
.back= link_to "⇧ home", root_path
|
||||
%h1.big_text
|
||||
Albums
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
- content_for :head do
|
||||
:javascript
|
||||
$(document).ready(function(){
|
||||
reset_photo_fancybox();
|
||||
});
|
||||
= javascript_include_tag 'photos', 'jquery.html5_upload'
|
||||
|
||||
.album_id{:id => @album.id, :style => "display:hidden;"}
|
||||
.back= link_to '⇧ albums', albums_path
|
||||
|
|
|
|||
|
|
@ -2,22 +2,25 @@
|
|||
= javascript_include_tag 'jquery-ui-1.8.4.custom.min.js'
|
||||
= javascript_include_tag 'group-edit.js'
|
||||
|
||||
.back
|
||||
= link_to "⇧ #{@group.name}", @group
|
||||
|
||||
%h1.big_text
|
||||
.back
|
||||
= link_to "⇧ #{@group.name}", @group
|
||||
%h1{:class => 'big_text', :id => 'group_title'}
|
||||
= "Editing Groups"
|
||||
|
||||
%ul
|
||||
%ul#group_list
|
||||
- for group in @groups
|
||||
%li.group
|
||||
%li{:class => 'group'}
|
||||
= group.name
|
||||
%ul
|
||||
stuff
|
||||
%ul{:id => group.id}
|
||||
dummy person for dropping onto
|
||||
-for person in group.people
|
||||
%li.person
|
||||
%li{:class => 'person', :id => person.id, :from_group_id => group.id}
|
||||
= image_tag(person.profile.image_url(:thumb_small),:size => "30x30") unless person.profile.image_url.nil?
|
||||
= person.real_name
|
||||
|
||||
%p
|
||||
%br
|
||||
= link_to 'Update Groups', '#', :class => 'button', :id => "move_friends_link"
|
||||
|
||||
#content_bottom
|
||||
.back
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@
|
|||
= csrf_meta_tag
|
||||
= yield(:head)
|
||||
|
||||
= javascript_include_tag 'jquery.html5_upload'
|
||||
|
||||
%body
|
||||
- flash.each do |name, msg|
|
||||
= content_tag :div, msg, :id => "flash_#{name}"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
%h1
|
||||
= @person.real_name
|
||||
- unless @person.id == current_user.person.id
|
||||
- if @person != current_user.person && current_user.friends.include?(@person)
|
||||
.right
|
||||
= link_to 'remove friend', @person, :confirm => 'Are you sure?', :method => :delete, :class => "button"
|
||||
|
||||
|
|
@ -13,17 +13,15 @@
|
|||
-unless @posts.first.nil?
|
||||
%li
|
||||
%i= "last seen: #{how_long_ago(@posts.first)}"
|
||||
%li
|
||||
%i= "friends since: #{how_long_ago(@person)}"
|
||||
%li
|
||||
="groups: #{@person_groups}"
|
||||
= "edit"
|
||||
= @groups_array.inspect
|
||||
= form_tag move_person_path
|
||||
= select :to, :to, @groups_array
|
||||
= hidden_field_tag :from, :from, :value => @person_groups.first.id
|
||||
= hidden_field_tag :friend_id, :friend_id, :value => @person.id
|
||||
= submit_tag "save"
|
||||
- if @person != current_user.person && current_user.friends.include?(@person)
|
||||
%li
|
||||
%i= "friends since: #{how_long_ago(@person)}"
|
||||
%li
|
||||
= form_tag move_friend_path
|
||||
= select :to, :to, @groups_dropdown_array, :selected_value => @groups_with_person.first.id
|
||||
= hidden_field_tag :from, :from, :value => @groups_with_person.first.id
|
||||
= hidden_field_tag :friend_id, :friend_id, :value => @person.id
|
||||
= submit_tag "save"
|
||||
%li
|
||||
url:
|
||||
= @person.url
|
||||
|
|
|
|||
|
|
@ -1,33 +1,3 @@
|
|||
:javascript
|
||||
$(function() {
|
||||
$("#photo_image").html5_upload({
|
||||
// WE INSERT ALBUM_ID PARAM HERE
|
||||
url: "/photos?album_id=#{@album.id}",
|
||||
sendBoundary: window.FormData || $.browser.mozilla,
|
||||
setName: function(text) {
|
||||
$("#progress_report_name").text(text);
|
||||
},
|
||||
onFinish: function(event, total){
|
||||
$("#add_photo_button").html( "Add Photos" );
|
||||
$("#add_photo_loader").fadeOut(400);
|
||||
|
||||
$("#photo_title_status").text("Done!");
|
||||
$("#progress_report").html("Good job me!");
|
||||
|
||||
$("#add_photo_button").addClass("uploading_complete");
|
||||
},
|
||||
onStart: function(event, total){
|
||||
$("#add_photo_button").html( "Uploading Photos" );
|
||||
$("#add_photo_loader").fadeIn(400);
|
||||
|
||||
$("form").fadeOut(0);
|
||||
$("#progress_report").fadeIn(0);
|
||||
$("#photo_title_status").text("Uploading...");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
%h1
|
||||
%span{:id=>"photo_title_status"}
|
||||
Add photos to
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
%li.message{:id => post.id}
|
||||
|
||||
= person_image_tag(post.person)
|
||||
|
||||
%span.from
|
||||
= link_to post.person.real_name, post.person
|
||||
%b
|
||||
posted a new photo to
|
||||
= link_to post.album.name, object_path(post.album)
|
||||
.content
|
||||
%span.from
|
||||
= link_to post.person.real_name, post.person
|
||||
%b
|
||||
posted a new photo to
|
||||
= link_to post.album.name, object_path(post.album)
|
||||
|
||||
%br
|
||||
|
||||
= render "albums/album", :post => post.album, :current_user => current_user
|
||||
|
||||
= link_to (image_tag post.url(:thumb_medium)), object_path(post)
|
||||
|
||||
%div.time
|
||||
= link_to(how_long_ago(post), photo_path(post))
|
||||
\--
|
||||
= link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
|
||||
= render "comments/comments", :post => post
|
||||
%br
|
||||
= render "albums/album", :post => post.album, :current_user => current_user
|
||||
= link_to (image_tag post.url(:thumb_medium)), object_path(post)
|
||||
|
||||
.info
|
||||
= link_to(how_long_ago(post), photo_path(post))
|
||||
\--
|
||||
= link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
|
||||
= render "comments/comments", :post => post
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
= link_to "All Groups", root_url
|
||||
- for group in @groups
|
||||
%li{:id => group.id, :class => ("selected" if current_group?(group))}
|
||||
= link_for_group group
|
||||
%span.group_name
|
||||
= link_for_group group
|
||||
%span{:class => '⚙'}
|
||||
= link_to "⚙", "#", :class => "edit_group_button"
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
= link_to post.person.real_name, post.person
|
||||
= auto_link sanitize post.message
|
||||
|
||||
%div.info
|
||||
.info
|
||||
= link_to(how_long_ago(post), object_path(post))
|
||||
\--
|
||||
= link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ Diaspora::Application.routes.draw do
|
|||
match 'login', :to => 'devise/sessions#new', :as => "new_user_session"
|
||||
match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session"
|
||||
match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration"
|
||||
match 'groups/move_person', :to => 'groups#move_person', :as => 'move_person'
|
||||
match 'groups/move_friends', :to => 'groups#move_friends', :as => 'move_friends'
|
||||
match 'groups/move_friend', :to => 'groups#move_friend', :as => 'move_friend'
|
||||
#public routes
|
||||
#
|
||||
match 'webfinger', :to => 'publics#webfinger'
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ module Diaspora
|
|||
Person.first(:id => id)
|
||||
end
|
||||
|
||||
def self.get_or_create_person_object_from_xml(xml)
|
||||
def self.parse_or_find_person_from_xml(xml)
|
||||
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
||||
person_xml = doc.xpath("//request/person").to_s
|
||||
person_id = doc.xpath("//request/person/_id").text.to_s
|
||||
person_xml = doc.xpath("//person").to_s
|
||||
person_id = doc.xpath("//person/_id").text.to_s
|
||||
person = Person.first(:_id => person_id)
|
||||
person ? person : Person.from_xml( person_xml)
|
||||
end
|
||||
|
|
@ -36,6 +36,5 @@ module Diaspora
|
|||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,10 @@
|
|||
$('#move_friends_link').live( 'click',
|
||||
function(){
|
||||
$.post('/groups/move_friends',
|
||||
{'moves' : $('#group_list').data()},
|
||||
function(){ $('#group_title').html("Groups edited successfully!");});
|
||||
});
|
||||
|
||||
$(function() {
|
||||
$("li .person").draggable({
|
||||
revert: true
|
||||
|
|
@ -7,8 +14,14 @@ $(function() {
|
|||
drop: function(event, ui) {
|
||||
$(this).closest("ul").append(ui.draggable)
|
||||
//$("<li class='person ui-draggable'></li>").text(ui.draggable.text()).appendTo(this).draggable();
|
||||
var move = {};
|
||||
move[ 'friend_id' ] = ui.draggable[0].id
|
||||
move[ 'to' ] = $(this)[0].id;
|
||||
move[ 'from' ] = ui.draggable[0].getAttribute('from_group_id');
|
||||
$('#group_list').data( ui.draggable[0].id, move);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
|
|
|||
51
public/javascripts/photos.js
Normal file
51
public/javascripts/photos.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
$(document).ready(function(){
|
||||
reset_photo_fancybox();
|
||||
|
||||
$("#add_photo_button").fancybox({
|
||||
'onClosed' : function(){
|
||||
if($("#add_photo_button").hasClass("uploading_complete")){
|
||||
$("#add_photo_button").removeClass("uploading_complete");
|
||||
reset_photo_fancybox();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(".image_thumb img").load( function() {
|
||||
$(this).fadeIn("slow");
|
||||
});
|
||||
|
||||
});//end document ready
|
||||
|
||||
function reset_photo_fancybox(){
|
||||
album_id = $(".album_id")[0].id;
|
||||
ajax = $.get("/photos/new?album_id=" + album_id, function(){
|
||||
$("#new_photo_pane").html(ajax.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
$("#photo_image").html5_upload({
|
||||
// WE INSERT ALBUM_ID PARAM HERE
|
||||
url: "/photos?album_id="+$(".album_id")[0].id,
|
||||
sendBoundary: window.FormData || $.browser.mozilla,
|
||||
setName: function(text) {
|
||||
$("#progress_report_name").text(text);
|
||||
},
|
||||
onFinish: function(event, total){
|
||||
$("#add_photo_button").html( "Add Photos" );
|
||||
$("#add_photo_loader").fadeOut(400);
|
||||
|
||||
$("#photo_title_status").text("Done!");
|
||||
$("#progress_report").html("Good job me!");
|
||||
|
||||
$("#add_photo_button").addClass("uploading_complete");
|
||||
},
|
||||
onStart: function(event, total){
|
||||
$("#add_photo_button").html( "Uploading Photos" );
|
||||
$("#add_photo_loader").fadeIn(400);
|
||||
|
||||
$("form.new_photo").fadeOut(0);
|
||||
$("#progress_report").fadeIn(0);
|
||||
$("#photo_title_status").text("Uploading...");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
@ -8,8 +8,6 @@ $(document).ready(function(){
|
|||
|
||||
$('#flash_notice, #flash_error, #flash_alert').delay(2500).slideUp(130);
|
||||
|
||||
|
||||
|
||||
$("div.image_cycle").cycle({
|
||||
fx: 'fade',
|
||||
random: 1,
|
||||
|
|
@ -18,42 +16,64 @@ $(document).ready(function(){
|
|||
});
|
||||
|
||||
//buttons//////
|
||||
|
||||
|
||||
$("#add_album_button").fancybox();
|
||||
$("#add_group_button").fancybox();
|
||||
$("#add_request_button").fancybox({ 'titleShow': false });
|
||||
$("#add_photo_button").fancybox({
|
||||
'onClosed' : function(){
|
||||
if($("#add_photo_button").hasClass("uploading_complete")){
|
||||
$("#add_photo_button").removeClass("uploading_complete");
|
||||
reset_photo_fancybox();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//pane_toggler_button("photo");
|
||||
|
||||
$("input[type='submit']").addClass("button");
|
||||
|
||||
$(".image_thumb img").load( function() {
|
||||
$(this).fadeIn("slow");
|
||||
});
|
||||
|
||||
$(".image_cycle img").load( function() {
|
||||
$(this).fadeIn("slow");
|
||||
});
|
||||
|
||||
|
||||
$(".edit_group_button").click(function() {
|
||||
|
||||
var element = $(this).closest("li").children(".group_name").children("a");
|
||||
var oldHTML = element.html();
|
||||
|
||||
var link = element.attr("href");
|
||||
|
||||
element.toggleClass("editing");
|
||||
|
||||
if( element.hasClass("editing") ) {
|
||||
|
||||
element.attr("contentEditable", true);
|
||||
element.focus();
|
||||
|
||||
|
||||
|
||||
//remove newline action
|
||||
$(element).keypress(function(e) {
|
||||
if (e.which == 13) {
|
||||
e.preventDefault();
|
||||
element.attr("contentEditable", false);
|
||||
element.toggleClass("editing");
|
||||
element.blur();
|
||||
|
||||
//save changes
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
url: link,
|
||||
data: {"group" : {"name" : element.text() }}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//update all other group links
|
||||
$(element).keyup(function(e) {
|
||||
$("a[href='"+link+"']").not(element).text(element.text());
|
||||
});
|
||||
|
||||
} else {
|
||||
element.attr("contentEditable", false);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
});//end document ready
|
||||
|
||||
function reset_photo_fancybox(){
|
||||
album_id = $(".album_id")[0].id;
|
||||
ajax = $.get("/photos/new?album_id=" + album_id, function(){
|
||||
$("#new_photo_pane").html(ajax.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function pane_toggler_button( name ) {
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,10 @@ body {
|
|||
margin: 0; }
|
||||
|
||||
a {
|
||||
color: #018790;
|
||||
color: #556270;
|
||||
text-decoration: none; }
|
||||
a:hover {
|
||||
color: white;
|
||||
background-color: #018790;
|
||||
background-color: #556270; }
|
||||
|
||||
.avatar {
|
||||
|
|
@ -381,9 +379,12 @@ label {
|
|||
/* cycle it! */
|
||||
.album {
|
||||
position: relative;
|
||||
height: 300px;
|
||||
width: 300px;
|
||||
height: 200px;
|
||||
width: 200px;
|
||||
display: inline-block; }
|
||||
.album img {
|
||||
width: 200px;
|
||||
height: 200px; }
|
||||
.album .name {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
|
|
@ -473,6 +474,8 @@ h1.big_text {
|
|||
color: #999999; }
|
||||
#group_nav ul > li a:hover {
|
||||
background: none; }
|
||||
#group_nav ul > li a.editable:hover {
|
||||
background: yellow; }
|
||||
#group_nav ul .⚙ {
|
||||
margin-left: 4px; }
|
||||
#group_nav ul .⚙ a {
|
||||
|
|
@ -569,3 +572,7 @@ h1.big_text {
|
|||
#global_search form label {
|
||||
font-size: 12px;
|
||||
margin-top: -3px; }
|
||||
|
||||
.editing, .editing:hover {
|
||||
background-color: yellow;
|
||||
border: 1px #666666 solid; }
|
||||
|
|
|
|||
|
|
@ -10,14 +10,12 @@ body
|
|||
:padding 2em
|
||||
:margin 0
|
||||
a
|
||||
:color #018790
|
||||
:color #556270
|
||||
:text
|
||||
:decoration none
|
||||
&:hover
|
||||
:color #fff
|
||||
:background
|
||||
:color #018790
|
||||
:color #556270
|
||||
|
||||
.avatar
|
||||
|
|
@ -480,10 +478,14 @@ label
|
|||
/* cycle it! */
|
||||
.album
|
||||
:position relative
|
||||
:height 300px
|
||||
:width 300px
|
||||
:height 200px
|
||||
:width 200px
|
||||
:display inline-block
|
||||
|
||||
img
|
||||
:width 200px
|
||||
:height 200px
|
||||
|
||||
.name
|
||||
:position absolute
|
||||
:z-index 6
|
||||
|
|
@ -601,6 +603,8 @@ h1.big_text
|
|||
:color #999
|
||||
&:hover
|
||||
:background none
|
||||
&.editable:hover
|
||||
:background yellow
|
||||
|
||||
.⚙
|
||||
:margin
|
||||
|
|
@ -738,4 +742,7 @@ h1.big_text
|
|||
:margin
|
||||
:top -3px
|
||||
|
||||
|
||||
.editing, .editing:hover
|
||||
:background
|
||||
:color yellow
|
||||
:border 1px #666 solid
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ describe GroupsController do
|
|||
@user = Factory.create(:user)
|
||||
@user.group(:name => "lame-os")
|
||||
@person = Factory.create(:person)
|
||||
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
|
||||
sign_in :user, @user
|
||||
end
|
||||
|
||||
it "on index sets a variable containing all a user's friends when a user is signed in" do
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ describe PeopleController do
|
|||
render_views
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
|
||||
|
||||
sign_in :user, @user
|
||||
@user.group(:name => "lame-os")
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ describe PublicsController do
|
|||
before do
|
||||
@user = Factory.create(:user)
|
||||
@user.person.save
|
||||
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
|
||||
sign_in :user, @user
|
||||
end
|
||||
|
||||
describe 'receive endpoint' do
|
||||
|
|
|
|||
|
|
@ -6,15 +6,11 @@ class SocketsController
|
|||
end
|
||||
end
|
||||
|
||||
describe 'SocketsController' do
|
||||
describe SocketsController do
|
||||
render_views
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
SocketsController.unstub!(:new)
|
||||
@controller = SocketsController.new
|
||||
@controller.request = mock_model(Request, :env =>
|
||||
{'warden' => mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)})
|
||||
stub_sockets_controller
|
||||
end
|
||||
|
||||
it 'should unstub the websockets' do
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ describe Diaspora::Parser do
|
|||
@xml = Factory.build(:status_message).to_diaspora_xml
|
||||
end
|
||||
|
||||
it 'should be able to correctly handle comments' do
|
||||
it 'should be able to correctly handle comments with person in db' do
|
||||
person = Factory.create(:person, :email => "test@testing.com")
|
||||
post = Factory.create(:status_message, :person => @user.person)
|
||||
comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!")
|
||||
|
|
@ -29,6 +29,23 @@ describe Diaspora::Parser do
|
|||
comment.person.should == person
|
||||
comment.post.should == post
|
||||
end
|
||||
|
||||
it 'should be able to correctly handle person on a comment with person not in db' do
|
||||
commenter = Factory.create(:user)
|
||||
commenter_group = commenter.group :name => "bruisers"
|
||||
friend_users(@user, @group, commenter, commenter_group)
|
||||
post = @user.post :status_message, :message => "hello", :to => @group.id
|
||||
comment = commenter.comment "Fool!", :on => post
|
||||
|
||||
xml = comment.to_diaspora_xml
|
||||
commenter.delete
|
||||
commenter.person.delete
|
||||
|
||||
parsed_person = Diaspora::Parser::parse_or_find_person_from_xml(xml)
|
||||
parsed_person.save.should be true
|
||||
parsed_person.email.should == commenter.person.email
|
||||
parsed_person.profile.should_not be_nil
|
||||
end
|
||||
|
||||
it 'should marshal retractions' do
|
||||
person = Factory.create(:person)
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ describe Salmon do
|
|||
x.magic_sig.signable_string.should == z.magic_sig.signable_string
|
||||
|
||||
|
||||
x.verified_for_key?(OpenSSL::PKey::RSA.new(@user.export_key)).should be true
|
||||
z.verified_for_key?(OpenSSL::PKey::RSA.new(@user.export_key)).should be true
|
||||
x.verified_for_key?(OpenSSL::PKey::RSA.new(@user.exported_key)).should be true
|
||||
z.verified_for_key?(OpenSSL::PKey::RSA.new(@user.exported_key)).should be true
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ describe Comment do
|
|||
describe "user" do
|
||||
before do
|
||||
@user = Factory.create :user
|
||||
@user.person.save
|
||||
@group = @user.group(:name => "Doofuses")
|
||||
|
||||
@user2 = Factory.create(:user)
|
||||
@group2 = @user2.group(:name => "Lame-faces")
|
||||
end
|
||||
it "should be able to comment on his own status" do
|
||||
status = Factory.create(:status_message, :person => @user.person)
|
||||
|
|
@ -31,10 +34,7 @@ describe Comment do
|
|||
|
||||
describe 'comment propagation' do
|
||||
before do
|
||||
@group = @user.group(:name => "Doofuses")
|
||||
|
||||
@user2 = Factory.create(:user)
|
||||
@group2 = @user2.group(:name => "Lame-faces")
|
||||
|
||||
request = @user.send_friend_request_to(@user2.receive_url, @group.id)
|
||||
reversed_request = @user2.accept_friend_request( request.id, @group2.id )
|
||||
|
|
@ -79,5 +79,16 @@ describe Comment do
|
|||
@user.receive(comment.to_diaspora_xml)
|
||||
end
|
||||
end
|
||||
describe 'serialization' do
|
||||
it 'should serialize the commenter' do
|
||||
commenter = Factory.create(:user)
|
||||
commenter_group = commenter.group :name => "bruisers"
|
||||
friend_users(@user, @group, commenter, commenter_group)
|
||||
post = @user.post :status_message, :message => "hello", :to => @group.id
|
||||
comment = commenter.comment "Fool!", :on => post
|
||||
comment.person.should_not == @user.person
|
||||
comment.to_diaspora_xml.include?(commenter.person.id.to_s).should be true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ describe User do
|
|||
|
||||
@user2 = Factory.create(:user)
|
||||
@group2 = @user2.group(:name => 'losers')
|
||||
|
||||
@user3 = Factory.create(:user)
|
||||
@group3 = @user3.group(:name => 'heroes')
|
||||
|
||||
friend_users(@user, @group, @user2, @group2)
|
||||
end
|
||||
|
||||
|
|
@ -39,8 +43,7 @@ describe User do
|
|||
|
||||
describe 'post refs' do
|
||||
before do
|
||||
@user3 = Factory.create(:user)
|
||||
@group3 = @user3.group(:name => 'heroes')
|
||||
|
||||
end
|
||||
|
||||
it "should add the post to that user's posts when a user posts it" do
|
||||
|
|
@ -130,4 +133,36 @@ describe User do
|
|||
Post.count.should be 1
|
||||
end
|
||||
end
|
||||
|
||||
describe 'comments' do
|
||||
it 'should correctly marshal a stranger for the downstream user' do
|
||||
|
||||
friend_users(@user, @group, @user3, @group3)
|
||||
post = @user.post :status_message, :message => "hello", :to => @group.id
|
||||
|
||||
@user2.receive post.to_diaspora_xml
|
||||
@user3.receive post.to_diaspora_xml
|
||||
|
||||
comment = @user2.comment('tada',:on => post)
|
||||
@user.receive comment.to_diaspora_xml
|
||||
@user.reload
|
||||
|
||||
commenter_id = @user2.person.id
|
||||
|
||||
@user2.person.delete
|
||||
@user2.delete
|
||||
comment_id = comment.id
|
||||
|
||||
comment.delete
|
||||
@user3.receive comment.to_diaspora_xml
|
||||
@user3.reload
|
||||
|
||||
new_comment = Comment.find_by_id(comment_id)
|
||||
new_comment.should_not be_nil
|
||||
new_comment.person.should_not be_nil
|
||||
new_comment.person.profile.should_not be_nil
|
||||
|
||||
@user3.visible_person_by_id(commenter_id).should_not be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,29 +21,27 @@ RSpec.configure do |config|
|
|||
config.before(:suite) do
|
||||
DatabaseCleaner.clean_with(:truncation)
|
||||
stub_signature_verification
|
||||
|
||||
end
|
||||
|
||||
config.before(:each) do
|
||||
DatabaseCleaner.start
|
||||
stub_sockets_controller
|
||||
stub_sockets
|
||||
end
|
||||
|
||||
config.after(:each) do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
end
|
||||
def stub_sockets_controller
|
||||
mock_sockets_controller = mock('sockets mock')
|
||||
mock_sockets_controller.stub!(:incoming).and_return(true)
|
||||
mock_sockets_controller.stub!(:new_subscriber).and_return(true)
|
||||
mock_sockets_controller.stub!(:outgoing).and_return(true)
|
||||
mock_sockets_controller.stub!(:delete_subscriber).and_return(true)
|
||||
SocketsController.stub!(:new).and_return(mock_sockets_controller)
|
||||
def stub_sockets
|
||||
Diaspora::WebSocket.stub!(:push_to_user).and_return(true)
|
||||
Diaspora::WebSocket.stub!(:subscribe).and_return(true)
|
||||
Diaspora::WebSocket.stub!(:unsubscribe).and_return(true)
|
||||
end
|
||||
|
||||
def stub_signature_verification
|
||||
(get_models.map{|model| model.camelize.constantize} - [User]).each do |model|
|
||||
model.any_instance.stubs(:signature_valid?).returns(true)
|
||||
model.any_instance.stubs(:verify_signature).returns(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ describe 'user encryption' do
|
|||
it 'should send over a public key' do
|
||||
message_queue.stub!(:add_post_request)
|
||||
request = @user.send_friend_request_to("http://example.com/", @group.id)
|
||||
request.to_diaspora_xml.include?( @user.export_key).should be true
|
||||
request.to_diaspora_xml.include?( @user.exported_key).should be true
|
||||
end
|
||||
|
||||
it 'should receive and marshal a public key from a request' do
|
||||
|
|
@ -41,7 +41,7 @@ describe 'user encryption' do
|
|||
remote_user.encryption_key.nil?.should== false
|
||||
#should move this to friend request, but i found it here
|
||||
id = remote_user.person.id
|
||||
original_key = remote_user.export_key
|
||||
original_key = remote_user.exported_key
|
||||
|
||||
request = remote_user.send_friend_request_to(
|
||||
@user.receive_url, remote_user.group(:name => "temp").id)
|
||||
|
|
@ -52,10 +52,10 @@ describe 'user encryption' do
|
|||
remote_user.destroy
|
||||
|
||||
person_count = Person.all.count
|
||||
proc {@user.receive xml}.should_not raise_error /Signature was not valid/
|
||||
proc {@user.receive xml}.should_not raise_error /ignature was not valid/
|
||||
Person.all.count.should == person_count + 1
|
||||
new_person = Person.first(:id => id)
|
||||
new_person.export_key.should == original_key
|
||||
new_person.exported_key.should == original_key
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ describe 'user encryption' do
|
|||
xml = message.to_diaspora_xml
|
||||
message.destroy
|
||||
Post.count.should be 0
|
||||
proc {@user.receive xml}.should raise_error /Signature was not valid/
|
||||
proc {@user.receive xml}.should raise_error /ignature was not valid/
|
||||
Post.count.should be 0
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue