Skip to content
Extraits de code Groupes Projets
Valider 70a22ae8 rédigé par Raphael's avatar Raphael
Parcourir les fichiers

Merge branch 'master' into HEAD

Conflicts:
	app/models/post.rb
	app/models/user.rb
	config/initializers/socket.rb
parents 35c9922c 16b6fc6c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 253 ajouts et 316 suppressions
...@@ -13,3 +13,4 @@ gpg/diaspora-production/*.gpg ...@@ -13,3 +13,4 @@ gpg/diaspora-production/*.gpg
gpg/*/random_seed gpg/*/random_seed
public/uploads/* public/uploads/*
.rvmrc .rvmrc
config/app_config.yml
Diaspora is copyright Diaspora Inc., 2010, and files herein are licensed under the Affero General Public License version 3, the text of which can be found in GNU-AGPL-3.0, unless otherwise noted. Components of Diaspora, including Rails, JQuery, and Devise, are licensed under the MIT/X11 license. Blueprint-CSS is licensed under a modified version of the MIT/X11 license. All unmodified files from these and other sources retain their original copyright and license notices: see the relevand individual files. Attribution information for Diaspora is contained in the AUTHORS file. Diaspora is copyright Diaspora Inc., 2010, and files herein are licensed
under the Affero General Public License version 3, the text of which can
be found in GNU-AGPL-3.0, or any later version of the AGPL, unless otherwise
noted. Components of Diaspora, including Rails, JQuery, and Devise, are
licensed under the MIT/X11 license. Blueprint-CSS is licensed under a
modified version of the MIT/X11 license. All unmodified files from these
and other sources retain their original copyright and license notices: see
the relevant individual files. Attribution information for Diaspora is
contained in the AUTHORS file.
In addition, as a special exception, the copyright holders give
permission to link the code of portions of this program with the
OpenSSL library under certain conditions as described in each
individual source file, and distribute linked combinations
including the two.
You must obey the GNU Affero General Public License V3 or later in all respects
for all of the code used other than OpenSSL or the components mentioned
above. If you modify file(s) with this exception, you may extend this
exception to your version of the file(s), but you are not obligated to
do so. If you do not wish to do so, delete this exception statement from your
version. If you delete this exception statement from all source files in the
program, then also delete it here.
...@@ -28,9 +28,12 @@ gem 'redfinger', :git => 'git://github.com/rsofaer/redfinger.git' ...@@ -28,9 +28,12 @@ gem 'redfinger', :git => 'git://github.com/rsofaer/redfinger.git'
#EventMachine #EventMachine
gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http' gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http'
gem 'em-websocket'
gem 'thin' gem 'thin'
#Websocket
gem 'em-websocket'
gem 'magent', :git => 'http://github.com/dcu/magent.git'
#File uploading #File uploading
gem 'carrierwave', :git => 'git://github.com/rsofaer/carrierwave.git' , :branch => 'master' #Untested mongomapper branch gem 'carrierwave', :git => 'git://github.com/rsofaer/carrierwave.git' , :branch => 'master' #Untested mongomapper branch
gem 'mini_magick' gem 'mini_magick'
......
...@@ -47,6 +47,14 @@ GIT ...@@ -47,6 +47,14 @@ GIT
bcrypt-ruby (~> 2.1.2) bcrypt-ruby (~> 2.1.2)
warden (~> 0.10.7) warden (~> 0.10.7)
GIT
remote: http://github.com/dcu/magent.git
revision: 06513f3dac812469a55f2e365c349af4d2abc92a
specs:
magent (0.4.2)
mongo (>= 0.1.0)
uuidtools (>= 2.0.0)
GIT GIT
remote: http://github.com/jnunemaker/mongomapper.git remote: http://github.com/jnunemaker/mongomapper.git
revision: 931dab779011aa7acf60c1a4c7ad19e1ba838345 revision: 931dab779011aa7acf60c1a4c7ad19e1ba838345
...@@ -206,6 +214,7 @@ GEM ...@@ -206,6 +214,7 @@ GEM
treetop (1.4.8) treetop (1.4.8)
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
tzinfo (0.3.23) tzinfo (0.3.23)
uuidtools (2.1.1)
warden (0.10.7) warden (0.10.7)
rack (>= 1.0.0) rack (>= 1.0.0)
webmock (1.3.5) webmock (1.3.5)
...@@ -235,6 +244,7 @@ DEPENDENCIES ...@@ -235,6 +244,7 @@ DEPENDENCIES
haml haml
jnunemaker-validatable (= 1.8.4)! jnunemaker-validatable (= 1.8.4)!
json json
magent!
mini_magick mini_magick
mocha mocha
mongo_mapper (= 0.8.4)! mongo_mapper (= 0.8.4)!
......
## Commit Guidlines ## Commit Guidlines
You are welcome to contribute, add and extend Diaspora however you see fit. We will do our best to incorporate everything that meets our guidelines.
All commits must be tested, and after each commit, all tests should be green before a pull request is sent. Please write your tests in Rspec or Test-Unit. You are welcome to contribute, add to and extend Diaspora however you see fit. We
will do our best to incorporate everything that meets our guidelines.
GEMS: We would like to keep external dependencies unduplicated. We're using Nokogiri, and Mongomapper, and EM::HttpRequest as much as possible. We have a few gems in the project we'd rather not use, but if you can, use dependencies we already have. We need you to fill out a
[contributor agreement form](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq)
before we can accept your patches. The agreement gives Diaspora joint
ownership of the patch so the copyright isn't scattered. You can find it
[here](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq).
# Diaspora All commits must be tested, and after each commit, all tests should be green
before a pull request is sent. Please write your tests in Rspec.
The privacy aware, personally controlled, do-it-all, open source social network.
**DISCLAIMER: THIS IS PRE-ALPHA SOFTWARE AND SHOULD BE TREATED ACCORDINGLY.**
These instructions are for machines running [Ubuntu](http://www.ubuntu.com/), [Fedora](http://www.fedoraproject.org) or Mac OS X. We are developing Diaspora for the latest and greatest browsers, so please update your Firefox, Chrome or Safari to the latest and greatest.
## Preparing your system
In order to run Diaspora, you will need to download the following dependencies (specific instructions follow):
- Build Tools - Packages needed to compile the components that follow.
- [Ruby](http://www.ruby-lang.org) - The Ruby programming language. (We're using **1.8.7**. It comes preinstalled on Mac OS X.)
- [MongoDB](http://www.mongodb.org) - A snappy noSQL database.
- [OpenSSL](http://www.openssl.org/) - An encryption library. (It comes preinstalled on Mac OS X and Ubuntu.)
- [ImageMagick](http://www.imagemagick.org/) - An Image processing library used to resize uploaded photos.
- [Git](http://git-scm.com/) - The fast version control system.
After you have Ruby installed on your system, you will need to get RubyGems, then install Bundler:
- [RubyGems](http://rubygems.org/) - Source for Ruby gems.
- [Bundler](http://gembundler.com/) - Gem management tool for Ruby projects.
**We suggest using a package management system to download these dependencies. Trust us, it's going to make your life a lot easier. If you're using Mac OS X, you can use [homebrew](http://mxcl.github.com/homebrew/); if you're using Ubuntu, just use [Synaptic](http://www.nongnu.org/synaptic/) (it comes pre-installed); if you're using Fedora simply use [yum](http://yum.baseurl.org/). The instructions below assume you have these installed.**
### Build Tools
To install build tools on **Ubuntu**, run the following (includes the gcc and xml parsing dependencies):
sudo apt-get install build-essential libxslt1.1 libxslt1-dev libxml2
To install build tools on **Fedora**, run the following:
sudo yum install libxslt libxslt-devel libxml2 libxml2-devel
To install build tools on **Mac OS X**, you need to download and install [Xcode](http://developer.apple.com/technologies/tools/xcode.html).
### Ruby
To install Ruby 1.8.7 on **Ubuntu**, run the following command:
sudo apt-get install ruby-full
At this time Fedora does not have Ruby 1.8.7. As a workaround it is possible to use [rvm](http://rvm.beginrescueend.com/) with a locally compiled Ruby installation. A semi automated method for doing this is available. It is highly recommended that you review the script before running it so you understand what will occur. The script can be executed by running the following command:
./script/bootstrap-fedora-diaspora.sh
After reviewing and executing the above script you will need to follow the "MongoDB" section and then you should skip all the way down to "Start Mongo".
If you're on **Mac OS X**, you already have Ruby on your system. Yay!
### MongoDB
To install MongoDB on **Ubuntu**, add the official MongoDB repository from this link:
http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages
For Lucid, add the following line to your /etc/apt/sources.list:
deb http://downloads.mongodb.org/distros/ubuntu 10.4 10gen
And then run:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
sudo apt-get update
sudo apt-get install mongodb-stable
You can also run the binary directly by doing the following:
If you're running a 32-bit system, run `wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.2.tgz`. If you're running a 64-bit system, run `wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.6.2.tgz`.
# extract
tar xzf mongodb-linux-i686-1.4.0.tgz
# create the required data directory
sudo mkdir -p /data/db
sudo chmod -Rv 777 /data/
To install MongoDB on a x86_64 **Fedora** system, add the official MongoDB repository from MongoDB (http://www.mongodb.org/display/DOCS/CentOS+and+Fedora+Packages) into /etc/yum.repos.d/10gen.repo:
[10gen]
name=10gen Repository
baseurl=http://downloads.mongodb.org/distros/fedora/13/os/x86_64/
gpgcheck=0
enabled=1
Then use yum to install the packages:
sudo yum install mongo-stable mongo-stable-server
If you're running a 32-bit system, run `wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.2.tgz`. If you're running a 64-bit system, run `wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.6.2.tgz`.
# extract
tar xzf mongodb-linux-i686-1.4.0.tgz
# create the required data directory
sudo mkdir -p /data/db
sudo chmod -Rv 777 /data/
To install MongoDB on **Mac OS X**, run the following:
brew install mongo GEMS: We would like to keep external dependencies unduplicated. We're using
Nokogiri, Mongomapper, and EM::HttpRequest as much as possible. We have a few
gems in the project we'd rather not use, but if you can, use dependencies we
already have.
### OpenSSL # Diaspora
If you're running either **Ubuntu**, **Fedora** or **Mac OS X** you already have OpenSSL installed!
### ImageMagick
To install ImageMagick on **Ubuntu**, run the following:
sudo apt-get install imagemagick libmagick9-dev
To install ImageMagick on **Fedora**, run the following:
sudo yum install ImageMagick
To install ImageMagick on **Mac OS X**, run the following:
brew install imagemagick
### Git
To install Git on **Ubuntu**, run the following:
sudo apt-get install git-core
To install Git on **Fedora**, run the following:
sudo yum install git
To install Git on **Mac OS X**, run the following:
brew install git
### Rubygems
On **Ubuntu**, run the following:
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
tar -xf rubygems-1.3.7.tgz
cd rubygems-1.3.7
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
On **Fedora**, run the following:
sudo yum install rubygems
On **Mac OS X**, RubyGems comes preinstalled; however, you might need to update it for use with the latest Bundler. To update RubyGems, run `sudo gem update --system`.
### Bundler
After RubyGems is updated, simply run `sudo gem install bundler` to get Bundler.
## Getting Diaspora
git clone http://github.com/diaspora/diaspora.git
If you have never used github before, their [help desk](http://help.github.com/) has a pretty awesome guide on getting setup.
## Running Diaspora
### Install required gems
To start the app server for the first time, you need to use Bundler to install Diaspora's gem depencencies. Run `bundle install` from Diaspora's root directory. Bundler will also warn you if there is a new dependency and you need to bundle install again.
### Start Mongo
If you installed the Ubuntu package, MongoDB should already be running (if not, run `service mongodb start`). If you installed the binary manually, run `sudo mongod` from where mongo is installed to start mongo.
If you installed the Fedora package, MongoDB will need to be started via `service mongodb start`. If you installed the binary manually, run `sudo mongod` from where mongo is installed to start mongo. The privacy aware, personally controlled, do-it-all, open source social
network.
Diaspora will not run unless mongo is running. Mongo will not run by default, and will need to be started every time you wish to use or run the test suite for Diaspora. **DISCLAIMER: THIS IS PRE-ALPHA SOFTWARE AND SHOULD BE TREATED ACCORDINGLY.**
**PLEASE, DO NOT RUN IN PRODUCTION. IT IS FUN TO GET RUNNING, BUT EXPECT THINGS
TO BE BROKEN**
### Run the app server Some initial installation instructions are [here](http://github.com/diaspora/diaspora/wiki/Installing-and-Running-Diaspora).
Once mongo is running and bundler has finished, run `bundle exec thin start` from the root Diaspora directory. This will start the app server in development mode[.](http://bit.ly/9mwtUw)
### Logging in We are continuing to build features and improve the code base.
Run `rake db:seed:tom`, then login with user `tom` and password `evankorth`. More details in db/seeds/tom.rb. When we think it is ready for general use, we will post more final
instructions.
### Testing
Diaspora's test suite uses [rspec](http://rspec.info/), a behavior driven testing framework. In order to run the tests, run `bundle exec rspec spec`.
## Resources ## Resources
We are maintaining a [public tracker project](http://www.pivotaltracker.com/projects/61641) and a [roadmap](https://github.com/diaspora/diaspora/wiki/Roadmap). Also, you can file [bug reports](https://github.com/diaspora/diaspora/issues) right here on github. We are maintaining a
[public tracker project](http://www.pivotaltracker.com/projects/61641)
and a
[roadmap](https://github.com/diaspora/diaspora/wiki/Roadmap). Also, you can
file [bug reports](https://github.com/diaspora/diaspora/issues) right here on
github.
Ongoing discussion: Ongoing discussion:
- [Diaspora Developer Google Group](http://groups.google.com/group/diaspora-dev) - [Diaspora Developer Google Group](http://groups.google.com/group/diaspora-dev)
- [Diaspora Discussion Google Group](http://groups.google.com/group/diaspora-discuss) - [Diaspora Discussion Google Group](http://groups.google.com/group/diaspora-discuss)
- [#diaspora-dev](irc://irc.freenode.net/#diaspora-dev) - [Diaspora Q&A site](http://diaspora.shapado.com/)
- [#diaspora-dev IRC channel](irc://irc.freenode.net/#diaspora-dev)
More general info and updates about the project can be found on our [blog](http://joindiaspora.com), [twitter](http://twitter.com/joindiaspora). Also, be sure to join the official [mailing list](http://http://eepurl.com/Vebk). ([join via the web client](http://webchat.freenode.net?channels=diaspora-dev))
More general info and updates about the project can be found on:
## License [Our blog](http://joindiaspora.com),
Copyright 2010 Diaspora Inc. [and on Twitter](http://twitter.com/joindiaspora).
Also, be sure to join the official [mailing list](http://http://eepurl.com/Vebk).
Diaspora is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
If you wish to contact us privately about any exploits in Diaspora you may
Diaspora is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. find, you can email
[exploits@joindiaspora.com](mailto:exploits@joindiaspora.com).
You should have received a copy of the GNU Affero General Public License along with Diaspora. If not, see <http://www.gnu.org/licenses/>.
...@@ -9,14 +9,18 @@ class AlbumsController < ApplicationController ...@@ -9,14 +9,18 @@ class AlbumsController < ApplicationController
respond_to :json, :only => [:index, :show] respond_to :json, :only => [:index, :show]
def index def index
@albums = current_user.albums_by_aspect(@aspect).paginate @albums = current_user.albums_by_aspect(@aspect).paginate :page => params[:page], :per_page => 9, :order => 'created_at DESC'
@aspect = :all
respond_with @albums, :aspect => @aspect respond_with @albums, :aspect => @aspect
end end
def create def create
aspect = params[:album][:to] aspect = params[:album][:to]
@album = current_user.post(:album, params[:album])
flash[:notice] = "You've created an album called #{@album.name}." data = clean_hash(params[:album])
@album = current_user.post(:album, data)
flash[:notice] = I18n.t 'albums.create.success', :name => @album.name
redirect_to :action => :show, :id => @album.id, :aspect => aspect redirect_to :action => :show, :id => @album.id, :aspect => aspect
end end
...@@ -25,34 +29,43 @@ class AlbumsController < ApplicationController ...@@ -25,34 +29,43 @@ class AlbumsController < ApplicationController
end end
def destroy def destroy
@album = Album.find_by_id params[:id] @album = current_user.find_visible_post_by_id params[:id]
@album.destroy @album.destroy
flash[:notice] = "Album #{@album.name} deleted." flash[:notice] = I18n.t 'albums.destroy.success', :name => @album.name
respond_with :location => albums_url respond_with :location => albums_url
end end
def show def show
@photo = Photo.new @photo = Photo.new
@album = Album.find_by_id params[:id] @album = current_user.find_visible_post_by_id( params[:id] )
@album_photos = @album.photos @album_photos = @album.photos
respond_with @album respond_with @album
end end
def edit def edit
@album = Album.find_by_id params[:id] @album = current_user.find_visible_post_by_id params[:id]
redirect_to @album unless current_user.owns? @album redirect_to @album unless current_user.owns? @album
end end
def update def update
@album = Album.find_params_by_id params[:id] @album = current_user.find_visible_post_by_id params[:id]
if @album.update_attributes params[:album]
flash[:notice] = "Album #{@album.name} successfully edited." data = clean_hash(params[:album])
if current_user.update_post( @album, data )
flash[:notice] = I18n.t 'albums.update.success', :name => @album.name
respond_with @album respond_with @album
else else
flash[:error] = "Failed to edit album #{@album.name}." flash[:error] = I18n.t 'albums.update.failure', :name => @album.name
render :action => :edit render :action => :edit
end end
end end
private
def clean_hash(params)
return {
:name => params[:name],
:to => params[:to]
}
end
end end
...@@ -16,7 +16,7 @@ class AspectsController < ApplicationController ...@@ -16,7 +16,7 @@ class AspectsController < ApplicationController
def create def create
@aspect = current_user.aspect params[:aspect] @aspect = current_user.aspect params[:aspect]
flash[:notice] = "Click on the plus on the left side to tell Diaspora who can see your new aspect." flash[:notice] = I18n.t('aspects.create.success')
respond_with :location => aspects_manage_path respond_with :location => aspects_manage_path
end end
...@@ -25,14 +25,20 @@ class AspectsController < ApplicationController ...@@ -25,14 +25,20 @@ class AspectsController < ApplicationController
end end
def destroy def destroy
@aspect = Aspect.find_by_id params[:id] @aspect = current_user.aspect_by_id params[:id]
@aspect.destroy
flash[:notice] = "You are no longer sharing the aspect called #{@aspect.name}." begin
respond_with :location => aspects_url current_user.drop_aspect @aspect
flash[:notice] = i18n.t 'aspects.destroy.success',:name => @aspect.name
rescue RuntimeError => e
flash[:error] = e.message
end
respond_with :location => aspects_manage_path
end end
def show def show
@aspect = Aspect.find_by_id params[:id] @aspect = current_user.aspect_by_id params[:id]
@friends = @aspect.people @friends = @aspect.people
@posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC' @posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC'
...@@ -41,13 +47,15 @@ class AspectsController < ApplicationController ...@@ -41,13 +47,15 @@ class AspectsController < ApplicationController
def manage def manage
@aspect = :manage @aspect = :manage
@remote_requests = Request.for_user current_user @remote_requests = Request.for_user(current_user).all
end end
def update def update
@aspect = Aspect.find_by_id(params[:id]) @aspect = current_user.aspect_by_id(params[:id])
@aspect.update_attributes(params[:aspect])
flash[:notice] = "Your aspect, #{@aspect.name}, has been successfully edited." data = clean_hash(params[:aspect])
@aspect.update_attributes( data )
flash[:notice] = i18n.t 'aspects.update.success',:name => @aspect.name
respond_with @aspect respond_with @aspect
end end
...@@ -55,26 +63,34 @@ class AspectsController < ApplicationController ...@@ -55,26 +63,34 @@ class AspectsController < ApplicationController
params[:moves].each{ |move| params[:moves].each{ |move|
move = move[1] move = move[1]
unless current_user.move_friend(move) unless current_user.move_friend(move)
flash[:error] = "Aspect editing failed for friend #{Person.find_by_id( move[:friend_id] ).real_name}." flash[:error] = i18n.t 'aspects.move_friends.failure', :real_name => Person.find_by_id( move[:friend_id] ).real_name
redirect_to Aspect.first, :action => "edit" redirect_to aspects_manage_path
return return
end end
} }
flash[:notice] = "Aspects edited successfully." flash[:notice] = i18n.t 'aspects.move_friends.success'
redirect_to Aspect.first, :action => "edit" redirect_to aspects_manage_path
end end
def move_friend def move_friend
unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to]) unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to])
flash[:error] = "didn't work #{params.inspect}" flash[:error] = I18n.t 'aspects.move_friend.error',:inspect => params.inspect
end end
if aspect = Aspect.first(:id => params[:to][:to]) if aspect = current_user.aspect_by_id(params[:to][:to])
flash[:notice] = "You are now showing your friend a different aspect of yourself." flash[:notice] = I18n.t 'aspects.move_friend.success'
respond_with aspect render :nothing => true
else else
flash[:notice] = "You are now showing your friend a different aspect of yourself." flash[:notice] = I18n.t 'aspects.move_friend.failure'
respond_with Person.first(:id => params[:friend_id]) render aspects_manage_path
end end
end end
private
def clean_hash(params)
return {
:name => params[:name]
}
end
end end
...@@ -10,16 +10,11 @@ class CommentsController < ApplicationController ...@@ -10,16 +10,11 @@ class CommentsController < ApplicationController
respond_to :json, :only => :show respond_to :json, :only => :show
def create def create
target = Post.find_by_id params[:comment][:post_id] target = current_user.find_visible_post_by_id params[:comment][:post_id]
text = params[:comment][:text] text = params[:comment][:text]
@comment = current_user.comment text, :on => target @comment = current_user.comment text, :on => target
render :nothing => true render :nothing => true
end end
def show
@comment = Comment.find_by_id params[:id]
respond_with @comment
end
end end
...@@ -7,24 +7,6 @@ class DevUtilitiesController < ApplicationController ...@@ -7,24 +7,6 @@ class DevUtilitiesController < ApplicationController
before_filter :authenticate_user!, :except => [:set_backer_number] before_filter :authenticate_user!, :except => [:set_backer_number]
include ApplicationHelper include ApplicationHelper
include RequestsHelper include RequestsHelper
def warzombie
render :nothing => true
if current_user.email == "tom@tom.joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil
current_user.post(:status_message, :message => "There's a bomb in the lasagna!?")
current_user.post(:status_message, :message => "xkcd \nhttp://xkcd.com/743/" )
current_user.post(:status_message, :message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :created_at => Time.now-930)
current_user.post(:status_message, :message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :created_at => Time.now-43990)
current_user.post(:status_message, :message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :created_at => Time.now-4390)
current_user.post(:status_message, :message => "Reddit\nhttp://reddit.com", :created_at => Time.now-54390)
current_user.post(:status_message, :message => "Commercials for IE make me SO MAD and my friends just don't get why.", :created_at => Time.now-30900)
current_user.post(:status_message, :message => "Zombo.com\nhttp://zombo.com", :created_at => Time.now-9090)
current_user.post(:status_message, :message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :created_at => Time.now-590000)
current_user.post(:status_message, :message => "Mmm. Friday night. Acknowledged.", :created_at => Time.now-503900)
current_user.post(:status_message, :message => "Getting a universal remote is the epitome of laziness, I do declare.", :created_at => Time.now-4400)
current_user.post(:status_message, :message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :created_at => Time.now-400239)
current_user.post(:status_message, :message => "A cool, cool morning for once.", :created_at => Time.now-150000)
end
end
def zombiefriends def zombiefriends
render :nothing => true render :nothing => true
......
...@@ -11,7 +11,9 @@ class PeopleController < ApplicationController ...@@ -11,7 +11,9 @@ class PeopleController < ApplicationController
def index def index
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]} @aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
@people = Person.search params[:q] @aspect = :all
@people = Person.search(params[:q]).paginate :page => params[:page], :per_page => 25, :order => 'created_at DESC'
respond_with @people respond_with @people
end end
...@@ -20,7 +22,7 @@ class PeopleController < ApplicationController ...@@ -20,7 +22,7 @@ class PeopleController < ApplicationController
@profile = @person.profile @profile = @person.profile
@aspects_with_person = current_user.aspects_with_person(@person) @aspects_with_person = current_user.aspects_with_person(@person)
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]} @aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
@posts = current_user.visible_posts_from_others(:from => @person).paginate :page => params[:page], :order => 'created_at DESC' @posts = current_user.visible_posts(:from => @person).paginate :page => params[:page], :order => 'created_at DESC'
@latest_status_message = current_user.raw_visible_posts.find_all_by__type_and_person_id("StatusMessage", params[:id]).last @latest_status_message = current_user.raw_visible_posts.find_all_by__type_and_person_id("StatusMessage", params[:id]).last
@post_count = @posts.count @post_count = @posts.count
respond_with @person respond_with @person
......
...@@ -10,9 +10,7 @@ class PhotosController < ApplicationController ...@@ -10,9 +10,7 @@ class PhotosController < ApplicationController
respond_to :json, :only => :show respond_to :json, :only => :show
def create def create
album = Album.find_by_id params[:album_id] album = Album.find_by_id params[:album_id]
begin begin
######################## dealing with local files ############# ######################## dealing with local files #############
...@@ -33,22 +31,26 @@ class PhotosController < ApplicationController ...@@ -33,22 +31,26 @@ class PhotosController < ApplicationController
params[:user_file] = file params[:user_file] = file
@photo = current_user.post(:photo, params)
data = clean_hash(params)
@photo = current_user.post(:photo, data)
respond_to do |format| respond_to do |format|
format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )} format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
end end
rescue TypeError rescue TypeError
message = "Photo upload failed. Are you sure an image was added?" message = I18n.t 'photos.create.type_error'
respond_with :location => album, :error => message respond_with :location => album, :error => message
rescue CarrierWave::IntegrityError rescue CarrierWave::IntegrityError
message = "Photo upload failed. Are you sure that was an image?" message = I18n.t 'photos.create.integrity_error'
respond_with :location => album, :error => message respond_with :location => album, :error => message
rescue RuntimeError => e rescue RuntimeError => e
message = "Photo upload failed. Are you sure that your seatbelt is fastened?" message = I18n.t 'photos.create.runtime_error'
respond_with :location => album, :error => message respond_with :location => album, :error => message
raise e raise e
end end
...@@ -61,34 +63,55 @@ class PhotosController < ApplicationController ...@@ -61,34 +63,55 @@ class PhotosController < ApplicationController
end end
def destroy def destroy
@photo = Photo.find_by_id params[:id] @photo = current_user.find_visible_post_by_id params[:id]
@photo.destroy @photo.destroy
flash[:notice] = "Photo deleted." flash[:notice] = I18n.t 'photos.destroy.notice'
respond_with :location => @photo.album respond_with :location => @photo.album
end end
def show def show
@photo = Photo.find_by_id params[:id] @photo = current_user.find_visible_post_by_id params[:id]
@album = @photo.album @album = @photo.album
respond_with @photo, @album respond_with @photo, @album
end end
def edit def edit
@photo = Photo.find_by_id params[:id] @photo = current_user.find_visible_post_by_id params[:id]
@album = @photo.album @album = @photo.album
redirect_to @photo unless current_user.owns? @album redirect_to @photo unless current_user.owns? @album
end end
def update def update
@photo = Photo.find_by_id params[:id] @photo = current_user.find_visible_post_by_id params[:id]
if @photo.update_attributes params[:photo]
flash[:notice] = "Photo successfully updated." data = clean_hash(params)
if current_user.update_post( @photo, data[:photo] )
flash[:notice] = I18n.t 'photos.update.notice'
respond_with @photo respond_with @photo
else else
flash[:error] = "Failed to edit photo." flash[:error] = I18n.t 'photos.update.error'
render :action => :edit render :action => :edit
end end
end end
private
def clean_hash(params)
if params[:photo]
return {
:photo => {
:caption => params[:photo][:caption],
}
}
else
return{
:album_id => params[:album_id],
:user_file => params[:user_file]
}
end
end
end end
...@@ -10,7 +10,6 @@ class PublicsController < ApplicationController ...@@ -10,7 +10,6 @@ class PublicsController < ApplicationController
def hcard def hcard
@person = Person.find_by_id params[:id] @person = Person.find_by_id params[:id]
puts @person
unless @person.nil? || @person.owner.nil? unless @person.nil? || @person.owner.nil?
render 'hcard' render 'hcard'
end end
...@@ -21,9 +20,11 @@ class PublicsController < ApplicationController ...@@ -21,9 +20,11 @@ class PublicsController < ApplicationController
end end
def webfinger def webfinger
@person = Person.by_webfinger(params[:q]) @person = Person.by_webfinger(params[:q], :local => true) if params[:q]
unless @person.nil? || @person.owner.nil? unless @person.nil? || @person.owner.nil?
render 'webfinger', :content_type => 'application/xrd+xml' render 'webfinger', :content_type => 'application/xrd+xml'
else
render :nothing => true
end end
end end
...@@ -31,9 +32,10 @@ class PublicsController < ApplicationController ...@@ -31,9 +32,10 @@ class PublicsController < ApplicationController
render :nothing => true render :nothing => true
return unless params[:xml] return unless params[:xml]
begin begin
@user = Person.first(:id => params[:id]).owner person = Person.first(:id => params[:id])
@user = person.owner
rescue NoMethodError => e rescue NoMethodError => e
Rails.logger.error("Received post #{params[:xml]} for nonexistent person #{params[:id]}") Rails.logger.error("Received post for nonexistent person #{params[:id]}")
return return
end end
@user.receive_salmon params[:xml] @user.receive_salmon params[:xml]
......
...@@ -15,9 +15,7 @@ class RegistrationsController < Devise::RegistrationsController ...@@ -15,9 +15,7 @@ class RegistrationsController < Devise::RegistrationsController
flash[:error] = e.message flash[:error] = e.message
end end
if user if user
#set_flash_message :notice, :signed_up flash[:notice] = I18n.t 'registrations.create.success'
flash[:notice] = "You've joined Diaspora!"
#redirect_to root_url
sign_in_and_redirect(:user, user) sign_in_and_redirect(:user, user)
else else
redirect_to new_user_registration_path redirect_to new_user_registration_path
......
...@@ -13,15 +13,15 @@ class RequestsController < ApplicationController ...@@ -13,15 +13,15 @@ class RequestsController < ApplicationController
if params[:accept] if params[:accept]
if params[:aspect_id] if params[:aspect_id]
@friend = current_user.accept_and_respond( params[:id], params[:aspect_id]) @friend = current_user.accept_and_respond( params[:id], params[:aspect_id])
flash[:notice] = "You are now friends." flash[:notice] = I18n.t 'requests.destroy.success'
respond_with :location => current_user.aspect_by_id(params[:aspect_id]) respond_with :location => current_user.aspect_by_id(params[:aspect_id])
else else
flash[:error] = "Please select an aspect!" flash[:error] = I18n.t 'requests.destroy.error'
respond_with :location => requests_url respond_with :location => requests_url
end end
else else
current_user.ignore_friend_request params[:id] current_user.ignore_friend_request params[:id]
flash[:notice] = "Ignored friend request." flash[:notice] = I18n.t 'requests.destroy.ignore'
respond_with :location => requests_url respond_with :location => requests_url
end end
end end
...@@ -36,27 +36,31 @@ class RequestsController < ApplicationController ...@@ -36,27 +36,31 @@ class RequestsController < ApplicationController
begin begin
rel_hash = relationship_flow(params[:request][:destination_url]) rel_hash = relationship_flow(params[:request][:destination_url])
rescue Exception => e rescue Exception => e
flash[:error] = "No diaspora seed found with this email!" raise e unless e.message.include? "not found"
flash[:error] = I18n.t 'requests.create.error'
respond_with :location => aspect respond_with :location => aspect
return return
end end
# rel_hash = {:friend => params[:friend_handle]}
Rails.logger.debug("Sending request: #{rel_hash}") Rails.logger.debug("Sending request: #{rel_hash}")
begin begin
@request = current_user.send_friend_request_to(rel_hash[:friend], aspect) @request = current_user.send_friend_request_to(rel_hash[:friend], aspect)
rescue Exception => e rescue Exception => e
raise e unless e.message.include? "already friends" raise e unless e.message.include? "already"
flash[:notice] = "You are already friends with #{params[:request][:destination_url]}!" flash[:notice] = I18n.t 'requests.create.already_friends', :destination_url => params[:request][:destination_url]
respond_with :location => aspect respond_with :location => aspect
return return
end end
if @request if @request
flash[:notice] = "A friend request was sent to #{@request.destination_url}." flash[:notice] = I18n.t 'requests.create.success',:destination_url => @request.destination_url
respond_with :location => aspect respond_with :location => aspect
else else
flash[:error] = "Something went horribly wrong." flash[:error] = I18n.t 'requests.create.horribly_wrong'
respond_with :location => aspect respond_with :location => aspect
end end
end end
......
...@@ -14,7 +14,7 @@ class SocketsController < ApplicationController ...@@ -14,7 +14,7 @@ class SocketsController < ApplicationController
def outgoing(uid,object,opts={}) def outgoing(uid,object,opts={})
@_request = ActionDispatch::Request.new({}) @_request = ActionDispatch::Request.new({})
Diaspora::WebSocket.push_to_user(uid, action_hash(uid, object, opts)) Diaspora::WebSocket.queue_to_user(uid, action_hash(uid, object, opts))
end end
end end
...@@ -11,18 +11,29 @@ class StatusMessagesController < ApplicationController ...@@ -11,18 +11,29 @@ class StatusMessagesController < ApplicationController
def create def create
params[:status_message][:to] = params[:aspect_ids] params[:status_message][:to] = params[:aspect_ids]
@status_message = current_user.post(:status_message, params[:status_message])
data = clean_hash params[:status_message]
@status_message = current_user.post(:status_message, data)
respond_with @status_message respond_with @status_message
end end
def destroy def destroy
@status_message = StatusMessage.find_by_id params[:id] @status_message = current_user.find_visible_post_by_id params[:id]
@status_message.destroy @status_message.destroy
respond_with :location => root_url respond_with :location => root_url
end end
def show def show
@status_message = StatusMessage.find_by_id params[:id] @status_message = current_user.find_visible_post_by_id params[:id]
respond_with @status_message respond_with @status_message
end end
private
def clean_hash(params)
return {
:message => params[:message],
:to => params[:to]
}
end
end end
...@@ -7,13 +7,6 @@ class UsersController < ApplicationController ...@@ -7,13 +7,6 @@ class UsersController < ApplicationController
before_filter :authenticate_user!, :except => [:new, :create] before_filter :authenticate_user!, :except => [:new, :create]
respond_to :html respond_to :html
respond_to :json, :only => :show
def show
@user = User.find_by_id params[:id]
@user_profile = @user.person.profile
respond_with @user
end
def edit def edit
@user = current_user @user = current_user
...@@ -23,15 +16,16 @@ class UsersController < ApplicationController ...@@ -23,15 +16,16 @@ class UsersController < ApplicationController
end end
def update def update
@user = User.find_by_id params[:id] @user = current_user
prep_image_url(params[:user])
@user.update_profile params[:user] data = clean_hash params[:user]
prep_image_url(data)
@user.update_profile data
respond_with(@user, :location => root_url) respond_with(@user, :location => root_url)
end end
private private
def prep_image_url(params) def prep_image_url(params)
if params[:profile][:image_url].empty? if params[:profile][:image_url].empty?
params[:profile].delete(:image_url) params[:profile].delete(:image_url)
...@@ -39,4 +33,16 @@ class UsersController < ApplicationController ...@@ -39,4 +33,16 @@ class UsersController < ApplicationController
params[:profile][:image_url] = "http://" + request.host + ":" + request.port.to_s + params[:profile][:image_url] params[:profile][:image_url] = "http://" + request.host + ":" + request.port.to_s + params[:profile][:image_url]
end end
end end
def clean_hash(params)
return {
:profile =>
{
:first_name => params[:profile][:first_name],
:last_name => params[:profile][:last_name],
:image_url => params[:profile][:image_url]
}
}
end
end end
...@@ -6,17 +6,17 @@ ...@@ -6,17 +6,17 @@
module AlbumsHelper module AlbumsHelper
def friends_albums_link def friends_albums_link
if params[:friends] if params[:friends]
"Friends Albums" I18n.t('albums.helper.friends_albums')
else else
link_to 'Friends Albums', albums_path({:friends => true}) link_to I18n.t('albums.helper.friends_albums'), albums_path({:friends => true})
end end
end end
def your_albums_link def your_albums_link
if params[:friends] if params[:friends]
link_to 'Your Albums', albums_path link_to I18n.t('albums.helper.your_albums'), albums_path
else else
'Your Albums' I18n.t('albums.helper.your_albums')
end end
end end
end end
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
module ApplicationHelper module ApplicationHelper
def current_aspect?(aspect) def current_aspect?(aspect)
!@aspect.is_a?(Symbol) && @aspect.id == aspect.id !@aspect.is_a?(Symbol) && @aspect.id == aspect.id
end end
def object_path(object, opts = {}) def object_path(object, opts = {})
object = object.person if object.is_a? User
eval("#{object.class.to_s.underscore}_path(object, opts)") eval("#{object.class.to_s.underscore}_path(object, opts)")
end end
...@@ -27,7 +27,7 @@ module ApplicationHelper ...@@ -27,7 +27,7 @@ module ApplicationHelper
end end
def how_long_ago(obj) def how_long_ago(obj)
"#{time_ago_in_words(obj.created_at)} ago." "#{time_ago_in_words(obj.created_at)} ago"
end end
def person_url(person) def person_url(person)
...@@ -37,16 +37,16 @@ module ApplicationHelper ...@@ -37,16 +37,16 @@ module ApplicationHelper
when "Person" when "Person"
person_path(person) person_path(person)
else else
"unknown person" I18n.t('application.helper.unknown_person')
end end
end end
def owner_image_tag def owner_image_tag
person_image_tag(current_user) person_image_tag(current_user.person)
end end
def owner_image_link def owner_image_link
person_image_link(current_user) person_image_link(current_user.person)
end end
def person_image_tag(person) def person_image_tag(person)
...@@ -61,11 +61,10 @@ module ApplicationHelper ...@@ -61,11 +61,10 @@ module ApplicationHelper
end end
def new_request(request_count) def new_request(request_count)
"new_requests" if request_count > 0 I18n.t('application.helper.new_requests') if request_count > 0
end end
def post_yield_tag(post) def post_yield_tag(post)
(':' + post.id.to_s).to_sym (':' + post.id.to_s).to_sym
end end
end end
...@@ -7,4 +7,12 @@ module AspectsHelper ...@@ -7,4 +7,12 @@ module AspectsHelper
def link_for_aspect( aspect ) def link_for_aspect( aspect )
link_to aspect.name, aspect link_to aspect.name, aspect
end end
def remove_link( aspect )
if aspect.people.size == 0
link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete
else
"<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
end
end
end end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter