From 2d7b72e51878cdfc9a126d1b4cb397bfa1c963a9 Mon Sep 17 00:00:00 2001 From: Pistos Date: Mon, 20 Sep 2010 21:18:37 -0400 Subject: [PATCH 01/38] Added a newline after headings where it was missing. --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0ae9faff1..3eade7240 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ ## 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. -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). +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). 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. @@ -14,7 +15,7 @@ The privacy aware, personally controlled, do-it-all, open source social network. **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** -Also, we really want to continue to focus on features and improving the code base. When we think it is +Also, we really want to continue to focus on features and improving the code base. When we think it is ready for general use, we will post more detailed instructions. ## Notice @@ -30,6 +31,7 @@ We will try and fully support more webservers later, but that is what works for 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. @@ -64,7 +66,7 @@ To install Ruby 1.8.7 on **Ubuntu**, run the following command: sudo apt-get install ruby-full -Please note that you need to have Universe enabled in your /etc/apt/sources.list file to install ruby using apt-get. +Please note that you need to have Universe enabled in your /etc/apt/sources.list file to install ruby using apt-get. 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: @@ -90,11 +92,11 @@ Then run: You can also run the binary directly by doing the following: -If you're running a 32-bit system, run: +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: + +If you're running a 64-bit system, run: wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.6.2.tgz @@ -202,9 +204,11 @@ If you have never used github before, their [help desk](http://help.github.com/) ## 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. @@ -214,19 +218,24 @@ If you installed the OsX package through "brew", MongoDB will need to be started 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. ### Run the server + `./script/server` will start both thin and the websocket server. If you want to run a different app server, you will have to run them separately. See below for instructions. ### Run the app server + 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) ### Run the websocket server + run `bundle exec ruby ./script/websocket_server` to start the websocket server on port 8080. Change the port in config/app_config.yml. ### Logging in with a sample user + Run `rake db:seed:tom`, then login with user `tom` and password `evankorth`. More details in db/seeds/tom.rb. ### 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 From fa1e09cadbfb5a1b505398e299e7777d40bf3ff2 Mon Sep 17 00:00:00 2001 From: Pistos Date: Mon, 20 Sep 2010 21:23:20 -0400 Subject: [PATCH 02/38] Hard-wrapped README text to confirm to an 80-character screen width. --- README.md | 185 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 133 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 3eade7240..e7c118631 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,87 @@ ## 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. +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. -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). +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). -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. +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. -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. +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. # Diaspora -The privacy aware, personally controlled, do-it-all, open source social network. +The privacy aware, personally controlled, do-it-all, open source social +network. **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** +**PLEASE, DO NOT RUN IN PRODUCTION. IT IS FUN TO GET RUNNING, BUT EXPECT THINGS +TO BE BROKEN** -Also, we really want to continue to focus on features and improving the code base. When we think it is -ready for general use, we will post more detailed instructions. +Also, we really want to continue to focus on features and improving the code +base. When we think it is ready for general use, we will post more detailed +instructions. ## Notice -We currently run Diaspora with the [thin](http://code.macournoyer.com/thin/) as our webserver, behind [nginx](http://wiki.nginx.org/Main). Diaspora uses the asynchronous feature of [EventMachine](http://rubyeventmachine.com/) to send messages between seeds, +We currently run Diaspora with the [thin](http://code.macournoyer.com/thin/) as +our webserver, behind [nginx](http://wiki.nginx.org/Main). Diaspora uses the +asynchronous feature of [EventMachine](http://rubyeventmachine.com/) to send +messages between seeds, using the power of the +[Reactor](http://en.wikipedia.org/wiki/Reactor_pattern) pattern. If you use +mod_rails, mongrel, or another non-eventmachine based application server, +federation and/or websockets may not work. -using the power of the [Reactor](http://en.wikipedia.org/wiki/Reactor_pattern) pattern. If you use mod_rails, mongrel, or another non-eventmachine based application server, federation and/or websockets may not work. +If you don't like thin, you can always try +[Rainbows!](http://rainbows.rubyforge.org/) We will try and fully support more +webservers later, but that is what works for now. -If you don't like thin, you can always try [Rainbows!](http://rainbows.rubyforge.org/) -We will try and fully support more webservers later, but that is what works for now. - - -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. +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): +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.) +- [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. +- [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: +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.** +**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): +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 @@ -58,7 +89,8 @@ 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). +To install build tools on **Mac OS X**, you need to download and install +[Xcode](http://developer.apple.com/technologies/tools/xcode.html). ### Ruby @@ -66,22 +98,30 @@ To install Ruby 1.8.7 on **Ubuntu**, run the following command: sudo apt-get install ruby-full -Please note that you need to have Universe enabled in your /etc/apt/sources.list file to install ruby using apt-get. +Please note that you need to have Universe enabled in your +/etc/apt/sources.list file to install ruby using apt-get. -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: +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". - +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 [here](http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages). +To install MongoDB on **Ubuntu**, add the official MongoDB repository +[here](http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages). -For Lucid, add the following line to your /etc/apt/sources.list (for other distros, see http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages): +For Lucid, add the following line to your /etc/apt/sources.list (for other +distros, see http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages): deb http://downloads.mongodb.org/distros/ubuntu 10.4 10gen @@ -109,7 +149,10 @@ Then run: 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: +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 @@ -117,13 +160,14 @@ To install MongoDB on a x86_64 **Fedora** system, add the official MongoDB repos 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`. +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 @@ -131,7 +175,6 @@ If you're running a 32-bit system, run `wget http://fastdl.mongodb.org/linux/mon sudo mkdir -p /data/db sudo chmod -Rv 777 /data/ - To install MongoDB on **Mac OS X**, run the following: brew install mongo @@ -140,7 +183,8 @@ To install MongoDB on **Mac OS X**, run the following: ### OpenSSL -If you're running either **Ubuntu**, **Fedora** or **Mac OS X** you already have OpenSSL installed! +If you're running either **Ubuntu**, **Fedora** or **Mac OS X** you already +have OpenSSL installed! ### ImageMagick @@ -180,67 +224,99 @@ On **Ubuntu** 10.04, run the following: sudo apt-get update sudo apt-get install rubygems -This PPA is maintained by an Ubuntu Developer. For Ubuntu 10.10, this version of rubygems is in the repositories. +This PPA is maintained by an Ubuntu Developer. For Ubuntu 10.10, this version +of rubygems is in the repositories. 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`. +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. If you're using Ubuntu repository .debs, bundler is found at /var/lib/gems/1.8/bin/bundle +After RubyGems is updated, simply run `sudo gem install bundler` to get +Bundler. If you're using Ubuntu repository .debs, bundler is found at +/var/lib/gems/1.8/bin/bundle ## 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. +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. +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 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. +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. -If you installed the OsX package through "brew", MongoDB will need to be started via `sudo launchctl load /Library/LaunchDaemons/org.mongodb.mongod.plist`. (before you have to go to /Library/LaunchDaemons and add a symlink to /usr/local/Cellar/mongodb/1.6.2-x86_64/org.mongodb.mongod.plist) +If you installed the OsX package through "brew", MongoDB will need to be +started via `sudo launchctl load +/Library/LaunchDaemons/org.mongodb.mongod.plist`. (before you have to go to +/Library/LaunchDaemons and add a symlink to +/usr/local/Cellar/mongodb/1.6.2-x86_64/org.mongodb.mongod.plist) -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. +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. ### Run the server -`./script/server` will start both thin and the websocket server. If you want to run a different app server, you will have to run them separately. See below for instructions. +`./script/server` will start both thin and the websocket server. If you want +to run a different app server, you will have to run them separately. See below +for instructions. ### Run the app server -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) +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) ### Run the websocket server -run `bundle exec ruby ./script/websocket_server` to start the websocket server on port 8080. Change the port in config/app_config.yml. +run `bundle exec ruby ./script/websocket_server` to start the websocket server +on port 8080. Change the port in config/app_config.yml. ### Logging in with a sample user -Run `rake db:seed:tom`, then login with user `tom` and password `evankorth`. More details in db/seeds/tom.rb. +Run `rake db:seed:tom`, then login with user `tom` and password `evankorth`. +More details in db/seeds/tom.rb. ### 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`. +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 -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: - [Diaspora Developer Google Group](http://groups.google.com/group/diaspora-dev) @@ -249,6 +325,11 @@ Ongoing discussion: - [#diaspora-dev IRC channel](irc://irc.freenode.net/#diaspora-dev) ([join via the web client](http://webchat.freenode.net?channels=diaspora-dev)) -More general info and updates about the project can be found on our [blog](http://joindiaspora.com), [and on Twitter](http://twitter.com/joindiaspora). Also, be sure to join the official [mailing list](http://http://eepurl.com/Vebk). +More general info and updates about the project can be found on our +[blog](http://joindiaspora.com), +[and on Twitter](http://twitter.com/joindiaspora). Also, be sure to join the +official [mailing list](http://http://eepurl.com/Vebk). -If you wish to contact us privately about any exploits in Diaspora you may find, you can email [exploits@joindiaspora.com](mailto:exploits@joindiaspora.com). +If you wish to contact us privately about any exploits in Diaspora you may +find, you can email +[exploits@joindiaspora.com](mailto:exploits@joindiaspora.com). From bdd752f07b43dd316b9c87d7d454538ebe69ea00 Mon Sep 17 00:00:00 2001 From: Thomas Krehbiel Date: Mon, 20 Sep 2010 21:49:14 -0400 Subject: [PATCH 03/38] Fix for 'Local variable hides method' --- app/models/person.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 72f4c46b9..8a6b85175 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -104,8 +104,8 @@ class Person return nil unless public_key_entry - public_key = public_key_entry.first.href - new_person.exported_key = Base64.decode64 public_key + pubkey = public_key_entry.first.href + new_person.exported_key = Base64.decode64 pubkey guid = profile.links.select{|x| x.rel == 'http://joindiaspora.com/guid'}.first.href new_person.id = guid From 11d31901e4647f15e02af3fb4d9a5f76a369ac47 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 21 Sep 2010 13:59:52 -0700 Subject: [PATCH 04/38] IZ, RS, Pulled receiving out of user file, refactored receive method to be clearer --- app/models/user.rb | 75 +-------------------------- lib/diaspora/user/receiving.rb | 93 ++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 73 deletions(-) create mode 100644 lib/diaspora/user/receiving.rb diff --git a/app/models/user.rb b/app/models/user.rb index e02c58534..7c9bfdc1b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,12 +5,14 @@ require 'lib/diaspora/user/friending.rb' require 'lib/diaspora/user/querying.rb' +require 'lib/diaspora/user/receiving.rb' require 'lib/salmon/salmon' class User include MongoMapper::Document include Diaspora::UserModules::Friending include Diaspora::UserModules::Querying + include Diaspora::UserModules::Receiving include Encryptor::Private QUEUE = MessageHandler.new @@ -220,79 +222,6 @@ class User end end - ###### Receiving ####### - def receive_salmon ciphertext - cleartext = decrypt( ciphertext) - salmon = Salmon::SalmonSlap.parse cleartext - if salmon.verified_for_key?(salmon.author.public_key) - Rails.logger.info("data in salmon: #{salmon.data}") - self.receive(salmon.data) - end - end - - def receive xml - object = Diaspora::Parser.from_xml(xml) - Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}") - Rails.logger.debug("From: #{object.person.inspect}") if object.person - - if object.is_a? Retraction - if object.type == 'Person' - - Rails.logger.info( "the person id is #{object.post_id} the friend found is #{visible_person_by_id(object.post_id).inspect}") - unfriended_by visible_person_by_id(object.post_id) -else - object.perform self.id - aspects = self.aspects_with_person(object.person) - aspects.each{ |aspect| aspect.post_ids.delete(object.post_id.to_id) - aspect.save - } - end - elsif object.is_a? Request - person = Diaspora::Parser.parse_or_find_person_from_xml( xml ) - person.serialized_key ||= object.exported_key - object.person = person - object.person.save - old_request = Request.first(:id => object.id) - object.aspect_id = old_request.aspect_id if old_request - object.save - receive_friend_request(object) - elsif object.is_a? Profile - person = Diaspora::Parser.owner_id_from_xml xml - person.profile = object - 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 = 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 - unless owns?(object) - dispatch_comment object - end - object.socket_to_uid(id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object)) - else - Rails.logger.debug("Saving object: #{object}") - object.user_refs += 1 - object.save - - self.raw_visible_posts << object - self.save - - aspects = self.aspects_with_person(object.person) - aspects.each{ |aspect| - aspect.posts << object - aspect.save - object.socket_to_uid(id, :aspect_ids => [aspect.id]) if (object.respond_to?(:socket_to_uid) && !self.owns?(object)) - } - - end - - end - ###Helpers############ def self.instantiate!( opts = {} ) hostname = opts[:url].gsub(/(https?:|www\.)\/\//, '') diff --git a/lib/diaspora/user/receiving.rb b/lib/diaspora/user/receiving.rb new file mode 100644 index 000000000..39b1af5d2 --- /dev/null +++ b/lib/diaspora/user/receiving.rb @@ -0,0 +1,93 @@ +module Diaspora + module UserModules + module Receiving + def receive_salmon ciphertext + cleartext = decrypt( ciphertext) + salmon = Salmon::SalmonSlap.parse cleartext + if salmon.verified_for_key?(salmon.author.public_key) + Rails.logger.info("data in salmon: #{salmon.data}") + self.receive(salmon.data) + end + end + + def receive xml + object = Diaspora::Parser.from_xml(xml) + Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}") + Rails.logger.debug("From: #{object.person.inspect}") if object.person + + if object.is_a? Retraction + receive_retraction object, xml + elsif object.is_a? Request + receive_request object, xml + elsif object.is_a? Profile + receive_profile object, xml + elsif object.is_a?(Comment) + receive_comment object, xml + else + receive_post object, xml + end + end + + def receive_retraction retraction, xml + if retraction.type == 'Person' + Rails.logger.info( "the person id is #{retraction.post_id} the friend found is #{visible_person_by_id(retraction.post_id).inspect}") + unfriended_by visible_person_by_id(retraction.post_id) + else + retraction.perform self.id + aspects = self.aspects_with_person(retraction.person) + aspects.each{ |aspect| aspect.post_ids.delete(retraction.post_id.to_id) + aspect.save + } + end + end + + def receive_request request, xml + person = Diaspora::Parser.parse_or_find_person_from_xml( xml ) + person.serialized_key ||= request.exported_key + request.person = person + request.person.save + old_request = Request.first(:id => request.id) + request.aspect_id = old_request.aspect_id if old_request + request.save + receive_friend_request(request) + end + + def receive_profile profile, xml + person = Diaspora::Parser.owner_id_from_xml xml + person.profile = profile + person.save + end + + def receive_comment comment, xml + comment.person = Diaspora::Parser.parse_or_find_person_from_xml( xml ).save if comment.person.nil? + self.visible_people = self.visible_people | [comment.person] + self.save + Rails.logger.debug("The person parsed from comment xml is #{comment.person.inspect}") unless comment.person.nil? + comment.person.save + Rails.logger.debug("From: #{comment.person.inspect}") if comment.person + raise "In receive for #{self.real_name}, signature was not valid on: #{comment.inspect}" unless comment.post.person == self.person || comment.verify_post_creator_signature + comment.save + unless owns?(comment) + dispatch_comment comment + end + comment.socket_to_uid(id) if (comment.respond_to?(:socket_to_uid) && !self.owns?(comment)) + end + + def receive_post post, xml + Rails.logger.debug("Saving post: #{post}") + post.user_refs += 1 + post.save + + self.raw_visible_posts << post + self.save + + aspects = self.aspects_with_person(post.person) + aspects.each{ |aspect| + aspect.posts << post + aspect.save + post.socket_to_uid(id, :aspect_ids => [aspect.id]) if (post.respond_to?(:socket_to_uid) && !self.owns?(post)) + } + end + end + end +end From 4e951d8abf8b773e548d4a77d3d857184c04e580 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 21 Sep 2010 14:08:18 -0700 Subject: [PATCH 05/38] Fixing COPYRIGHT file --- COPYRIGHT | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/COPYRIGHT b/COPYRIGHT index 8a380cc7e..f1bed1a6b 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,14 +1,23 @@ -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. +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 General Public License in all respects -* for all of the code used other than OpenSSL. 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. +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. From 9db4fea9ac4d2d14a7a24314b8e517c6861ac09c Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Tue, 21 Sep 2010 14:44:36 -0700 Subject: [PATCH 06/38] Correct mailing list link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ae9faff1..6e9c40aa0 100644 --- a/README.md +++ b/README.md @@ -240,6 +240,6 @@ Ongoing discussion: - [#diaspora-dev IRC channel](irc://irc.freenode.net/#diaspora-dev) ([join via the web client](http://webchat.freenode.net?channels=diaspora-dev)) -More general info and updates about the project can be found on our [blog](http://joindiaspora.com), [and on Twitter](http://twitter.com/joindiaspora). Also, be sure to join the official [mailing list](http://http://eepurl.com/Vebk). +More general info and updates about the project can be found on our [blog](http://joindiaspora.com), [and on Twitter](http://twitter.com/joindiaspora). Also, be sure to join the official [mailing list](http://eepurl.com/Vebk). If you wish to contact us privately about any exploits in Diaspora you may find, you can email [exploits@joindiaspora.com](mailto:exploits@joindiaspora.com). From 44db21ffd4fc27656da7ef68e8344eb194ac5311 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 21 Sep 2010 15:12:47 -0700 Subject: [PATCH 07/38] DG MS; cleaned up spec --- app/models/user.rb | 1 - spec/models/user/posting_spec.rb | 101 ++++++++++++++++--------------- spec/models/user_spec.rb | 9 +-- 3 files changed, 53 insertions(+), 58 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 86b818bb0..4e2e642e3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -98,7 +98,6 @@ class User ######## Posting ######## def post(class_name, options = {}) - puts options.inspect if class_name == :photo raise ArgumentError.new("No album_id given") unless options[:album_id] aspect_ids = aspects_with_post( options[:album_id] ) diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index d00747a2d..1f24f3fed 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -7,65 +7,68 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe User do - before do - @user = Factory.create :user - @aspect = @user.aspect(:name => 'heroes') - @aspect1 = @user.aspect(:name => 'heroes') - @user2 = Factory.create(:user) - @aspect2 = @user2.aspect(:name => 'losers') + let(:user) { Factory(:user) } + let(:user2) { Factory(:user) } + let(:user3) { Factory(:user) } + let(:user4) { Factory(:user) } - @user3 = Factory.create(:user) - @aspect3 = @user3.aspect(:name => 'heroes') + let(:aspect) {user.aspect(:name => 'heroes')} + let!(:aspect1) {user.aspect(:name => 'heroes')} + let!(:aspect2) {user2.aspect(:name => 'losers')} + let!(:aspect3) {user3.aspect(:name => 'heroes')} + let!(:aspect4) {user4.aspect(:name => 'heroes')} - @user4 = Factory.create(:user) - @aspect4 = @user4.aspect(:name => 'heroes') - - friend_users(@user, @aspect, @user2, @aspect2) - friend_users(@user, @aspect, @user3, @aspect3) - friend_users(@user, @aspect1, @user4, @aspect4) - end - - it 'should not be able to post without a aspect' do - proc {@user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/ + before do + friend_users(user, aspect, user2, aspect2) + friend_users(user, aspect, user3, aspect3) + friend_users(user, aspect1, user4, aspect4) end - it 'should not be able to post to someone elses aspect' do - proc {@user.post(:status_message, :message => "heyheyhey", :to => @aspect2.id)}.should raise_error /Cannot post to an aspect you do not own./ - end - - it 'should put the post in the aspect post array' do - post = @user.post(:status_message, :message => "hey", :to => @aspect.id) - @aspect.reload - @aspect.post_ids.include?(post.id).should be true + context 'posting' do + describe '#post' do + it 'should not be able to post without a aspect' do + proc {user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/ + end + + it 'should not be able to post to someone elses aspect' do + proc {user.post(:status_message, :message => "heyheyhey", :to => aspect2.id)}.should raise_error /Cannot post to an aspect you do not own./ + end + + it 'should put the post in the aspect post array' do + post = user.post(:status_message, :message => "hey", :to => aspect.id) + aspect.reload + aspect.posts.should include post + end + + it 'should put an album in the aspect post array' do + album = user.post :album, :name => "Georges", :to => aspect.id + aspect.reload + aspect.posts.should include album + end + end end - it 'should put an album in the aspect post array' do - album = @user.post :album, :name => "Georges", :to => @aspect.id - @aspect.reload - @aspect.post_ids.include?(album.id).should be true - @aspect.posts.include?(album).should be true - end + context 'dispatching' do + let!(:post) { user.build_post :status_message, :message => "hey" } - describe 'dispatching' do - before do - @post = @user.build_post :status_message, :message => "hey" - end - it 'should push a post to a aspect' do - @user.should_receive(:salmon).twice - @user.push_to_aspects(@post, @aspect.id) + describe '#push_to_aspects' do + it 'should push a post to a aspect' do + user.should_receive(:salmon).twice + user.push_to_aspects(post, aspect.id) + end + + it 'should push a post to all aspects' do + user.should_receive(:salmon).exactly(3).times + user.push_to_aspects(post, :all) + end end - it 'should push a post to all aspects' do - @user.should_receive(:salmon).exactly(3).times - @user.push_to_aspects(@post, :all) + describe '#push_to_people' do + it 'should push to people' do + user.should_receive(:salmon).twice + user.push_to_people(post, [user2.person, user3.person]) + end end - - it 'should push to people' do - @user.should_receive(:salmon).twice - @user.push_to_people(@post, [@user2.person, @user3.person]) - end - - end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 223881671..ef9a08cc5 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -12,14 +12,6 @@ describe User do @aspect = @user.aspect(:name => 'heroes') end - it 'should create with pivotal or allowed emails' do - user1 = Factory.create(:user, :email => "kimfuh@yahoo.com") - user2 = Factory.create(:user, :email => "awesome@sofaer.net") - user3 = Factory.create(:user, :email => "steveellis@pivotallabs.com") - user1.created_at.nil?.should be false - user2.created_at.nil?.should be false - user3.created_at.nil?.should be false - end describe 'profiles' do it 'should be able to update their profile and send it to their friends' do @@ -58,4 +50,5 @@ describe User do @user.aspects.include?(@aspect).should == true end end + end From efd901dcd9c71cd9e671973b8bd3d0ea834ff338 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 15:46:57 -0700 Subject: [PATCH 08/38] RS, IZ; Pod url moved to app_config.yml, app_config.yml refactored, diaspora_handle now set based on APP_CONFIG --- app/controllers/photos_controller.rb | 3 --- app/helpers/requests_helper.rb | 1 - app/models/user.rb | 10 ++-------- config/app_config.yml | 20 +++++--------------- config/initializers/_load_app_config.rb | 10 ++++++++-- spec/factories.rb | 5 ++++- spec/models/person_spec.rb | 16 ++++++++++++++-- spec/models/user_spec.rb | 20 +++++++++++++------- 8 files changed, 46 insertions(+), 39 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 42b00007c..afc193413 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -10,10 +10,7 @@ class PhotosController < ApplicationController respond_to :json, :only => :show def create - album = Album.find_by_id params[:album_id] - puts params - begin ######################## dealing with local files ############# diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb index faefe1f6e..fec093aac 100644 --- a/app/helpers/requests_helper.rb +++ b/app/helpers/requests_helper.rb @@ -32,7 +32,6 @@ module RequestsHelper def relationship_flow(identifier) action = :none person = nil - puts identifier person = Person.by_webfinger identifier if person action = (person == current_user.person ? :none : :friend) diff --git a/app/models/user.rb b/app/models/user.rb index 86b818bb0..d129db2ce 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -97,8 +97,6 @@ class User ######## Posting ######## def post(class_name, options = {}) - - puts options.inspect if class_name == :photo raise ArgumentError.new("No album_id given") unless options[:album_id] aspect_ids = aspects_with_post( options[:album_id] ) @@ -225,11 +223,7 @@ class User ###Helpers############ def self.instantiate!( opts = {} ) - hostname = opts[:url].gsub(/(https?:|www\.)\/\//, '') - hostname.chop! if hostname[-1, 1] == '/' - - opts[:person][:diaspora_handle] = "#{opts[:username]}@#{hostname}" - puts opts[:person][:diaspora_handle] + opts[:person][:diaspora_handle] = "#{opts[:username]}@#{terse_url}" opts[:person][:serialized_key] = generate_key User.create(opts) end @@ -240,7 +234,7 @@ class User end def terse_url - terse = self.url.gsub(/(https?:|www\.)\/\//, '') + terse = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '') terse = terse.chop! if terse[-1, 1] == '/' terse end diff --git a/config/app_config.yml b/config/app_config.yml index b4fd6f0ab..5ee07c405 100644 --- a/config/app_config.yml +++ b/config/app_config.yml @@ -3,8 +3,8 @@ # the COPYRIGHT file. - -development: +default: + pod_url: "http://example.org/" debug: false socket_debug : false socket_host: 0.0.0.0 @@ -13,21 +13,11 @@ development: pubsub_server: 'https://pubsubhubbub.appspot.com/' mongo_host: 'localhost' mongo_post: 27017 + +development: test: - debug: false - socket_debug : false - socket_host: 0.0.0.0 + pod_url: "http://example.org/" socket_port: 8081 - pubsub_server: 'https://pubsubhubbub.appspot.com/' - mongo_host: 'localhost' - mongo_post: 27017 production: - debug: false - socket_debug : false - socket_host: 0.0.0.0 - socket_port: 8080 - pubsub_server: 'https://pubsubhubbub.appspot.com/' - mongo_host: 'localhost' - mongo_post: 27017 diff --git a/config/initializers/_load_app_config.rb b/config/initializers/_load_app_config.rb index 1a5094d9b..ac14c97d8 100644 --- a/config/initializers/_load_app_config.rb +++ b/config/initializers/_load_app_config.rb @@ -2,6 +2,12 @@ # licensed under the Affero General Public License version 3. See # the COPYRIGHT file. - raw_config = File.read("#{Rails.root}/config/app_config.yml") -APP_CONFIG = YAML.load(raw_config)[Rails.env].symbolize_keys +all_envs = YAML.load(raw_config) +if all_envs[Rails.env] + APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env]).symbolize_keys +else + APP_CONFIG = all_envs['default'].symbolize_keys +end + +puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" if APP_CONFIG[:pod_url] == "http://example.org/" && Rails.env != :test diff --git a/spec/factories.rb b/spec/factories.rb index c1dfcd50a..21a7ad110 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -39,7 +39,10 @@ Factory.define :user do |u| u.sequence(:email) {|n| "bob#{n}@pivotallabs.com"} u.password "bluepin7" u.password_confirmation "bluepin7" - u.person { |a| Factory.create(:person_with_user, :owner_id => a._id)} + u.person { |a| Factory.create(:person_with_user, + :owner_id => a._id, + :diaspora_handle => "#{a.username}@#{APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '').chop!}") + } end Factory.define :status_message do |m| diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 4f236b733..3275d9245 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -15,6 +15,20 @@ describe Person do @aspect2 = @user2.aspect(:name => "Abscence of Babes") end + describe '#diaspora_handle' do + context 'local people' do + it 'uses the pod config url to set the diaspora_handle' do + @user.person.diaspora_handle.should == @user.username + "@example.org" + end + end + + context 'remote people' do + it 'stores the diaspora_handle in the database' do + @person.diaspora_handle.include?(@user.terse_url).should be false + end + end + end + it 'should not allow two people with the same diaspora_handle' do person_two = Factory.build(:person, :url => @person.diaspora_handle) person_two.valid?.should == false @@ -148,13 +162,11 @@ describe Person do end it 'should search by diaspora_handle exactly' do - stub_success("tom@tom.joindiaspora.com") Person.by_webfinger(@friend_one.diaspora_handle).should == @friend_one end it 'should create a stub for a remote user' do - stub_success("tom@tom.joindiaspora.com") tom = Person.by_webfinger('tom@tom.joindiaspora.com') tom.real_name.include?("Hamiltom").should be true diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 223881671..63639bc73 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -7,11 +7,17 @@ require File.dirname(__FILE__) + '/../spec_helper' describe User do - before do - @user = Factory.create(:user) - @aspect = @user.aspect(:name => 'heroes') - end - + before do + @user = Factory.create(:user) + @aspect = @user.aspect(:name => 'heroes') + end + + describe '#diaspora_handle' do + it 'uses the pod config url to set the diaspora_handle' do + @user.diaspora_handle.should == @user.username + "@example.org" + end + end + it 'should create with pivotal or allowed emails' do user1 = Factory.create(:user, :email => "kimfuh@yahoo.com") user2 = Factory.create(:user, :email => "awesome@sofaer.net") @@ -49,12 +55,12 @@ describe User do friend_users(@user, Aspect.find_by_id(@aspect.id), user2, Aspect.find_by_id(aspect2.id)) @aspect.reload - + @user.aspects.include?(@aspect).should == true proc{@user.drop_aspect(@aspect)}.should raise_error /Aspect not empty/ - @user.reload + @user.reload @user.aspects.include?(@aspect).should == true end end From d26e7850ac72fd02d152bf6775f7592aa48bd468 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 15:52:26 -0700 Subject: [PATCH 09/38] RS, IZ; removed url from user and views --- app/models/user.rb | 3 +-- app/views/devise/sessions/new.html.haml | 2 +- app/views/registrations/new.html.haml | 3 --- app/views/users/edit.html.haml | 4 ++-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index d129db2ce..4e9e968ca 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -25,8 +25,6 @@ class User key :visible_post_ids, Array key :visible_person_ids, Array - key :url, String - one :person, :class_name => 'Person', :foreign_key => :owner_id many :friends, :in => :friend_ids, :class_name => 'Person' @@ -224,6 +222,7 @@ class User ###Helpers############ def self.instantiate!( opts = {} ) opts[:person][:diaspora_handle] = "#{opts[:username]}@#{terse_url}" + opts[:person][:url] = APP_CONFIG[:pod_url] opts[:person][:serialized_key] = generate_key User.create(opts) end diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 7ce75f5f3..15880df0b 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -10,7 +10,7 @@ = f.label :username = f.text_field :username %p.user_network - ="@#{request.host}" + ="@#{APP_CONFIG[:pod_url]}" %p = f.label :password diff --git a/app/views/registrations/new.html.haml b/app/views/registrations/new.html.haml index eefa94519..3e1dc0830 100644 --- a/app/views/registrations/new.html.haml +++ b/app/views/registrations/new.html.haml @@ -2,7 +2,6 @@ = form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| - = f.hidden_field :url, :value => request.host %p = f.label :username = f.text_field :username @@ -17,8 +16,6 @@ = f.password_field :password_confirmation = f.fields_for :person do |p| - = p.hidden_field :url, :value => request.host - = p.fields_for :profile do |pr| %p = pr.label :first_name diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index fd94b2a42..880d25ef4 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -17,11 +17,11 @@ %h3 Picture %div#image_picker - = p.hidden_field :image_url, :value => (@profile.image_url.sub(@user.url,'/') if @profile.image_url), :id => 'image_url_field' + = p.hidden_field :image_url, :value => (@profile.image_url.sub(APP_CONFIG[:pod_url],'/') if @profile.image_url), :id => 'image_url_field' - unless @photos.nil? || @photos.empty? - for photo in @photos - - if @profile.image_url && (photo.url(:thumb_medium) == @profile.image_url.sub(@user.url,'/')) + - if @profile.image_url && (photo.url(:thumb_medium) == @profile.image_url.sub(APP_CONFIG[:pod_url],'/')) %div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'} = check_box_tag 'checked_photo', true, true = link_to image_tag(photo.url(:thumb_medium)), "#" From d3b0b9c07e4bf61e1bb0964de47713ffafd3d20c Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 16:13:21 -0700 Subject: [PATCH 10/38] Make db seed set app_config[:pod_url] --- db/seeds/backer.rb | 23 ++++++++++++++++++----- db/seeds/dev.rb | 12 ++---------- db/seeds/tom.rb | 27 +++++++++++++++++---------- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index b32b62377..d39ce490c 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -15,25 +15,38 @@ require 'config/environment' def create + + config = YAML.load_file(File.dirname(__FILE__) + '/../../config/deploy_config.yml') backer_info = config['servers']['backer'] backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i - # Create seed user + + #set pod url username = backer_info[backer_number]['username'].gsub(/ /,'').downcase + set_app_config username + require 'config/initializers/_load_app_config.rb' + + # Create seed user user = User.instantiate!(:email => "#{username}@#{username}.joindiaspora.com", :username => username, :password => "#{username+backer_info[backer_number]['pin'].to_s}", :password_confirmation => "#{username+backer_info[backer_number]['pin'].to_s}", - :url=> "http://#{username}.joindiaspora.com/", :person => Person.new( - :diaspora_handle => "#{username}@#{username}.joindiaspora.com", :profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'], - :image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg"), - :url=> "http://#{username}.joindiaspora.com/") + :image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg") ) user.person.save! user.aspect(:name => "Presidents") end +def set_app_config username + current_config = YAML.load(Rails.root.join('config', 'app_config.yml')) + current_config[Rails.env] ||= {} + current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com" + current_config[:default][:pod_url] = "#{username}.joindiaspora.com" + file = File.new(Rails.root.join('config','app_config.yml'),'w') + file.write(current_config.to_yaml) + file.close +end diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index 12c728ddf..ef9dddecf 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -6,31 +6,23 @@ require 'config/environment' -host = "localhost:3000" -url = "http://#{host}/" username = "tom" # Create seed user user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", :password => "evankorth", :password_confirmation => "evankorth", - :url=> "http://#{username}.joindiaspora.com/" :person => Person.new( - :diaspora_handle => "tom@tom.joindiaspora.com", - :url => url, :profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" )) ) user.person.save! user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com", :username => "korth", - :url=> "http://#{username}.joindiaspora.com/" :password => "evankorth", :password_confirmation => "evankorth", - :person => Person.new( :diaspora_handle => "korth@tom.joindiaspora.com", - :url => url, - :profile => Profile.new( :first_name => "Evan", - :last_name => "Korth"))) + :person => Person.new( + :profile => Profile.new( :first_name => "Evan", :last_name => "Korth"))) user2.person.save! diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 61b2ad44f..b81d10827 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -6,17 +6,26 @@ require 'config/environment' -remote_url = "http://tom.joindiaspora.com/" -#remote_url = "http://localhost:3000/" +def set_app_config username + current_config = YAML.load(Rails.root.join('config', 'app_config.yml')) + current_config[Rails.env] ||= {} + current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com" + current_config[:default][:pod_url] = "#{username}.joindiaspora.com" + file = File.new(Rails.root.join('config','app_config.yml'),'w') + file.write(current_config.to_yaml) + file.close +end + +set_app_config "tom" +require 'config/initializers/_load_app_config.rb' + + # Create seed user user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", :password => "evankorth", :password_confirmation => "evankorth", - :url => remote_url, :person => { - :diaspora_handle => "tom@tom.joindiaspora.com", - :url => remote_url, :profile => { :first_name => "Alexander", :last_name => "Hamiltom", :image_url => "http://tom.joindiaspora.com/images/user/tom.jpg"}} ) @@ -26,11 +35,7 @@ user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com", :password => "evankorth", :password_confirmation => "evankorth", :username => "korth", - :url => remote_url, - :person => { :diaspora_handle => "korth@tom.joindiaspora.com", - :url => remote_url, - :profile => { :first_name => "Evan", - :last_name => "Korth", + :person => {:profile => { :first_name => "Evan", :last_name => "Korth", :image_url => "http://tom.joindiaspora.com/images/user/korth.jpg"}}) user2.person.save! @@ -41,3 +46,5 @@ request = user.send_friend_request_to(user2, aspect) reversed_request = user2.accept_friend_request( request.id, user2.aspect(:name => "presidents").id ) user.receive reversed_request.to_diaspora_xml user.aspect(:name => "Presidents") + + From dc0a08172d8daee7e487e51c62580258092deb39 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 16:23:42 -0700 Subject: [PATCH 11/38] syntax error in seed script --- db/seeds/backer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index d39ce490c..277615323 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -35,7 +35,7 @@ def create :person => Person.new( :profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'], :image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg") - ) + )) user.person.save! user.aspect(:name => "Presidents") From c8e52526d9c8b4af5b29a36056e70c6ce990563d Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 16:31:27 -0700 Subject: [PATCH 12/38] another silly mistake, need to symbolize keys in deploy scripts --- db/seeds/backer.rb | 2 +- db/seeds/tom.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 277615323..9ebe1248f 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -42,7 +42,7 @@ def create end def set_app_config username - current_config = YAML.load(Rails.root.join('config', 'app_config.yml')) + current_config = YAML.load(Rails.root.join('config', 'app_config.yml')).symbolize_keys current_config[Rails.env] ||= {} current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com" current_config[:default][:pod_url] = "#{username}.joindiaspora.com" diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index b81d10827..c35058bf7 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -7,7 +7,7 @@ require 'config/environment' def set_app_config username - current_config = YAML.load(Rails.root.join('config', 'app_config.yml')) + current_config = YAML.load(Rails.root.join('config', 'app_config.yml')).symbolize_keys current_config[Rails.env] ||= {} current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com" current_config[:default][:pod_url] = "#{username}.joindiaspora.com" From 107c05ef6f89c99d41fa65a0703b7d63cdc96618 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 21 Sep 2010 16:35:18 -0700 Subject: [PATCH 13/38] DG MS; validate_aspect_permissions broken out of post method --- app/models/user.rb | 28 +++++++++++++++++++++++----- spec/models/user/posting_spec.rb | 25 +++++++++++++++++++++---- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 4e2e642e3..91d84340d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -106,11 +106,7 @@ class User aspect_ids = options.delete(:to) end - aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId - - raise ArgumentError.new("You must post to someone.") if aspect_ids.nil? || aspect_ids.empty? - aspect_ids.each{ |aspect_id| - raise ArgumentError.new("Cannot post to an aspect you do not own.") unless aspect_id == "all" || self.aspects.find(aspect_id) } + aspect_ids = validate_aspect_permissions(aspect_ids) post = build_post(class_name, options) @@ -120,6 +116,28 @@ class User post end + def repost( post, options = {} ) + aspect_ids = validate_aspect_permissions(options[:to]) + push_to_aspects(post, aspect_ids) + post + end + + def validate_aspect_permissions(aspect_ids) + aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId + + if aspect_ids.nil? || aspect_ids.empty? + raise ArgumentError.new("You must post to someone.") + end + + aspect_ids.each do |aspect_id| + unless aspect_id == "all" || self.aspects.find(aspect_id) + raise ArgumentError.new("Cannot post to an aspect you do not own.") + end + end + + aspect_ids + end + def build_post( class_name, options = {}) options[:person] = self.person model_class = class_name.to_s.camelize.constantize diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 1f24f3fed..da52ed849 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -26,15 +26,22 @@ describe User do end context 'posting' do - describe '#post' do + + describe '#validate_aspect_permissions' do it 'should not be able to post without a aspect' do - proc {user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/ + proc { + user.validate_aspect_permissions([]) + }.should raise_error /You must post to someone/ end it 'should not be able to post to someone elses aspect' do - proc {user.post(:status_message, :message => "heyheyhey", :to => aspect2.id)}.should raise_error /Cannot post to an aspect you do not own./ + proc { + user.validate_aspect_permissions(aspect2.id) + }.should raise_error /Cannot post to an aspect you do not own./ end - + end + + describe '#post' do it 'should put the post in the aspect post array' do post = user.post(:status_message, :message => "hey", :to => aspect.id) aspect.reload @@ -47,6 +54,16 @@ describe User do aspect.posts.should include album end end + + describe '#repost' do + let!(:status_message) { user.post(:status_message, :message => "hello", :to => aspect.id) } + + it 'should make the post visible in another aspect' do + user.repost( status_message, :to => aspect1.id ) + aspect1.reload + aspect1.posts.count.should be 1 + end + end end context 'dispatching' do From 020ff603bdbbea476483a70c0aad764de646893a Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 16:59:06 -0700 Subject: [PATCH 14/38] terse_url in user, db seeds are fixed, config/app_config.yml is now in gitignore, copy over config/app_config_example.yml. --- .gitignore | 1 + app/models/user.rb | 3 +++ config/app_config.yml | 34 ++++++++++++++-------------------- config/app_config_example.yml | 23 +++++++++++++++++++++++ db/seeds/backer.rb | 8 ++++---- db/seeds/dev.rb | 12 ++++++++++++ db/seeds/tom.rb | 8 ++++---- 7 files changed, 61 insertions(+), 28 deletions(-) create mode 100644 config/app_config_example.yml diff --git a/.gitignore b/.gitignore index 89b33da60..0025a86f5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ gpg/diaspora-production/*.gpg gpg/*/random_seed public/uploads/* .rvmrc +config/app_config.yml diff --git a/app/models/user.rb b/app/models/user.rb index 4e9e968ca..a98217b4e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -221,6 +221,9 @@ class User ###Helpers############ def self.instantiate!( opts = {} ) + terse_url = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '') + terse_url.chop! if terse_url[-1, 1] == '/' + opts[:person][:diaspora_handle] = "#{opts[:username]}@#{terse_url}" opts[:person][:url] = APP_CONFIG[:pod_url] opts[:person][:serialized_key] = generate_key diff --git a/config/app_config.yml b/config/app_config.yml index 5ee07c405..bd306725e 100644 --- a/config/app_config.yml +++ b/config/app_config.yml @@ -1,23 +1,17 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3. See -# the COPYRIGHT file. - - -default: - pod_url: "http://example.org/" - debug: false - socket_debug : false +--- +default: socket_host: 0.0.0.0 - socket_port: 8080 - socket_collection_name: 'websocket' - pubsub_server: 'https://pubsubhubbub.appspot.com/' - mongo_host: 'localhost' + socket_debug: false + pod_url: tom.joindiaspora.com mongo_post: 27017 - -development: - -test: - pod_url: "http://example.org/" + socket_collection_name: websocket + socket_port: 8080 + pubsub_server: https://pubsubhubbub.appspot.com/ + mongo_host: localhost + debug: false +production: +development: + pod_url: tom.joindiaspora.com +test: + pod_url: http://example.org/ socket_port: 8081 - -production: diff --git a/config/app_config_example.yml b/config/app_config_example.yml new file mode 100644 index 000000000..5ee07c405 --- /dev/null +++ b/config/app_config_example.yml @@ -0,0 +1,23 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3. See +# the COPYRIGHT file. + + +default: + pod_url: "http://example.org/" + debug: false + socket_debug : false + socket_host: 0.0.0.0 + socket_port: 8080 + socket_collection_name: 'websocket' + pubsub_server: 'https://pubsubhubbub.appspot.com/' + mongo_host: 'localhost' + mongo_post: 27017 + +development: + +test: + pod_url: "http://example.org/" + socket_port: 8081 + +production: diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 9ebe1248f..700839f62 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -42,10 +42,10 @@ def create end def set_app_config username - current_config = YAML.load(Rails.root.join('config', 'app_config.yml')).symbolize_keys - current_config[Rails.env] ||= {} - current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com" - current_config[:default][:pod_url] = "#{username}.joindiaspora.com" + current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml'))) + current_config[Rails.env.to_s] ||= {} + current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" + current_config['default']['pod_url'] = "#{username}.joindiaspora.com" file = File.new(Rails.root.join('config','app_config.yml'),'w') file.write(current_config.to_yaml) file.close diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index ef9dddecf..4ffa947e7 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -6,7 +6,19 @@ require 'config/environment' +def set_app_config username + current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml'))) + current_config[Rails.env.to_s] ||= {} + current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" + current_config['default']['pod_url'] = "#{username}.joindiaspora.com" + file = File.new(Rails.root.join('config','app_config.yml'),'w') + file.write(current_config.to_yaml) + file.close +end + username = "tom" +set_app_config username + # Create seed user user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index c35058bf7..cf6a1ed0c 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -7,10 +7,10 @@ require 'config/environment' def set_app_config username - current_config = YAML.load(Rails.root.join('config', 'app_config.yml')).symbolize_keys - current_config[Rails.env] ||= {} - current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com" - current_config[:default][:pod_url] = "#{username}.joindiaspora.com" + current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml'))) + current_config[Rails.env.to_s] ||= {} + current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" + current_config['default']['pod_url'] = "#{username}.joindiaspora.com" file = File.new(Rails.root.join('config','app_config.yml'),'w') file.write(current_config.to_yaml) file.close From e3d52bb467bd8f45d380a8715c80799065ccb036 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 17:39:44 -0700 Subject: [PATCH 15/38] putting the config file in a shared directory for in the deploy scripts --- config/deploy.rb | 7 ++++++- db/seeds/backer.rb | 2 +- db/seeds/tom.rb | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index c84d25556..478736392 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -53,6 +53,11 @@ namespace :deploy do run "ln -s -f #{shared_path}/bundle #{current_path}/vendor/bundle" end + task :symlink_config do + run "touch #{shared_path}/app_config.yml" + run "ln -s -f #{shared_path}/app_config.yml #{current_path}/config/app_config.yml" + end + task :start do start_mongo start_thin @@ -150,4 +155,4 @@ namespace :db do end -after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle" +after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config" diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 700839f62..1730ee202 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -46,7 +46,7 @@ def set_app_config username current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "#{username}.joindiaspora.com" - file = File.new(Rails.root.join('config','app_config.yml'),'w') + file = File.new(Rails.root.join('..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close end diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index cf6a1ed0c..d8152a33b 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -11,7 +11,7 @@ def set_app_config username current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "#{username}.joindiaspora.com" - file = File.new(Rails.root.join('config','app_config.yml'),'w') + file = File.new(Rails.root.join('..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close end From 74a92a26374cebd9adbf236c47f148d85dd307ce Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 17:40:43 -0700 Subject: [PATCH 16/38] tiny typo --- config/deploy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index 478736392..2f8065134 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -155,4 +155,4 @@ namespace :db do end -after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config" +after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config' From 4a3bfea1ba1f13d8f03fe1c478cd50d6ba433b66 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 21 Sep 2010 17:43:46 -0700 Subject: [PATCH 17/38] DG MS; cleaned spec --- lib/diaspora/user/querying.rb | 5 - spec/models/user/visible_posts_spec.rb | 131 ++++++++++++------------- 2 files changed, 64 insertions(+), 72 deletions(-) diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index 00ae27735..bd4174c76 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -35,11 +35,6 @@ module Diaspora aspects.detect{|x| x.id == id } end - def album_by_id( id ) - id = id.to_id - albums.detect{|x| x.id == id } - end - def aspects_with_post( id ) self.aspects.find_all_by_post_ids( id.to_id ) end diff --git a/spec/models/user/visible_posts_spec.rb b/spec/models/user/visible_posts_spec.rb index 5c44a2ce8..bcab473bc 100644 --- a/spec/models/user/visible_posts_spec.rb +++ b/spec/models/user/visible_posts_spec.rb @@ -7,83 +7,80 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe User do - before do - @user = Factory.create(:user) - @aspect = @user.aspect(:name => 'heroes') - @aspect2 = @user.aspect(:name => 'losers') + let(:user) { Factory(:user) } - @user2 = Factory.create :user - @user2_aspect = @user2.aspect(:name => 'dudes') + let(:user2) { Factory(:user) } + let(:user3) { Factory(:user) } + let(:user4) { Factory(:user) } - friend_users(@user, @aspect, @user2, @user2_aspect) + let!(:aspect) { user.aspect(:name => 'heroes') } + let!(:aspect2) { user.aspect(:name => 'losers') } - @user3 = Factory.create :user - @user3_aspect = @user3.aspect(:name => 'dudes') - friend_users(@user, @aspect2, @user3, @user3_aspect) + let!(:user2_aspect) { user2.aspect(:name => 'dudes') } + let!(:user3_aspect) { user3.aspect(:name => 'dudes') } + let!(:user4_aspect) { user4.aspect(:name => 'dudes') } - @user4 = Factory.create :user - @user4_aspect = @user4.aspect(:name => 'dudes') - friend_users(@user, @aspect2, @user4, @user4_aspect) - end + let(:status_message1) { user2.post :status_message, :message => "hi", :to => user2_aspect.id } + let(:status_message2) { user3.post :status_message, :message => "heyyyy", :to => user3_aspect.id } + let(:status_message3) { user4.post :status_message, :message => "yooo", :to => user4_aspect.id } - it 'should generate a valid stream for a aspect of people' do - status_message1 = @user2.post :status_message, :message => "hi", :to => @user2_aspect.id - status_message2 = @user3.post :status_message, :message => "heyyyy", :to => @user3_aspect.id - status_message3 = @user4.post :status_message, :message => "yooo", :to => @user4_aspect.id + before do + friend_users(user, aspect, user2, user2_aspect) + friend_users(user, aspect2, user3, user3_aspect) + friend_users(user, aspect2, user4, user4_aspect) + end - @user.receive status_message1.to_diaspora_xml - @user.receive status_message2.to_diaspora_xml - @user.receive status_message3.to_diaspora_xml - @user.reload + it 'should generate a valid stream for a aspect of people' do + (1..3).each{ |n| + eval("user.receive status_message#{n}.to_diaspora_xml") + } - @user.visible_posts(:by_members_of => @aspect).include?(status_message1).should be true - @user.visible_posts(:by_members_of => @aspect).include?(status_message2).should be false - @user.visible_posts(:by_members_of => @aspect).include?(status_message3).should be false + user.visible_posts(:by_members_of => aspect).should include status_message1 + user.visible_posts(:by_members_of => aspect).should_not include status_message2 + user.visible_posts(:by_members_of => aspect).should_not include status_message3 - @user.visible_posts(:by_members_of => @aspect2).include?(status_message1).should be false - @user.visible_posts(:by_members_of => @aspect2).include?(status_message2).should be true - @user.visible_posts(:by_members_of => @aspect2).include?(status_message3).should be true - end + user.visible_posts(:by_members_of => aspect2).should_not include status_message1 + user.visible_posts(:by_members_of => aspect2).should include status_message2 + user.visible_posts(:by_members_of => aspect2).should include status_message3 + end - describe 'querying' do - - it 'should find a visible post by id' do - status_message1 = @user.post :status_message, :message => "hi", :to => @aspect.id - status_message2 = @user2.post :status_message, :message => "heyyyy", :to => @user2_aspect.id - status_message3 = @user3.post :status_message, :message => "yooo", :to => @user3_aspect.id - - @user.find_visible_post_by_id(status_message1.id).should == status_message1 - @user2.find_visible_post_by_id(status_message1.id).should == nil - end - - end - - describe 'albums' do - before do - @album = @user.post :album, :name => "Georges", :to => @aspect.id - @aspect.reload - @aspect2.reload - @user.reload - - @album2 = @user.post :album, :name => "Borges", :to => @aspect.id - @aspect.reload - @aspect2.reload - @user.reload - - @user.post :album, :name => "Luises", :to => @aspect2.id - @aspect.reload - @aspect2.reload - @user.reload - end - - it 'should find all albums if passed :all' do - @user.albums_by_aspect(:all).size.should == 3 - end - - it 'should return the right number of albums' do - @user.albums_by_aspect(@aspect).size.should == 2 - @user.albums_by_aspect(@aspect2).size.should == 1 + context 'querying' do + describe '#find_visible_post_by_id' do + it 'should query' do + user2.find_visible_post_by_id(status_message1.id).should == status_message1 + user.find_visible_post_by_id(status_message1.id).should == nil end end + end + + context 'albums' do + + + before do + @album = user.post :album, :name => "Georges", :to => aspect.id + aspect.reload + aspect2.reload + user.reload + + @album2 = user.post :album, :name => "Borges", :to => aspect.id + aspect.reload + aspect2.reload + user.reload + + user.post :album, :name => "Luises", :to => aspect2.id + aspect.reload + aspect2.reload + user.reload + end + + it 'should find all albums if passed :all' do + user.albums_by_aspect(:all).should have(3).albums + end + + it 'should return the right number of albums' do + user.albums_by_aspect(aspect).should have(2).albums + user.albums_by_aspect(aspect2).should have(1).album + end + end end From b01928af4bdfb43201ec8abda59b4f4eb92869b7 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 17:52:11 -0700 Subject: [PATCH 18/38] RS IZ if yaml fails to load (empty config) file load the example --- config/initializers/_load_app_config.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/initializers/_load_app_config.rb b/config/initializers/_load_app_config.rb index ac14c97d8..034a62f24 100644 --- a/config/initializers/_load_app_config.rb +++ b/config/initializers/_load_app_config.rb @@ -4,6 +4,12 @@ raw_config = File.read("#{Rails.root}/config/app_config.yml") all_envs = YAML.load(raw_config) + +unless all_envs + raw_config = File.read("#{Rails.root}/config/app_config_example.yml") + all_envs = YAML.load(raw_config) +end + if all_envs[Rails.env] APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env]).symbolize_keys else From 96aaf3093cb99d383fbdbfb6ebfa778207f20ee7 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 18:04:36 -0700 Subject: [PATCH 19/38] Make load_app_config more robust, point to the right folder in db seed --- config/initializers/_load_app_config.rb | 20 ++++++++++++-------- db/seeds/backer.rb | 2 +- db/seeds/tom.rb | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/config/initializers/_load_app_config.rb b/config/initializers/_load_app_config.rb index 034a62f24..33f7b183b 100644 --- a/config/initializers/_load_app_config.rb +++ b/config/initializers/_load_app_config.rb @@ -2,16 +2,20 @@ # licensed under the Affero General Public License version 3. See # the COPYRIGHT file. -raw_config = File.read("#{Rails.root}/config/app_config.yml") -all_envs = YAML.load(raw_config) - -unless all_envs - raw_config = File.read("#{Rails.root}/config/app_config_example.yml") - all_envs = YAML.load(raw_config) +def load_config_yaml filename + YAML.load(File.read(filename)) end -if all_envs[Rails.env] - APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env]).symbolize_keys +if File.exist? "#{Rails.root}/config/app_config.yml" + all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml" + all_envs = load_config_yaml "#{Rails.root}/config/app_config_example.yml" unless all_envs +else + puts "WARNING: No config/app_config.yml found! Look at config/app_config_example.yml for help." + all_envs = load_config_yaml "#{Rails.root}/config/app_config_example.yml" +end + +if all_envs[Rails.env.to_s] + APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env.to_s]).symbolize_keys else APP_CONFIG = all_envs['default'].symbolize_keys end diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 1730ee202..8fa72f23d 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -46,7 +46,7 @@ def set_app_config username current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "#{username}.joindiaspora.com" - file = File.new(Rails.root.join('..','shared','app_config.yml'),'w') + file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close end diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index d8152a33b..50d41eb91 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -11,7 +11,7 @@ def set_app_config username current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "#{username}.joindiaspora.com" - file = File.new(Rails.root.join('..','shared','app_config.yml'),'w') + file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close end From d60dc03d35e6b918b069d1447f5b1dcd8ec42740 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 18:10:26 -0700 Subject: [PATCH 20/38] removed app_config from repo --- config/app_config.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 config/app_config.yml diff --git a/config/app_config.yml b/config/app_config.yml deleted file mode 100644 index bd306725e..000000000 --- a/config/app_config.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -default: - socket_host: 0.0.0.0 - socket_debug: false - pod_url: tom.joindiaspora.com - mongo_post: 27017 - socket_collection_name: websocket - socket_port: 8080 - pubsub_server: https://pubsubhubbub.appspot.com/ - mongo_host: localhost - debug: false -production: -development: - pod_url: tom.joindiaspora.com -test: - pod_url: http://example.org/ - socket_port: 8081 From df5b7d6d848bbcad04ecb9b58fb23a8c4d8be38e Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 21 Sep 2010 18:14:46 -0700 Subject: [PATCH 21/38] DG MS; new function in post --- app/models/user.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 928a02173..2277f1583 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -105,12 +105,15 @@ class User aspect_ids = validate_aspect_permissions(aspect_ids) - post = build_post(class_name, options) + intitial_post(class_name, aspect_ids, options) + end + + def intitial_post(class_name, aspect_ids, options = {}) + post = build_post(class_name, options) post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid) push_to_aspects(post, aspect_ids) - - post + post end def repost( post, options = {} ) From 6d6ca3d8bca9707b302e051b3bd936e29b524cc2 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 20:01:56 -0700 Subject: [PATCH 22/38] added terse_pod_url to the APP_CONFIG hash --- app/models/user.rb | 7 ++----- config/initializers/_load_app_config.rb | 5 ++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 928a02173..c68cbb6dc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -239,11 +239,8 @@ class User ###Helpers############ def self.instantiate!( opts = {} ) - terse_url = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '') - terse_url.chop! if terse_url[-1, 1] == '/' - - opts[:person][:diaspora_handle] = "#{opts[:username]}@#{terse_url}" - opts[:person][:url] = APP_CONFIG[:pod_url] + opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}" + pts[:person][:url] = APP_CONFIG[:pod_url] opts[:person][:serialized_key] = generate_key User.create(opts) end diff --git a/config/initializers/_load_app_config.rb b/config/initializers/_load_app_config.rb index 33f7b183b..521f9f0a0 100644 --- a/config/initializers/_load_app_config.rb +++ b/config/initializers/_load_app_config.rb @@ -20,4 +20,7 @@ else APP_CONFIG = all_envs['default'].symbolize_keys end -puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" if APP_CONFIG[:pod_url] == "http://example.org/" && Rails.env != :test +APP_CONFIG[:terse_pod_url] = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '') +APP_CONFIG[:terse_pod_url].chop! if APP_CONFIG[:terse_pod_url][-1, 1] == '/' + +puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" if APP_CONFIG[:terse_pod_url] == "example.org" && Rails.env != :test From 4c0dc584583d862172e460e036830407ab40fb5e Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 21 Sep 2010 20:02:37 -0700 Subject: [PATCH 23/38] spec cleanup --- spec/models/user_spec.rb | 53 +++++++++++++++------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2249ae0b1..1608bbe58 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -7,54 +7,41 @@ require File.dirname(__FILE__) + '/../spec_helper' describe User do - before do - @user = Factory.create(:user) - @aspect = @user.aspect(:name => 'heroes') - end + let(:user) { Factory(:user) } + let(:aspect) { user.aspect(:name => 'heroes') } describe '#diaspora_handle' do it 'uses the pod config url to set the diaspora_handle' do - @user.diaspora_handle.should == @user.username + "@example.org" + user.diaspora_handle.should == user.username + "@example.org" end end - - - describe 'profiles' do + context 'profiles' do it 'should be able to update their profile and send it to their friends' do - Factory.create(:person) + updated_profile = { :profile => { + :first_name => 'bob', + :last_name => 'billytown', + :image_url => "http://clown.com"} } - updated_profile = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clown.com"}} - - @user.update_profile(updated_profile).should == true - @user.profile.image_url.should == "http://clown.com" + user.update_profile(updated_profile).should be true + user.profile.image_url.should == "http://clown.com" end end - describe 'aspects' do - it 'should delete an empty aspect' do - @user.aspects.include?(@aspect).should == true - @user.drop_aspect(@aspect) - @user.reload + context 'aspects' do + let(:user2) { Factory(:user) } + let(:aspect2) { user2.aspect(:name => 'stuff') } - @user.aspects.include?(@aspect).should == false + it 'should delete an empty aspect' do + user.drop_aspect(aspect) + user.aspects.include?(aspect).should == false end it 'should not delete an aspect with friends' do - user2 = Factory.create(:user) - aspect2 = user2.aspect(:name => 'stuff') - user2.reload - aspect2.reload - - friend_users(@user, Aspect.find_by_id(@aspect.id), user2, Aspect.find_by_id(aspect2.id)) - @aspect.reload - - @user.aspects.include?(@aspect).should == true - - proc{@user.drop_aspect(@aspect)}.should raise_error /Aspect not empty/ - - @user.reload - @user.aspects.include?(@aspect).should == true + friend_users(user, Aspect.find_by_id(aspect.id), user2, Aspect.find_by_id(aspect2.id)) + aspect.reload + proc{user.drop_aspect(aspect)}.should raise_error /Aspect not empty/ + user.aspects.include?(aspect).should == true end end From 6bd22034b7978b090cdf9bbc9cf3d4824f2f189a Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 21:45:29 -0700 Subject: [PATCH 24/38] typo in user --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 99230b8f6..06652a494 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -243,7 +243,7 @@ class User ###Helpers############ def self.instantiate!( opts = {} ) opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}" - pts[:person][:url] = APP_CONFIG[:pod_url] + opts[:person][:url] = APP_CONFIG[:pod_url] opts[:person][:serialized_key] = generate_key User.create(opts) end From c87ad060abc0ae4919fa41761f0ee7ed590a1413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Di=C3=B3genes?= Date: Wed, 22 Sep 2010 20:34:43 +0800 Subject: [PATCH 25/38] Add translation (from English locale) to Brazilian Portuguese --- config/locales/pt-BR.yml | 135 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 134 insertions(+), 1 deletion(-) diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 67c077090..10425864b 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -7,4 +7,137 @@ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. pt-BR: - hello: "Olá Mundo" + hello: "Olá mundo" + layouts: + application: + edit_profile: "editar perfil" + logout: "sair" + shared: + aspect_nav: + all_aspects: "Todos Aspectos" + manage: "Gerenciar" + manage_your_aspects: "Gerencie seus Aspectos" + sub_header: + all_aspects: "Todos Aspectos" + manage_aspects: "Gerenciar Aspectos" + publisher: + share: "Compartilhar" + aspect_friends: + add_friends: "adicionar amigos" + albums: + album: + you: "você" + new_album: + create: "criar" + add_a_new_album: "Adicionar novo álbum" + show: + edit_album: "Editar Álbum" + albums: "álbuns" + updated: "atualizado" + by: "por" + edit: + editing: "Editando" + updated: "atualizado" + are_you_sure: "Tem certeza?" + delete_album: "Excluir Álbum" + cancel: "Cancelar" + index: + home: "home" + new_album: "Novo Álbum" + create: + success: "Você criou com sucesso um álbum chamado %{name}." + update: + success: "O álbum %{name} foi editado com sucesso." + failure: "Erro ao editar o álbum %{name}." + destroy: + success: "O álbum %{name} foi excluído com sucesso." + aspects: + index: + photos: "photos" + show: + photos: "photos" + manage: + add_a_new_aspect: "Adicionar um novo aspecto" + add_a_new_friend: "Adicionar um novo amigo" + show: "Exibir" + update_aspects: "Atualizar Aspectos" + requests: "Solicitações" + ignore_remove: "Ignorar/Excluir" + new_aspect: + add_a_new_aspect: "Adicionar um novo aspecto" + create: "Criar" + create: + success:"Clique no mais(+) do lado esquerdo para dizer ao Diaspora quem pode ver seu novo aspecto." + users: + edit: + cancel: "Cancelar" + update_profile: "Atualizar Perfil" + home: "Home" + diaspora_username: "USUÁRIO DIASPORA" + info: "Informações" + picture: "Imagem" + editing_profile: "Editando perfil" + albums: "Álbuns" + you_dont_have_any_photos: "Você não possui nenhuma photo! Vá para" + page_to_upload_some: "para fazer o upload de alguma." + comments: + comment: + ago: "atrás" + new_comment: + comment: "Comentário" + photos: + show: + prev: "anterior" + full_size: "tamanho máximo" + next: "próxima" + edit_photo: "Editar Foto" + delete_photo: "Excluir Foto" + are_you_sure: "Tem certeza?" + comments: "comentários" + edit: + editing: "Editando" + are_you_sure: "Tem certeza?" + delete_photo: "Excluir Foto" + photo: + show_comments: "exibir comentários" + posted_a_new_photo_to: "enviada um nova foto para" + new: + new_photo: "Nova Foto" + back_to_list: "Voltar para a Lista" + post_it: "enviar!" + registrations: + new: + sign_up: "Cadastro" + status_messages: + new_status_message: + tell_me_something_good: "diga-me qualquer coisa legal" + oh_yeah: "É isso aí!" + status_message: + show_comments: "exibir comentários" + delete: "Excluir" + are_you_sure: "Tem certeza?" + show: + status_message: "Mensagem de Status" + comments: "comentários" + are_you_sure: "Tem certeza?" + destroy: "Excluir" + view_all: "Exibir Todas" + message: "Mensagem" + owner: "Pertence a" + people: + index: + add_friend: "adicionar amigo(a)" + real_name: "nome real" + diaspora_handle: "diaspora handle" + thats_you: "esse é você!" + friend_request_pending: "pedido de amizade pendente" + you_have_a_friend_request_from_this_person: "você possui um pedido de amizade dessa pessoa" + new: + new_person: "Nova Pessoa" + back_to_list: "Voltar para a Lista" + show: + last_seen: "visto pela última vez a: %{how_long_ago}" + friends_since: "amigos desde: %{how_long_ago}" + save: "salvar" + are_you_sure: "Tem certeza?" + remove_friend: "excluir amigo" From 7049cb3ca49f1f1a2208eaf616120c633272f0c1 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Sep 2010 10:31:40 -0700 Subject: [PATCH 26/38] A less efficient, but simpler way of checking whether the photo is the profile photo --- app/views/users/edit.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 880d25ef4..cb578c590 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -17,11 +17,11 @@ %h3 Picture %div#image_picker - = p.hidden_field :image_url, :value => (@profile.image_url.sub(APP_CONFIG[:pod_url],'/') if @profile.image_url), :id => 'image_url_field' + = p.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field' - unless @photos.nil? || @photos.empty? - for photo in @photos - - if @profile.image_url && (photo.url(:thumb_medium) == @profile.image_url.sub(APP_CONFIG[:pod_url],'/')) + - if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium)) %div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'} = check_box_tag 'checked_photo', true, true = link_to image_tag(photo.url(:thumb_medium)), "#" From 6dd7911c8c3a07d2757c946dfa39241733a984c7 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 10:52:29 -0700 Subject: [PATCH 27/38] DG IZ; update_or_repost --- app/controllers/albums_controller.rb | 2 +- app/controllers/photos_controller.rb | 2 +- app/models/user.rb | 10 ++++++++++ spec/models/user/posting_spec.rb | 23 +++++++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index c6cf7a829..14adcebe1 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -52,7 +52,7 @@ class AlbumsController < ApplicationController data = clean_hash(params[:album]) - if @album.update_attributes data + if current_user.update_or_repost( @album, data ) flash[:notice] = "Album #{@album.name} successfully edited." respond_with @album else diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index afc193413..8d383f53a 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -88,7 +88,7 @@ class PhotosController < ApplicationController data = clean_hash(params) - if @photo.update_attributes data[:photo] + if current_user.update_or_repost( @photo, data[:photo] ) flash[:notice] = "Photo successfully updated." respond_with @photo else diff --git a/app/models/user.rb b/app/models/user.rb index 06652a494..45f947807 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -122,6 +122,16 @@ class User post end + def update_or_repost( post, post_hash = {} ) + if self.owns? post + if post_hash[:aspect_ids] + repost(post, post_hash[:aspect_ids]) if validate_aspect_permissions post_hash[:aspect_ids] + else + post.update_attributes!(post_hash) + end + end + end + def validate_aspect_permissions(aspect_ids) aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index da52ed849..6b939b573 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -64,6 +64,29 @@ describe User do aspect1.posts.count.should be 1 end end + + describe '#update_or_repost' do + let!(:album) { user.post(:album, :name => "Profile Photos", :to => aspect.id) } + + it 'should repost' do + update_hash = { :aspect_ids => aspect1.id } + user.should_receive(:repost).with(album, update_hash[:aspect_ids]).and_return album + user.update_or_repost( album, update_hash ) + end + + it 'should update fields' do + update_hash = { :name => "Other Photos" } + user.update_or_repost( album, update_hash ) + album.name.should == "Other Photos" + end + + it 'should reject posting to an external aspect' do + update_hash = { :aspect_ids => [aspect3.id] } + proc{ + user.update_or_repost( album, update_hash ) + }.should raise_error /Cannot post to an aspect you do not own./ + end + end end context 'dispatching' do From 894197522443eaa5b2989f1e2dbddb5ade9ba630 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 10:59:23 -0700 Subject: [PATCH 28/38] DG IZ; example extension convention for app_config --- config/{app_config_example.yml => app_config.yml.example} | 0 config/initializers/_load_app_config.rb | 6 +++--- db/seeds/backer.rb | 2 +- db/seeds/dev.rb | 2 +- db/seeds/tom.rb | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename config/{app_config_example.yml => app_config.yml.example} (100%) diff --git a/config/app_config_example.yml b/config/app_config.yml.example similarity index 100% rename from config/app_config_example.yml rename to config/app_config.yml.example diff --git a/config/initializers/_load_app_config.rb b/config/initializers/_load_app_config.rb index 521f9f0a0..e739941e9 100644 --- a/config/initializers/_load_app_config.rb +++ b/config/initializers/_load_app_config.rb @@ -8,10 +8,10 @@ end if File.exist? "#{Rails.root}/config/app_config.yml" all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml" - all_envs = load_config_yaml "#{Rails.root}/config/app_config_example.yml" unless all_envs + all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example" unless all_envs else - puts "WARNING: No config/app_config.yml found! Look at config/app_config_example.yml for help." - all_envs = load_config_yaml "#{Rails.root}/config/app_config_example.yml" + puts "WARNING: No config/app_config.yml found! Look at config/app_config.yml.example for help." + all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example" end if all_envs[Rails.env.to_s] diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 8fa72f23d..20fe90fdf 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -42,7 +42,7 @@ def create end def set_app_config username - current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml'))) + current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example'))) current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "#{username}.joindiaspora.com" diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index 4ffa947e7..e2d8a5495 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -7,7 +7,7 @@ require 'config/environment' def set_app_config username - current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml'))) + current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example'))) current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "#{username}.joindiaspora.com" diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 50d41eb91..cc3000d0b 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -7,7 +7,7 @@ require 'config/environment' def set_app_config username - current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml'))) + current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example'))) current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "#{username}.joindiaspora.com" From 5ef32b7d55947f745256d98658f717da3f91297c Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 12:03:25 -0700 Subject: [PATCH 29/38] DG IZ; a user can repost. aspects are not sent through the websocket. post does not show where it curently is going in its partial --- app/controllers/application_controller.rb | 9 +++++++++ app/views/status_messages/_status_message.html.haml | 6 ++++++ config/routes.rb | 4 +++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f0ca5bfc8..ac0d11b1c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -37,4 +37,13 @@ class ApplicationController < ActionController::Base @request_count = Request.for_user(current_user).size if current_user end + def repost + @post = current_user.find_visible_post_by_id params[:id] + if current_user.repost( @post, :to => params[:aspect_ids] ) + flash[:notice] = "Item re-shared." + else + flash[:error] = "Failed to re-share." + end + end + end diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index dcee761d1..ee484f47b 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -22,3 +22,9 @@ - if current_user.owns?(post) .destroy_link = link_to 'Delete', status_message_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "delete" + + %b reshare: + -if @aspects + - for aspect in @aspects + = link_to aspect, repost_path( :id => post.id, :aspect_ids => aspect.id ) + diff --git a/config/routes.rb b/config/routes.rb index ae757499c..1a7a53925 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,12 +7,14 @@ Diaspora::Application.routes.draw do resources :people, :only => [:index, :show, :destroy] resources :users, :except => [:create, :new, :show] - resources :status_messages, :only => [:create, :destroy, :show] + resources :status_messages resources :comments, :except => [:index] resources :requests, :except => [:edit, :update] resources :photos, :except => [:index] resources :albums + match 'repost', :to => 'application#repost', :as => 'repost' + match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends' match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend' match 'aspects/manage', :to => 'aspects#manage' From de9092363115adca04879f06961d9bd5d7fd8d63 Mon Sep 17 00:00:00 2001 From: Thomas Krehbiel Date: Wed, 22 Sep 2010 18:05:11 -0400 Subject: [PATCH 30/38] Fix for sending unlimited duplicate friend requests --- lib/diaspora/user/friending.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index a4dcdd38d..f3b30f9b3 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -8,6 +8,9 @@ module Diaspora module UserModules module Friending def send_friend_request_to(desired_friend, aspect) + # should have different exception types for these? + raise "You have already sent a friend request to that person!" if self.pending_requests.detect{ + |x| x.destination_url == desired_friend.receive_url } raise "You are already friends with that person!" if self.friends.detect{ |x| x.receive_url == desired_friend.receive_url} request = Request.instantiate( From 474cf7770815bb1cf87c277cc9727be9e8d627bc Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 15:05:51 -0700 Subject: [PATCH 31/38] DG IZ; reposting now works. redirects to a template missing page, though. --- app/views/shared/_reshare.haml | 27 +++++++++ .../status_messages/_status_message.html.haml | 8 +-- public/stylesheets/application.css | 37 ++++++++++++ public/stylesheets/sass/application.sass | 56 +++++++++++++++++++ 4 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 app/views/shared/_reshare.haml diff --git a/app/views/shared/_reshare.haml b/app/views/shared/_reshare.haml new file mode 100644 index 000000000..61f48e73b --- /dev/null +++ b/app/views/shared/_reshare.haml @@ -0,0 +1,27 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3. See +-# the COPYRIGHT file. + + + +:javascript + $(".reshare_button").toggle(function(e){ + e.preventDefault(); + $(this).parent(".reshare_pane").children(".reshare_box").fadeIn(200); + }, function(e) { + e.preventDefault(); + $(this).parent(".reshare_pane").children(".reshare_box").fadeOut(200); + }); + +.reshare_pane + %span.reshare_button + = link_to "Reshare", "#" + + %ul.reshare_box + - for aspect in current_user.aspects_with_post( post.id ) + %li.currently_sharing= aspect.name + + - for aspect in current_user.aspects + - unless aspect.posts.include? post + %li.aspect_to_share= link_to aspect, repost_path( :id => post.id, :aspect_ids => aspect.id ) + diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index ee484f47b..33764453f 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -17,14 +17,10 @@ \-- = link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments" - = render "comments/comments", :post => post + = render "comments/comments", :post => post - if current_user.owns?(post) .destroy_link = link_to 'Delete', status_message_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "delete" - - %b reshare: - -if @aspects - - for aspect in @aspects - = link_to aspect, repost_path( :id => post.id, :aspect_ids => aspect.id ) + = render "shared/reshare", :post => post, :current_user => current_user diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 9e8561cc2..e95107081 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -171,6 +171,40 @@ li.message { li.message .content div.info .time a { color: #666666; } +.reshare_pane { + margin-left: 5px; + margin-right: 5px; + display: inline; + position: relative; } + .reshare_pane ul.reshare_box { + display: none; + z-index: 10; + position: absolute; + margin-top: 5px; + padding: 0; + background-color: #fafafa; + list-style: none; + border: 5px solid #666666; + -webkit-box-shadow: 0 0 5px #666666; + -moz-box-shadow: 0 0 5px #666666; + text-shadow: 0 2px white; + color: black; } + .reshare_pane ul.reshare_box > li { + font-weight: bold; + padding: 8px; + padding-right: 15px; + border-top: 1px solid white; + border-bottom: 1px solid #cccccc; } + .reshare_pane ul.reshare_box > li:first-child { + border-top: none; } + .reshare_pane ul.reshare_box > li:last-child { + border-bottom: none; } + .reshare_pane ul.reshare_box > li a { + display: block; + height: 100%; } + .reshare_pane ul.reshare_box > li a:hover { + background-color: #eeeeee; } + form { position: relative; font-size: 120%; @@ -270,6 +304,9 @@ ul.comment_set { .destroy_link a, .request_button a { color: #999999; font-weight: normal; } + .destroy_link a:hover, .request_button a:hover { + text-decoration: underline; + background: none; } .destroy_link { display: none; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 88145b6df..30f03f8c0 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -225,6 +225,58 @@ li.message a :color #666 +.reshare_pane + :margin + :left 5px + :right 5px + :display inline + :position relative + + ul.reshare_box + :display none + :z-index 10 + :position absolute + :margin + :top 5px + :padding 0 + + :background + :color #fafafa + + :list + :style none + + :border 5px solid #666 + :-webkit-box-shadow 0 0 5px #666 + :-moz-box-shadow 0 0 5px #666 + + :text-shadow 0 2px #fff + :color #000 + + > li + :font + :weight bold + + :padding 8px + :right 15px + :border + :top 1px solid #fff + :bottom 1px solid #ccc + + &:first-child + :border + :top none + &:last-child + :border + :bottom none + a + :display block + :height 100% + + &:hover + :background + :color #eee + form :position relative @@ -360,6 +412,10 @@ ul.comment_set :color #999 :font :weight normal + &:hover + :text + :decoration underline + :background none .destroy_link :display none From 10e6ff9df8e3168545d4ba8d074d22e78132d37e Mon Sep 17 00:00:00 2001 From: Thomas Krehbiel Date: Wed, 22 Sep 2010 18:05:11 -0400 Subject: [PATCH 32/38] Fix for sending unlimited duplicate friend requests --- app/controllers/requests_controller.rb | 4 ++-- lib/diaspora/user/friending.rb | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 6087ebe85..2a8090c9e 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -47,8 +47,8 @@ class RequestsController < ApplicationController begin @request = current_user.send_friend_request_to(rel_hash[:friend], aspect) rescue Exception => e - raise e unless e.message.include? "already friends" - flash[:notice] = "You are already friends with #{params[:request][:destination_url]}!" + raise e unless e.message.include? "already" + flash[:notice] = "#{e.message} #{params[:request][:destination_url]}" respond_with :location => aspect return end diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index a4dcdd38d..f3b30f9b3 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -8,6 +8,9 @@ module Diaspora module UserModules module Friending def send_friend_request_to(desired_friend, aspect) + # should have different exception types for these? + raise "You have already sent a friend request to that person!" if self.pending_requests.detect{ + |x| x.destination_url == desired_friend.receive_url } raise "You are already friends with that person!" if self.friends.detect{ |x| x.receive_url == desired_friend.receive_url} request = Request.instantiate( From 695e5fe396457b1b894c2ad378f4470574d3e80a Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Sep 2010 15:19:26 -0700 Subject: [PATCH 33/38] Don't log huge encrypted params --- config/application.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/application.rb b/config/application.rb index b409f91d3..bf3b5699a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -51,5 +51,6 @@ module Diaspora # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] + config.filter_parameters += [:xml] end end From b9be543ef6695ee6737b40f9600815247ce7f5dc Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 15:32:11 -0700 Subject: [PATCH 34/38] DG IZ; reshare redirects to specific page --- app/views/shared/_publisher.haml | 2 +- app/views/shared/_reshare.haml | 4 ++-- public/stylesheets/application.css | 1 + public/stylesheets/sass/application.sass | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 4645ec65c..130f136a9 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -10,7 +10,7 @@ = f.error_messages %p %label{:for => "status_message_message"} Message - = f.text_area :message, :rows => 2 + = f.text_area :message, :rows => 2, :value => params[:prefill] %ul.aspect_selector{ :style => "display:none;"} going to... diff --git a/app/views/shared/_reshare.haml b/app/views/shared/_reshare.haml index 61f48e73b..0b4120d52 100644 --- a/app/views/shared/_reshare.haml +++ b/app/views/shared/_reshare.haml @@ -19,9 +19,9 @@ %ul.reshare_box - for aspect in current_user.aspects_with_post( post.id ) + %li.currently_sharing= aspect.name - for aspect in current_user.aspects - unless aspect.posts.include? post - %li.aspect_to_share= link_to aspect, repost_path( :id => post.id, :aspect_ids => aspect.id ) - + %li.aspect_to_share= link_to aspect, :controller => "aspects", :action => "show", :id => aspect.id, :prefill => post.message diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index e95107081..82bbd8b6d 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -177,6 +177,7 @@ li.message { display: inline; position: relative; } .reshare_pane ul.reshare_box { + width: 150px; display: none; z-index: 10; position: absolute; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 30f03f8c0..7c77a0b79 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -233,6 +233,7 @@ li.message :position relative ul.reshare_box + :width 150px :display none :z-index 10 :position absolute From 955d9130a24fdb700b60cb5c241ebde707f5206f Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 15:35:23 -0700 Subject: [PATCH 35/38] DG IZ; shift+enter in publisher box submits contents --- public/javascripts/view.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 4713c7164..092d69f16 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -41,6 +41,12 @@ $(document).ready(function(){ } ); + $("#publisher textarea").keydown( function(e) { + if (e.shiftKey && e.keyCode == 13) { + $("#publisher form").submit(); + } + }); + });//end document ready From d0dbcd47fc7f76b4faab3e9cbf8166fa1390c666 Mon Sep 17 00:00:00 2001 From: Pistos Date: Tue, 21 Sep 2010 09:18:37 +0800 Subject: [PATCH 36/38] Added a newline after headings where it was missing. --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6e9c40aa0..d20252583 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ ## 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. -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). +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). 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. @@ -14,7 +15,7 @@ The privacy aware, personally controlled, do-it-all, open source social network. **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** -Also, we really want to continue to focus on features and improving the code base. When we think it is +Also, we really want to continue to focus on features and improving the code base. When we think it is ready for general use, we will post more detailed instructions. ## Notice @@ -30,6 +31,7 @@ We will try and fully support more webservers later, but that is what works for 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. @@ -64,7 +66,7 @@ To install Ruby 1.8.7 on **Ubuntu**, run the following command: sudo apt-get install ruby-full -Please note that you need to have Universe enabled in your /etc/apt/sources.list file to install ruby using apt-get. +Please note that you need to have Universe enabled in your /etc/apt/sources.list file to install ruby using apt-get. 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: @@ -90,11 +92,11 @@ Then run: You can also run the binary directly by doing the following: -If you're running a 32-bit system, run: +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: + +If you're running a 64-bit system, run: wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.6.2.tgz @@ -202,9 +204,11 @@ If you have never used github before, their [help desk](http://help.github.com/) ## 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. @@ -214,19 +218,24 @@ If you installed the OsX package through "brew", MongoDB will need to be started 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. ### Run the server + `./script/server` will start both thin and the websocket server. If you want to run a different app server, you will have to run them separately. See below for instructions. ### Run the app server + 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) ### Run the websocket server + run `bundle exec ruby ./script/websocket_server` to start the websocket server on port 8080. Change the port in config/app_config.yml. ### Logging in with a sample user + Run `rake db:seed:tom`, then login with user `tom` and password `evankorth`. More details in db/seeds/tom.rb. ### 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 From e9d16cc09b5c6dd2ae256658e0ec8b30fb56f882 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 15:48:50 -0700 Subject: [PATCH 37/38] DG IZ; cleanup --- app/controllers/albums_controller.rb | 2 +- app/controllers/application_controller.rb | 9 --------- app/controllers/photos_controller.rb | 2 +- app/models/user.rb | 8 ++------ config/routes.rb | 2 -- spec/models/user/posting_spec.rb | 17 ++--------------- 6 files changed, 6 insertions(+), 34 deletions(-) diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index 14adcebe1..d3cad54e2 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -52,7 +52,7 @@ class AlbumsController < ApplicationController data = clean_hash(params[:album]) - if current_user.update_or_repost( @album, data ) + if current_user.update_post( @album, data ) flash[:notice] = "Album #{@album.name} successfully edited." respond_with @album else diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ac0d11b1c..f0ca5bfc8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -37,13 +37,4 @@ class ApplicationController < ActionController::Base @request_count = Request.for_user(current_user).size if current_user end - def repost - @post = current_user.find_visible_post_by_id params[:id] - if current_user.repost( @post, :to => params[:aspect_ids] ) - flash[:notice] = "Item re-shared." - else - flash[:error] = "Failed to re-share." - end - end - end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 8d383f53a..d0cb1871e 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -88,7 +88,7 @@ class PhotosController < ApplicationController data = clean_hash(params) - if current_user.update_or_repost( @photo, data[:photo] ) + if current_user.update_post( @photo, data[:photo] ) flash[:notice] = "Photo successfully updated." respond_with @photo else diff --git a/app/models/user.rb b/app/models/user.rb index 45f947807..8f74e2233 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -122,13 +122,9 @@ class User post end - def update_or_repost( post, post_hash = {} ) + def update_post( post, post_hash = {} ) if self.owns? post - if post_hash[:aspect_ids] - repost(post, post_hash[:aspect_ids]) if validate_aspect_permissions post_hash[:aspect_ids] - else - post.update_attributes!(post_hash) - end + post.update_attributes(post_hash) end end diff --git a/config/routes.rb b/config/routes.rb index 1a7a53925..0ac115b76 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,8 +13,6 @@ Diaspora::Application.routes.draw do resources :photos, :except => [:index] resources :albums - match 'repost', :to => 'application#repost', :as => 'repost' - match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends' match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend' match 'aspects/manage', :to => 'aspects#manage' diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 6b939b573..d307e7a43 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -65,27 +65,14 @@ describe User do end end - describe '#update_or_repost' do + describe '#update_post' do let!(:album) { user.post(:album, :name => "Profile Photos", :to => aspect.id) } - it 'should repost' do - update_hash = { :aspect_ids => aspect1.id } - user.should_receive(:repost).with(album, update_hash[:aspect_ids]).and_return album - user.update_or_repost( album, update_hash ) - end - it 'should update fields' do update_hash = { :name => "Other Photos" } - user.update_or_repost( album, update_hash ) + user.update_post( album, update_hash ) album.name.should == "Other Photos" end - - it 'should reject posting to an external aspect' do - update_hash = { :aspect_ids => [aspect3.id] } - proc{ - user.update_or_repost( album, update_hash ) - }.should raise_error /Cannot post to an aspect you do not own./ - end end end From 5fad23c63245301d3bbc71274d9788f6077b6c67 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Sep 2010 15:53:40 -0700 Subject: [PATCH 38/38] Adjust readme wording --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2aeba0670..4e5152fbf 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ network. **PLEASE, DO NOT RUN IN PRODUCTION. IT IS FUN TO GET RUNNING, BUT EXPECT THINGS TO BE BROKEN** -Also, we really want to continue to focus on features and improving the code -base. When we think it is ready for general use, we will post more detailed +We are continuing to build features and improve the code base. +When we think it is ready for general use, we will post more detailed instructions. ## Notice