Merge branch 'master' of github.com:diaspora/diaspora_rails
This commit is contained in:
commit
3376057c33
19 changed files with 119 additions and 38 deletions
4
Gemfile
4
Gemfile
|
|
@ -1,8 +1,8 @@
|
|||
source 'http://rubygems.org'
|
||||
source 'http://gemcutter.org'
|
||||
|
||||
gem 'rails', '3.0.0.beta4'
|
||||
gem 'bundler', '0.9.26'
|
||||
gem 'rails', '3.0.0.rc'
|
||||
gem 'bundler', '1.0.0.rc.1'
|
||||
|
||||
#Security
|
||||
gem 'gpgme'
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
|
|||
protect_from_forgery :except => :receive
|
||||
layout 'application'
|
||||
|
||||
before_filter :set_friends_and_authors, :count_requests
|
||||
before_filter :set_friends_authors_and_status, :count_requests
|
||||
|
||||
layout :layout_by_resource
|
||||
|
||||
|
|
@ -16,9 +16,11 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def set_friends_and_authors
|
||||
def set_friends_authors_and_status
|
||||
@friends = Person.friends.all if current_user
|
||||
@subscribed_persons = Author.all if current_user
|
||||
@latest_status_message = StatusMessage.newest(current_user) if current_user
|
||||
|
||||
end
|
||||
|
||||
def count_requests
|
||||
|
|
|
|||
|
|
@ -4,12 +4,10 @@ class DashboardsController < ApplicationController
|
|||
|
||||
def index
|
||||
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
|
||||
@latest_status_message = StatusMessage.newest(current_user)
|
||||
end
|
||||
|
||||
def ostatus
|
||||
@posts = OstatusPost.paginate :page => params[:page], :order => 'created_at DESC'
|
||||
@latest_status_message = StatusMessage.newest(current_user)
|
||||
render :index
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,8 @@ class UsersController < ApplicationController
|
|||
|
||||
def update
|
||||
@user = User.where(:id => params[:id]).first
|
||||
puts params.inspect
|
||||
|
||||
if @user.update_attributes(params[:user])
|
||||
if @user.update_profile(params[:user])
|
||||
flash[:notice] = "Successfully updated user."
|
||||
redirect_to @user
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
module StatusMessagesHelper
|
||||
|
||||
def my_latest_message
|
||||
message = @latest_status_message
|
||||
unless message.nil?
|
||||
return message.message#+ " - " + how_long_ago(message)
|
||||
unless @latest_status_message.nil?
|
||||
return @latest_status_message.message
|
||||
else
|
||||
return "No message to display."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,9 +26,13 @@ class Photo < Post
|
|||
after_save :log_save_inspection
|
||||
validates_true_for :album_id, :logic => lambda {self.validate_album_person}
|
||||
|
||||
before_destroy :ensure_user_picture
|
||||
|
||||
|
||||
def validate_album_person
|
||||
album.person_id == person_id
|
||||
end
|
||||
|
||||
def remote_photo
|
||||
@remote_photo ||= User.owner.url.chop + image.url(:scaled_full)
|
||||
end
|
||||
|
|
@ -40,4 +44,11 @@ class Photo < Post
|
|||
image.store!
|
||||
Rails.logger.info("Setting remote photo with id #{id}")
|
||||
end
|
||||
|
||||
def ensure_user_picture
|
||||
user = User.owner
|
||||
if user.profile.image_url == image.url(:thumb_medium)
|
||||
user.profile.update_attributes!(:image_url => nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
class Post
|
||||
require 'lib/encryptable'
|
||||
include MongoMapper::Document
|
||||
include ApplicationHelper
|
||||
include ROXML
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
class Profile
|
||||
include MongoMapper::EmbeddedDocument
|
||||
require 'lib/diaspora/webhooks'
|
||||
include Diaspora::Webhooks
|
||||
include ROXML
|
||||
|
||||
xml_reader :person_id
|
||||
xml_accessor :first_name
|
||||
xml_accessor :last_name
|
||||
xml_accessor :image_url
|
||||
|
||||
|
||||
key :first_name, String
|
||||
key :last_name, String
|
||||
|
|
@ -20,5 +24,12 @@ class Profile
|
|||
# self.image_url = self._parent_document.url + self.image_url
|
||||
# end
|
||||
# end
|
||||
def person_id
|
||||
self._parent_document.id
|
||||
end
|
||||
|
||||
def to_diaspora_xml
|
||||
self.to_xml.to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -28,6 +28,17 @@ class User < Person
|
|||
end
|
||||
false
|
||||
end
|
||||
|
||||
##profile
|
||||
def update_profile(params)
|
||||
if self.update_attributes(params)
|
||||
puts self.profile.class
|
||||
self.profile.notify_people!
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
######### Friend Requesting
|
||||
def send_friend_request_to(friend_url)
|
||||
|
|
|
|||
25
app/views/albums/edit.html.haml
Normal file
25
app/views/albums/edit.html.haml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
%h1.big_text
|
||||
.back
|
||||
= link_to "⇧ #{@album.name}", @album
|
||||
|
||||
= "Editing #{@album.name}"
|
||||
|
||||
.sub_header
|
||||
="updated #{how_long_ago(@album)}"
|
||||
|
||||
- form_for @album do |a|
|
||||
= a.error_messages
|
||||
%p
|
||||
= a.text_field :name
|
||||
|
||||
#submit_block
|
||||
= link_to "Cancel", root_path
|
||||
or
|
||||
= a.submit
|
||||
|
||||
.button.delete
|
||||
= link_to 'Delete Album', @album, :confirm => 'Are you sure?', :method => :delete
|
||||
|
||||
#content_bottom
|
||||
.back
|
||||
= link_to "⇧ #{@album.name}", @album
|
||||
|
|
@ -3,6 +3,9 @@
|
|||
= link_to '⇧ ostatus', ostatus_path
|
||||
= "#{@author.username}'s stream"
|
||||
|
||||
.sub_header
|
||||
= @author.profile_url
|
||||
|
||||
- if @author_ostatus_posts
|
||||
%ul#stream
|
||||
- for post in @author_ostatus_posts
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@
|
|||
= link_to current_user.real_name, root_path
|
||||
%span#latest_message
|
||||
= my_latest_message
|
||||
%span{:style => "font-size: small"}
|
||||
= " - #{how_long_ago @latest_status_message}"
|
||||
|
||||
%ul.nav
|
||||
%li= link_to "home", root_path
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
%p
|
||||
%label{:for => "status_message_message"} Message
|
||||
= f.text_area :message, :rows => 2
|
||||
%p
|
||||
%p.right
|
||||
= f.submit "Post"
|
||||
|
||||
= form_for Bookmark.new, :remote => true do |f|
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
%p
|
||||
%label{:for => "bookmark_link"} Link
|
||||
= f.text_field :link
|
||||
%p
|
||||
%p.right
|
||||
= f.submit "Post"
|
||||
|
||||
= form_for Blog.new, :remote => true do |f|
|
||||
|
|
@ -32,5 +32,5 @@
|
|||
%p
|
||||
%label{:for => "blog_body"} Body
|
||||
= f.text_area :body
|
||||
%p
|
||||
%p.right
|
||||
= f.submit "Post"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
|
||||
module Diaspora
|
||||
module Webhooks
|
||||
def self.included(klass)
|
||||
klass.class_eval do
|
||||
#require 'message_handler'
|
||||
require 'message_handler'
|
||||
|
||||
@@queue = MessageHandler.new
|
||||
|
||||
def notify_people
|
||||
|
|
@ -10,6 +12,10 @@ module Diaspora
|
|||
push_to(people_with_permissions)
|
||||
end
|
||||
end
|
||||
|
||||
def notify_people!
|
||||
push_to(people_with_permissions)
|
||||
end
|
||||
|
||||
def subscribe_to_ostatus(feed_url)
|
||||
@@queue.add_subscription_request(feed_url)
|
||||
|
|
@ -54,6 +60,7 @@ module Diaspora
|
|||
[*posts].each {|x| xml << x.to_diaspora_xml}
|
||||
xml += "</posts>"
|
||||
xml += "</XML>"
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class MessageHandler
|
|||
case query.type
|
||||
when :post
|
||||
http = EventMachine::HttpRequest.new(query.destination).post :timeout => TIMEOUT, :body =>{:xml => query.body}
|
||||
http.callback { puts query.destination; process; process}
|
||||
http.callback { process; process}
|
||||
when :get
|
||||
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
|
||||
http.callback {send_to_seed(query, http.response); process}
|
||||
|
|
|
|||
|
|
@ -174,6 +174,9 @@ form {
|
|||
#user_name #latest_message {
|
||||
font-weight: normal;
|
||||
color: #999999; }
|
||||
#user_name #latest_message span {
|
||||
size: small;
|
||||
font-style: italic; }
|
||||
#user_name ul {
|
||||
display: inline;
|
||||
margin: 0;
|
||||
|
|
|
|||
|
|
@ -209,6 +209,9 @@ form
|
|||
:font
|
||||
:weight normal
|
||||
:color #999
|
||||
span
|
||||
:size small
|
||||
:font-style italic
|
||||
|
||||
ul
|
||||
:display inline
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ describe Photo do
|
|||
binary.should == fixture_binary
|
||||
end
|
||||
|
||||
it 'must have an album' do
|
||||
|
||||
it 'must have an album' do
|
||||
photo = Photo.new(:person => @user)
|
||||
photo.image = File.open(@fixture_name)
|
||||
photo.save
|
||||
|
|
@ -36,6 +35,18 @@ describe Photo do
|
|||
Photo.first.album.name.should == 'foo'
|
||||
end
|
||||
|
||||
it 'should remove its reference in user profile if it is referred' do
|
||||
@photo.image.store! File.open(@fixture_name)
|
||||
@photo.save
|
||||
|
||||
@user.profile.image_url = @photo.image.url(:thumb_medium)
|
||||
@user.save
|
||||
|
||||
User.first.profile.image_url.should == @photo.image.url(:thumb_medium)
|
||||
@photo.destroy
|
||||
User.first.profile.image_url.should be nil
|
||||
end
|
||||
|
||||
describe 'non-image files' do
|
||||
it 'should not store' do
|
||||
file = File.open(@fail_fixture_name)
|
||||
|
|
@ -52,9 +63,6 @@ describe Photo do
|
|||
@photo.image = file
|
||||
@photo.save.should == false
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
describe 'with encryption' do
|
||||
|
|
@ -80,12 +88,12 @@ describe Photo do
|
|||
@photo.image = File.open(@fixture_name)
|
||||
@photo.image.store!
|
||||
@photo.save
|
||||
|
||||
|
||||
xml = @photo.to_xml.to_s
|
||||
|
||||
xml.include?("bp.jpeg").should be true
|
||||
end
|
||||
|
||||
it 'should have an album id on serialization' do
|
||||
@photo.image = File.open(@fixture_name)
|
||||
|
||||
|
|
|
|||
|
|
@ -59,26 +59,22 @@ describe User do
|
|||
end
|
||||
|
||||
it 'should be able to update their profile and send it to their friends' do
|
||||
pending
|
||||
Factory.create(:person)
|
||||
p = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clowntown.com"}}
|
||||
|
||||
profile = {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clowntown.com"}
|
||||
|
||||
@user = Factory.create(:user, :profile => Profile.new(profile))
|
||||
profile = {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://awesome.com"}
|
||||
@user = Factory.create(:user)
|
||||
p = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clown.com"}}
|
||||
|
||||
|
||||
@user.update_profile(profile)
|
||||
@user.update_profile(p).should == true
|
||||
|
||||
@user.profile.image_url.should == "http://awesome.com"
|
||||
#puts @user.to_xml.to_s
|
||||
@user.profile.image_url.should == "http://clown.com"
|
||||
|
||||
Profile.should_receive(:build_xml_for)
|
||||
|
||||
n = Profile.send :class_variable_get, :@@queue
|
||||
n.should_receive(:process)
|
||||
end
|
||||
|
||||
|
||||
it 'should fix the image_url 'do
|
||||
pending
|
||||
profile = Profile.new(:image_url => "/images/foo.jpg")
|
||||
user = Factory.create(:user, :profile => profile)
|
||||
|
||||
puts user.profile.image_url
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue