From b17ae0bf3835802216e92791d8030ea577dd0129 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 25 Oct 2010 12:26:08 -0700 Subject: [PATCH 01/22] DG MS removed unused fb_status model and respective specs, fixtures. --- Gemfile.lock | 21 ++++++---- app/models/fb_status.rb | 29 ------------- spec/factories.rb | 7 ---- spec/fixtures/fb_status | 79 ----------------------------------- spec/lib/encryptor_spec.rb | 10 ++--- spec/models/fb_status_spec.rb | 44 ------------------- 6 files changed, 18 insertions(+), 172 deletions(-) delete mode 100644 app/models/fb_status.rb delete mode 100644 spec/fixtures/fb_status delete mode 100644 spec/models/fb_status_spec.rb diff --git a/Gemfile.lock b/Gemfile.lock index 8f325e5ca..20a7f252c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,6 +98,7 @@ GEM activesupport (= 3.0.1) activesupport (3.0.1) addressable (2.2.2) + archive-tar-minitar (0.5.2) arel (1.0.1) activesupport (~> 3.0.0) aws (2.3.22) @@ -184,7 +185,8 @@ GEM launchy (0.3.7) configuration (>= 0.0.5) rake (>= 0.8.1) - linecache (0.43) + linecache19 (0.5.11) + ruby_core_source (>= 0.1.4) mail (2.2.7) activesupport (>= 2.3.6) mime-types @@ -259,11 +261,16 @@ GEM rspec-expectations (~> 2.0.1) rspec-rails (2.0.1) rspec (~> 2.0.0) - ruby-debug (0.10.3) - columnize (>= 0.1) - ruby-debug-base (~> 0.10.3.0) - ruby-debug-base (0.10.3) - linecache (>= 0.3) + ruby-debug-base19 (0.11.24) + columnize (>= 0.3.1) + linecache19 (>= 0.5.11) + ruby_core_source (>= 0.1.4) + ruby-debug19 (0.11.6) + columnize (>= 0.3.1) + linecache19 (>= 0.5.11) + ruby-debug-base19 (>= 0.11.19) + ruby_core_source (0.1.4) + archive-tar-minitar (>= 0.5.2) rubyzip (0.9.4) selenium-webdriver (0.0.29) childprocess (>= 0.0.7) @@ -324,7 +331,7 @@ DEPENDENCIES roxml! rspec (>= 2.0.0) rspec-rails (>= 2.0.0) - ruby-debug + ruby-debug19 sprinkle! thin webmock diff --git a/app/models/fb_status.rb b/app/models/fb_status.rb deleted file mode 100644 index 7076cbd31..000000000 --- a/app/models/fb_status.rb +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - - -class FbStatus - include MongoMapper::Document - - key :graph_id, String - key :author_id, String - key :author_name, String - key :message, String - key :updated_time, Time - - timestamps! - - validates_presence_of :graph_id,:author_id,:author_name,:message,:updated_time - - def self.from_api(hash) - #just keeping them in memory for now - self.new( - :graph_id => hash['id'], - :author_id => hash['from']['id'], - :author_name => hash['from']['name'], - :message => hash['message'], - :updated_time => Time.parse(hash['updated_time']) - ) - end -end diff --git a/spec/factories.rb b/spec/factories.rb index 8d0b76aee..982a3a07e 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -71,10 +71,3 @@ end Factory.define(:comment) {} -Factory.define :fb_status do |s| - s.graph_id "367501354973" - s.author_name "Bret Taylor" - s.author_id "220439" - s.message "Pigs run from our house in fear. Tonight, I am wrapping the pork tenderloin in bacon and putting pancetta in the corn." - s.updated_time Time.parse "2010-03-06T02:57:48+0000" -end diff --git a/spec/fixtures/fb_status b/spec/fixtures/fb_status deleted file mode 100644 index 5602e8343..000000000 --- a/spec/fixtures/fb_status +++ /dev/null @@ -1,79 +0,0 @@ -{ - "id": "367501354973", - "from": { - "name": "Bret Taylor", - "id": "220439" - }, - "message": "Pigs run from our house in fear. Tonight, I am wrapping the pork tenderloin in bacon and putting pancetta in the corn.", - "updated_time": "2010-03-06T02:57:48+0000", - "likes": { - "data": [ - { - "id": "29906278", - "name": "Ross Miller" - } - ] - }, - "comments": { - "data": [ - { - "id": "367501354973_12216733", - "from": { - "name": "Doug Edwards", - "id": "628675309" - }, - "message": "Make sure you don't, as they say, go whole hog...\nhttp://www.youtube.com/watch?v=U4wTFuaV8VQ", - "created_time": "2010-03-06T03:24:46+0000" - }, - { - "id": "367501354973_12249673", - "from": { - "name": "Tom Taylor", - "id": "1249191863" - }, - "message": "Are you and Karen gonna, as they say, pig out?", - "created_time": "2010-03-06T21:05:21+0000" - }, - { - "id": "367501354973_12249857", - "from": { - "name": "Sheila Taylor", - "id": "1315606682" - }, - "message": "how did it turn out? Sounds nummy!\n", - "created_time": "2010-03-06T21:10:30+0000" - }, - { - "id": "367501354973_12250973", - "from": { - "name": "Bret Taylor", - "id": "220439" - }, - "message": "Mom: turned out well. Sauce was good as well: pan sauce with mustard, balsamic, onion, and maple syrup. Surprisingly good in the end, and not too sweet, which was my concern. ", - "created_time": "2010-03-06T21:44:53+0000" - }, - { - "id": "367501354973_12251276", - "from": { - "name": "Sheila Taylor", - "id": "1315606682" - }, - "message": "Sounds delicious! I probably would have skipped the maple syrup, but I am not married to a Canadian :)\n\nSheila Taylor\n(925) 818-7795\nP.O. Box 938\nGlen Ellen, CA 95442\nwww.winecountrytrekking.com", - "created_time": "2010-03-06T21:55:12+0000" - }, - { - "id": "367501354973_12264435", - "from": { - "name": "Amelia Ann Arapoff", - "id": "1580390378" - }, - "message": "Bacon is always in our refrigerator, in case of need, somehow there is always need.", - "created_time": "2010-03-07T05:11:52+0000" - } - ], - "paging": { - "previous": "https://graph.facebook.com/367501354973/comments?access_token=2227470867%7C2.wNlupL2HPsOtrlYFBF56NA__.3600.1285354800-100001548997697%7C8lZ_pdgNDvSHYS4o1OkqhdQu6mA&limit=25&since=2010-03-07T05%3A11%3A52%2B0000", - "next": "https://graph.facebook.com/367501354973/comments?access_token=2227470867%7C2.wNlupL2HPsOtrlYFBF56NA__.3600.1285354800-100001548997697%7C8lZ_pdgNDvSHYS4o1OkqhdQu6mA&limit=25&until=2010-03-06T03%3A24%3A45%2B0000" - } - } -} \ No newline at end of file diff --git a/spec/lib/encryptor_spec.rb b/spec/lib/encryptor_spec.rb index e993dac45..3e6df211d 100644 --- a/spec/lib/encryptor_spec.rb +++ b/spec/lib/encryptor_spec.rb @@ -42,13 +42,11 @@ describe 'user encryption' do end describe 'encryption' do - before do - @string = File.open(File.dirname(__FILE__) + '/../fixtures/fb_status').read - end it 'should encrypt a string' do - ciphertext = @user.encrypt @string - ciphertext.include?(@string).should be false - @user.decrypt(ciphertext).should == @string + string = "Secretsauce" + ciphertext = @user.encrypt string + ciphertext.include?(string).should be false + @user.decrypt(ciphertext).should == string end end end diff --git a/spec/models/fb_status_spec.rb b/spec/models/fb_status_spec.rb deleted file mode 100644 index 7d46d9553..000000000 --- a/spec/models/fb_status_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - - - -require File.join(Rails.root,'spec/spec_helper') - - -describe FbStatus do - - let(:fb_status) { Factory.create :fb_status } - - it 'is valid' do - fb_status.should be_valid - end - - describe '#from_api' do - let!(:json_string) {File.open(File.dirname(__FILE__) + '/../fixtures/fb_status').read} - let!(:json_object) { JSON.parse(json_string) } - let!(:status_from_json) {FbStatus.from_api(json_object)} - - it 'has graph_id' do - status_from_json.graph_id.should == json_object['id'] - end - - it 'has author_id' do - status_from_json.author_id.should == json_object['from']['id'] - end - - it 'has author_name' do - status_from_json.author_name.should == json_object['from']['name'] - end - - it 'has message' do - status_from_json.message.should == json_object['message'] - end - - it 'has author_name' do - status_from_json.updated_time.should == Time.parse(json_object['updated_time']) - end - end - -end From 31b3d739c0e82609d255e30b0b822c6335d16720 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Mon, 25 Oct 2010 04:04:34 +0200 Subject: [PATCH 02/22] Bundle: add licenses, handle git gems Adding a docs dir collexting README and licenses from contained gems. git gems, which bundler does not handle well today, are handled by a hacked parsing of Gemfile.log, gem built into the source bundle and installed on target system --- pkg/Licenses | 99 +++++++++++++++++++++ pkg/fedora/.gitignore | 1 + pkg/fedora/diaspora-bundle.spec | 17 ++-- pkg/fedora/diaspora.spec | 3 +- pkg/fedora/make-dist.sh | 135 ++++++++++++++++++++--------- pkg/ubuntu/diaspora-bundle-install | 15 +++- 6 files changed, 218 insertions(+), 52 deletions(-) create mode 100644 pkg/Licenses diff --git a/pkg/Licenses b/pkg/Licenses new file mode 100644 index 000000000..cc8f33741 --- /dev/null +++ b/pkg/Licenses @@ -0,0 +1,99 @@ + +abstract: Ruby +actionmailer: MIT +actionpack: MIT +activemodel: MIT +activerecord: MIT +activeresource: ? (Other distros uses MIT, "Ruby-alike", no pointers) +activesupport: MIT +addressable: MIT +arel: MIT +aws MIT +bcrypt-ruby: MIT +builder: MIT +bunny: MIT +capistrano: MIT +capybara: MIT +chef: ASL 2.0 +childprocess: MIT +columnize: GPLv2 +crack: MIT +cucumber: MIT +cucumber-rails: MIT +culerity: MIT +daemons: Ruby+MIT +database_cleaner: MIT +devise: MIT +devise_invitable MIT +diff Ruby+GPLv2+ Artistic 2.0 +em-websocket: MIT +eribus: MIT +event-machine: Ruby+GPLv2 +extlib: MIT +factory_girls MIT +factory_girls_rails: MIT +ffi MIT +haml MIT +http_connection: MIT +gherkin: MIT +hashie: MIT +highline GPLv2+Ruby +json: Ruby +json-pure: Ruby +launchy: MIT +linecache: GPLv2 +mail: MIT +mime-types: GPLv2+Ruby+Artistic 2.0 +mini_magick: MIT +mini_fb: ? +mixlib-authentication: ASL 2.0 +mixlib-cli ASL 2.0 +mixlib-config ASL 2.0 +mixlib-log ASL 2.0 +mocha Ruby+MIT +moneta: MIT +mongo: ASL 2.0 +net-scp: MIT +net-sftp: MIT +net-ssh: MIT +net-ssh-gatawey: MIT +ohai: ASL 2.0 +plucky: MIT +polyglot. MIT +pubsubhubbub: ASL 2.0 http://code.google.com/p/pubsubhubbub/ +rake: MIT +rack-mount: MIT +rack-test: MIT +railties: MIT +rest-client: MIT +rspec-core: MIT +rspec-expectations: MIT +rspec-mocks: MIT +rspec-rails: MIT +rack: MIT +rack-mount: MIT +ruby-debug: MIT +ruby-debug-base: MIT +rubyzip: Ruby +selenium-webdriver: ASL 2.0 +subexec: MIT +term-ansicolor: GPLv2 +textile. MIT +textile-warden: MIT +thin: MIT +thor: MIT +treetop: MIT +tx-info: MIT +uutdtools: MIT +iwarden: MIT +webmock: MIT +will-paginate MIT + + + + + + + + + diff --git a/pkg/fedora/.gitignore b/pkg/fedora/.gitignore index bedbdc760..2a21dd54d 100644 --- a/pkg/fedora/.gitignore +++ b/pkg/fedora/.gitignore @@ -1,3 +1,4 @@ TODO dist .stgit* +vendor diff --git a/pkg/fedora/diaspora-bundle.spec b/pkg/fedora/diaspora-bundle.spec index dee189a26..a13a85368 100644 --- a/pkg/fedora/diaspora-bundle.spec +++ b/pkg/fedora/diaspora-bundle.spec @@ -38,9 +38,16 @@ Source file usede to compile native libraries in diaspora-bundle. %setup -q -n %{name}-%{version}-%{git_release} %build -mkdir -p vendor/cache -mv *.gem vendor/cache -bundle install --local --deployment --without ri rdoc +bundle install --local --deployment --without ri rdoc test +for gem in vendor/git/*; do + gem install --local \ + --force \ + --no-rdoc \ + --no-ri \ + --install-dir vendor/bundle/ruby/1.8/bundler \ + $gem + +done pushd vendor/bundle/ruby/1.8/gems # In repo (2.2.4) @@ -200,7 +207,7 @@ popd } mkdir -p $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle -cp -ar vendor/bundle $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle +cp -ar vendor $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle find %{buildroot}/%{_libdir}/diaspora-bundle \ -type d -fprintf dirs '%%%dir "%%p"\n' @@ -218,7 +225,7 @@ cat files >> dirs && cp dirs files %files -f files %defattr(-, diaspora, diaspora, 0755) -%doc COPYRIGHT Gemfile Gemfile.lock AUTHORS GNU-AGPL-3.0 +%doc COPYRIGHT Gemfile Gemfile.lock AUTHORS GNU-AGPL-3.0 docs %files -f dev-files devel %defattr(-, root, root, 0644) diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index 1d61026e5..8a30492c8 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -49,13 +49,12 @@ find . -perm /u+x -type f -exec \ %build rm -rf master/vendor/bundle -mkdir master/tmp || : %install rm -fr $RPM_BUILD_ROOT sed -i \ - '/BUNDLE_PATH/s|:.*|: %{_libdir}/diaspora-bundle/bundle|' \ + '/BUNDLE_PATH/s|:.*|: %{_libdir}/diaspora-bundle/vendor/bundle|' \ master/.bundle/config cp master/GNU-AGPL-3.0 master/COPYRIGHT master/README.md master/AUTHORS . diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index 3da2ab6e3..2ff8c9ef2 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -138,7 +138,7 @@ function checkout() cd diaspora; git fetch --quiet upstream git merge --quiet upstream/master - git checkout --quiet ${1:-'HEAD'} + [ -n "$1" ] && git reset --hard --quiet $1 git_id -n ) } @@ -175,41 +175,91 @@ function make_src echo "Required bundle: $(git_id dist/diaspora/Gemfile)" } -function get_git_repos() + +function build_git_gems() +# Usage: build_git_gems +# Horrible hack, in wait for bundler handling git gems OK. { - grep -A 2 GIT $1 | - awk ' /remote:/ { repo = $2 } - /revision:/ { printf "%s=%s\n",repo, $2}' + mkdir gem-tmp || : + cd gem-tmp + rm -rf * + + grep 'git:' ../$1 | sed 's/,/ /' | awk ' + /^.*git:\/\/.*$/ { + gsub( "=>", "") + gsub( ",", "") + if ( $1 != "gem") { + print "Strange git: line (ignored) :" $0 + next + } + name = $2 + suffix = "" + url="" + for (i = 3; i <= NF; i += 1) { + key = $i + i += 1 + if (key == ":git") + url = $i + else if ( key == ":ref") { + suffix = "; cd " name + suffix = suffix "; git reset --hard " $i + suffix = suffix "; cd .." + } + else if ( key == ":branch") + suffix = "; git checkout " $i + } + print "Running: ", cmd + cmd = sprintf( "git clone --quiet %s %s %s\n", + url, name, suffix) + system( cmd) + }' + sed -i 's/Date.today/"2010-10-24"/' carrierwave/carrierwave.gemspec + for dir in *; do + cd $dir + gem build *.gemspec + cp *.gem ../../$2 + cd .. + done + + cd .. + # rm -rf gem-tmp } - -function package_git_gems() +function make_docs() { - gemfile="$1" - dest="$2" + local gemfile=$1 + for url in $(read_git_urls $gemfile); do + local name=${url##*/} + name=${name%.*} + rm -rf vendor/git/$name + git clone --bare --quiet $url vendor/git/$name && + sed -i "s#$url#vendor/git/$name#" $gemfile || + echo "Cannot fix git repo \"$url\"" + done +} - rm -rf git-tmp - mkdir git-tmp - cd git-tmp - for repo in $( get_git_repos $1); do - url=${repo%%=*} - rev=${repo##*=} +function make_docs() +{ + local gems=$1 + local dest=$2 - name=${url##*/} - name="${name%.git}" - - rm -rf "$name" - git clone "$url" "$name" - cd $name - git reset --hard $rev - sed -i '/s.date/s/Date.today/"2010-09-25"/' *.gemspec - gem build *.gemspec - cp *.gem $dest - echo "Built GIT gem $name (*.gem)" - echo "Where: $dest" - cd .. - done - cd .. + for gem in $(ls $gems); do + local name=$(basename $gem) + [ -r $gems/$gem/README* ] && { + local readme=$(basename $gems/$gem/README*) + cp -a $gems/$gem/$readme $dest/$readme.$name + } + [ -r $gems/$gem/COPYRIGHT ] && \ + cp -a $gems/$gem/COPYRIGHT $dest/COPYRIGHT.$name + [ -r $gems/$gem/LICENSE ] && \ + cp -a $gems/$gem/LICENSE $dest/LICENSE.$name + [ -r $gems/$gem/License ] && \ + cp -a $gems/$gem/License $dest/License.$name + [ -r $gems/$gem/MIT-LICENSE ] && \ + cp -a $gems/$gem/MIT-LICENSE $dest/MIT-LICENSE.$name + [ -r $gems/$gem/COPYING ] && \ + cp -a $gems/$gem/COPYING $dest/COPYING.$name + done } @@ -219,8 +269,8 @@ function make_bundle() # { checkout ${1:-'HEAD'} >/dev/null - bundle_id=$( git_id dist/diaspora/Gemfile) - bundle_name="diaspora-bundle-$VERSION-$bundle_id" + local bundle_id=$( git_id dist/diaspora/Gemfile) + local bundle_name="diaspora-bundle-$VERSION-$bundle_id" test -e "dist/$bundle_name.tar.gz" || { echo "Creating bundle $bundle_name" cd dist @@ -231,22 +281,25 @@ function make_bundle() rm -rf .bundle bundle update fi - bundle install --deployment + [ -d 'vendor/git' ] || mkdir vendor/git + bundle install bundle package - package_git_gems "$PWD/Gemfile.lock" "$PWD/vendor/cache" + mkdir vendor/git + build_git_gems Gemfile vendor/git + + mkdir -p "../$bundle_name/docs" + mkdir -p "../$bundle_name/vendor" cp -ar AUTHORS Gemfile Gemfile.lock GNU-AGPL-3.0 COPYRIGHT \ - vendor/cache - cd vendor - mv cache $bundle_name - tar czf ../../$bundle_name.tar.gz $bundle_name - mv $bundle_name cache - cd .. + ../$bundle_name + make_docs "vendor/gems" "../$bundle_name/docs" + mv vendor/cache ../$bundle_name/vendor cd .. + tar czf $bundle_name.tar.gz $bundle_name + mv $bundle_name/vendor/cache diaspora/vendor/cache cd .. } echo echo "Bundle: dist/$bundle_name.tar.gz" - echo "Current dir:$PWD" } diff --git a/pkg/ubuntu/diaspora-bundle-install b/pkg/ubuntu/diaspora-bundle-install index 88924b930..65ae9520e 100755 --- a/pkg/ubuntu/diaspora-bundle-install +++ b/pkg/ubuntu/diaspora-bundle-install @@ -23,11 +23,18 @@ mv $(basename $1 .tar.gz) diaspora-bundle mkdir -p /usr/share/doc/diaspora-bundle || : cd /usr/lib/diaspora-bundle -cp AUTHORS GNU-AGPL-3.0 COPYRIGHT Gemfile Gemfile.lock \ +cp -a AUTHORS GNU-AGPL-3.0 COPYRIGHT Gemfile Gemfile.lock \ /usr/share/doc/diaspora-bundle - -mkdir -p vendor/cache -mv *.gem vendor/cache +cp -ar docs /usr/share/doc/diaspora-bundle bundle install --local --deployment --without ri rdoc +for gem in vendor/git/*; do + gem install --local \ + --force \ + --no-rdoc \ + --no-ri \ + --install-dir vendor/bundle/ruby/1.8/bundler \ + $gem +done + From c4ff07b09a35ec2dd5e44c8afae135b19f86f229 Mon Sep 17 00:00:00 2001 From: maxwell Date: Sat, 23 Oct 2010 16:09:58 -0700 Subject: [PATCH 03/22] twitter oauth dance complete --- Gemfile | 4 ++ Gemfile.lock | 64 +++++++++++++++++++ .../omniauth_services_controller.rb | 30 +++++++++ app/models/omniauth_service.rb | 13 ++++ app/models/user.rb | 2 + app/views/omniauth_services/index.html.haml | 17 +++++ config/initializers/_load_services.rb | 15 +++++ config/initializers/omniauth.rb | 9 +++ config/oauth_keys.yml | 3 + config/oauth_keys.yml.example | 3 + config/routes.rb | 5 +- 11 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 app/controllers/omniauth_services_controller.rb create mode 100644 app/models/omniauth_service.rb create mode 100644 app/views/omniauth_services/index.html.haml create mode 100644 config/initializers/_load_services.rb create mode 100644 config/initializers/omniauth.rb create mode 100644 config/oauth_keys.yml create mode 100644 config/oauth_keys.yml.example diff --git a/Gemfile b/Gemfile index bd90c0a46..766e3fd69 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,10 @@ gem "chef" gem 'devise', '1.1.3' gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper' gem 'devise_invitable', '~> 0.3.4' + +#Authentication +gem 'omniauth' + #Mongo gem 'mongo_mapper', :branch => 'rails3', :git => 'git://github.com/jnunemaker/mongomapper.git' gem 'bson_ext', '1.1' diff --git a/Gemfile.lock b/Gemfile.lock index 20a7f252c..7a1caf8ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -170,6 +170,9 @@ GEM factory_girl_rails (1.0) factory_girl (~> 1.3) rails (>= 3.0.0.beta4) + faraday (0.4.6) + addressable (>= 2.1.1) + rack (>= 1.0.1) ffi (0.6.3) rake (>= 0.8.7) gherkin (2.2.9) @@ -182,11 +185,20 @@ GEM i18n (0.4.1) json (1.4.6) json_pure (1.4.6) +<<<<<<< HEAD launchy (0.3.7) configuration (>= 0.0.5) rake (>= 0.8.1) +<<<<<<< HEAD linecache19 (0.5.11) ruby_core_source (>= 0.1.4) +======= + linecache (0.43) +======= + linecache19 (0.5.11) + ruby_core_source (>= 0.1.4) +>>>>>>> twitter oauth dance complete +>>>>>>> twitter oauth dance complete mail (2.2.7) activesupport (>= 2.3.6) mime-types @@ -207,6 +219,8 @@ GEM moneta (0.6.0) mongo (1.1) bson (>= 1.0.5) + multi_json (0.0.4) + net-ldap (0.1.1) net-scp (1.0.4) net-ssh (>= 1.99.1) net-sftp (2.0.5) @@ -215,6 +229,7 @@ GEM net-ssh-gateway (1.0.1) net-ssh (>= 1.99.1) nokogiri (1.4.3.1) +<<<<<<< HEAD ohai (0.5.8) extlib json (>= 1.4.4, <= 1.4.6) @@ -222,15 +237,54 @@ GEM mixlib-config mixlib-log systemu +======= + oa-basic (0.1.5) + multi_json (~> 0.0.2) + nokogiri (~> 1.4.2) + oa-core (= 0.1.5) + rest-client (~> 1.6.0) + oa-core (0.1.5) + rack (~> 1.1) + oa-enterprise (0.1.5) + net-ldap (~> 0.1.1) + nokogiri (~> 1.4.2) + oa-core (= 0.1.5) + pyu-ruby-sasl (~> 0.0.3.1) + rubyntlm (~> 0.1.1) + oa-oauth (0.1.5) + multi_json (~> 0.0.2) + nokogiri (~> 1.4.2) + oa-core (= 0.1.5) + oauth (~> 0.4.0) + oauth2 (~> 0.0.10) + oa-openid (0.1.5) + oa-core (= 0.1.5) + rack-openid (~> 1.1.1) + ruby-openid-apps-discovery + oauth (0.4.3) + oauth2 (0.0.13) + faraday (~> 0.4.1) + multi_json (>= 0.0.4) + omniauth (0.1.5) + oa-basic (= 0.1.5) + oa-core (= 0.1.5) + oa-enterprise (= 0.1.5) + oa-oauth (= 0.1.5) + oa-openid (= 0.1.5) +>>>>>>> twitter oauth dance complete plucky (0.3.6) mongo (~> 1.1) polyglot (0.3.1) pubsubhubbub (0.1.1) em-http-request (>= 0.1.5) eventmachine (>= 0.12.9) + pyu-ruby-sasl (0.0.3.2) rack (1.2.1) rack-mount (0.6.13) rack (>= 1.0.0) + rack-openid (1.1.2) + rack (>= 0.4) + ruby-openid (>= 2.0.3) rack-test (0.5.6) rack (>= 1.0) rails (3.0.1) @@ -269,8 +323,17 @@ GEM columnize (>= 0.3.1) linecache19 (>= 0.5.11) ruby-debug-base19 (>= 0.11.19) +<<<<<<< HEAD ruby_core_source (0.1.4) archive-tar-minitar (>= 0.5.2) +======= + ruby-openid (2.1.8) + ruby-openid-apps-discovery (1.2.0) + ruby-openid (>= 2.1.7) + ruby_core_source (0.1.4) + archive-tar-minitar (>= 0.5.2) + rubyntlm (0.1.1) +>>>>>>> twitter oauth dance complete rubyzip (0.9.4) selenium-webdriver (0.0.29) childprocess (>= 0.0.7) @@ -325,6 +388,7 @@ DEPENDENCIES mini_magick mocha mongo_mapper! + omniauth pubsubhubbub rails (>= 3.0.0) redfinger! diff --git a/app/controllers/omniauth_services_controller.rb b/app/controllers/omniauth_services_controller.rb new file mode 100644 index 000000000..cbc59be69 --- /dev/null +++ b/app/controllers/omniauth_services_controller.rb @@ -0,0 +1,30 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + + +class OmniauthServicesController < ApplicationController + before_filter :authenticate_user! + + def index + @services = current_user.services + end + + def create + auth = request.env['omniauth.auth'] + + + puts auth['extra']['access_token'].inspect + + current_user.services.create(:provider => auth['provider'], :uid => auth['uid']) + flash[:notice] = "Authentication successful." + redirect_to omniauth_services_url + end + + def destroy + @service = current_user.services.find(params[:id]) + @service.destroy + flash[:notice] = "Successfully destroyed authentication." + redirect_to omniauth_services_url + end +end diff --git a/app/models/omniauth_service.rb b/app/models/omniauth_service.rb new file mode 100644 index 000000000..1fe6ece32 --- /dev/null +++ b/app/models/omniauth_service.rb @@ -0,0 +1,13 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +class OmniauthService + include MongoMapper::Document + + belongs_to :user + + key :provider, String + key :uid, String + +end diff --git a/app/models/user.rb b/app/models/user.rb index 343cc2d76..8d876f0e6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -61,6 +61,8 @@ class User many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post' many :aspects, :class_name => 'Aspect', :dependent => :destroy + many :services, :class_name => "OmniauthService" + #after_create :seed_aspects before_destroy :unfriend_everyone, :remove_person diff --git a/app/views/omniauth_services/index.html.haml b/app/views/omniauth_services/index.html.haml new file mode 100644 index 000000000..6e77ade58 --- /dev/null +++ b/app/views/omniauth_services/index.html.haml @@ -0,0 +1,17 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +%h2 + Services + +%ul#stream + - for service in @services + %h3 + = service.provider + %b + =service.uid + = link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete + += link_to "Connect to twitter", "/auth/twitter" + diff --git a/config/initializers/_load_services.rb b/config/initializers/_load_services.rb new file mode 100644 index 000000000..d65f2a695 --- /dev/null +++ b/config/initializers/_load_services.rb @@ -0,0 +1,15 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +def load_config_yaml filename + YAML.load(File.read(filename)) +end + +oauth_keys_file = "#{Rails.root}/config/oauth_keys.yml" + +if File.exist? oauth_keys_file + SERVICES = load_config_yaml(oauth_keys_file) + SERVICES ||= load_config_yaml("#{oauth_keys_file}.example") +end + diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb new file mode 100644 index 000000000..876d3f3f2 --- /dev/null +++ b/config/initializers/omniauth.rb @@ -0,0 +1,9 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +Rails.application.config.middleware.use OmniAuth::Builder do + provider :twitter, SERVICES['twitter']['consumer_key'], SERVICES['twitter']['consumer_secret'] + #provider :facebook, 'APP_ID', 'APP_SECRET' +end + diff --git a/config/oauth_keys.yml b/config/oauth_keys.yml new file mode 100644 index 000000000..1460b861f --- /dev/null +++ b/config/oauth_keys.yml @@ -0,0 +1,3 @@ +twitter: + consumer_key: no69jTnL5SCOnWgk5XWqbQ + consumer_secret: 2DZyu8DA43AIeFsRVdz8OtAHLvCtPjdRKdNO3UZGqWM diff --git a/config/oauth_keys.yml.example b/config/oauth_keys.yml.example new file mode 100644 index 000000000..3397b2832 --- /dev/null +++ b/config/oauth_keys.yml.example @@ -0,0 +1,3 @@ +twitter: + consumer_key: "" + consumer_secret: "" diff --git a/config/routes.rb b/config/routes.rb index 7364f9016..470193a74 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,6 +9,9 @@ Diaspora::Application.routes.draw do resources :requests, :except => [:edit, :update] resources :photos, :except => [:index] resources :albums + resources :omniauth_services + + match '/auth/:provider/callback' => 'omniauth_services#create' devise_for :users, :controllers => {:registrations => "registrations", :password => "devise/passwords", @@ -18,7 +21,7 @@ Diaspora::Application.routes.draw do match 'users/export', :to => 'users#export' match 'users/import', :to => 'users#import' match 'users/export_photos', :to => 'users#export_photos' - resources :users, :except => [:create, :new, :show] + resources :users, :except => [:create, :new, :show] match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend' match 'aspects/add_to_aspect',:to => 'aspects#add_to_aspect', :as => 'add_to_aspect' From 606c7a02a4d742ebb85bf0beeb3c92ee5f263ab9 Mon Sep 17 00:00:00 2001 From: maxwell Date: Sat, 23 Oct 2010 17:35:10 -0700 Subject: [PATCH 04/22] MS DG public message now post to twitter, if connected --- Gemfile | 2 +- app/controllers/omniauth_services_controller.rb | 11 +++++++---- app/controllers/status_messages_controller.rb | 9 +++++++-- app/models/omniauth_service.rb | 4 +++- app/models/user.rb | 10 ++++++++++ app/views/omniauth_services/index.html.haml | 5 +++-- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 766e3fd69..cd11c7ceb 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'devise_invitable', '~> 0.3.4' #Authentication gem 'omniauth' - +gem 'twitter' #Mongo gem 'mongo_mapper', :branch => 'rails3', :git => 'git://github.com/jnunemaker/mongomapper.git' gem 'bson_ext', '1.1' diff --git a/app/controllers/omniauth_services_controller.rb b/app/controllers/omniauth_services_controller.rb index cbc59be69..b15746875 100644 --- a/app/controllers/omniauth_services_controller.rb +++ b/app/controllers/omniauth_services_controller.rb @@ -13,10 +13,13 @@ class OmniauthServicesController < ApplicationController def create auth = request.env['omniauth.auth'] - - puts auth['extra']['access_token'].inspect - - current_user.services.create(:provider => auth['provider'], :uid => auth['uid']) + access_token = auth['extra']['access_token'] + user = auth['user_info'] + current_user.services.create(:nickname => user['nickname'], + :access_token => access_token.token, + :access_secret => access_token.secret, + :provider => auth['provider'], + :uid => auth['uid']) flash[:notice] = "Authentication successful." redirect_to omniauth_services_url end diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 526818472..2e4c74472 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -10,12 +10,17 @@ class StatusMessagesController < ApplicationController def create data = clean_hash params[:status_message] + message = params[:status_message][:message] - if logged_into_fb? && params[:status_message][:public] == '1' - current_user.post_to_message_fb(params[:status_message][:message], @access_token) + if params[:status_message][:public] == '1' + current_user.post_to_twitter(message) + if logged_into_fb? + current_user.post_to_message_fb(message, @access_token) + end end @status_message = current_user.post(:status_message, data) + render :nothing => true end diff --git a/app/models/omniauth_service.rb b/app/models/omniauth_service.rb index 1fe6ece32..d30ab9f7d 100644 --- a/app/models/omniauth_service.rb +++ b/app/models/omniauth_service.rb @@ -9,5 +9,7 @@ class OmniauthService key :provider, String key :uid, String - + key :access_token, String + key :access_secret, String + key :nickname, String end diff --git a/app/models/user.rb b/app/models/user.rb index 8d876f0e6..1bcc5417c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -161,6 +161,16 @@ class User EventMachine::HttpRequest.new("https://graph.facebook.com/me/feed?message=#{message}&access_token=#{access_token}").post end + def post_to_twitter(message) + twitter = self.services.find_by_provider("twitter") + if twitter + oauth = Twitter::OAuth.new(SERVICES['twitter']['consumer_token'], SERVICES['twitter']['consumer_secret']) + oauth.authorize_from_access(twitter.access_token, twitter.access_secret) + client = Twitter::Base.new(oauth) + client.update(message) + end + 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) diff --git a/app/views/omniauth_services/index.html.haml b/app/views/omniauth_services/index.html.haml index 6e77ade58..9b6be3946 100644 --- a/app/views/omniauth_services/index.html.haml +++ b/app/views/omniauth_services/index.html.haml @@ -8,9 +8,10 @@ %ul#stream - for service in @services %h3 - = service.provider + %b= service.provider + logged in as %b - =service.uid + = service.nickname = link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete = link_to "Connect to twitter", "/auth/twitter" From d66e986971b78a10e42397223e79c298e12daf5d Mon Sep 17 00:00:00 2001 From: maxwell Date: Sat, 23 Oct 2010 22:14:05 -0700 Subject: [PATCH 05/22] removing oauth keys --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a17dc3a1b..b09f9b136 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Configuration files config/app_config.yml config/fb_config.yml +config/oauth_keys.yml config/initializers/secret_token.rb .bundle vendor/bundle/* From 154b6e0ee7c7e55cdfcea7552e901b25ce203fff Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 25 Oct 2010 11:54:52 -0700 Subject: [PATCH 06/22] MS DG added specs for posting to twitter, and basic services controller tests --- app/controllers/status_messages_controller.rb | 2 +- app/models/user.rb | 2 +- spec/controllers/albums_controller_spec.rb | 1 - .../omniauth_services_controller_spec.rb | 48 +++++++++++++++++ .../status_message_controller_spec.rb | 51 ++++++++++++------- spec/factories.rb | 21 +++----- 6 files changed, 91 insertions(+), 34 deletions(-) create mode 100644 spec/controllers/omniauth_services_controller_spec.rb diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 2e4c74472..f2792f8f3 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -15,7 +15,7 @@ class StatusMessagesController < ApplicationController if params[:status_message][:public] == '1' current_user.post_to_twitter(message) if logged_into_fb? - current_user.post_to_message_fb(message, @access_token) + current_user.post_to_facebook(message, @access_token) end end diff --git a/app/models/user.rb b/app/models/user.rb index 1bcc5417c..75a0d0989 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -154,7 +154,7 @@ class User intitial_post(class_name, aspect_ids, options) end - def post_to_message_fb(message, access_token) + def post_to_facebook(message, access_token) id = 'me' type = 'feed' Rails.logger.info("Sending a message: #{message} to Facebook") diff --git a/spec/controllers/albums_controller_spec.rb b/spec/controllers/albums_controller_spec.rb index 5c53f1909..74bec4045 100644 --- a/spec/controllers/albums_controller_spec.rb +++ b/spec/controllers/albums_controller_spec.rb @@ -14,7 +14,6 @@ describe AlbumsController do end it "should update the name of an album" do - sign_in :user, @user put :update, :id => @album.id, :album => { :name => "new_name"} @album.reload.name.should eql("new_name") end diff --git a/spec/controllers/omniauth_services_controller_spec.rb b/spec/controllers/omniauth_services_controller_spec.rb new file mode 100644 index 000000000..b72426eba --- /dev/null +++ b/spec/controllers/omniauth_services_controller_spec.rb @@ -0,0 +1,48 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' + +describe OmniauthServicesController do + render_views + let(:user) { Factory(:user) } + let!(:aspect) { user.aspect(:name => "lame-os") } + + let!(:service1) {a = Factory(:omniauth_service); user.services << a; a} + let!(:service2) {a = Factory(:omniauth_service); user.services << a; a} + let!(:service3) {a = Factory(:omniauth_service); user.services << a; a} + let!(:service4) {a = Factory(:omniauth_service); user.services << a; a} + + let(:mock_access_token) { Object.new } + + let(:omniauth_auth) {{ 'provider' => 'twitter', 'uid' => '2', + 'user_info' => { 'nickname' => 'grimmin' }, + 'extra' => { 'access_token' => mock_access_token }}} + + before do + sign_in :user, user + mock_access_token.stub!(:token).and_return("12345") + mock_access_token.stub!(:secret).and_return("56789") + end + + describe '#index' do + it 'displays all connected serivices for a user' do + get :index + assigns[:services].should == user.services + end + end + + describe '#create' do + it 'creates a new OmniauthService' do + request.env['omniauth.auth'] = omniauth_auth + lambda{post :create}.should change(user.services, :count).by(1) + end + end + + describe '#destroy' do + it 'should destroy a service of a users with the id' do + lambda{delete :destroy, :id => service1.id.to_s}.should change(user.services, :count).by(-1) + end + end +end diff --git a/spec/controllers/status_message_controller_spec.rb b/spec/controllers/status_message_controller_spec.rb index 9c84fe3e8..536db40d4 100644 --- a/spec/controllers/status_message_controller_spec.rb +++ b/spec/controllers/status_message_controller_spec.rb @@ -12,27 +12,42 @@ describe StatusMessagesController do before do sign_in :user, user + @controller.stub!(:current_user).and_return(user) end describe '#create' do - let(:status_message_hash) {{"status_message"=>{"public"=>"1", "message"=>"facebook, is that you?", "to" =>"#{aspect.id}"}}} - - before do - @controller.stub!(:logged_into_fb?).and_return(true) - end + let(:status_message_hash) {{"status_message"=>{"public"=>"1", "message"=>"facebook, is that you?", "to" =>"#{aspect.id}"}}} - it 'should post to facebook when public is set' do - my_mock = mock("http") - my_mock.stub!(:post) - EventMachine::HttpRequest.should_receive(:new).and_return(my_mock) - post :create, status_message_hash - end - - it 'should not post to facebook when public in not set' do - status_message_hash['status_message']['public'] = '0' - EventMachine::HttpRequest.should_not_receive(:new) - post :create, status_message_hash - end + + context "posting out to facebook" do + before do + @controller.stub!(:logged_into_fb?).and_return(true) + end + + it 'should post to facebook when public is set' do + user.should_receive(:post_to_facebook) + post :create, status_message_hash + end + + it 'should not post to facebook when public in not set' do + status_message_hash['status_message']['public'] = '0' + user.should_not_receive(:post_to_facebook) + post :create, status_message_hash + end + end + + + context "posting to twitter" do + it 'should post to twitter if public is set' do + user.should_receive(:post_to_twitter).and_return(true) + post :create, status_message_hash + end + + it 'should not post to twitter when public in not set' do + status_message_hash['status_message']['public'] = '0' + user.should_not_receive(:post_to_twitter) + post :create, status_message_hash + end + end end end - diff --git a/spec/factories.rb b/spec/factories.rb index 982a3a07e..81f001a17 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -52,22 +52,17 @@ Factory.define :status_message do |m| m.person end -Factory.define :blog do |b| - b.sequence(:title) {|n| "bobby's #{n} penguins"} - b.sequence(:body) {|n| "jimmy's huge #{n} whales"} -end - -Factory.define :bookmark do |b| - b.link "http://www.yahooligans.com/" -end - -Factory.define :post do |p| -end - Factory.define :photo do |p| p.image File.open( File.dirname(__FILE__) + '/fixtures/button.png') end -Factory.define(:comment) {} +Factory.define :omniauth_service do |service| + service.nickname "sirrobertking" + service.provider "twitter" + + service.sequence(:uid) { |token| "000#{token}" } + service.sequence(:access_token) { |token| "12345#{token}" } + service.sequence(:access_secret) { |token| "98765#{token}" } +end From fdd222003a0ca72026b2db1f4deefc9c49af9d60 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 25 Oct 2010 12:14:27 -0700 Subject: [PATCH 07/22] fixed failing specs due to omitted factories. --- Gemfile.lock | 31 ++++++++++++++++++++----------- spec/factories.rb | 9 +++++++++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7a1caf8ce..0a8a3eb65 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -182,13 +182,15 @@ GEM hashie (0.4.0) highline (1.6.1) http_connection (1.4.0) + httparty (0.6.1) + crack (= 0.1.8) i18n (0.4.1) json (1.4.6) json_pure (1.4.6) -<<<<<<< HEAD launchy (0.3.7) configuration (>= 0.0.5) rake (>= 0.8.1) +<<<<<<< HEAD <<<<<<< HEAD linecache19 (0.5.11) ruby_core_source (>= 0.1.4) @@ -199,6 +201,10 @@ GEM ruby_core_source (>= 0.1.4) >>>>>>> twitter oauth dance complete >>>>>>> twitter oauth dance complete +======= + linecache19 (0.5.11) + ruby_core_source (>= 0.1.4) +>>>>>>> fixed failing specs due to omitted factories. mail (2.2.7) activesupport (>= 2.3.6) mime-types @@ -229,15 +235,6 @@ GEM net-ssh-gateway (1.0.1) net-ssh (>= 1.99.1) nokogiri (1.4.3.1) -<<<<<<< HEAD - ohai (0.5.8) - extlib - json (>= 1.4.4, <= 1.4.6) - mixlib-cli - mixlib-config - mixlib-log - systemu -======= oa-basic (0.1.5) multi_json (~> 0.0.2) nokogiri (~> 1.4.2) @@ -265,13 +262,19 @@ GEM oauth2 (0.0.13) faraday (~> 0.4.1) multi_json (>= 0.0.4) + ohai (0.5.8) + extlib + json (>= 1.4.4, <= 1.4.6) + mixlib-cli + mixlib-config + mixlib-log + systemu omniauth (0.1.5) oa-basic (= 0.1.5) oa-core (= 0.1.5) oa-enterprise (= 0.1.5) oa-oauth (= 0.1.5) oa-openid (= 0.1.5) ->>>>>>> twitter oauth dance complete plucky (0.3.6) mongo (~> 1.1) polyglot (0.3.1) @@ -350,6 +353,11 @@ GEM thor (0.14.3) treetop (1.4.8) polyglot (>= 0.3.1) + twitter (0.9.12) + hashie (~> 0.4.0) + httparty (~> 0.6.1) + multi_json (~> 0.0.4) + oauth (~> 0.4.3) tzinfo (0.3.23) uuidtools (2.1.1) warden (0.10.7) @@ -398,5 +406,6 @@ DEPENDENCIES ruby-debug19 sprinkle! thin + twitter webmock will_paginate (= 3.0.pre2) diff --git a/spec/factories.rb b/spec/factories.rb index 81f001a17..6c6d69f4f 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -66,3 +66,12 @@ Factory.define :omniauth_service do |service| service.sequence(:access_secret) { |token| "98765#{token}" } end +Factory.define(:comment) {} + +Factory.define :fb_status do |s| + s.graph_id "367501354973" + s.author_name "Bret Taylor" + s.author_id "220439" + s.message "Pigs run from our house in fear. Tonight, I am wrapping the pork tenderloin in bacon and putting pancetta in the corn." + s.updated_time Time.parse "2010-03-06T02:57:48+0000" +end From be39df75fed3c7495be1e6a25781a745c1400610 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 25 Oct 2010 12:28:45 -0700 Subject: [PATCH 08/22] removed fb_status from the factories. whoops. --- Gemfile.lock | 18 ------------------ spec/factories.rb | 7 ------- 2 files changed, 25 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0a8a3eb65..1a3128822 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -190,21 +190,8 @@ GEM launchy (0.3.7) configuration (>= 0.0.5) rake (>= 0.8.1) -<<<<<<< HEAD -<<<<<<< HEAD linecache19 (0.5.11) ruby_core_source (>= 0.1.4) -======= - linecache (0.43) -======= - linecache19 (0.5.11) - ruby_core_source (>= 0.1.4) ->>>>>>> twitter oauth dance complete ->>>>>>> twitter oauth dance complete -======= - linecache19 (0.5.11) - ruby_core_source (>= 0.1.4) ->>>>>>> fixed failing specs due to omitted factories. mail (2.2.7) activesupport (>= 2.3.6) mime-types @@ -326,17 +313,12 @@ GEM columnize (>= 0.3.1) linecache19 (>= 0.5.11) ruby-debug-base19 (>= 0.11.19) -<<<<<<< HEAD - ruby_core_source (0.1.4) - archive-tar-minitar (>= 0.5.2) -======= ruby-openid (2.1.8) ruby-openid-apps-discovery (1.2.0) ruby-openid (>= 2.1.7) ruby_core_source (0.1.4) archive-tar-minitar (>= 0.5.2) rubyntlm (0.1.1) ->>>>>>> twitter oauth dance complete rubyzip (0.9.4) selenium-webdriver (0.0.29) childprocess (>= 0.0.7) diff --git a/spec/factories.rb b/spec/factories.rb index 6c6d69f4f..b64cbbc5e 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -68,10 +68,3 @@ end Factory.define(:comment) {} -Factory.define :fb_status do |s| - s.graph_id "367501354973" - s.author_name "Bret Taylor" - s.author_id "220439" - s.message "Pigs run from our house in fear. Tonight, I am wrapping the pork tenderloin in bacon and putting pancetta in the corn." - s.updated_time Time.parse "2010-03-06T02:57:48+0000" -end From c489f49a25939d66a8c7be989a9ffb9f922fe667 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 25 Oct 2010 13:59:26 -0700 Subject: [PATCH 09/22] DG beginning to collapse twitter&facebook --- app/controllers/application_controller.rb | 3 ++- app/controllers/omniauth_services_controller.rb | 2 ++ app/controllers/services_controller.rb | 1 - app/models/user.rb | 11 ++++++----- app/views/omniauth_services/index.html.haml | 1 + config/initializers/omniauth.rb | 2 +- config/oauth_keys.yml | 3 +++ 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 137705df4..d61cb193d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -45,15 +45,16 @@ class ApplicationController < ActionController::Base end end + ## take this out def fb_user_info if current_user @access_token = warden.session[:access_token] @logged_in = @access_token.present? end end - def logged_into_fb? @logged_in end + ## end diff --git a/app/controllers/omniauth_services_controller.rb b/app/controllers/omniauth_services_controller.rb index b15746875..23ff7afe5 100644 --- a/app/controllers/omniauth_services_controller.rb +++ b/app/controllers/omniauth_services_controller.rb @@ -13,6 +13,8 @@ class OmniauthServicesController < ApplicationController def create auth = request.env['omniauth.auth'] + puts auth.inspect + access_token = auth['extra']['access_token'] user = auth['user_info'] current_user.services.create(:nickname => user['nickname'], diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 97f52cef2..29da09872 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -12,7 +12,6 @@ class ServicesController < ApplicationController code = params['code'] # Facebooks verification string if code access_token_hash = MiniFB.oauth_access_token(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", FB_SECRET, code) - p access_token_hash @access_token = access_token_hash["access_token"] # TODO: This is where you'd want to store the token in your database diff --git a/app/models/user.rb b/app/models/user.rb index 75a0d0989..a52201fa0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -154,11 +154,12 @@ class User intitial_post(class_name, aspect_ids, options) end - def post_to_facebook(message, access_token) - id = 'me' - type = 'feed' - Rails.logger.info("Sending a message: #{message} to Facebook") - EventMachine::HttpRequest.new("https://graph.facebook.com/me/feed?message=#{message}&access_token=#{access_token}").post + def post_to_facebook(message) + facebook = self.services.find_by_provider("facebook") + if facebook + Rails.logger.info("Sending a message: #{message} to Facebook") + EventMachine::HttpRequest.new("https://graph.facebook.com/me/feed?message=#{message}&access_token=#{facebook.access_token}").post + end end def post_to_twitter(message) diff --git a/app/views/omniauth_services/index.html.haml b/app/views/omniauth_services/index.html.haml index 9b6be3946..282df96fc 100644 --- a/app/views/omniauth_services/index.html.haml +++ b/app/views/omniauth_services/index.html.haml @@ -15,4 +15,5 @@ = link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete = link_to "Connect to twitter", "/auth/twitter" += link_to "Connect to facebook", "/auth/facebook" diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 876d3f3f2..a9253f6c2 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -4,6 +4,6 @@ Rails.application.config.middleware.use OmniAuth::Builder do provider :twitter, SERVICES['twitter']['consumer_key'], SERVICES['twitter']['consumer_secret'] - #provider :facebook, 'APP_ID', 'APP_SECRET' + provider :facebook, SERVICES['facebook']['app_id'], SERVICES['facebook']['app_secret'] end diff --git a/config/oauth_keys.yml b/config/oauth_keys.yml index 1460b861f..c3dc20afd 100644 --- a/config/oauth_keys.yml +++ b/config/oauth_keys.yml @@ -1,3 +1,6 @@ twitter: consumer_key: no69jTnL5SCOnWgk5XWqbQ consumer_secret: 2DZyu8DA43AIeFsRVdz8OtAHLvCtPjdRKdNO3UZGqWM +facebook: + app_id: 120373411325347 + app_secret: 7fe864834726f8a5e65bc93928b99a53 From 3d302f8db7c2a794038a27dfabc43aced2e22acb Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 25 Oct 2010 14:49:55 -0700 Subject: [PATCH 10/22] facebook and twitter both use omniauth and are saved as OmniauthServices --- Gemfile.lock | 21 +++++---------- .../omniauth_services_controller.rb | 26 +++++++++++++------ app/controllers/status_messages_controller.rb | 4 +-- app/views/omniauth_services/index.html.haml | 4 +-- config/deploy_config.yml | 2 +- 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1a3128822..1abff88d1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,7 +98,6 @@ GEM activesupport (= 3.0.1) activesupport (3.0.1) addressable (2.2.2) - archive-tar-minitar (0.5.2) arel (1.0.1) activesupport (~> 3.0.0) aws (2.3.22) @@ -190,8 +189,7 @@ GEM launchy (0.3.7) configuration (>= 0.0.5) rake (>= 0.8.1) - linecache19 (0.5.11) - ruby_core_source (>= 0.1.4) + linecache (0.43) mail (2.2.7) activesupport (>= 2.3.6) mime-types @@ -305,19 +303,14 @@ GEM rspec-expectations (~> 2.0.1) rspec-rails (2.0.1) rspec (~> 2.0.0) - ruby-debug-base19 (0.11.24) - columnize (>= 0.3.1) - linecache19 (>= 0.5.11) - ruby_core_source (>= 0.1.4) - ruby-debug19 (0.11.6) - columnize (>= 0.3.1) - linecache19 (>= 0.5.11) - ruby-debug-base19 (>= 0.11.19) + ruby-debug (0.10.3) + columnize (>= 0.1) + ruby-debug-base (~> 0.10.3.0) + ruby-debug-base (0.10.3) + linecache (>= 0.3) ruby-openid (2.1.8) ruby-openid-apps-discovery (1.2.0) ruby-openid (>= 2.1.7) - ruby_core_source (0.1.4) - archive-tar-minitar (>= 0.5.2) rubyntlm (0.1.1) rubyzip (0.9.4) selenium-webdriver (0.0.29) @@ -385,7 +378,7 @@ DEPENDENCIES roxml! rspec (>= 2.0.0) rspec-rails (>= 2.0.0) - ruby-debug19 + ruby-debug sprinkle! thin twitter diff --git a/app/controllers/omniauth_services_controller.rb b/app/controllers/omniauth_services_controller.rb index 23ff7afe5..d7659236e 100644 --- a/app/controllers/omniauth_services_controller.rb +++ b/app/controllers/omniauth_services_controller.rb @@ -13,15 +13,25 @@ class OmniauthServicesController < ApplicationController def create auth = request.env['omniauth.auth'] - puts auth.inspect + provider = auth['provider'] + user = auth['user_info'] + + if provider == 'twitter' + access_token = auth['extra']['access_token'] + current_user.services.create(:nickname => user['nickname'], + :access_token => access_token.token, + :access_secret => access_token.secret, + :provider => provider, + :uid => auth['uid']) + + elsif provider == 'facebook' + current_user.services.create(:nickname => user['nickname'], + :access_token => auth['credentials']['token'], + :provider => provider, + :uid => auth['uid']) + end + - access_token = auth['extra']['access_token'] - user = auth['user_info'] - current_user.services.create(:nickname => user['nickname'], - :access_token => access_token.token, - :access_secret => access_token.secret, - :provider => auth['provider'], - :uid => auth['uid']) flash[:notice] = "Authentication successful." redirect_to omniauth_services_url end diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index f2792f8f3..47caf4bf9 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -14,9 +14,7 @@ class StatusMessagesController < ApplicationController if params[:status_message][:public] == '1' current_user.post_to_twitter(message) - if logged_into_fb? - current_user.post_to_facebook(message, @access_token) - end + current_user.post_to_facebook(message) end @status_message = current_user.post(:status_message, data) diff --git a/app/views/omniauth_services/index.html.haml b/app/views/omniauth_services/index.html.haml index 282df96fc..7d7e7c13f 100644 --- a/app/views/omniauth_services/index.html.haml +++ b/app/views/omniauth_services/index.html.haml @@ -14,6 +14,6 @@ = service.nickname = link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete -= link_to "Connect to twitter", "/auth/twitter" -= link_to "Connect to facebook", "/auth/facebook" +%h4= link_to "Connect to twitter", "/auth/twitter" +%h4= link_to "Connect to facebook", "/auth/facebook" diff --git a/config/deploy_config.yml b/config/deploy_config.yml index 06a6747e1..dda2cc200 100644 --- a/config/deploy_config.yml +++ b/config/deploy_config.yml @@ -6,7 +6,7 @@ cross_server: deploy_to: '/usr/local/app/diaspora' user: 'root' repo: 'git://github.com/diaspora/diaspora.git' - branch: 'master' + branch: 'twitter' default_env: 'development' servers: tom: From b2e8ebd0bcea57693e60b992ff4fb544fa4e90d0 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 25 Oct 2010 16:17:19 -0700 Subject: [PATCH 11/22] OmniauthService -> Service. Cleaned up views. --- app/controllers/application_controller.rb | 14 ----- app/controllers/aspects_controller.rb | 12 ----- .../omniauth_services_controller.rb | 45 ---------------- app/controllers/services_controller.rb | 52 +++++++++++-------- app/controllers/users_controller.rb | 3 -- app/helpers/application_helper.rb | 5 -- .../{omniauth_service.rb => service.rb} | 2 +- app/models/user.rb | 2 +- app/views/omniauth_services/index.html.haml | 19 ------- app/views/services/index.html.haml | 28 ++++++++++ app/views/shared/_aspect_friends.haml | 5 -- app/views/shared/_public_explain.haml | 12 +++-- app/views/shared/_publisher.haml | 28 +++++----- app/views/users/_services.haml | 26 ---------- app/views/users/edit.html.haml | 5 +- config/routes.rb | 11 ++-- ...er_spec.rb => services_controller_spec.rb} | 10 ++-- spec/factories.rb | 6 +-- 18 files changed, 94 insertions(+), 191 deletions(-) delete mode 100644 app/controllers/omniauth_services_controller.rb rename app/models/{omniauth_service.rb => service.rb} (93%) delete mode 100644 app/views/omniauth_services/index.html.haml create mode 100644 app/views/services/index.html.haml delete mode 100644 app/views/users/_services.haml rename spec/controllers/{omniauth_services_controller_spec.rb => services_controller_spec.rb} (78%) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d61cb193d..df08808ae 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,7 +8,6 @@ class ApplicationController < ActionController::Base before_filter :set_friends_and_status, :except => [:create, :update] before_filter :count_requests - before_filter :fb_user_info before_filter :set_invites layout :layout_by_resource @@ -44,17 +43,4 @@ class ApplicationController < ActionController::Base @invites = current_user.invites end end - - ## take this out - def fb_user_info - if current_user - @access_token = warden.session[:access_token] - @logged_in = @access_token.present? - end - end - def logged_into_fb? - @logged_in - end - ## - end diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index ddde8a725..0129c0abf 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -11,9 +11,6 @@ class AspectsController < ApplicationController def index @posts = current_user.visible_posts(:by_members_of => :all).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' @aspect = :all - - @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", - :scope=>MiniFB.scopes.join(",")) end def create @@ -56,15 +53,6 @@ class AspectsController < ApplicationController end end - def public - # @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", - # :scope=>MiniFB.scopes.join(",")) - - @posts = current_user.visible_posts(:person_id => current_user.person.id, :public => true).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' - - respond_with @aspect - end - def manage @aspect = :manage @remote_requests = current_user.requests_for_me diff --git a/app/controllers/omniauth_services_controller.rb b/app/controllers/omniauth_services_controller.rb deleted file mode 100644 index d7659236e..000000000 --- a/app/controllers/omniauth_services_controller.rb +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - - -class OmniauthServicesController < ApplicationController - before_filter :authenticate_user! - - def index - @services = current_user.services - end - - def create - auth = request.env['omniauth.auth'] - - provider = auth['provider'] - user = auth['user_info'] - - if provider == 'twitter' - access_token = auth['extra']['access_token'] - current_user.services.create(:nickname => user['nickname'], - :access_token => access_token.token, - :access_secret => access_token.secret, - :provider => provider, - :uid => auth['uid']) - - elsif provider == 'facebook' - current_user.services.create(:nickname => user['nickname'], - :access_token => auth['credentials']['token'], - :provider => provider, - :uid => auth['uid']) - end - - - flash[:notice] = "Authentication successful." - redirect_to omniauth_services_url - end - - def destroy - @service = current_user.services.find(params[:id]) - @service.destroy - flash[:notice] = "Successfully destroyed authentication." - redirect_to omniauth_services_url - end -end diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 29da09872..7c5da42a7 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -4,36 +4,42 @@ class ServicesController < ApplicationController + before_filter :authenticate_user! + + def index + @services = current_user.services + end def create - puts 'services/create' - p params + auth = request.env['omniauth.auth'] - code = params['code'] # Facebooks verification string - if code - access_token_hash = MiniFB.oauth_access_token(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", FB_SECRET, code) - @access_token = access_token_hash["access_token"] + provider = auth['provider'] + user = auth['user_info'] - # TODO: This is where you'd want to store the token in your database - # but for now, we'll just keep it in the session so we don't need a database - warden.session[:access_token] = @access_token - flash[:success] = "Authentication successful." + if provider == 'twitter' + access_token = auth['extra']['access_token'] + current_user.services.create(:nickname => user['nickname'], + :access_token => access_token.token, + :access_secret => access_token.secret, + :provider => provider, + :uid => auth['uid']) + + elsif provider == 'facebook' + current_user.services.create(:nickname => user['nickname'], + :access_token => auth['credentials']['token'], + :provider => provider, + :uid => auth['uid']) end - redirect_to edit_user_url current_user + + + flash[:notice] = "Authentication successful." + redirect_to services_url end def destroy - warden.session[:access_token] = nil - warden.session[:user_id] = nil - redirect_to edit_user_url current_user + @service = current_user.services.find(params[:id]) + @service.destroy + flash[:notice] = "Successfully destroyed authentication." + redirect_to services_url end - - def fb_post - id = 'me' - type = 'feed' - - @res = MiniFB.post(@access_token, id, :type=>type, :metadata=>true, :params=>params) - redirect_to edit_user_url current_user - end - end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index aacff8504..9c1bb3e9c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -19,9 +19,6 @@ class UsersController < ApplicationController @person = @user.person @profile = @user.person.profile @photos = current_user.visible_posts(:person_id => current_user.person.id, :_type => 'Photo').paginate :page => params[:page], :order => 'created_at DESC' - - @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", - :scope=>MiniFB.scopes.join(",")) end def update diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8851f3c8e..869d49a98 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -78,9 +78,4 @@ module ApplicationHelper def post_yield_tag(post) (':' + post.id.to_s).to_sym end - - def connected_fb_as token - response_hash = MiniFB.get(token, 'me') - "Connected to facebook as #{response_hash[:name]}" - end end diff --git a/app/models/omniauth_service.rb b/app/models/service.rb similarity index 93% rename from app/models/omniauth_service.rb rename to app/models/service.rb index d30ab9f7d..1b64f013e 100644 --- a/app/models/omniauth_service.rb +++ b/app/models/service.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class OmniauthService +class Service include MongoMapper::Document belongs_to :user diff --git a/app/models/user.rb b/app/models/user.rb index a52201fa0..48420e577 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -61,7 +61,7 @@ class User many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post' many :aspects, :class_name => 'Aspect', :dependent => :destroy - many :services, :class_name => "OmniauthService" + many :services, :class_name => "Service" #after_create :seed_aspects diff --git a/app/views/omniauth_services/index.html.haml b/app/views/omniauth_services/index.html.haml deleted file mode 100644 index 7d7e7c13f..000000000 --- a/app/views/omniauth_services/index.html.haml +++ /dev/null @@ -1,19 +0,0 @@ --# Copyright (c) 2010, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3 or later. See --# the COPYRIGHT file. - -%h2 - Services - -%ul#stream - - for service in @services - %h3 - %b= service.provider - logged in as - %b - = service.nickname - = link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete - -%h4= link_to "Connect to twitter", "/auth/twitter" -%h4= link_to "Connect to facebook", "/auth/facebook" - diff --git a/app/views/services/index.html.haml b/app/views/services/index.html.haml new file mode 100644 index 000000000..ea375e9ac --- /dev/null +++ b/app/views/services/index.html.haml @@ -0,0 +1,28 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +#section_header + %h2 + Settings + %ul#settings_nav + %li=link_to 'Profile', '#', :class => 'profile' + %li=link_to 'Account', '#', :class => 'account' + %li=link_to 'Services', services_path + +.span-19.prepend-5.last + %h2 + Services + + %ul#stream + - for service in @services + %h3 + %b= service.provider + logged in as + %b + = service.nickname + = link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete + + %h4= link_to "Connect to twitter", "/auth/twitter" + %h4= link_to "Connect to facebook", "/auth/facebook" + diff --git a/app/views/shared/_aspect_friends.haml b/app/views/shared/_aspect_friends.haml index c44d88e6b..f4b2f06f7 100644 --- a/app/views/shared/_aspect_friends.haml +++ b/app/views/shared/_aspect_friends.haml @@ -15,11 +15,6 @@ - for friend in @friends = person_image_link(friend) - - if @logged_in && (@aspect == :public) - %h3 Facebook Friends - - @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends") - - @fb_friends[:data].each do |friend| - = image_tag( "http://graph.facebook.com/#{friend[:id]}/picture" ) -unless (@aspect == :all) = link_to (image_tag('add_friend_button.png', :title => "add to #{@aspect}")), "#add_request_pane", :id => 'add_request_button' diff --git a/app/views/shared/_public_explain.haml b/app/views/shared/_public_explain.haml index ca1a2b1d7..3d7e7f644 100644 --- a/app/views/shared/_public_explain.haml +++ b/app/views/shared/_public_explain.haml @@ -9,10 +9,14 @@ Public messages will be available for others outside of Diaspora to see. %br %br - - if @logged_in - = connected_fb_as(@access_token) - - else - = link_to "Connect to Facebook", @fb_access_url + + - if current_user.services + - for service in current_user.services + = "logged in to #{service.provider}" + %br + + = link_to "manage connected services", services_path + %br %br = link_to "OK", '#', :class => "button", :onClick => '$.fancybox.close();' diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 56ac9e440..5e3be8f2a 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -2,20 +2,22 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -:javascript - $("div.public_toggle input").live("click", function(evt){ - if("#{@logged_in}" == "false" && $(this).attr('checked') == true){ - $(".question_mark").click(); - }; - }); - - $("#publisher textarea, #publisher input").live("focus", function(evt){ - $("#publisher .options_and_submit").fadeIn(50); - }); - $("#publisher form").live("submit", function(evt){ - $("#publisher .options_and_submit").hide(); - }); +- content_for :head do + :javascript + $("div.public_toggle input").live("click", function(evt){ + if($(this).attr('checked') == true){ + $(".question_mark").click(); + }; + }); + + $("#publisher textarea, #publisher input").live("focus", function(evt){ + $("#publisher .options_and_submit").fadeIn(50); + }); + + $("#publisher form").live("submit", function(evt){ + $("#publisher .options_and_submit").hide(); + }); #publisher = owner_image_tag diff --git a/app/views/users/_services.haml b/app/views/users/_services.haml deleted file mode 100644 index a9a6d7977..000000000 --- a/app/views/users/_services.haml +++ /dev/null @@ -1,26 +0,0 @@ --# Copyright (c) 2010, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3 or later. See --# the COPYRIGHT file. - - -%h2 Services - -- if FACEBOOK - %h3 Facebook - %p - - if @logged_in - = connected_fb_as(@access_token) - - %p - - @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends") - - @fb_friends[:data].each do |friend| - = image_tag( "http://graph.facebook.com/#{friend[:id]}/picture" ) - - = link_to "Disconnect from Facebook", services_destroy_path - - else - = link_to "Connect to Facebook", @fb_access_url - - #content_bottom - .back - = link_to "⇧ home", root_path - diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 48b266c09..104a9e8fd 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -18,7 +18,7 @@ %ul#settings_nav %li=link_to 'Profile', '#', :class => 'profile' %li=link_to 'Account', '#', :class => 'account' - %li=link_to 'Services', '#', :class => 'services' + %li=link_to 'Services', services_path .span-19.prepend-5.last #profile.settings_pane{:style=>"display:block;"} @@ -27,6 +27,3 @@ #account.settings_pane = render 'users/account' - #services.settings_pane - = render 'users/services' - diff --git a/config/routes.rb b/config/routes.rb index 470193a74..b9b05ca65 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,13 +9,13 @@ Diaspora::Application.routes.draw do resources :requests, :except => [:edit, :update] resources :photos, :except => [:index] resources :albums - resources :omniauth_services + resources :services - match '/auth/:provider/callback' => 'omniauth_services#create' + match '/auth/:provider/callback' => 'services#create' devise_for :users, :controllers => {:registrations => "registrations", :password => "devise/passwords", - :invitations => "invitations"} + :invitations => "invitations"} # added public route to user match 'public/:username', :to => 'users#public' match 'users/export', :to => 'users#export' @@ -27,13 +27,8 @@ Diaspora::Application.routes.draw do match 'aspects/add_to_aspect',:to => 'aspects#add_to_aspect', :as => 'add_to_aspect' match 'aspects/remove_from_aspect',:to => 'aspects#remove_from_aspect', :as => 'remove_from_aspect' match 'aspects/manage', :to => 'aspects#manage' - match 'aspects/public', :to => 'aspects#public' resources :aspects, :except => [:edit] - match 'services/create', :to => "services#create" - match 'services/destroy', :to => "services#destroy" - match 'services/fb_post', :to => "services#fb_post" - match 'warzombie', :to => "dev_utilities#warzombie" match 'zombiefriends', :to => "dev_utilities#zombiefriends" match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept" diff --git a/spec/controllers/omniauth_services_controller_spec.rb b/spec/controllers/services_controller_spec.rb similarity index 78% rename from spec/controllers/omniauth_services_controller_spec.rb rename to spec/controllers/services_controller_spec.rb index b72426eba..0c19c1e23 100644 --- a/spec/controllers/omniauth_services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -4,15 +4,15 @@ require 'spec_helper' -describe OmniauthServicesController do +describe ServicesController do render_views let(:user) { Factory(:user) } let!(:aspect) { user.aspect(:name => "lame-os") } - let!(:service1) {a = Factory(:omniauth_service); user.services << a; a} - let!(:service2) {a = Factory(:omniauth_service); user.services << a; a} - let!(:service3) {a = Factory(:omniauth_service); user.services << a; a} - let!(:service4) {a = Factory(:omniauth_service); user.services << a; a} + let!(:service1) {a = Factory(:service); user.services << a; a} + let!(:service2) {a = Factory(:service); user.services << a; a} + let!(:service3) {a = Factory(:service); user.services << a; a} + let!(:service4) {a = Factory(:service); user.services << a; a} let(:mock_access_token) { Object.new } diff --git a/spec/factories.rb b/spec/factories.rb index b64cbbc5e..32d747937 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -57,12 +57,12 @@ Factory.define :photo do |p| end -Factory.define :omniauth_service do |service| +Factory.define :service do |service| service.nickname "sirrobertking" service.provider "twitter" - service.sequence(:uid) { |token| "000#{token}" } - service.sequence(:access_token) { |token| "12345#{token}" } + service.sequence(:uid) { |token| "00000#{token}" } + service.sequence(:access_token) { |token| "12345#{token}" } service.sequence(:access_secret) { |token| "98765#{token}" } end From 287d633c443ad383cd4a9463701cc2ab2260380f Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 25 Oct 2010 17:22:03 -0700 Subject: [PATCH 12/22] user#post now handles posting to services. --- app/controllers/status_messages_controller.rb | 7 ------ app/models/user.rb | 19 +++++++++------- spec/models/user/posting_spec.rb | 22 +++++++++++++++++-- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 47caf4bf9..89cf59f32 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -11,14 +11,7 @@ class StatusMessagesController < ApplicationController def create data = clean_hash params[:status_message] message = params[:status_message][:message] - - if params[:status_message][:public] == '1' - current_user.post_to_twitter(message) - current_user.post_to_facebook(message) - end - @status_message = current_user.post(:status_message, data) - render :nothing => true end diff --git a/app/models/user.rb b/app/models/user.rb index 48420e577..8c179c239 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -151,7 +151,17 @@ class User aspect_ids = validate_aspect_permissions(aspect_ids) - 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) + + if options[:public] + self.services.each do |service| + self.send("post_to_#{service.provider}".to_sym) + end + end + + post end def post_to_facebook(message) @@ -172,13 +182,6 @@ class User end 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 - end - def update_post(post, post_hash = {}) if self.owns? post post.update_attributes(post_hash) diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 70438bbec..f21bad8a7 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -7,12 +7,16 @@ require 'spec_helper' describe User do let!(:user) { Factory(:user) } + let!(:user2) { Factory(:user) } + let!(:aspect) { user.aspect(:name => 'heroes') } let!(:aspect1) { user.aspect(:name => 'other') } - - let!(:user2) { Factory(:user) } let!(:aspect2) { user2.aspect(:name => 'losers') } + let!(:service1) { user.services << Factory(:service, :provider => 'twitter') } + let!(:service2) { user.services << Factory(:service, :provider => 'facebook') } + + describe '#validate_aspect_permissions' do it 'requires an aspect' do proc { @@ -44,11 +48,25 @@ describe User do aspect.reload aspect.posts.should include album end + it "should add the post to that user's visible posts" do status_message = user.post :status_message, :message => "hi", :to => aspect.id user.reload user.raw_visible_posts.include?(status_message).should be true end + + it "posts to services if post is public" do + user.should_receive(:post_to_twitter).exactly(1).times + user.should_receive(:post_to_facebook).exactly(1).times + user.post :status_message, :message => "hi", :to => "all", :public => true + end + + it "does not post to services if post is not public" do + user.should_receive(:post_to_twitter).exactly(0).times + user.should_receive(:post_to_facebook).exactly(0).times + user.post :status_message, :message => "hi", :to => "all" + end + end describe '#update_post' do From 6ff94e67b3b404965625e298bb1a5704b5b6ea0d Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 25 Oct 2010 17:26:07 -0700 Subject: [PATCH 13/22] remove unused fb_config.yml files. removed oauth_keys.yml from git, updated .example" --- config/fb_config.yml | 4 ---- config/fb_config.yml.example | 4 ---- config/initializers/_load_services.rb | 3 ++- config/oauth_keys.yml | 6 ------ config/oauth_keys.yml.example | 3 +++ 5 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 config/fb_config.yml delete mode 100644 config/fb_config.yml.example delete mode 100644 config/oauth_keys.yml diff --git a/config/fb_config.yml b/config/fb_config.yml deleted file mode 100644 index 4c3309fac..000000000 --- a/config/fb_config.yml +++ /dev/null @@ -1,4 +0,0 @@ -fb_api_key: {dcf4e90df086cf6d3e531b31e043ff32} -fb_secret: {7fe864834726f8a5e65bc93928b99a53} -fb_app_id: {120373411325347} -host: http://localhost:3000/ diff --git a/config/fb_config.yml.example b/config/fb_config.yml.example deleted file mode 100644 index 5bb145316..000000000 --- a/config/fb_config.yml.example +++ /dev/null @@ -1,4 +0,0 @@ -fb_api_key: {key} -fb_secret: {secret} -fb_app_id: {app_id} -host: http://localhost:3000/ diff --git a/config/initializers/_load_services.rb b/config/initializers/_load_services.rb index d65f2a695..ef41d75a7 100644 --- a/config/initializers/_load_services.rb +++ b/config/initializers/_load_services.rb @@ -10,6 +10,7 @@ oauth_keys_file = "#{Rails.root}/config/oauth_keys.yml" if File.exist? oauth_keys_file SERVICES = load_config_yaml(oauth_keys_file) - SERVICES ||= load_config_yaml("#{oauth_keys_file}.example") end +SERVICES ||= load_config_yaml("#{oauth_keys_file}.example") + diff --git a/config/oauth_keys.yml b/config/oauth_keys.yml deleted file mode 100644 index c3dc20afd..000000000 --- a/config/oauth_keys.yml +++ /dev/null @@ -1,6 +0,0 @@ -twitter: - consumer_key: no69jTnL5SCOnWgk5XWqbQ - consumer_secret: 2DZyu8DA43AIeFsRVdz8OtAHLvCtPjdRKdNO3UZGqWM -facebook: - app_id: 120373411325347 - app_secret: 7fe864834726f8a5e65bc93928b99a53 diff --git a/config/oauth_keys.yml.example b/config/oauth_keys.yml.example index 3397b2832..8e1db632a 100644 --- a/config/oauth_keys.yml.example +++ b/config/oauth_keys.yml.example @@ -1,3 +1,6 @@ twitter: consumer_key: "" consumer_secret: "" +facebook: + app_id: "" + app_secret: "" From 060d8f9c7bb6b240d6f8b1fc9939e1932f86db5a Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 25 Oct 2010 19:24:48 -0700 Subject: [PATCH 14/22] DG MS; fixed some bugs with posting publicly. --- app/controllers/status_messages_controller.rb | 12 ++++----- app/models/user.rb | 26 +++++++------------ app/views/shared/_publisher.haml | 2 +- .../status_message_controller_spec.rb | 16 +++++------- spec/models/user/posting_spec.rb | 11 ++++---- 5 files changed, 30 insertions(+), 37 deletions(-) diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 89cf59f32..cf6625839 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -9,9 +9,13 @@ class StatusMessagesController < ApplicationController respond_to :json, :only => :show def create + public_flag = params[:status_message][:public] + public_flag.match(/(true)/) ? public_flag = true : public_flag = false + params[:status_message][:public] = public_flag + data = clean_hash params[:status_message] message = params[:status_message][:message] - @status_message = current_user.post(:status_message, data) + status_message = current_user.post(:status_message, data) render :nothing => true end @@ -23,11 +27,7 @@ class StatusMessagesController < ApplicationController def show @status_message = current_user.find_visible_post_by_id params[:id] - unless @status_message - render :status => 404 - else - respond_with @status_message - end + respond_with @status_message end private diff --git a/app/models/user.rb b/app/models/user.rb index 8c179c239..6a184b156 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -155,31 +155,25 @@ class User post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid) push_to_aspects(post, aspect_ids) - if options[:public] + if options[:public] == true self.services.each do |service| - self.send("post_to_#{service.provider}".to_sym) + self.send("post_to_#{service.provider}".to_sym, service, post.message) end end post end - def post_to_facebook(message) - facebook = self.services.find_by_provider("facebook") - if facebook - Rails.logger.info("Sending a message: #{message} to Facebook") - EventMachine::HttpRequest.new("https://graph.facebook.com/me/feed?message=#{message}&access_token=#{facebook.access_token}").post - end + def post_to_facebook(service, message) + Rails.logger.info("Sending a message: #{message} to Facebook") + EventMachine::HttpRequest.new("https://graph.facebook.com/me/feed?message=#{message}&access_token=#{service.access_token}").post end - def post_to_twitter(message) - twitter = self.services.find_by_provider("twitter") - if twitter - oauth = Twitter::OAuth.new(SERVICES['twitter']['consumer_token'], SERVICES['twitter']['consumer_secret']) - oauth.authorize_from_access(twitter.access_token, twitter.access_secret) - client = Twitter::Base.new(oauth) - client.update(message) - end + def post_to_twitter(service, message) + oauth = Twitter::OAuth.new(SERVICES['twitter']['consumer_token'], SERVICES['twitter']['consumer_secret']) + oauth.authorize_from_access(service.access_token, service.access_secret) + client = Twitter::Base.new(oauth) + client.update(message) end def update_post(post, post_hash = {}) diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 5e3be8f2a..4ac7c5392 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -35,7 +35,7 @@ - if aspect == :all .public_toggle - = status.check_box( :public, :value => false ) + = status.check_box( :public, {}, true, false ) make public = link_to '(?)', "#question_mark_pane", :class => 'question_mark' diff --git a/spec/controllers/status_message_controller_spec.rb b/spec/controllers/status_message_controller_spec.rb index 536db40d4..0869972b3 100644 --- a/spec/controllers/status_message_controller_spec.rb +++ b/spec/controllers/status_message_controller_spec.rb @@ -16,35 +16,33 @@ describe StatusMessagesController do end describe '#create' do - let(:status_message_hash) {{"status_message"=>{"public"=>"1", "message"=>"facebook, is that you?", "to" =>"#{aspect.id}"}}} - + let(:status_message_hash) {{"status_message"=>{"public"=>"true", "message"=>"facebook, is that you?", "to" =>"#{aspect.id}"}}} context "posting out to facebook" do - before do - @controller.stub!(:logged_into_fb?).and_return(true) - end + let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s } it 'should post to facebook when public is set' do user.should_receive(:post_to_facebook) post :create, status_message_hash end - it 'should not post to facebook when public in not set' do - status_message_hash['status_message']['public'] = '0' + it 'should not post to facebook when public is not set' do + status_message_hash['status_message']['public'] = 'false' user.should_not_receive(:post_to_facebook) post :create, status_message_hash end end - context "posting to twitter" do + let!(:service1) { s = Factory(:service, :provider => 'twitter'); user.services << s; s } + it 'should post to twitter if public is set' do user.should_receive(:post_to_twitter).and_return(true) post :create, status_message_hash end it 'should not post to twitter when public in not set' do - status_message_hash['status_message']['public'] = '0' + status_message_hash['status_message']['public'] = 'false' user.should_not_receive(:post_to_twitter) post :create, status_message_hash end diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index f21bad8a7..5e1b115ae 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -13,8 +13,8 @@ describe User do let!(:aspect1) { user.aspect(:name => 'other') } let!(:aspect2) { user2.aspect(:name => 'losers') } - let!(:service1) { user.services << Factory(:service, :provider => 'twitter') } - let!(:service2) { user.services << Factory(:service, :provider => 'facebook') } + let!(:service1) { s = Factory(:service, :provider => 'twitter'); user.services << s; s } + let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s } describe '#validate_aspect_permissions' do @@ -56,9 +56,10 @@ describe User do end it "posts to services if post is public" do - user.should_receive(:post_to_twitter).exactly(1).times - user.should_receive(:post_to_facebook).exactly(1).times - user.post :status_message, :message => "hi", :to => "all", :public => true + message = "hello, world!" + user.should_receive(:post_to_twitter).with(service1, message).exactly(1).times + user.should_receive(:post_to_facebook).with(service2, message).exactly(1).times + user.post :status_message, :message => message, :to => "all", :public => true end it "does not post to services if post is not public" do From a1d00d41e50c66d25aec8e98f64fc98fccffcff3 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 25 Oct 2010 19:33:23 -0700 Subject: [PATCH 15/22] deploys back to master --- config/deploy_config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy_config.yml b/config/deploy_config.yml index dda2cc200..06a6747e1 100644 --- a/config/deploy_config.yml +++ b/config/deploy_config.yml @@ -6,7 +6,7 @@ cross_server: deploy_to: '/usr/local/app/diaspora' user: 'root' repo: 'git://github.com/diaspora/diaspora.git' - branch: 'twitter' + branch: 'master' default_env: 'development' servers: tom: From 33410899d9db557b6ad593ad959e30483f82bb18 Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Mon, 25 Oct 2010 21:38:53 -0700 Subject: [PATCH 16/22] Fix for build breakage --- config/initializers/_load_services.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/config/initializers/_load_services.rb b/config/initializers/_load_services.rb index ef41d75a7..e893ce9ae 100644 --- a/config/initializers/_load_services.rb +++ b/config/initializers/_load_services.rb @@ -8,9 +8,12 @@ end oauth_keys_file = "#{Rails.root}/config/oauth_keys.yml" -if File.exist? oauth_keys_file - SERVICES = load_config_yaml(oauth_keys_file) -end - -SERVICES ||= load_config_yaml("#{oauth_keys_file}.example") +SERVICES = nil +silence_warnings do + if File.exist? oauth_keys_file + SERVICES = load_config_yaml(oauth_keys_file) + else + SERVICES = load_config_yaml("#{oauth_keys_file}.example") + end +end \ No newline at end of file From 69fc293829ea42dea3b4963e65e0ed6bbb4ffa1a Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Mon, 25 Oct 2010 21:54:13 -0700 Subject: [PATCH 17/22] CI does a clean checkout --- cruise_config.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/cruise_config.rb b/cruise_config.rb index a5efcd3d7..04b5bb284 100644 --- a/cruise_config.rb +++ b/cruise_config.rb @@ -2,4 +2,5 @@ require 'fileutils' Project.configure do |project| project.build_command = './ci.sh' + project.do_clean_checkout :always end From cd67d38a24ef8fc3b172855b379f4ab39a458f3c Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Mon, 25 Oct 2010 22:00:33 -0700 Subject: [PATCH 18/22] Clean checkout: bad idea. --- cruise_config.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/cruise_config.rb b/cruise_config.rb index 04b5bb284..a5efcd3d7 100644 --- a/cruise_config.rb +++ b/cruise_config.rb @@ -2,5 +2,4 @@ require 'fileutils' Project.configure do |project| project.build_command = './ci.sh' - project.do_clean_checkout :always end From ed99f29a09dea11b637ad01883f321acdd6255b2 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 25 Oct 2010 22:03:36 -0700 Subject: [PATCH 19/22] dont show service if you dont have the keys for it. also, update deploy script --- app/views/services/index.html.haml | 4 ++-- config/deploy.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/services/index.html.haml b/app/views/services/index.html.haml index ea375e9ac..5bec55933 100644 --- a/app/views/services/index.html.haml +++ b/app/views/services/index.html.haml @@ -23,6 +23,6 @@ = service.nickname = link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete - %h4= link_to "Connect to twitter", "/auth/twitter" - %h4= link_to "Connect to facebook", "/auth/facebook" + %h4= link_to "Connect to twitter", "/auth/twitter" if SERVICES['twitter']['consumer_key']!= "" + %h4= link_to "Connect to facebook", "/auth/facebook" if SERVICES['facebook']['app_id'] !="" diff --git a/config/deploy.rb b/config/deploy.rb index b4893ec93..91fab2f85 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -56,9 +56,9 @@ namespace :deploy do run "ln -s -f #{shared_path}/app_config.yml #{current_path}/config/app_config.yml" end - task :symlink_fb_config do - run "touch #{shared_path}/fb_config.yml" - run "ln -s -f #{shared_path}/fb_config.yml #{current_path}/config/fb_config.yml" + task :symlink_oauth_keys_config do + run "touch #{shared_path}/oauth_keys.yml" + run "ln -s -f #{shared_path}/oauth_keys.yml #{current_path}/config/oauth_keys.yml" end task :start do From a992c5fbc218ed8c813240e75b153fed92ef53be Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 25 Oct 2010 22:03:36 -0700 Subject: [PATCH 20/22] dont show service if you dont have the keys for it. also, update deploy script --- app/views/services/index.html.haml | 4 ++-- config/deploy.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/services/index.html.haml b/app/views/services/index.html.haml index ea375e9ac..5bec55933 100644 --- a/app/views/services/index.html.haml +++ b/app/views/services/index.html.haml @@ -23,6 +23,6 @@ = service.nickname = link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete - %h4= link_to "Connect to twitter", "/auth/twitter" - %h4= link_to "Connect to facebook", "/auth/facebook" + %h4= link_to "Connect to twitter", "/auth/twitter" if SERVICES['twitter']['consumer_key']!= "" + %h4= link_to "Connect to facebook", "/auth/facebook" if SERVICES['facebook']['app_id'] !="" diff --git a/config/deploy.rb b/config/deploy.rb index b4893ec93..09d8c0bc3 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -56,9 +56,9 @@ namespace :deploy do run "ln -s -f #{shared_path}/app_config.yml #{current_path}/config/app_config.yml" end - task :symlink_fb_config do - run "touch #{shared_path}/fb_config.yml" - run "ln -s -f #{shared_path}/fb_config.yml #{current_path}/config/fb_config.yml" + task :symlink_oauth_keys_config do + run "touch #{shared_path}/oauth_keys.yml" + run "ln -s -f #{shared_path}/oauth_keys.yml #{current_path}/config/oauth_keys.yml" end task :start do @@ -157,4 +157,4 @@ namespace :db do end -after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config', 'deploy:symlink_fb_config' +after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config', 'deploy:symlink_oauth_keys_config' From af917557f601a06f7056f5edea92a683bd5b54b1 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 25 Oct 2010 22:56:50 -0700 Subject: [PATCH 21/22] can't call match on nil --- app/controllers/status_messages_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index cf6625839..a5c018af2 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -10,7 +10,7 @@ class StatusMessagesController < ApplicationController def create public_flag = params[:status_message][:public] - public_flag.match(/(true)/) ? public_flag = true : public_flag = false + public_flag.to_s.match(/(true)/) ? public_flag = true : public_flag = false params[:status_message][:public] = public_flag data = clean_hash params[:status_message] From ff13cad116edc5875bfd9147ecf697392400008b Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 26 Oct 2010 12:19:32 -0700 Subject: [PATCH 22/22] names of people display immediately on aspect#manage page --- public/javascripts/aspect-edit.js | 4 ++++ public/javascripts/view.js | 1 + 2 files changed, 5 insertions(+) diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 9e565e4b2..4b6f1c421 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -25,8 +25,12 @@ $(function() { revert: true, start: function(event,ui){ $(this).children("img").animate({'height':80, 'width':80, 'opacity':0.8},200); + $(this).children("img").tipsy("hide"); $(".draggable_info").fadeIn(100); }, + drag: function(event,ui){ + $(this).children("img").tipsy("hide"); //ensure this is hidden + }, stop: function(event,ui){ $(this).children("img").animate({'height':70, 'width':70, 'opacity':1},200); $(".draggable_info").fadeOut(100); diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 0b3987d53..26b3fea55 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -76,6 +76,7 @@ $(document).ready(function(){ $("img", "#left_pane").tipsy({live:true}); $(".add_aspect_button", "#aspect_nav").tipsy({gravity:'w'}); + $(".person img", ".dropzone").tipsy({live:true}); });//end document ready