Merge branch 'master' into group-top

Conflicts:
	public/stylesheets/application.css
	public/stylesheets/sass/application.sass
This commit is contained in:
danielvincent 2010-08-02 16:09:13 -07:00
commit 3e5cecd532
11 changed files with 100 additions and 62 deletions

View file

@ -22,6 +22,8 @@ module SocketsHelper
if object.is_a? Photo
action_hash[:photo_hash] = object.thumb_hash
elsif object.is_a? StatusMessage
action_hash[:status_message_hash] = object.latest_hash
end
action_hash.to_json

View file

@ -21,9 +21,8 @@ class StatusMessage < Post
XML
end
def ==(other)
(self.message == other.message) && (self.person.email == other.person.email)
def latest_hash
{:mine? => self.person == User.owner, :text => message}
end
end

View file

@ -10,7 +10,11 @@ class ImageUploader < CarrierWave::Uploader::Base
def extension_white_list
%w(jpg jpeg gif png)
end
def filename
model.id.to_s + File.extname(@filename)
end
version :thumb_small do
process :resize_to_fill => [30,30]
end

View file

@ -20,9 +20,13 @@
}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'])
}else{
processPost(obj['class'], obj['html'])
}
};
ws.onclose = function() { debug("socket closed"); };
ws.onopen = function() {
@ -56,6 +60,18 @@
}
}
function processStatusMessage(className, html, messageHash){
processPost(className, html);
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 ;
@ -65,7 +81,7 @@
<img alt=\"New thumbnail\" src=\""+ photoHash['thumb_url'] +"\" /> \
</a> </div>"
$("#thumbnails").append( $(html) )
$(".image_thumb img").load( function() {
$("#"+ photoHash['id'] + " img").load( function() {
$(this).fadeIn("slow");
});
}

View file

@ -73,9 +73,9 @@
= link_to current_user.real_name, root_path
%span#latest_message
= my_latest_message
- unless @latest_status_message.nil?
%span{:style => "font-size: small"}
= " - #{how_long_ago @latest_status_message}"
- unless @latest_status_message.nil?
%span{:style => "font-size: small", :id => 'latest_message_time'}
= " - #{how_long_ago @latest_status_message}"
%ul.nav
%li= link_to "home", root_path

View file

@ -7,8 +7,6 @@
$("#new_status_message").submit(function() {
var new_status = $('#status_message_message').val() + " - just now";
$('#latest_message').text( new_status );
});
function selectPublisherTab(evt){

View file

@ -171,12 +171,11 @@ form {
line-height: 18px; }
#user_name h1 a {
color: black; }
#user_name #latest_message {
#user_name span {
size: small;
font-style: italic;
font-weight: normal;
color: #999999; }
#user_name #latest_message span {
size: small;
font-style: italic; }
#user_name ul {
display: inline;
margin: 0;
@ -302,7 +301,8 @@ label {
border-bottom: 2px #999999 solid;
color: #999999;
padding: 15px 1em;
padding-bottom: 30px; }
padding-bottom: 30px;
position: relative; }
#new_blog,
#new_bookmark {

View file

@ -204,13 +204,12 @@ form
a
:color #000
#latest_message
span
:size small
:font-style italic
:font
:weight normal
:color #999
span
:size small
:font-style italic
ul
:display inline
@ -365,6 +364,7 @@ label
:color #999
:padding 15px 1em
:bottom 30px
:position relative
#new_blog,
#new_bookmark

View file

@ -154,25 +154,36 @@ describe Diaspora::DiasporaParser do
end
it 'should marshal a profile for a person' do
#Create person
person = Factory.create(:person)
id = person.id
person.profile = Profile.new(:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clown.com")
person.save
#Cache profile for checking against marshaled profile
old_profile = person.profile
puts person.profile.inspect
old_profile.first_name.should == 'bob'
xml = Post.build_xml_for(person.profile)
person.profile = nil
person.save
#Build xml for profile, clear profile
xml = Post.build_xml_for(person.profile)
reloaded_person = Person.first(:id => id)
reloaded_person.profile = nil
reloaded_person.save
puts person.profile.inspect
person.profile.should_be nil
store_objects_from_xml xml
#Make sure profile is cleared
Person.first(:id=> id).profile.should be nil
old_profile.first_name.should == 'bob'
#Marshal profile
store_objects_from_xml xml
#Check that marshaled profile is the same as old profile
person = Person.first(:id => person.id)
person.profile.should == old_profile
person.profile.should_not be nil
person.profile.first_name.should == old_profile.first_name
person.profile.last_name.should == old_profile.last_name
person.profile.image_url.should == old_profile.image_url
end
end

View file

@ -2,6 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
describe Album do
before do
@fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg'
@user = Factory.create(:user)
@album = Album.new(:name => "test collection", :person => @user)
end
@ -33,11 +34,13 @@ describe Album do
end
it 'should remove all photos on album delete' do
photo_one = Factory.create(:photo, :person => @user, :album => @album, :created_at => Time.now)
photo_two = Factory.create(:photo, :person => @user, :album => @album, :created_at => Time.now-1)
photo_three = Factory.create(:photo, :person => @user, :album => @album, :created_at => Time.now-2)
@album.photos += [photo_one, photo_two, photo_three]
photos = []
1.upto 3 do
photo = Photo.new(:person => @user, :album => @album, :created_at => Time.now)
photo.image.store! File.open @fixture_name
photos << photo
end
@album.photos += photos
Photo.all.count.should == 3
@album.destroy
@ -46,29 +49,28 @@ describe Album do
describe 'traversing' do
before do
@photo_one = Factory.create(:photo, :person => @user, :album => @album, :created_at => Time.now)
@photo_two = Factory.create(:photo, :person => @user, :album => @album, :created_at => Time.now+1)
@photo_three = Factory.create(:photo, :person => @user, :album => @album, :created_at => Time.now+2)
@album.photos += [@photo_one, @photo_two, @photo_three]
end
it 'should retrieve the next photo relative to a given photo' do
@album.next_photo(@photo_two).id.should == @photo_three.id
end
it 'should retrieve the previous photo relative to a given photo' do
@album.prev_photo(@photo_two).id.should == @photo_one.id
end
describe 'wrapping' do
it 'does next photo of last to first' do
@album.next_photo(@photo_three).id.should == @photo_one.id
@photos = []
1.upto 3 do |n|
photo = Photo.new(:person => @user, :album => @album, :created_at => Time.now + n)
photo.image.store! File.open @fixture_name
@photos << photo
end
@album.photos += @photos
end
it 'should traverse the album correctly' do
#should retrieve the next photo relative to a given photo
@album.next_photo(@photos[1]).id.should == @photos[2].id
it 'does previous photo of first to last' do
@album.prev_photo(@photo_one).id.should == @photo_three.id
end
#should retrieve the previous photo relative to a given photo
@album.prev_photo(@photos[1]).id.should == @photos[0].id
#wrapping
#does next photo of last to first
@album.next_photo(@photos[2]).id.should == @photos[0].id
#does previous photo of first to last
@album.prev_photo(@photos[0]).id.should == @photos[2].id
end
end

View file

@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
describe Photo do
before do
@user = Factory.create(:user)
@fixture_filename = 'bp.jpeg'
@fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg'
@fail_fixture_name = File.dirname(__FILE__) + '/../fixtures/msg.xml'
@album = Album.create(:name => "foo", :person => @user)
@ -47,6 +48,13 @@ describe Photo do
User.first.profile.image_url.should be nil
end
it 'should not use the imported filename as the url' do
@photo.image.store! File.open(@fixture_name)
puts @photo.image.url(:thumb_medium)
@photo.image.url.include?(@fixture_filename).should be false
@photo.image.url(:thumb_medium).include?(@fixture_filename).should be false
end
describe 'non-image files' do
it 'should not store' do
file = File.open(@fail_fixture_name)
@ -64,7 +72,7 @@ describe Photo do
@photo.save.should == false
end
end
describe 'with encryption' do
before do
@ -91,15 +99,13 @@ describe Photo do
xml = @photo.to_xml.to_s
xml.include?("bp.jpeg").should be true
xml.include?(@photo.image.url).should be true
end
it 'should have an album id on serialization' do
@photo.image = File.open(@fixture_name)
@photo.image.store! File.open(@fixture_name)
xml = @photo.to_xml.to_s
puts xml
xml.include?("scaled_full_bp.").should be true
xml.include?(@photo.album_id.to_s).should be true
end
end
end