Merge branch 'friend-refactor' of github.com:diaspora/diaspora_rails into friend-refactor

This commit is contained in:
ilya 2010-08-16 10:00:25 -07:00
commit 053ed9176d
16 changed files with 119 additions and 89 deletions

View file

@ -31,7 +31,6 @@ class GroupsController < ApplicationController
@people_ids = @group.people.map {|p| p.id}
@posts = Post.paginate :person_id => @people_ids, :order => 'created_at DESC'
@group = Group.first(:id => params[:id])
render :index
end
def edit

View file

@ -18,10 +18,8 @@ class Comment
key :person_id, ObjectId
belongs_to :person, :class_name => "Person"
def ==(other)
(self.message == other.message) && (self.person.email == other.person.email)
end
validates_presence_of :text
def push_upstream
push_to([post.person])
@ -34,7 +32,6 @@ class Comment
#ENCRYPTION
before_validation :sign_if_mine, :sign_if_my_post
#validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature}
validates_true_for :post_creator_signature, :logic => lambda {self.verify_post_creator_signature}
xml_accessor :creator_signature

View file

@ -5,9 +5,11 @@ class Group
key :person_ids, Array
key :request_ids, Array
key :post_ids, Array
many :people, :in => :person_ids, :class_name => 'Person'
many :requests, :in => :request_ids, :class_name => 'Request'
many :posts, :in => :post_ids, :class_name => 'Post'
belongs_to :user, :class_name => 'User'

View file

@ -165,7 +165,8 @@ class User
person.profile = object
person.save
elsif object.verify_creator_signature == true
Rails.logger.debug("Saving object with success: #{object.save}")
Rails.logger.debug("Saving object: #{object}")
object.save
object.socket_to_uid( id) if object.respond_to? :socket_to_uid
end
end

View file

@ -24,7 +24,7 @@ class ImageUploader < CarrierWave::Uploader::Base
end
version :thumb_large do
process :resize_to_fill => [300,200]
process :resize_to_fill => [300,300]
end
version :scaled_full do

View file

@ -1,6 +1,5 @@
.back= link_to "⇧ #{@album.name}", @album
%h1.big_text
.back
= link_to "⇧ #{@album.name}", @album
= "Editing #{@album.name}"

View file

@ -1,6 +1,5 @@
.back= link_to "⇧ home", root_path
%h1.big_text
.back
= link_to "⇧ home", root_path
Albums
.right
= link_to 'New Album', '#new_album_pane', {:class => "button", :id => "add_album_button"}

View file

@ -1,6 +1,5 @@
.back= link_to '⇧ albums', albums_path
%h1.big_text
.back
= link_to '⇧ albums', albums_path
= @album.name

View file

@ -1,3 +1,7 @@
%h1
welcome home,
= current_user.profile.first_name
= render "shared/publisher"
%ul#stream
- for post in @posts

View file

@ -0,0 +1,7 @@
= render "shared/publisher"
%ul#stream
- for post in @posts
= render type_partial(post), :post => post
#pagination
= will_paginate @posts

View file

@ -29,45 +29,28 @@
= javascript_include_tag 'jquery.html5_upload'
%body
- flash.each do |name, msg|
= content_tag :div, msg, :id => "flash_#{name}"
%header
.container
- flash.each do |name, msg|
= content_tag :div, msg, :id => "flash_#{name}"
#session_action
- if user_signed_in?
%ul#user_menu
%li.name= link_to current_user.real_name, current_user.person
%li= link_to "requests (#{@request_count})", requests_path, :class => new_request(@request_count)
%li= link_to "settings", edit_user_path(current_user)
%li= link_to "logout", destroy_user_session_path
- else
= link_to "login", new_user_session_path
#diaspora_text{:href => root_path}
= link_to "DIASPORA*", root_path
%span.sub_text
PREVIEW
#session_action
- if user_signed_in?
= link_to current_user.real_name, current_user.person
|
= link_to "requests (#{@request_count})", requests_path, :class => new_request(@request_count)
|
= link_to "logout", destroy_user_session_path
- else
= link_to "login", new_user_session_path
= render "shared/group_nav"
.container
- if user_signed_in?
#user_name
= link_to(person_image_tag(current_user), root_path)
%h1
= link_to current_user.real_name, root_path
%span#latest_message
= my_latest_message
%span{:style => "font-size: small", :id => 'latest_message_time'}
- unless @latest_status_message.nil?
= "- #{how_long_ago @latest_status_message}"
%ul.nav
%li= link_to "home", root_path
%li= link_to "photos", albums_path
%li= "|"
%li= link_to "edit profile", edit_user_path(current_user)
= link_to "photos", albums_path
.container
.span-24.last

View file

@ -1,6 +1,5 @@
.back= link_to "⇧ #{@album.name}", album_path(@album)
%h1.big_text
.back
= link_to "⇧ #{@album.name}", album_path(@album)
= @photo.image
.right

View file

@ -14,9 +14,8 @@
#friend_pictures
- for friend in @group.people
= person_image_link(friend)
= link_to "+", "#add_request_pane", :id => 'add_request_button', :class => "add_new"
.add_new
= link_to "+", "#add_request_pane", :id => 'add_request_button'
.yo{:style => 'display:none'}
#add_request_pane
= render "requests/new_request"

View file

@ -66,7 +66,7 @@ a {
header {
position: relative;
margin: -2em;
margin-bottom: 30px;
margin-bottom: 20px;
color: #555555;
background-color: #2b2726;
background-color: black;
@ -88,11 +88,8 @@ header {
float: right;
text-shadow: 0 1px 0 black;
padding-right: 10px; }
header #session_action a {
color: #777777;
border: none; }
header #session_action a.new_requests {
color: #df0101; }
header #session_action a.new_requests {
color: #df0101; }
#show_filters {
z-index: 100;
@ -144,10 +141,9 @@ h1 {
font-size: 21px;
font-weight: bold;
line-height: 36px; }
h1 p.description, h1 span.description {
h1 p.description, h1 span.description, h1 .description {
font-weight: 200;
color: #999999;
padding: 0.1em; }
color: #999999; }
h3 {
position: relativex;
@ -352,7 +348,7 @@ ul#publisher_content_pickers li {
/* cycle it! */
.album {
position: relative;
height: 200px;
height: 300px;
width: 300px;
display: inline-block; }
.album .name {
@ -377,11 +373,9 @@ ul#publisher_content_pickers li {
h1.big_text {
position: relative;
line-height: auto;
border-bottom: 1px solid #666666;
text-align: center; }
.big_text .right {
top: -8px; }
border-bottom: 1px solid #666666; }
h1.big_text .right {
top: -6px; }
#content_bottom .right {
top: -5px; }
@ -391,7 +385,6 @@ h1.big_text {
float: right; }
.back {
position: absolute;
font-size: 12px;
font-weight: normal; }
@ -449,12 +442,12 @@ h1.big_text {
width: 40px;
background-color: #222222;
text-align: center;
font-size: 40px; }
#group #friend_pictures .add_new a {
display: block;
position: absolute;
top: -13px;
left: 7px; }
font-size: 40px;
line-height: 33px;
top: -9px; }
#group #friend_pictures .add_new:hover {
background: #999999;
color: black; }
#group #friend_pictures img {
display: none;
height: 40px; }
@ -464,3 +457,16 @@ h1.big_text {
display: none;
left: -25px;
top: 4px; }
#user_menu {
background: #333333;
padding: 5px;
margin: 0;
list-style: none; }
#user_menu a {
color: #999999; }
#user_menu > li {
display: inline;
margin-right: 1em; }
#user_menu > li:last-child {
margin-right: 0; }

View file

@ -70,7 +70,7 @@ a
header
:position relative
:margin -2em
:bottom 30px
:bottom 20px
:color #555
:background
:color #2B2726
@ -101,8 +101,6 @@ header
:float right
:text-shadow 0 1px 0 #000
a
:color #777
:border none
&.new_requests
:color #DF0101
:padding-right 10px
@ -168,11 +166,10 @@ h1
:weight bold
:line-height 36px
p.description, span.description
p.description, span.description, .description
:font
:weight 200
:color #999
:padding 0.1em
h3
:position relativex
@ -432,7 +429,7 @@ ul#publisher_content_pickers li
.album
:position relative
:height 200px
:height 300px
:width 300px
:display inline-block
@ -467,14 +464,11 @@ h1.big_text
:position relative
:line-height auto
:border
//:top 2px solid #666
:bottom 1px solid #666
:text
:align center
.big_text
.right
:top -8px
:top -6px
#content_bottom
.right
:top -5px
@ -484,7 +478,6 @@ h1.big_text
:float right
.back
:position absolute
:font
:size 12px
:weight normal
@ -563,11 +556,13 @@ h1.big_text
:color #222
:text-align center
:font-size 40px
a
:display block
:position absolute
:top -13px
:left 7px
:line-height 33px
:top -9px
&:hover
:background #999
:color #000
img
:display none
:height 40px
@ -578,3 +573,22 @@ h1.big_text
:left -25px
:top 4px
#user_menu
:background #333
:padding 5px
:margin 0
:list-style none
a
:color #999
> li
:display inline
:margin
:right 1em
&:last-child
:margin
:right 0

View file

@ -12,6 +12,29 @@ describe Diaspora::Parser do
@person = Factory.create(:person_with_private_key, :email => "bill@gates.com")
@user2 = Factory.create(:user)
end
it "should associate the post with a group" do
@user.activate_friend(@person, @group)
status_message = Factory.build(:status_message, :message => "hey!", :person => @person)
@user.receive status_message.to_diaspora_xml
# mongomapper doesn't support joins, meaning we can't do a query
# on user.groups.
# should this code below be a function of a user?
# something like self.find_group_for(friend_id) ?
groups = @user.groups
groups.shift while not groups[0].person_ids.include?(@person.id)
group = groups[0]
####
@group.posts.count.should == 1
end
describe 'with encryption' do
before do
unstub_mocha_stubs
@ -38,7 +61,6 @@ describe Diaspora::Parser do
</XML>"
@user.receive xml
Post.count.should == 0
end
end