From 19b633d3a3d33b99f0f59434473f46bbbdd2dc9b Mon Sep 17 00:00:00 2001 From: danielvincent Date: Sun, 1 Aug 2010 22:21:57 -0700 Subject: [PATCH 001/198] top nav for groups partially there. --- app/views/layouts/application.html.haml | 31 +++++++++++++++++++----- public/stylesheets/application.css | 24 +++++++++++++++--- public/stylesheets/sass/application.sass | 30 +++++++++++++++++++---- 3 files changed, 70 insertions(+), 15 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 31388333b..4a96e6b2a 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -42,6 +42,28 @@ - else = link_to "login", new_user_session_path + #group + %ul + %li.selected ACM + %li FAMILY + %li WORK + %li HIGH SCHOOL + #user_pictures + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + - for friend in @friends + = person_image_link(friend) + .container - if user_signed_in? #user_name @@ -63,12 +85,9 @@ .container .span-24.last - .span-20.append-1.last - = yield + = yield - .span-3.last - = render 'people/sidebar' if user_signed_in? - .span-24.last - = render "posts/debug" + .span-24.last + = render "posts/debug" diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index c50e1e9ff..b11e56ba1 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -67,24 +67,24 @@ header { margin-bottom: 30px; color: #555555; background-color: #2b2726; + background-color: black; border-bottom: 3px solid #333333; padding: 6px 0; padding-top: 0; } header #diaspora_text { + margin-bottom: 1em; font-family: "BrandonGrotesqueLightRegular"; - font-size: 24px; - position: absolute; + font-size: 16px; border: none; color: white; text-shadow: 0 2px 0 black; } header #diaspora_text a { color: #666666; } header #diaspora_text span.sub_text { - color: black; text-shadow: none; } header #session_action { float: right; - margin-top: 9px; + top: 0; text-shadow: 0 1px 0 black; padding-right: 10px; } header #session_action a { @@ -412,3 +412,19 @@ h1.big_text { .image_cycle img { display: none; } + +#group { + color: #333333; } + #group ul { + font-size: 18px; + margin: 0; + padding: 0; } + #group ul > li { + display: inline; + margin-right: 10px; } + #group ul > li.selected { + color: white; + font-weight: bold; } + #group #user_pictures img { + display: inline-block; + height: 40px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 3490e3b39..0c436867a 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -72,16 +72,18 @@ header :color #555 :background :color #2B2726 + :color #000 :border :bottom 3px solid #333 :padding 6px 0 :top 0 #diaspora_text + :margin + :bottom 1em :font :family 'BrandonGrotesqueLightRegular' - :size 24px - :position absolute + :size 16px :border none :color #fff :text @@ -90,14 +92,12 @@ header :color #666 span.sub_text - :color #000 :text :shadow none #session_action :float right - :margin - :top 9px + :top 0 :text-shadow 0 1px 0 #000 a :color #777 @@ -513,3 +513,23 @@ h1.big_text .image_cycle img :display none + +#group + :color #333 + ul + :font-size 18px + :margin 0 + :padding 0 + > li + :display inline + :margin + :right 10px + + &.selected + :color #fff + :font-weight bold + + #user_pictures + img + :display inline-block + :height 40px From 5974bf357121509ca1fe8854fd6e7f9c3c0cc0f9 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Sun, 1 Aug 2010 22:27:39 -0700 Subject: [PATCH 002/198] group nav is now links to nothing --- app/views/layouts/application.html.haml | 18 ++++++++-------- public/stylesheets/application.css | 24 ++++++++++++++-------- public/stylesheets/sass/application.sass | 26 +++++++++++++++++------- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 4a96e6b2a..9cf9e25c9 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -18,8 +18,7 @@ = csrf_meta_tag = yield(:head) - = javascript_include_tag 'satisfaction' , 'satisfaction-display' - + = javascript_include_tag 'satisfaction', 'satisfaction-display' = javascript_include_tag 'jquery.html5_upload' %body @@ -44,11 +43,11 @@ #group %ul - %li.selected ACM - %li FAMILY - %li WORK - %li HIGH SCHOOL - #user_pictures + %li.selected= link_to "OTHER PRESIDENTS", root_path + %li= link_to "OSTATUS", ostatus_path + /%li= link_to "NEW YORK", "#" + /%li= link_to "NEW CIRCLE", "#" + #friend_pictures = link_to(person_image_tag(current_user), root_path) = link_to(person_image_tag(current_user), root_path) = link_to(person_image_tag(current_user), root_path) @@ -63,6 +62,8 @@ = link_to(person_image_tag(current_user), root_path) - for friend in @friends = person_image_link(friend) + .add_new + = link_to "+", requests_path .container - if user_signed_in? @@ -85,9 +86,6 @@ .container .span-24.last - = yield - - .span-24.last = render "posts/debug" diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index b11e56ba1..357f7bc99 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -84,7 +84,6 @@ header { text-shadow: none; } header #session_action { float: right; - top: 0; text-shadow: 0 1px 0 black; padding-right: 10px; } header #session_action a { @@ -155,9 +154,10 @@ h3 { font-weight: bold; } form { + position: relative; font-size: 120%; margin: 1em; - margin-left: 0em; } + margin-left: 0em; } #user_name { margin-bottom: 20px; } @@ -301,7 +301,8 @@ label { background-color: rgba(10, 81, 109, 0.05); border-bottom: 2px #999999 solid; color: #999999; - padding: 15px 1em; } + padding: 15px 1em; + padding-bottom: 30px; } #new_blog, #new_bookmark { @@ -416,15 +417,22 @@ h1.big_text { #group { color: #333333; } #group ul { - font-size: 18px; margin: 0; - padding: 0; } + padding: 0; + font-size: 14px; } #group ul > li { display: inline; margin-right: 10px; } - #group ul > li.selected { + #group ul > li.selected, #group ul > li.selected a { color: white; - font-weight: bold; } - #group #user_pictures img { + font-weight: bold; + font-size: 18px; } + #group a { + color: #333333; + font-weight: normal; } + #group #friend_pictures .add_new { + display: inline; + font-size: 40px; } + #group #friend_pictures img { display: inline-block; height: 40px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 0c436867a..fe309e07f 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -97,7 +97,6 @@ header #session_action :float right - :top 0 :text-shadow 0 1px 0 #000 a :color #777 @@ -181,11 +180,11 @@ h3 :weight bold form + :position relative :font :size 120% :margin 1em - :margin-left 0em - + :left 0em #user_name :margin @@ -365,6 +364,7 @@ label :bottom 2px #999 solid :color #999 :padding 15px 1em + :bottom 30px #new_blog, #new_bookmark @@ -517,19 +517,31 @@ h1.big_text #group :color #333 ul - :font-size 18px :margin 0 :padding 0 + :font + :size 14px > li :display inline :margin :right 10px - &.selected + &.selected, &.selected a :color #fff - :font-weight bold + :font + :weight bold + :size 18px - #user_pictures + a + :color #333 + :font + :weight normal + + #friend_pictures + .add_new + :display inline + :font + :size 40px img :display inline-block :height 40px From 102b9128784e07136184c7357b283d40707b7cda Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 2 Aug 2010 16:20:30 -0700 Subject: [PATCH 003/198] moved group nav to its own partial --- app/views/layouts/application.html.haml | 28 +++---------------------- app/views/shared/_group_nav.haml | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 25 deletions(-) create mode 100644 app/views/shared/_group_nav.haml diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 4f647d00e..f5400aef9 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -10,8 +10,7 @@ = stylesheet_link_tag "application", "ui", 'bubble' /= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" = javascript_include_tag 'jquery142', 'rails', 'google' - = javascript_include_tag 'tiny_mce/tiny_mce', 'jquery.infieldlabel' - = javascript_include_tag 'jquery.cycle/jquery.cycle.min.js' + = javascript_include_tag 'tiny_mce/tiny_mce', 'jquery.infieldlabel', 'jquery.cycle/jquery.cycle.min.js' = javascript_include_tag 'view', 'publisher', 'image_picker' = render 'js/websocket_js' @@ -40,30 +39,9 @@ = link_to "logout", destroy_user_session_path - else = link_to "login", new_user_session_path + + = render "shared/group_nav" - #group - %ul - %li.selected= link_to "OTHER PRESIDENTS", root_path - %li= link_to "OSTATUS", ostatus_path - /%li= link_to "NEW YORK", "#" - /%li= link_to "NEW CIRCLE", "#" - #friend_pictures - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - - for friend in @friends - = person_image_link(friend) - .add_new - = link_to "+", requests_path .container - if user_signed_in? diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml new file mode 100644 index 000000000..813473c60 --- /dev/null +++ b/app/views/shared/_group_nav.haml @@ -0,0 +1,21 @@ +#group + %ul + %li.selected= link_to "OTHER PRESIDENTS", root_path + %li= link_to "OSTATUS", ostatus_path + #friend_pictures + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + - for friend in @friends + = person_image_link(friend) + .add_new + = link_to "+", requests_path From 3d5f27fe5a49dad74f18bbab576bfe5ad4977a80 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 2 Aug 2010 17:27:45 -0700 Subject: [PATCH 004/198] javascript gets group param for temp testing... friend pictures on group nav displays all people and authors, also for testing --- app/views/layouts/application.html.haml | 2 +- app/views/shared/_group_nav.haml | 21 +++++++-------------- public/javascripts/group_nav.js | 13 +++++++++++++ public/stylesheets/application.css | 12 +++++++++++- public/stylesheets/sass/application.sass | 16 +++++++++++++--- 5 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 public/javascripts/group_nav.js diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f5400aef9..44bce846b 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -11,7 +11,7 @@ /= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" = javascript_include_tag 'jquery142', 'rails', 'google' = javascript_include_tag 'tiny_mce/tiny_mce', 'jquery.infieldlabel', 'jquery.cycle/jquery.cycle.min.js' - = javascript_include_tag 'view', 'publisher', 'image_picker' + = javascript_include_tag 'view', 'publisher', 'image_picker', 'group_nav' = render 'js/websocket_js' = csrf_meta_tag diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index 813473c60..9ba2f6d67 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -1,21 +1,14 @@ #group %ul - %li.selected= link_to "OTHER PRESIDENTS", root_path - %li= link_to "OSTATUS", ostatus_path + %li.other_presidents= link_to "OTHER PRESIDENTS", root_path(:g => "other_presidents") + %li.ostatus= link_to "OSTATUS", ostatus_path(:g => "ostatus") + %li.new_circle= link_to "NEW CIRCLE", "#" + #friend_pictures - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - for friend in @friends = person_image_link(friend) + + -for author in @subscribed_persons + = link_to (image_tag author.avatar_thumbnail, :class => "person_picture"), author_path(author) .add_new = link_to "+", requests_path diff --git a/public/javascripts/group_nav.js b/public/javascripts/group_nav.js new file mode 100644 index 000000000..62b99e18c --- /dev/null +++ b/public/javascripts/group_nav.js @@ -0,0 +1,13 @@ +$(document).ready( function() { + + var vars = [], hash; + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for(var i = 0; i < hashes.length; i++) + { + hash = hashes[i].split('='); + vars.push(hash[0]); + vars[hash[0]] = hash[1]; + } + + $("."+vars['g']).addClass('selected'); +}); diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index dbb9964a0..1ba47cbca 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -431,8 +431,18 @@ h1.big_text { color: #333333; font-weight: normal; } #group #friend_pictures .add_new { - display: inline; + position: relative; + display: inline-block; + height: 40px; + width: 40px; + background-color: #222222; + text-align: center; font-size: 40px; } + #group #friend_pictures .add_new a { + display: block; + position: absolute; + top: -13px; + left: 7px; } #group #friend_pictures img { display: inline-block; height: 40px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 13d2e6dca..bf3441940 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -539,9 +539,19 @@ h1.big_text #friend_pictures .add_new - :display inline - :font - :size 40px + :position relative + :display inline-block + :height 40px + :width 40px + :background + :color #222 + :text-align center + :font-size 40px + a + :display block + :position absolute + :top -13px + :left 7px img :display inline-block :height 40px From f3bc65135963003d686beb3c7f7ff6801c02c060 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 2 Aug 2010 19:16:01 -0700 Subject: [PATCH 005/198] stuff fades --- public/javascripts/group_nav.js | 3 +++ public/stylesheets/application.css | 2 +- public/stylesheets/sass/application.sass | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/public/javascripts/group_nav.js b/public/javascripts/group_nav.js index 62b99e18c..f3d9600bb 100644 --- a/public/javascripts/group_nav.js +++ b/public/javascripts/group_nav.js @@ -10,4 +10,7 @@ $(document).ready( function() { } $("."+vars['g']).addClass('selected'); + + $("#group img").load(function(){$(this).fadeIn("slow");}); + }); diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 7cdcd5beb..929192e13 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -445,5 +445,5 @@ h1.big_text { top: -13px; left: 7px; } #group #friend_pictures img { - display: inline-block; + display: none; height: 40px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index a170bb967..6b7bc1317 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -553,5 +553,5 @@ h1.big_text :top -13px :left 7px img - :display inline-block + :display none :height 40px From c92a2255561c9469a8a60cc7909bc6d29c106940 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 4 Aug 2010 19:22:04 -0700 Subject: [PATCH 006/198] DG MS; user-person relationship done. bunch of failing stuff. --- app/models/person.rb | 55 +++++++++++++++++++++++----- app/models/user.rb | 74 ++++++++++++++++++-------------------- spec/factories.rb | 13 ++++--- spec/models/person_spec.rb | 32 +++++------------ spec/models/user_spec.rb | 1 + 5 files changed, 96 insertions(+), 79 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 276f5a062..ffa1f5b91 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -9,23 +9,27 @@ class Person xml_accessor :profile, :as => Profile - key :email, String + key :email, String, :unique => true key :url, String - key :active, Boolean, :default => false key :key_fingerprint, String + key :owner_id, ObjectId + + belongs_to :owner, :class_name => 'User' one :profile, :class_name => 'Profile' + + many :users, :class_name => 'User' many :posts, :class_name => 'Post', :foreign_key => :person_id many :albums, :class_name => 'Album', :foreign_key => :person_id + timestamps! before_validation :clean_url - validates_presence_of :email, :url, :key_fingerprint + validates_presence_of :email, :url, :key_fingerprint, :profile validates_format_of :url, :with => /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix - validates_true_for :url, :logic => lambda { self.url_unique?} after_destroy :remove_all_traces, :remove_key @@ -45,13 +49,46 @@ class Person GPGME::export(key_fingerprint, :armor => true) end - protected - - def url_unique? - same_url = Person.first(:url => self.url) - return same_url.nil? || same_url.id == self.id + + + + + ######## Posting ######## + def post(class_name, options = {}) + options[:person] = self + model_class = class_name.to_s.camelize.constantize + post = model_class.instantiate(options) end + ######## Commenting ######## + def comment(text, options = {}) + raise "must comment on something!" unless options[:on] + c = Comment.new(:person_id => self.id, :text => text, :post => options[:on]) + if c.save + if mine?(c.post) + c.push_to(c.post.people_with_permissions) # should return plucky query + else + c.push_to([c.post.person]) + end + true + end + false + end + + ##profile + def update_profile(params) + if self.update_attributes(params) + puts self.profile.class + self.profile.notify_people! + true + else + false + end + end + + + + protected def clean_url self.url ||= "http://localhost:3000/" if self.class == User if self.url diff --git a/app/models/user.rb b/app/models/user.rb index ba06815a8..0fe65b719 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,49 +1,36 @@ -class User < Person +class User + include MongoMapper::Document devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable - - before_validation_on_create :assign_key - validates_presence_of :profile + + #before_validation_on_create :assign_key before_validation :do_bad_things - - - - ######## Posting ######## - def post(class_name, options = {}) - options[:person] = self - model_class = class_name.to_s.camelize.constantize - post = model_class.instantiate(options) + one :person, :class_name => 'Person', :foreign_key => :owner_id + + key :friend_ids, Array + key :pending_friend_ids, Array + + + def friends + Person.all(:id => self.friend_ids) end - ######## Commenting ######## - def comment(text, options = {}) - raise "must comment on something!" unless options[:on] - c = Comment.new(:person_id => self.id, :text => text, :post => options[:on]) - if c.save - if mine?(c.post) - c.push_to(c.post.people_with_permissions) # should return plucky query - else - c.push_to([c.post.person]) - end - true - end - false + def pending_friends + Person.all(:id => self.pending_friend_ids) + end + + + def real_name + "#{person.profile.first_name.to_s} #{person.profile.last_name.to_s}" end - ##profile - def update_profile(params) - if self.update_attributes(params) - puts self.profile.class - self.profile.notify_people! - true - else - false - end - end + + + ######### Friend Requesting def send_friend_request_to(friend_url) @@ -86,11 +73,18 @@ class User < Person end def unfriend(friend_id) - bad_friend = Person.first(:id => friend_id, :active => true) + bad_friend = self.friends.first(:id => friend_id) + self.friends.detect{|x| x.id == friend_id}.delete if bad_friend - Retraction.for(self).push_to_url(bad_friend.url) - bad_friend.destroy + + + bad + + + Retraction.for(self).push_to_url(bad_friend.url) + bad_friend.destroy if bad_friend.users.count == 0 end + self.save end def send_request(rel_hash) @@ -125,11 +119,11 @@ class User < Person protected def assign_key - keys = GPGME.list_keys(real_name, true) + keys = GPGME.list_keys(self.real_name, true) if keys.empty? generate_key end - self.key_fingerprint = GPGME.list_keys(real_name, true).first.subkeys.first.fingerprint + self.key_fingerprint = GPGME.list_keys(self.real_name, true).first.subkeys.first.fingerprint end def generate_key diff --git a/spec/factories.rb b/spec/factories.rb index 076ce1782..3a71bb2fc 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -11,21 +11,20 @@ Factory.define :profile do |p| end Factory.define :person do |p| - p.email "bob-person@aol.com" - p.active true - p.sequence(:url) {|n|"http://google-#{n}.com/"} + p.sequence(:email) {|n| "bob-person-#{n}@aol.com"} + p.sequence(:url) {|n| "http://google-#{n}.com/"} p.key_fingerprint GPGME::list_keys("Wesley").first.subkeys.first.fingerprint - p.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" ) + p.profile Factory.create(:profile) end Factory.define :user do |u| u.sequence(:email) {|n| "bob#{n}@aol.com"} u.password "bluepin7" u.password_confirmation "bluepin7" - u.url "www.example.com/" - u.key_fingerprint GPGME.list_keys("Smith", true).first.subkeys.first.fingerprint - u.profile Profile.new( :first_name => "Bob", :last_name => "Smith" ) + + u.person Factory.create(:person) end + Factory.define :status_message do |m| m.sequence(:message) {|n| "jimmy's #{n} whales"} m.person diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 1660371b6..15a53cf80 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -1,17 +1,11 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Person do - it 'should not allow two people with the same url' do + it 'should not allow two people with the same email' do person_one = Factory.create(:person) - person_two = Factory.build(:person, :url => person_one.url) + person_two = Factory.build(:person, :url => person_one.email) person_two.valid?.should == false end - - it 'should not allow a person with the same url as the user' do - user = Factory.create(:user) - person = Factory.build(:person, :url => user.url) - person.valid?.should == false - end it 'should serialize to xml' do person = Factory.create(:person) @@ -25,15 +19,6 @@ describe Person do (xml.include? "first_name").should == true end - it 'should only return active friends' do - Factory.create(:person) - Factory.create(:person, :active => false) - Factory.create(:person, :active => false) - - Person.friends.all.count.should == 1 - end - - it 'should delete all of user except comments upon user deletion' do Factory.create(:user) @@ -57,14 +42,15 @@ describe Person do s.comments.count.should == 4 end - it 'should let a user unfriend another user' do - u = Factory.create(:user) + it 'should let a user unfriend a person' do + user = Factory.create(:user) + person = Factory.create(:person) - f = Factory.create(:person, :active => true) + user.friends << person - Person.friends.all.count.should == 1 - u.unfriend(f.id) - Person.friends.all.count.should == 0 + user.friends.count.should == 1 + user.unfriend(person.id) + user.friends.count.should == 0 Person.all.count.should == 1 end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 1431b1cd5..8124f90bd 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,6 +1,7 @@ require File.dirname(__FILE__) + '/../spec_helper' describe User do + it "should be a person" do n = Person.count Factory.create(:user) From f2d7f35b84b3b904aa5eaa6b426655f4e29f153a Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 4 Aug 2010 20:29:54 -0700 Subject: [PATCH 007/198] unfriend still not removing association from bad_friend --- app/models/person.rb | 3 +-- app/models/user.rb | 20 +++++++++------- spec/factories.rb | 2 +- spec/models/person_spec.rb | 49 +++++++++++++++++++++++++++++++------- 4 files changed, 55 insertions(+), 19 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index ffa1f5b91..9c148b50a 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -33,8 +33,7 @@ class Person after_destroy :remove_all_traces, :remove_key - scope :friends, where(:_type => "Person", :active => true) - + scope :friends, where(:_type => "Person", :active => true) def real_name diff --git a/app/models/user.rb b/app/models/user.rb index 0fe65b719..503b93d9a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -73,18 +73,22 @@ class User end def unfriend(friend_id) - bad_friend = self.friends.first(:id => friend_id) - self.friends.detect{|x| x.id == friend_id}.delete + bad_friend = Person.first(:id => friend_id) + + + puts bad_friend.users.count + + self.friend_ids.delete( friend_id ) + self.save + + + + puts bad_friend.users.count + if bad_friend - - - bad - - Retraction.for(self).push_to_url(bad_friend.url) bad_friend.destroy if bad_friend.users.count == 0 end - self.save end def send_request(rel_hash) diff --git a/spec/factories.rb b/spec/factories.rb index 3a71bb2fc..284a67813 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -22,7 +22,7 @@ Factory.define :user do |u| u.password "bluepin7" u.password_confirmation "bluepin7" - u.person Factory.create(:person) + u.sequence(:person) {|p| Factory.create(:person, :email => "robert-#{p}@grimm.org")} end Factory.define :status_message do |m| diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 15a53cf80..8e8a0f926 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -42,16 +42,49 @@ describe Person do s.comments.count.should == 4 end - it 'should let a user unfriend a person' do - user = Factory.create(:user) - person = Factory.create(:person) + describe "unfriending" do + it 'should delete an orphaned friend' do + user = Factory.create(:user) + user.save + + person = Factory.create(:person) - user.friends << person + person.users << user + user.friend_ids << person.id - user.friends.count.should == 1 - user.unfriend(person.id) - user.friends.count.should == 0 - Person.all.count.should == 1 + Person.all.count.should == 2 + user.friends.count.should == 1 + user.unfriend(person.id) + user.friends.count.should == 0 + Person.all.count.should == 1 + end + + it 'should not delete an un-orphaned friend' do + user_one = Factory.create(:user) + user_two = Factory.create(:user) + + user_one.save + user_two.save + + person = Factory.create(:person) + + person.users << user_one + person.users << user_two + + user_one.friend_ids << person.id + user_two.friend_ids << person.id + + Person.all.count.should == 3 + user_one.friends.count.should == 1 + user_two.friends.count.should == 1 + + user_one.unfriend(person.id) + + user_one.friends.count.should == 0 + user_two.friends.count.should == 1 + + Person.all.count.should == 2 + end end end From d6bc93fb960dae6f489e6dc716c525cdb41efaaa Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 4 Aug 2010 23:47:27 -0700 Subject: [PATCH 008/198] commented out retraction on unfriending due to ROXML messing things up . --- app/models/user.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 503b93d9a..caf8e2941 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,6 @@ class User devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable - #before_validation_on_create :assign_key before_validation :do_bad_things @@ -73,7 +72,7 @@ class User end def unfriend(friend_id) - bad_friend = Person.first(:id => friend_id) + bad_friend = Person.first(:_id => friend_id) puts bad_friend.users.count @@ -81,12 +80,18 @@ class User self.friend_ids.delete( friend_id ) self.save + bad_friend.users.delete( self.id ) + + + puts bad_friend.users.inspect + puts bad_friend.users.count if bad_friend - Retraction.for(self).push_to_url(bad_friend.url) + puts bad_friend.url + #Retraction.for(self).push_to_url(bad_friend.url) bad_friend.destroy if bad_friend.users.count == 0 end end From 42c0b82068a76032b3e1e2e031dd20abec92801a Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 4 Aug 2010 23:54:15 -0700 Subject: [PATCH 009/198] one failing test in Person. i have no idea. --- app/models/user.rb | 8 +++----- spec/models/person_spec.rb | 10 +++++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index caf8e2941..f022066f0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,13 +10,10 @@ class User one :person, :class_name => 'Person', :foreign_key => :owner_id - key :friend_ids, Array key :pending_friend_ids, Array + many :friends, :class_name => 'Person' - def friends - Person.all(:id => self.friend_ids) - end def pending_friends Person.all(:id => self.pending_friend_ids) @@ -76,8 +73,9 @@ class User puts bad_friend.users.count + puts self.friends.inspect - self.friend_ids.delete( friend_id ) + self.friends.delete( friend_id ) self.save bad_friend.users.delete( self.id ) diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 8e8a0f926..553b88489 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -50,7 +50,7 @@ describe Person do person = Factory.create(:person) person.users << user - user.friend_ids << person.id + user.friends << person Person.all.count.should == 2 user.friends.count.should == 1 @@ -68,11 +68,15 @@ describe Person do person = Factory.create(:person) + person.users << user_one person.users << user_two + person.save - user_one.friend_ids << person.id - user_two.friend_ids << person.id + user_one.friends << person + user_two.friends << person + user_one.save + user_two.save Person.all.count.should == 3 user_one.friends.count.should == 1 From 4827953bec250f630ca19ede3af37d1587ff1f62 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 5 Aug 2010 10:29:30 -0700 Subject: [PATCH 010/198] DG MS; person specs are now passing. retraction on unfriend is now uncommented --- app/models/person.rb | 5 +---- app/models/user.rb | 39 +++++++++++++------------------------- spec/models/person_spec.rb | 13 ++++++------- 3 files changed, 20 insertions(+), 37 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 9c148b50a..b7bb371dd 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -14,11 +14,11 @@ class Person key :key_fingerprint, String key :owner_id, ObjectId + key :user_refs, Integer, :default => 0 belongs_to :owner, :class_name => 'User' one :profile, :class_name => 'Profile' - many :users, :class_name => 'User' many :posts, :class_name => 'Post', :foreign_key => :person_id many :albums, :class_name => 'Album', :foreign_key => :person_id @@ -49,9 +49,6 @@ class Person end - - - ######## Posting ######## def post(class_name, options = {}) options[:person] = self diff --git a/app/models/user.rb b/app/models/user.rb index f022066f0..8b9995c46 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,15 +4,17 @@ class User devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable - #before_validation_on_create :assign_key - - before_validation :do_bad_things - - one :person, :class_name => 'Person', :foreign_key => :owner_id - + key :friend_ids, Array key :pending_friend_ids, Array - many :friends, :class_name => 'Person' + one :person, :class_name => 'Person', :foreign_key => :owner_id + many :friends, :in => :friend_ids, :class_name => 'Person' + + #before_validation_on_create :assign_key + before_validation :do_bad_things + + + def pending_friends @@ -24,8 +26,6 @@ class User "#{person.profile.first_name.to_s} #{person.profile.last_name.to_s}" end - - ######### Friend Requesting @@ -71,26 +71,13 @@ class User def unfriend(friend_id) bad_friend = Person.first(:_id => friend_id) - - puts bad_friend.users.count - puts self.friends.inspect - - self.friends.delete( friend_id ) + self.friend_ids.delete( friend_id ) self.save - bad_friend.users.delete( self.id ) - - - puts bad_friend.users.inspect - - - - puts bad_friend.users.count - if bad_friend - puts bad_friend.url - #Retraction.for(self).push_to_url(bad_friend.url) - bad_friend.destroy if bad_friend.users.count == 0 + Retraction.for(self).push_to_url(bad_friend.url) + bad_friend.update_attributes(:user_refs => bad_friend.user_refs - 1) + bad_friend.destroy if bad_friend.user_refs == 0 end end diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 553b88489..ca3b9aead 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -49,8 +49,9 @@ describe Person do person = Factory.create(:person) - person.users << user user.friends << person + person.user_refs += 1 + person.save Person.all.count.should == 2 user.friends.count.should == 1 @@ -68,16 +69,14 @@ describe Person do person = Factory.create(:person) - - person.users << user_one - person.users << user_two - person.save - user_one.friends << person user_two.friends << person user_one.save user_two.save + person.user_refs += 2 + person.save + Person.all.count.should == 3 user_one.friends.count.should == 1 user_two.friends.count.should == 1 @@ -87,7 +86,7 @@ describe Person do user_one.friends.count.should == 0 user_two.friends.count.should == 1 - Person.all.count.should == 2 + Person.all.count.should == 3 end end From dae8f2669209ae1a52c91072b388bf9e81c1a5cb Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 5 Aug 2010 11:56:37 -0700 Subject: [PATCH 011/198] DG MS; fixed most photo specs --- app/models/user.rb | 5 +++-- spec/models/photo_spec.rb | 16 +++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 8b9995c46..8a21f509a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -14,8 +14,9 @@ class User before_validation :do_bad_things - - + def method_missing(method, *args) + self.person.send(method, *args) + end def pending_friends Person.all(:id => self.pending_friend_ids) diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 3920d83b2..403dc463b 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -3,18 +3,19 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Photo do before do @user = Factory.create(:user) + @user.person.save + @fixture_filename = 'bp.jpeg' @fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg' @fail_fixture_name = File.dirname(__FILE__) + '/../fixtures/msg.xml' - @album = Album.create(:name => "foo", :person => @user) - @photo = Photo.new(:person => @user, :album => @album) + @album = Album.create(:name => "foo", :person => @user.person) + @photo = Photo.new(:person => @user.person, :album => @album) end it 'should have a constructor' do image = File.open(@fixture_name) - photo = Photo.instantiate(:person => @user, :album => @album, :user_file => [image]) + photo = Photo.instantiate(:person => @user.person, :album => @album, :user_file => [image]) photo.created_at.nil?.should be false - photo.image.read.nil?.should be false end @@ -27,11 +28,11 @@ describe Photo do end it 'must have an album' do - photo = Photo.new(:person => @user) + photo = Photo.new(:person => @user.person) photo.image = File.open(@fixture_name) photo.save photo.valid?.should be false - photo.album = Album.create(:name => "foo", :person => @user) + photo.album = Album.create(:name => "foo", :person => @user.person) photo.save Photo.first.album.name.should == 'foo' end @@ -49,6 +50,7 @@ describe Photo do @user.profile.image_url = @photo.image.url(:thumb_medium) @user.save + @user.person.save User.first.profile.image_url.should == @photo.image.url(:thumb_medium) @photo.destroy @@ -91,7 +93,7 @@ describe Photo do end it 'should save a signed @photo to GridFS' do - photo = Photo.create(:person => @user, :album => @album, :image => File.open(@fixture_name)) + photo = Photo.create(:person => @user.person, :album => @album, :image => File.open(@fixture_name)) photo.save.should == true photo.verify_creator_signature.should be true end From 67d4aea1dbfdc5efd0bb0657b43f578b8c2b5ea4 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 5 Aug 2010 11:58:39 -0700 Subject: [PATCH 012/198] DG MS; fixed album specs --- spec/models/album_spec.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/models/album_spec.rb b/spec/models/album_spec.rb index b93de4888..f5038ec1c 100644 --- a/spec/models/album_spec.rb +++ b/spec/models/album_spec.rb @@ -4,7 +4,8 @@ describe Album do before do @fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg' @user = Factory.create(:user) - @album = Album.new(:name => "test collection", :person => @user) + @user.person.save + @album = Album.new(:name => "test collection", :person => @user.person) end it 'should belong to a person' do @@ -26,8 +27,8 @@ describe Album do end it 'should contain photos' do - album = Album.create(:name => "test collection", :person => @user) - photo = Factory.build(:photo, :person => @user) + album = Album.create(:name => "test collection", :person => @user.person) + photo = Factory.build(:photo, :person => @user.person) album.photos << photo album.photos.count.should == 1 @@ -36,7 +37,7 @@ describe Album do it 'should remove all photos on album delete' do photos = [] 1.upto 3 do - photo = Photo.new(:person => @user, :album => @album, :created_at => Time.now) + photo = Photo.new(:person => @user.person, :album => @album, :created_at => Time.now) photo.image.store! File.open @fixture_name photos << photo end @@ -51,7 +52,7 @@ describe Album do before do @photos = [] 1.upto 3 do |n| - photo = Photo.new(:person => @user, :album => @album, :created_at => Time.now + n) + photo = Photo.new(:person => @user.person, :album => @album, :created_at => Time.now + n) photo.image.store! File.open @fixture_name @photos << photo end From cc04d4e08d308a1e076decdf988d1f490f31e4fe Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 5 Aug 2010 13:25:31 -0700 Subject: [PATCH 013/198] MS DG; more tests pass after making person have many people --- spec/controllers/dashboards_controller_spec.rb | 3 ++- spec/controllers/publics_controller_spec.rb | 1 + spec/controllers/sockets_controller_spec.rb | 1 + spec/models/comments_spec.rb | 1 + spec/models/post_spec.rb | 13 +++++++------ 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/spec/controllers/dashboards_controller_spec.rb b/spec/controllers/dashboards_controller_spec.rb index b05603fb6..8652223c5 100644 --- a/spec/controllers/dashboards_controller_spec.rb +++ b/spec/controllers/dashboards_controller_spec.rb @@ -3,7 +3,8 @@ require File.dirname(__FILE__) + '/../spec_helper' describe DashboardsController do render_views before do - @user = Factory.create(:user, :profile => Profile.new( :first_name => "bob", :last_name => "smith")) + @user = Factory.create(:user) + @user.person.save request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user) end diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 132210e66..d473ae936 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -5,6 +5,7 @@ describe PublicsController do before do @user = Factory.create(:user, :profile => Profile.new( :first_name => "bob", :last_name => "smith")) + @user.person.save request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user) end diff --git a/spec/controllers/sockets_controller_spec.rb b/spec/controllers/sockets_controller_spec.rb index a5109e356..71310c94e 100644 --- a/spec/controllers/sockets_controller_spec.rb +++ b/spec/controllers/sockets_controller_spec.rb @@ -4,6 +4,7 @@ describe 'SocketsController' do render_views before do @user = Factory.create(:user) + @user.person.save SocketsController.unstub!(:new) #EventMachine::WebSocket.stub!(:start) @controller = SocketsController.new diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index 4f5b79115..d1a7d2135 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -4,6 +4,7 @@ describe Comment do describe "user" do before do @user = Factory.create :user + @user.person.save end it "should be able to comment on his own status" do status = Factory.create(:status_message, :person => @user) diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index aac4898aa..84f8c8299 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Post do before do @user = Factory.create(:user, :email => "bob@aol.com") + @user.person.save end describe 'defaults' do @@ -20,8 +21,8 @@ describe Post do before do @person_one = Factory.create(:person, :email => "some@dudes.com") @person_two = Factory.create(:person, :email => "other@dudes.com") - (2..4).each {|n| Blog.create(:title => "title #{n}", :body => "test #{n}", :person => @person_one)} - (5..8).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @user)} + (2..4).each {|n| Blog.create(:title => "title #{n}", :body => "test #{n}", :person => @person_one.person)} + (5..8).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @user.person)} (9..11).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @person_two)} Factory.create(:status_message) @@ -51,10 +52,10 @@ describe Post do @person_one = Factory.create(:person, :email => "some@dudes.com") @person_two = Factory.create(:person, :email => "other@dudes.com") - Factory.create(:status_message, :message => "puppies", :created_at => Time.now+1, :person => @owner) + Factory.create(:status_message, :message => "puppies", :created_at => Time.now+1, :person => @owner.person) Factory.create(:bookmark, :title => "Reddit", :link => "http://reddit.com", :created_at => Time.now+2, :person => @person_one) Factory.create(:status_message, :message => "kittens", :created_at => Time.now+3, :person => @person_two) - Factory.create(:blog, :title => "Bears", :body => "Bear's body", :created_at => Time.now+4, :person => @owner) + Factory.create(:blog, :title => "Bears", :body => "Bear's body", :created_at => Time.now+4, :person => @owner.person) Factory.create(:bookmark, :title => "Google", :link => "http://google.com", :created_at => Time.now+5, :person => @person_two) end @@ -78,14 +79,14 @@ describe Post do end describe 'xml' do it 'should serialize to xml with its person' do - message = Factory.create(:status_message, :person => @user) + message = Factory.create(:status_message, :person => @user.person) (message.to_xml.to_s.include? @user.email).should == true end end describe 'deletion' do it 'should delete a posts comments on delete' do - post = Factory.create(:status_message, :person => @user) + post = Factory.create(:status_message, :person => @user.person) @user.comment "hey", :on=> post post.destroy Post.all(:id => post.id).empty?.should == true From 7a1011c46cca8fe721281802c2e4df9a0f643243 Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 5 Aug 2010 15:41:32 -0700 Subject: [PATCH 014/198] DG MS; webhook specs fixed --- lib/diaspora/webhooks.rb | 5 ++--- spec/lib/web_hooks_spec.rb | 15 +++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index d6e8513c3..d301c999b 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -18,7 +18,7 @@ module Diaspora def push_to(recipients) unless recipients.empty? - recipients.map!{|x| x = x.url + "receive/"} + recipients.map!{|x| x = x.url + "receive/"} xml = Post.build_xml_for(self) Rails.logger.info("Adding xml for #{self} to message queue to #{recipients}") @@queue.add_post_request( recipients, xml ) @@ -39,8 +39,7 @@ module Diaspora end def people_with_permissions - puts "#{self.person.owner.friends.count} foo" - self.person.owner.friends.all + self.person.owner.friends end def self.build_xml_for(posts) diff --git a/spec/lib/web_hooks_spec.rb b/spec/lib/web_hooks_spec.rb index 6a7c34179..bb1dbc32d 100644 --- a/spec/lib/web_hooks_spec.rb +++ b/spec/lib/web_hooks_spec.rb @@ -9,13 +9,11 @@ describe Diaspora do @user = Factory.create(:user, :email => "bob@aol.com") @user.person.save @person = Factory.create(:person) - @user.friends << @person - @user.save end describe "body" do before do - @post = Factory.create(:status_message, :person => @user.person) + @post = Factory.build(:status_message, :person => @user.person) end it "should add the following methods to Post on inclusion" do @@ -33,8 +31,10 @@ describe Diaspora do @user.friends << Factory.create(:person, :url => "http://www.alice.com/") @user.friends << Factory.create(:person, :url => "http://www.jane.com/") @user.save - - @post.people_with_permissions.should == @user.friends.map{|friend| friend.url + "receive/ "} + + @post.person.owner.reload + + @post.people_with_permissions.should == @user.friends end it "should send an owners post to their people" do @@ -53,7 +53,10 @@ describe Diaspora do it "should ensure one url is created for every person" do 5.times {@user.friends << Factory.create(:person)} @user.save - @post.people_with_permissions.size.should == 6 + + @post.person.owner.reload + + @post.people_with_permissions.size.should == 5 end it "should build an xml object containing multiple Post types" do From 5d924dadf415834f6f02fd2fac20fb654d9a09d3 Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 5 Aug 2010 17:16:51 -0700 Subject: [PATCH 015/198] MS DG; 19 failing specs left --- app/controllers/application_controller.rb | 5 ++--- app/helpers/application_helper.rb | 2 +- app/models/person.rb | 2 +- app/models/post.rb | 11 +--------- app/models/retraction.rb | 4 ++++ lib/diaspora/webhooks.rb | 2 +- lib/message_handler.rb | 2 ++ .../controllers/dashboards_controller_spec.rb | 2 +- spec/controllers/publics_controller_spec.rb | 2 +- spec/helpers/application_helper_spec.rb | 9 +++++++- spec/lib/diaspora_parser_spec.rb | 10 ++++----- spec/models/blogs_spec.rb | 2 +- spec/models/bookmark_spec.rb | 4 ++-- spec/models/comments_spec.rb | 21 +++++++++++-------- spec/models/post_spec.rb | 19 ++++++----------- spec/models/status_message_spec.rb | 2 +- 16 files changed, 48 insertions(+), 51 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c525ad1cd..bb091706b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,9 +16,8 @@ class ApplicationController < ActionController::Base end def set_friends_and_status - @friends = Person.friends.all if current_user - @latest_status_message = StatusMessage.newest(current_user) if current_user - + @friends = current_user.friends if current_user + @latest_status_message = StatusMessage.newest_for(current_user) if current_user end def count_requests diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2e2895fbb..0c4c0b61e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,7 +8,7 @@ module ApplicationHelper end def mine?(post) - post.person == User.owner + post.person.id == current_user.person.id end def type_partial(post) diff --git a/app/models/person.rb b/app/models/person.rb index c87148b70..1dbf8eee7 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -87,7 +87,7 @@ class Person end def mine?(post) - self == post.person + self.id == post.person.id end diff --git a/app/models/post.rb b/app/models/post.rb index 1b4149fdc..fc4fea28c 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -35,19 +35,10 @@ class Post Post.sort(:created_at.desc).all end - def self.newest(person = nil) - return self.last if person.nil? - + def self.newest_for(person) self.first(:person_id => person.id, :order => '_id desc') end - def self.my_newest - self.newest(User.owner) - end - def self.newest_by_email(email) - self.newest(Person.first(:email => email)) - end - #ENCRYPTION before_validation :sign_if_mine validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature} diff --git a/app/models/retraction.rb b/app/models/retraction.rb index 9a07de141..05a207a8a 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -44,6 +44,10 @@ class Retraction object.person.id end end + + def person + Person.first(:id => self.person_id) + end #ENCRYPTION xml_reader :creator_signature diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index d301c999b..972a98cb2 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -39,7 +39,7 @@ module Diaspora end def people_with_permissions - self.person.owner.friends + self.person.owner.friends.all end def self.build_xml_for(posts) diff --git a/lib/message_handler.rb b/lib/message_handler.rb index 4bc54b4c9..db987f418 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -14,6 +14,8 @@ class MessageHandler def add_post_request(destinations, body) b = CGI::escape( body ) + puts body + puts destinations.inspect [*destinations].each{|dest| @queue.push(Message.new(:post, dest, :body => b))} end diff --git a/spec/controllers/dashboards_controller_spec.rb b/spec/controllers/dashboards_controller_spec.rb index 8652223c5..a485d275a 100644 --- a/spec/controllers/dashboards_controller_spec.rb +++ b/spec/controllers/dashboards_controller_spec.rb @@ -12,7 +12,7 @@ describe DashboardsController do sign_in :user, @user Factory.create :person get :index - assigns[:friends].should == Person.friends.all + assigns[:friends].should == @user.friends end end diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index d473ae936..5b84098a4 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -4,7 +4,7 @@ describe PublicsController do render_views before do - @user = Factory.create(:user, :profile => Profile.new( :first_name => "bob", :last_name => "smith")) + @user = Factory.create(:user) @user.person.save request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user) end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index f47856265..28cb8d09a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -6,6 +6,9 @@ describe ApplicationHelper do before do @user = Factory.create(:user) @person = Factory.create(:person) + request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user) + sign_in @user + @user.save end it "should specifiy if a post is not owned user" do @@ -14,7 +17,11 @@ describe ApplicationHelper do end it "should specifiy if a post is owned current user" do - p = Factory.create(:post, :person => @user) + ApplicatonHelper.any_instance.stub!(:current_user).and_return(@user) + p = Factory.create(:post, :person => @user.person) + + puts p.person.id == @user.person.id + mine?(p).should be true end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 10f02f6ef..4b9ecbcb6 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -86,7 +86,7 @@ describe Diaspora::Parser do it 'should be able to correctly handle comments' do person = Factory.create(:person, :email => "test@testing.com") - post = Factory.create(:status_message) + post = Factory.create(:status_message, :person => @user.person) comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!") xml = " @@ -166,12 +166,12 @@ describe Diaspora::Parser do #Build xml for profile, clear profile xml = Post.build_xml_for(person.profile) - reloaded_person = Person.first(:id => id) + reloaded_person = Person.first(:id => id) reloaded_person.profile = nil - reloaded_person.save + reloaded_person.profile.save #Make sure profile is cleared - Person.first(:id=> id).profile.should be nil + Person.first(:id => id).profile.should be nil old_profile.first_name.should == 'bob' #Marshal profile @@ -183,8 +183,6 @@ describe Diaspora::Parser do person.profile.first_name.should == old_profile.first_name person.profile.last_name.should == old_profile.last_name person.profile.image_url.should == old_profile.image_url - - end end end diff --git a/spec/models/blogs_spec.rb b/spec/models/blogs_spec.rb index 270339a85..9be9db74b 100644 --- a/spec/models/blogs_spec.rb +++ b/spec/models/blogs_spec.rb @@ -18,7 +18,7 @@ describe Blog do describe "XML" do it 'should serialize to XML' do - body = Factory.create(:blog, :title => "yessir", :body => "penguins") + body = Factory.create(:blog, :title => "yessir", :body => "penguins", :person => @user.person) body.to_xml.to_s.should include "yessir" body.to_xml.to_s.should include "penguins" end diff --git a/spec/models/bookmark_spec.rb b/spec/models/bookmark_spec.rb index 879408430..f583e0844 100644 --- a/spec/models/bookmark_spec.rb +++ b/spec/models/bookmark_spec.rb @@ -57,8 +57,8 @@ describe Bookmark do describe "XML" do it 'should serialize to XML' do - Factory.create(:user) - message = Factory.create(:bookmark, :title => "Reddit", :link => "http://reddit.com/") + u = Factory.create(:user) + message = Factory.create(:bookmark, :title => "Reddit", :link => "http://reddit.com/", :person => u.person) message.to_xml.to_s.should include "Reddit" message.to_xml.to_s.should include "http://reddit.com/" end diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index d40a35b35..358b46514 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -17,7 +17,7 @@ describe Comment do it "should be able to comment on a person's status" do person= Factory.create :person status = Factory.create(:status_message, :person => person) - @user.person.comment "sup dog", :on => status + @user.comment "sup dog", :on => status StatusMessage.first.comments.first.text.should == "sup dog" StatusMessage.first.comments.first.person.should == @user.person @@ -32,30 +32,33 @@ describe Comment do describe 'comment propagation' do before do @person = Factory.create(:person) - @person_two = Factory.create(:person) - @person_status = Factory.create(:status_message, :person => @person) - @user_status = Factory.create(:status_message, :person => @user.person) + @user.friends << Factory.create(:person) + @user.save + + @person_status = Factory.build(:status_message, :person => @person) + @user_status = Factory.build(:status_message, :person => @user.person) end it "should send a user's comment on a person's post to that person" do Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request) - @user.person.comment "yo", :on => @person_status + @user.comment "yo", :on => @person_status end it 'should send a user comment on his own post to lots of people' do allowed_urls = @user_status.people_with_permissions.map!{|x| x = x.url + "receive/"} - Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request).with(allowed_urls, anything ) - @user.person.comment "yo", :on => @user_status + + Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request).with(allowed_urls, anything) + @user.comment "yo", :on => @user_status end it 'should send a comment a person made on your post to all people' do Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request) - com = Comment.create(:person => @person, :text => "balls", :post => @user_status) + Comment.create(:person => @person, :text => "balls", :post => @user_status) end it 'should not send a comment a person made on a person post to anyone' do Comment.send(:class_variable_get, :@@queue).should_not_receive(:add_post_request) - com = Comment.create(:person => @person, :text => "balls", :post => @person_status) + Comment.create(:person => @person, :text => "balls", :post => @person_status) end end end diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 84f8c8299..c03e2c61c 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -21,7 +21,7 @@ describe Post do before do @person_one = Factory.create(:person, :email => "some@dudes.com") @person_two = Factory.create(:person, :email => "other@dudes.com") - (2..4).each {|n| Blog.create(:title => "title #{n}", :body => "test #{n}", :person => @person_one.person)} + (2..4).each {|n| Blog.create(:title => "title #{n}", :body => "test #{n}", :person => @person_one)} (5..8).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @user.person)} (9..11).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @person_two)} @@ -30,20 +30,13 @@ describe Post do end it "should give the most recent blog title and body from owner" do - blog = Blog.my_newest() - blog.person.email.should == @user.email + blog = Blog.newest_for(@user.person) + blog.person.email.should == @user.person.email blog.class.should == Blog blog.title.should == "title 8" blog.body.should == "test 8" end - - it "should give the most recent blog body for a given email" do - blog = Blog.newest_by_email("some@dudes.com") - blog.person.email.should == @person_one.email - blog.class.should == Blog - blog.title.should == "title 4" - blog.body.should == "test 4" - end + end describe "stream" do @@ -80,14 +73,14 @@ describe Post do describe 'xml' do it 'should serialize to xml with its person' do message = Factory.create(:status_message, :person => @user.person) - (message.to_xml.to_s.include? @user.email).should == true + (message.to_xml.to_s.include? @user.person.email).should == true end end describe 'deletion' do it 'should delete a posts comments on delete' do post = Factory.create(:status_message, :person => @user.person) - @user.comment "hey", :on=> post + @user.comment "hey", :on => post post.destroy Post.all(:id => post.id).empty?.should == true Comment.all(:text => "hey").empty?.should == true diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 4bab96af2..e4d5b0f50 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -18,7 +18,7 @@ describe StatusMessage do describe "XML" do it 'should serialize to XML' do - message = Factory.create(:status_message, :message => "I hate WALRUSES!") + message = Factory.create(:status_message, :message => "I hate WALRUSES!", :person => @user.person) message.to_xml.to_s.should include "I hate WALRUSES!" end From b5cbfab36ea80ef24065fb1654dd3a44f62c6414 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 5 Aug 2010 19:01:45 -0700 Subject: [PATCH 016/198] RS, IZ; Comment spec now passes --- app/models/comment.rb | 18 +++-- app/models/person.rb | 24 ++++-- app/models/post.rb | 1 - lib/message_handler.rb | 3 +- spec/models/comments_spec.rb | 15 ++-- ...elete_status_message_not_testing_websocket | 77 ------------------- 6 files changed, 40 insertions(+), 98 deletions(-) delete mode 100644 test/selenium/post_and_delete_status_message_not_testing_websocket diff --git a/app/models/comment.rb b/app/models/comment.rb index 1808952a8..40e31e257 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -18,7 +18,6 @@ class Comment key :person_id, ObjectId belongs_to :person, :class_name => "Person" - after_save :send_people_comments_on_my_posts after_save :send_to_view @@ -26,6 +25,16 @@ class Comment (self.message == other.message) && (self.person.email == other.person.email) end + def push_upstream + puts "Comment going upstream" + push_to([post.person]) + end + + def push_downstream + puts "Comment going downstream" + push_to(post.people_with_permissions) + end + #ENCRYPTION before_validation :sign_if_mine, :sign_if_my_post @@ -69,13 +78,6 @@ class Comment end end - def send_people_comments_on_my_posts - if User.owner.mine?(self.post) && !(self.person.is_a? User) - self.push_to(self.post.people_with_permissions) - end - end - - def send_to_view SocketsController.new.outgoing(self) end diff --git a/app/models/person.rb b/app/models/person.rb index 1dbf8eee7..612f12a84 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -58,6 +58,9 @@ class Person options[:person] = self model_class = class_name.to_s.camelize.constantize post = model_class.instantiate(options) + if owns?(post) + post.notify_people + end end ######## Commenting ######## @@ -65,16 +68,27 @@ class Person raise "must comment on something!" unless options[:on] c = Comment.new(:person_id => self.id, :text => text, :post => options[:on]) if c.save - if mine?(c.post) - c.push_to(c.post.people_with_permissions) # should return plucky query + if self.owner.nil? + if c.post.person.owner.nil? + #puts "The commenter is not here, and neither is the poster" + elsif c.post.person.owner + #puts "The commenter is not here, and the poster is" + c.push_downstream + end else - c.push_to([c.post.person]) + if owns? c.post + #puts "The commenter is here, and is the poster" + c.push_downstream + else + #puts "The commenter is here, and is not the poster" + c.push_upstream + end end true end false end - + ##profile def update_profile(params) if self.update_attributes(params) @@ -86,7 +100,7 @@ class Person end end - def mine?(post) + def owns?(post) self.id == post.person.id end diff --git a/app/models/post.rb b/app/models/post.rb index fc4fea28c..74fce8881 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -21,7 +21,6 @@ class Post timestamps! after_save :send_to_view - after_save :notify_people before_destroy :propagate_retraction after_destroy :destroy_comments, :remove_from_view diff --git a/lib/message_handler.rb b/lib/message_handler.rb index db987f418..17f11368c 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -13,9 +13,8 @@ class MessageHandler end def add_post_request(destinations, body) + puts "sending to: #{destinations.inspect}" b = CGI::escape( body ) - puts body - puts destinations.inspect [*destinations].each{|dest| @queue.push(Message.new(:post, dest, :body => b))} end diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index 358b46514..3f0d03659 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -34,7 +34,7 @@ describe Comment do @person = Factory.create(:person) @user.friends << Factory.create(:person) @user.save - + @person2 = Factory.create(:person) @person_status = Factory.build(:status_message, :person => @person) @user_status = Factory.build(:status_message, :person => @user.person) end @@ -46,19 +46,24 @@ describe Comment do it 'should send a user comment on his own post to lots of people' do allowed_urls = @user_status.people_with_permissions.map!{|x| x = x.url + "receive/"} - - Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request).with(allowed_urls, anything) + puts allowed_urls + queue = Comment.send(:class_variable_get, :@@queue) + queue.should_receive(:add_post_request).with(allowed_urls, anything) @user.comment "yo", :on => @user_status end it 'should send a comment a person made on your post to all people' do Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request) - Comment.create(:person => @person, :text => "balls", :post => @user_status) + @person.comment "balls", :on => @user_status end + it 'should not send a comment a person made on his own post to anyone' do + Comment.send(:class_variable_get, :@@queue).should_not_receive(:add_post_request) + @person.comment "balls", :on => @person_status + end it 'should not send a comment a person made on a person post to anyone' do Comment.send(:class_variable_get, :@@queue).should_not_receive(:add_post_request) - Comment.create(:person => @person, :text => "balls", :post => @person_status) + @person2.comment "balls", :on => @person_status end end end diff --git a/test/selenium/post_and_delete_status_message_not_testing_websocket b/test/selenium/post_and_delete_status_message_not_testing_websocket deleted file mode 100644 index bb1cbf7da..000000000 --- a/test/selenium/post_and_delete_status_message_not_testing_websocket +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - -post_and_delete_status_message_not_testing_websocket - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
post_and_delete_status_message_not_testing_websocket
open/login
typeuser_passwordevankorth
clickAndWaituser_submit
typestatus_message_messageTHIS IS A RUNNING SELENIUM TEST AAAAAAAAH
clickstatus_message_submit
refreshAndWait
verifyTextPresentTHIS IS A RUNNING SELENIUM TEST AAAAAAAAH
clicklink=Delete
assertConfirmationAre you sure?
refreshAndWait
verifyTextNotPresentTHIS IS A RUNNING SELENIUM TEST AAAAAAAAH
clickAndWaitlink=logout
- - From c54d47337b326b433019a1b014c8c812cbd58ba6 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 6 Aug 2010 00:15:22 -0700 Subject: [PATCH 017/198] updated button style --- app/views/albums/index.html.haml | 4 +- app/views/albums/show.html.haml | 8 ++-- public/javascripts/view.js | 10 +---- public/stylesheets/application.css | 9 ++-- public/stylesheets/sass/application.sass | 6 ++- public/stylesheets/sass/ui.sass | 52 +++++++++++++----------- public/stylesheets/ui.css | 51 +++++++++++------------ 7 files changed, 70 insertions(+), 70 deletions(-) diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 8f3816f3d..2e47295d6 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -2,8 +2,8 @@ .back = link_to "⇧ home", root_path Albums - .button.right#add_album_button - = link_to 'New Album', "#" + .right#add_album_button + = link_to 'New Album', "#", :class => "button" #add_album_box.contextual_pane = render "albums/new_album" diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index 253d94d19..208c3ae2b 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -5,8 +5,8 @@ = @album.name -if mine? @album - .button.right#add_photos_button - = link_to 'Add Photos', '#' + .right#add_photos_button + = link_to 'Add Photos', '#', :class => "button" #add_photo_box.contextual_pane = render "photos/new_photo", :photo => @photo, :album => @album @@ -26,5 +26,5 @@ .back = link_to "⇧ albums", albums_path -if mine? @album - .button.right - = link_to 'Edit Album', edit_album_path(@album) + .right + = link_to 'Edit Album', edit_album_path(@album), :class => "button" diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 5da7a9f9e..5e0f2ef51 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -21,15 +21,7 @@ $(document).ready(function(){ var show_comments_toggle = $(this).parent().prev().children(".show_post_comments"); show_comments_toggle.html("hide comments ("+ ($(this).children().length - 1) + ")"); }; - }); - - $('a').hover(function(){ - if( $(this).children("img").length < 1 ) - $(this).fadeTo(60, 0.5); - }, function(){ - if( $(this).children("img").length < 1 ) - $(this).fadeTo(80, 1); - }); + }); $('#debug_info').click(function() { $('#debug_more').toggle('fast', function() { diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 929192e13..6710c853d 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -12,10 +12,10 @@ body { a { color: #018790; - text-decoration: none; - font-weight: bold; } + text-decoration: none; } a:hover { - color: #018790; } + color: white; + background-color: #018790; } #flash_notice, #flash_error, @@ -377,7 +377,8 @@ h1.big_text { .back { position: absolute; - font-size: 12px; } + font-size: 12px; + font-weight: normal; } #content_bottom { position: relative; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 6b7bc1317..223080f2d 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -13,9 +13,10 @@ a :color #018790 :text :decoration none - :font-weight bold &:hover - :color #018790 + :color #fff + :background + :color #018790 #flash_notice, @@ -464,6 +465,7 @@ h1.big_text :position absolute :font :size 12px + :weight normal #content_bottom :position relative diff --git a/public/stylesheets/sass/ui.sass b/public/stylesheets/sass/ui.sass index 50000a8d3..7a64e4ce6 100644 --- a/public/stylesheets/sass/ui.sass +++ b/public/stylesheets/sass/ui.sass @@ -5,21 +5,22 @@ :display inline - :color #777 + :padding 4px + :font-size 12px :line-height 100% :text-shadow 0 1px 0 #fff - :min-height 14px + :min-height 10px - :background -webkit-gradient(linear, 0% 29%, 0% 85%, from(#FAFAFA), to(#E0E0E0)) - :background -moz-linear-gradient(top, #FAFAFA, #E0E0E0) + :background -webkit-gradient(linear, 0% 29%, 0% 85%, from(#FCFCFC), to(#F6F6F6)) + :background -moz-linear-gradient(top, #FCFCFC, #F6F6F6) - :border 1px solid #ccc - :bottom 1px solid #666 - :left 1px solid #999 - :right 1px solid #999 + :border 1px solid #EEE + :bottom 1px solid #999 + :left 1px solid #ccc + :right 1px solid #ccc :border-radius 3px :-moz-border-radius 3px @@ -27,28 +28,31 @@ :cursor pointer + :box-shadow 0 1px 1px #eee + :-webkit-box-shadow 0 1px 1px #eee + :-moz-box-shadow 0 1px 1px #eee - :box-shadow 0 1px 1px #ccc - :-webkit-box-shadow 0 1px 1px #ccc - :-moz-box-shadow 0 1px 1px #ccc + :font-weight normal - a - :font-weight normal - :color #777 + :color #666 - -.button - :padding 5px + &:hover + :color #666 + :background -webkit-gradient(linear, 0% 29%, 0% 85%, from(#FAFAFA), to(#F0F0F0)) + :background -moz-linear-gradient(top, #FAFAFA, #F0F0F0) &:active - :box-shadow 0 0px 2px #000 - :-webkit-box-shadow 0 0px 2px #000 - :-moz-box-shadow 0 0px 2px #000 - :color #555 + :color #666 + :background -webkit-gradient(linear, 0% 29%, 0% 85%, from(#F0F0F0), to(#FAFAFA)) + :background -moz-linear-gradient(top, #F0F0F0, #FAFAFA) + :border + :top 1px solid #ccc ul.button_set - :padding 5px 0 + :padding + :left 0 + :right 0 > li :padding 5px @@ -75,8 +79,8 @@ ul.button_set :right none .button .selected, .button_set .selected - :background -webkit-gradient(linear, 0% 29%, 0% 85%, from(#E0E0E0), to(#FAFAFA)) - :background -moz-linear-gradient(top, #e0e0e0, #fafafa) + :background -webkit-gradient(linear, 0% 29%, 0% 85%, from(#F0F0F0), to(#FAFAFA)) + :background -moz-linear-gradient(top, #F0F0F0, #fafafa) :border :top 1px solid #aaa diff --git a/public/stylesheets/ui.css b/public/stylesheets/ui.css index 63c8dc0cc..f83cc7957 100644 --- a/public/stylesheets/ui.css +++ b/public/stylesheets/ui.css @@ -2,38 +2,39 @@ font-family: "Lucida Grande", sans-serif; font-style: normal; display: inline; - color: #777777; + padding: 4px; font-size: 12px; line-height: 100%; text-shadow: 0 1px 0 white; - min-height: 14px; - background: -webkit-gradient(linear, 0% 29%, 0% 85%, from(#fafafa), to(#e0e0e0)); - background: -moz-linear-gradient(top, #fafafa, #e0e0e0); - border: 1px solid #cccccc; - border-bottom: 1px solid #666666; - border-left: 1px solid #999999; - border-right: 1px solid #999999; + min-height: 10px; + background: -webkit-gradient(linear, 0% 29%, 0% 85%, from(#fcfcfc), to(#f6f6f6)); + background: -moz-linear-gradient(top, #fcfcfc, #f6f6f6); + border: 1px solid #eeeeee; + border-bottom: 1px solid #999999; + border-left: 1px solid #cccccc; + border-right: 1px solid #cccccc; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; cursor: pointer; - box-shadow: 0 1px 1px #cccccc; - -webkit-box-shadow: 0 1px 1px #cccccc; - -moz-box-shadow: 0 1px 1px #cccccc; } - .button a, .button_set a { - font-weight: normal; - color: #777777; } - -.button { - padding: 5px; } - .button:active { - box-shadow: 0 0px 2px black; - -webkit-box-shadow: 0 0px 2px black; - -moz-box-shadow: 0 0px 2px black; - color: #555555; } + box-shadow: 0 1px 1px #eeeeee; + -webkit-box-shadow: 0 1px 1px #eeeeee; + -moz-box-shadow: 0 1px 1px #eeeeee; + font-weight: normal; + color: #666666; } + .button:hover, .button_set:hover { + color: #666666; + background: -webkit-gradient(linear, 0% 29%, 0% 85%, from(#fafafa), to(#f0f0f0)); + background: -moz-linear-gradient(top, #fafafa, #f0f0f0); } + .button:active, .button_set:active { + color: #666666; + background: -webkit-gradient(linear, 0% 29%, 0% 85%, from(#f0f0f0), to(#fafafa)); + background: -moz-linear-gradient(top, #f0f0f0, #fafafa); + border-top: 1px solid #cccccc; } ul.button_set { - padding: 5px 0; } + padding-left: 0; + padding-right: 0; } ul.button_set > li { padding: 5px; display: inline; @@ -50,8 +51,8 @@ ul.button_set { border-right: none; } .button .selected, .button_set .selected { - background: -webkit-gradient(linear, 0% 29%, 0% 85%, from(#e0e0e0), to(#fafafa)); - background: -moz-linear-gradient(top, #e0e0e0, #fafafa); + background: -webkit-gradient(linear, 0% 29%, 0% 85%, from(#f0f0f0), to(#fafafa)); + background: -moz-linear-gradient(top, #f0f0f0, #fafafa); border-top: 1px solid #aaaaaa; } .right { From 6f1a596dff79ab459a6985fb0324dca8b2ad5e7d Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 6 Aug 2010 00:40:44 -0700 Subject: [PATCH 018/198] small color changes --- app/views/authors/show.html.haml | 4 ++-- app/views/photos/show.html.haml | 8 ++++---- .../status_messages/_status_message.html.haml | 2 +- public/javascripts/view.js | 3 +++ public/stylesheets/application.css | 15 ++++++++------- public/stylesheets/sass/application.sass | 12 +++++++----- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/app/views/authors/show.html.haml b/app/views/authors/show.html.haml index 89b6cd165..fbabf20ce 100644 --- a/app/views/authors/show.html.haml +++ b/app/views/authors/show.html.haml @@ -17,5 +17,5 @@ #content_bottom .back = link_to "⇧ ostatus", ostatus_path - .button.right - = link_to 'Unsubscribe', @author, :confirm => 'Are you sure?', :method => :delete + .right + = link_to 'Unsubscribe', @author, :confirm => 'Are you sure?', :method => :delete, :class => "button" diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 0714ec692..4da35fd36 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -3,8 +3,8 @@ = link_to "⇧ #{@album.name}", album_path(@album) = @photo.image - .button.right - = link_to 'Edit Photo', edit_photo_path(@photo) + .right + = link_to 'Edit Photo', edit_photo_path(@photo), :class => "button" .sub_header = link_to "full size", @photo.image.url @@ -23,8 +23,8 @@ .back = link_to "⇧ #{@album.name}", album_path(@album) -if mine? @album - .button.right - = link_to 'Delete Photo', @photo, :confirm => 'Are you sure?', :method => :delete + .right + = link_to 'Delete Photo', @photo, :confirm => 'Are you sure?', :method => :delete, :class => "button" %h4{:class => "show_post_comments"} = "comments (#{@photo.comments.count})" diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index 5681e9753..954128431 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -14,4 +14,4 @@ - if mine?(post) .destroy_link - = link_to 'Delete', status_message_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true + = link_to 'Delete', status_message_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "delete" diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 5e0f2ef51..c181e3bcc 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -107,5 +107,8 @@ $(document).ready(function(){ $(this).fadeIn("slow"); }); + $(".delete").hover(function(){ + $(this).toggleClass("button"); + }); });//end document ready diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 6710c853d..437ba0fd7 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -12,10 +12,12 @@ body { a { color: #018790; + color: #556270; text-decoration: none; } a:hover { color: white; - background-color: #018790; } + background-color: #018790; + background-color: #556270; } #flash_notice, #flash_error, @@ -107,13 +109,12 @@ header { ul#stream, ul#friend_stream { margin: 0; - padding: 0; - color: #666666; } + padding: 0; } ul#stream > li, ul#friend_stream > li { list-style: none; padding: 15px 0; - border-bottom: 1px solid #f1f1f1; - margin-bottom: 5px; } + margin-bottom: 5px; + border-bottom: 1px solid #eeeeee; } ul#friend_stream > li { padding: 0.2em 0; } @@ -295,7 +296,8 @@ label { color: #999999; position: absolute; top: 3px; - left: 0.48em; } + left: 0.48em; + font-weight: normal; } #publisher { background-color: rgba(10, 81, 109, 0.05); @@ -367,7 +369,6 @@ ul#publisher_content_pickers li { h1.big_text { position: relative; line-height: auto; - border-top: 2px solid #666666; border-bottom: 1px solid #666666; text-align: center; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 223080f2d..f84d8b0c3 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -11,13 +11,14 @@ body :margin 0 a :color #018790 + :color #556270 :text :decoration none &:hover :color #fff :background :color #018790 - + :color #556270 #flash_notice, #flash_error, @@ -121,13 +122,12 @@ header ul#stream, ul#friend_stream :margin 0 :padding 0 - :color #666 > li :list-style none :padding 15px 0 - :border - :bottom 1px solid #f1f1f1 :margin-bottom 5px + :border + :bottom 1px solid #eee ul#friend_stream > li @@ -356,6 +356,8 @@ label :position absolute :top 3px :left 0.48em + :font + :weight normal #publisher :background @@ -451,7 +453,7 @@ h1.big_text :position relative :line-height auto :border - :top 2px solid #666 + //:top 2px solid #666 :bottom 1px solid #666 :text :align center From 6449d206870c2318b7a3a03abe8f39cfd9a76c1a Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 6 Aug 2010 11:19:40 -0700 Subject: [PATCH 019/198] Working on devise mocking in helper specs --- spec/helpers/application_helper_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 28cb8d09a..cfece45ed 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,12 +1,11 @@ require File.dirname(__FILE__) + '/../spec_helper' include ApplicationHelper - describe ApplicationHelper do before do @user = Factory.create(:user) @person = Factory.create(:person) - request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user) + #env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user) sign_in @user @user.save end @@ -17,7 +16,6 @@ describe ApplicationHelper do end it "should specifiy if a post is owned current user" do - ApplicatonHelper.any_instance.stub!(:current_user).and_return(@user) p = Factory.create(:post, :person => @user.person) puts p.person.id == @user.person.id From d130b82e425538b036621b5839ec758ffcacbec9 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 6 Aug 2010 11:52:33 -0700 Subject: [PATCH 020/198] RS, IZ; ApplicationHelper specs now passed, specs for mine? moved into person spec as specs for owns? --- app/helpers/application_helper.rb | 2 +- .../controllers/dashboards_controller_spec.rb | 3 +- spec/helpers/application_helper_spec.rb | 15 ----- spec/models/person_spec.rb | 59 +++++++++++-------- 4 files changed, 37 insertions(+), 42 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0c4c0b61e..69011b563 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,7 +8,7 @@ module ApplicationHelper end def mine?(post) - post.person.id == current_user.person.id + current_user.owns? post end def type_partial(post) diff --git a/spec/controllers/dashboards_controller_spec.rb b/spec/controllers/dashboards_controller_spec.rb index a485d275a..6e1138a35 100644 --- a/spec/controllers/dashboards_controller_spec.rb +++ b/spec/controllers/dashboards_controller_spec.rb @@ -1,10 +1,11 @@ require File.dirname(__FILE__) + '/../spec_helper' - +include ApplicationHelper describe DashboardsController do render_views before do @user = Factory.create(:user) @user.person.save + @person = Factory.create(:person) request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user) end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index cfece45ed..d03987740 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -5,23 +5,8 @@ describe ApplicationHelper do before do @user = Factory.create(:user) @person = Factory.create(:person) - #env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user) - sign_in @user - @user.save end - it "should specifiy if a post is not owned user" do - p = Factory.create(:post, :person => @person) - mine?(p).should be false - end - - it "should specifiy if a post is owned current user" do - p = Factory.create(:post, :person => @user.person) - - puts p.person.id == @user.person.id - - mine?(p).should be true - end it "should provide a correct show path for a given person" do person_url(@person).should == "/people/#{@person.id}" diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index ca3b9aead..6fcd775d3 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -1,39 +1,50 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Person do + before do + @person = Factory.create(:person) + end it 'should not allow two people with the same email' do - person_one = Factory.create(:person) - person_two = Factory.build(:person, :url => person_one.email) + person_two = Factory.build(:person, :url => @person.email) person_two.valid?.should == false end - it 'should serialize to xml' do - person = Factory.create(:person) - xml = person.to_xml.to_s - (xml.include? "person").should == true - end + describe 'xml' do + before do + @xml = @person.to_xml.to_s + end + it 'should serialize to xml' do + (@xml.include? "person").should == true + end - it 'should have a profile in its xml' do - person = Factory.create(:person) - xml = person.to_xml.to_s - (xml.include? "first_name").should == true + it 'should have a profile in its xml' do + (@xml.include? "first_name").should == true + end + end + + it 'should know when a post belongs to it' do + person_message = Factory.create(:status_message, :person => @person) + person_two = Factory.create(:person) + + @person.owns?(person_message).should be true + person_two.owns?(person_message).should be false end it 'should delete all of user except comments upon user deletion' do Factory.create(:user) f = Factory.create(:person) - p = Factory.create(:person) + Factory.create(:status_message, :person => f) Factory.create(:blog, :person => f) Factory.create(:bookmark, :person => f) Factory.create(:status_message, :person => f) - s = Factory.create(:status_message, :person => p) + s = Factory.create(:status_message, :person => @person) Factory.create(:comment, :person_id => f.id, :text => "yes i do", :post => s) Factory.create(:comment, :person_id => f.id, :text => "i love you", :post => s) Factory.create(:comment, :person_id => f.id, :text => "hello", :post => s) - Factory.create(:comment, :person_id => p.id, :text => "you are creepy", :post => s) + Factory.create(:comment, :person_id => @person.id, :text => "you are creepy", :post => s) f.destroy @@ -47,15 +58,14 @@ describe Person do user = Factory.create(:user) user.save - person = Factory.create(:person) - user.friends << person - person.user_refs += 1 - person.save + user.friends << @person + @person.user_refs += 1 + @person.save Person.all.count.should == 2 user.friends.count.should == 1 - user.unfriend(person.id) + user.unfriend(@person.id) user.friends.count.should == 0 Person.all.count.should == 1 end @@ -67,21 +77,20 @@ describe Person do user_one.save user_two.save - person = Factory.create(:person) - user_one.friends << person - user_two.friends << person + user_one.friends << @person + user_two.friends << @person user_one.save user_two.save - person.user_refs += 2 - person.save + @person.user_refs += 2 + @person.save Person.all.count.should == 3 user_one.friends.count.should == 1 user_two.friends.count.should == 1 - user_one.unfriend(person.id) + user_one.unfriend(@person.id) user_one.friends.count.should == 0 user_two.friends.count.should == 1 From 62e6ea07567267cbd46318e7ee7261939addd783 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 6 Aug 2010 12:14:51 -0700 Subject: [PATCH 021/198] Error rescue in parser now is specific to not a real type error --- lib/diaspora/parser.rb | 12 +++++++++--- spec/lib/diaspora_parser_spec.rb | 1 + spec/models/retraction_spec.rb | 7 +++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index 07439dbb9..b404fe3fc 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -22,7 +22,8 @@ module Diaspora body.children.each do |post| begin object = post.name.camelize.constantize.from_xml post.to_s - if object.respond_to? :person + if object.is_a? Retraction + elsif object.respond_to? :person object.person = parse_owner_from_xml post.to_s elsif object.is_a? Profile puts "got into parse objects from xml PROFILE" @@ -31,8 +32,12 @@ module Diaspora person.save end objects << object - rescue - Rails.logger.info "Not a real type: #{object.to_s}" + rescue NameError => e + if e.message.include? 'wrong constant name' + Rails.logger.info "Not a real type: #{object.to_s}" + else + raise e + end end end objects @@ -43,6 +48,7 @@ module Diaspora objects.each do |p| Rails.logger.info("Receiving object:\n#{p.inspect}") if p.is_a? Retraction + puts "Got a retraction for #{p.post_id}" p.perform elsif p.is_a? Request User.owner.receive_friend_request(p) diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 4b9ecbcb6..6b1578e68 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -105,6 +105,7 @@ describe Diaspora::Parser do message = Factory.create(:status_message, :person => person) retraction = Retraction.for(message) request = Post.build_xml_for( [retraction] ) + puts request StatusMessage.count.should == 1 store_objects_from_xml( request ) diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index 276a74cb6..f33557eda 100644 --- a/spec/models/retraction_spec.rb +++ b/spec/models/retraction_spec.rb @@ -1,23 +1,22 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Retraction do - describe "posts" do before do @user = Factory.create(:user) @post = Factory.create(:status_message, :person => @user) end - + describe 'serialization' do it 'should have a post id after serialization' do retraction = Retraction.for(@post) xml = retraction.to_xml.to_s xml.include?(@post.id.to_s).should == true end - + end + describe 'dispatching' do it 'should dispatch a message on delete' do Factory.create(:person) Post.send(:class_variable_get, :@@queue).should_receive(:add_post_request) @post.destroy end - end end From 5b14c4822c3ef514dd9557be756b6f5394d13dc2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 6 Aug 2010 12:19:24 -0700 Subject: [PATCH 022/198] RS, IZ; webhooks spec should use user.post --- spec/lib/web_hooks_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/lib/web_hooks_spec.rb b/spec/lib/web_hooks_spec.rb index bb1dbc32d..71e3ed71f 100644 --- a/spec/lib/web_hooks_spec.rb +++ b/spec/lib/web_hooks_spec.rb @@ -40,6 +40,7 @@ describe Diaspora do it "should send an owners post to their people" do q = Post.send(:class_variable_get, :@@queue) q.should_receive :process + @user.post :status_message, :message => "hi" @post.save end From 0f596af5c4c2e3a43ba00cdf5b128f2a1205b7db Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 6 Aug 2010 13:13:00 -0700 Subject: [PATCH 023/198] Refactored message_queue getting, fixed retraction spec --- app/models/person.rb | 1 + app/models/post.rb | 1 + app/models/retraction.rb | 2 ++ lib/diaspora/webhooks.rb | 3 ++- spec/controllers/sockets_controller_spec.rb | 5 +++-- spec/lib/web_hooks_spec.rb | 4 +--- spec/models/comments_spec.rb | 13 ++++++------- spec/models/photo_spec.rb | 4 ++-- spec/models/retraction_spec.rb | 8 ++++++-- spec/models/user_spec.rb | 3 +-- spec/spec_helper.rb | 4 ++++ spec/user_encryption_spec.rb | 4 ++-- 12 files changed, 31 insertions(+), 21 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 612f12a84..adc7addaa 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -61,6 +61,7 @@ class Person if owns?(post) post.notify_people end + post end ######## Commenting ######## diff --git a/app/models/post.rb b/app/models/post.rb index 74fce8881..6fc92d1ae 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -72,6 +72,7 @@ protected end def propagate_retraction + puts 'propagating retraction' Retraction.for(self).notify_people end diff --git a/app/models/retraction.rb b/app/models/retraction.rb index 05a207a8a..a49282a0b 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -8,7 +8,9 @@ class Retraction retraction.post_id= object.id retraction.person_id = person_id_from(object) retraction.type = object.class.to_s + puts retraction.inspect retraction + end xml_accessor :post_id diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index 972a98cb2..de9a46900 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -7,7 +7,7 @@ module Diaspora @@queue = MessageHandler.new def notify_people - if self.person_id == User.owner.person.id + unless self.person.owner.nil? push_to(people_with_permissions) end end @@ -17,6 +17,7 @@ module Diaspora end def push_to(recipients) + puts "recipients are #{recipients.inspect}" unless recipients.empty? recipients.map!{|x| x = x.url + "receive/"} xml = Post.build_xml_for(self) diff --git a/spec/controllers/sockets_controller_spec.rb b/spec/controllers/sockets_controller_spec.rb index aba8d9f52..6c4dac866 100644 --- a/spec/controllers/sockets_controller_spec.rb +++ b/spec/controllers/sockets_controller_spec.rb @@ -4,10 +4,11 @@ describe 'SocketsController' do render_views before do @user = Factory.create(:user) - @user.person.save SocketsController.unstub!(:new) #EventMachine::WebSocket.stub!(:start) @controller = SocketsController.new + @controller.request = mock_model(Request, :env => + {'warden' => mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)}) stub_sockets_controller end @@ -22,7 +23,7 @@ describe 'SocketsController' do end describe 'actionhash' do before do - @message = Factory.create(:status_message, :person => @user) + @message = @user.post :status_message, :message => "post through user for victory" end it 'should actionhash posts' do diff --git a/spec/lib/web_hooks_spec.rb b/spec/lib/web_hooks_spec.rb index 71e3ed71f..32a8d4cb0 100644 --- a/spec/lib/web_hooks_spec.rb +++ b/spec/lib/web_hooks_spec.rb @@ -38,10 +38,8 @@ describe Diaspora do end it "should send an owners post to their people" do - q = Post.send(:class_variable_get, :@@queue) - q.should_receive :process + message_queue.should_receive :process @user.post :status_message, :message => "hi" - @post.save end it "should check that it does not send a person's post to an owners people" do diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index 3f0d03659..5dc7ca2c2 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -25,7 +25,7 @@ describe Comment do it 'should not send out comments when we have no people' do status = Factory.create(:status_message, :person => @user.person) - Comment.send(:class_variable_get, :@@queue).should_not_receive(:add_post_request) + message_queue.should_not_receive(:add_post_request) @user.comment "sup dog", :on => status end @@ -40,29 +40,28 @@ describe Comment do end it "should send a user's comment on a person's post to that person" do - Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request) + message_queue.should_receive(:add_post_request) @user.comment "yo", :on => @person_status end it 'should send a user comment on his own post to lots of people' do allowed_urls = @user_status.people_with_permissions.map!{|x| x = x.url + "receive/"} puts allowed_urls - queue = Comment.send(:class_variable_get, :@@queue) - queue.should_receive(:add_post_request).with(allowed_urls, anything) + message_queue.should_receive(:add_post_request).with(allowed_urls, anything) @user.comment "yo", :on => @user_status end it 'should send a comment a person made on your post to all people' do - Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request) + message_queue.should_receive(:add_post_request) @person.comment "balls", :on => @user_status end it 'should not send a comment a person made on his own post to anyone' do - Comment.send(:class_variable_get, :@@queue).should_not_receive(:add_post_request) + message_queue.should_not_receive(:add_post_request) @person.comment "balls", :on => @person_status end it 'should not send a comment a person made on a person post to anyone' do - Comment.send(:class_variable_get, :@@queue).should_not_receive(:add_post_request) + message_queue.should_not_receive(:add_post_request) @person2.comment "balls", :on => @person_status end end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 403dc463b..6b57913d4 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -19,7 +19,7 @@ describe Photo do photo.image.read.nil?.should be false end - it 'should save a @photo to GridFS' do + it 'should save a photo to GridFS' do @photo.image.store! File.open(@fixture_name) @photo.save.should == true binary = @photo.image.read @@ -92,7 +92,7 @@ describe Photo do stub_signature_verification end - it 'should save a signed @photo to GridFS' do + it 'should save a signed photo to GridFS' do photo = Photo.create(:person => @user.person, :album => @album, :image => File.open(@fixture_name)) photo.save.should == true photo.verify_creator_signature.should be true diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index f33557eda..9ccaa1c5e 100644 --- a/spec/models/retraction_spec.rb +++ b/spec/models/retraction_spec.rb @@ -3,7 +3,11 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Retraction do before do @user = Factory.create(:user) - @post = Factory.create(:status_message, :person => @user) + @user.person.save + @post = @user.post(:status_message, :message => "Destroy!") + @person = Factory.create(:person) + @user.friends << @person + @user.save end describe 'serialization' do it 'should have a post id after serialization' do @@ -15,7 +19,7 @@ describe Retraction do describe 'dispatching' do it 'should dispatch a message on delete' do Factory.create(:person) - Post.send(:class_variable_get, :@@queue).should_receive(:add_post_request) + message_queue.should_receive(:add_post_request) @post.destroy end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 0356a06ee..ea24f1bd7 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -55,8 +55,7 @@ describe User do updated_profile = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clown.com"}} - queue = Profile.send :class_variable_get, :@@queue - queue.should_receive(:process) + message_queue.should_receive(:process) @user.person.update_profile(updated_profile).should == true @user.profile.image_url.should == "http://clown.com" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9eba3000c..fb730c6db 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -71,3 +71,7 @@ end end models end + + def message_queue + Post.send(:class_variable_get, :@@queue) + end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 729920af2..1506a123d 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -36,8 +36,8 @@ describe 'user encryption' do @user.key.should_not be nil end describe 'key exchange on friending' do - it 'should send over a public key' do - Comment.send(:class_variable_get, :@@queue).stub!(:add_post_request) + it 'should send over a public key' do + message_queue.stub!(:add_post_request) request = @user.send_friend_request_to("http://example.com/") Request.build_xml_for([request]).include?( @user.export_key).should be true end From f2e327d908802b12386bc3e2ca2621db7716ffe3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 6 Aug 2010 13:27:42 -0700 Subject: [PATCH 024/198] User factory now works --- app/models/post.rb | 1 - app/models/retraction.rb | 1 - lib/diaspora/webhooks.rb | 1 - spec/factories.rb | 6 ++++-- spec/misc_spec.rb | 5 +++++ spec/models/retraction_spec.rb | 1 - 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 6fc92d1ae..74fce8881 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -72,7 +72,6 @@ protected end def propagate_retraction - puts 'propagating retraction' Retraction.for(self).notify_people end diff --git a/app/models/retraction.rb b/app/models/retraction.rb index a49282a0b..fcd461059 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -8,7 +8,6 @@ class Retraction retraction.post_id= object.id retraction.person_id = person_id_from(object) retraction.type = object.class.to_s - puts retraction.inspect retraction end diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index de9a46900..929dff515 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -17,7 +17,6 @@ module Diaspora end def push_to(recipients) - puts "recipients are #{recipients.inspect}" unless recipients.empty? recipients.map!{|x| x = x.url + "receive/"} xml = Post.build_xml_for(self) diff --git a/spec/factories.rb b/spec/factories.rb index 4da77078c..88f34e1f6 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -20,12 +20,14 @@ Factory.define :person_with_private_key, :parent => :person do |p| p.serialized_key OpenSSL::PKey::RSA.generate(1024).export end +Factory.define :person_with_user, :parent => :person_with_private_key do |p| +end + Factory.define :user do |u| u.sequence(:email) {|n| "bob#{n}@aol.com"} u.password "bluepin7" u.password_confirmation "bluepin7" - - u.sequence(:person) {|p| Factory.create(:person_with_private_key, :email => "robert-#{p}@grimm.org")} + u.person { |a| Factory.create(:person_with_user, :owner_id => a._id)} end Factory.define :status_message do |m| diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index 773b8c6d9..9e9d61efa 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -12,6 +12,11 @@ describe 'making sure the spec runner works' do User.count.should == 0 end + it 'should factory create a user with a person saved' do + user = Factory.create(:user) + loaded_user = User.first(:id => user.id) + loaded_user.person.owner_id.should == user.id + end describe 'testing a before do block' do before do Factory.create(:user) diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index 9ccaa1c5e..da11dbfae 100644 --- a/spec/models/retraction_spec.rb +++ b/spec/models/retraction_spec.rb @@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Retraction do before do @user = Factory.create(:user) - @user.person.save @post = @user.post(:status_message, :message => "Destroy!") @person = Factory.create(:person) @user.friends << @person From 4350e1765674680f28ecd3799d99aac58e242a43 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 6 Aug 2010 16:01:39 -0700 Subject: [PATCH 025/198] RS, IZ; removed lots of putses, fixed up request, parser, retractions --- app/controllers/publics_controller.rb | 2 +- app/helpers/sockets_helper.rb | 5 ++-- app/models/comment.rb | 3 -- app/models/person.rb | 1 - app/models/request.rb | 9 ++++-- app/models/retraction.rb | 11 +++++-- app/models/user.rb | 21 +++++++------- lib/diaspora/parser.rb | 7 ++--- lib/message_handler.rb | 1 - spec/lib/diaspora_parser_spec.rb | 10 ++++--- spec/lib/message_handler_spec.rb | 1 - spec/models/comments_spec.rb | 1 - spec/models/photo_spec.rb | 1 - spec/models/user_spec.rb | 41 ++++++++++++++++++++++----- 14 files changed, 71 insertions(+), 43 deletions(-) diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index 128999d09..0582e4571 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -18,7 +18,7 @@ class PublicsController < ApplicationController end def receive - puts "SOMEONE JUST SENT ME: #{params[:xml]}" + Rails.logger.info "PublicsController has received: #{params[:xml]}" store_objects_from_xml params[:xml] render :nothing => true end diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb index f13576306..cbb913b23 100644 --- a/app/helpers/sockets_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -13,9 +13,8 @@ module SocketsHelper begin v = render_to_string(:partial => type_partial(object), :locals => {:post => object}) unless object.is_a? Retraction rescue Exception => e - puts "web socket view rendering failed for some reason." + v.inspect - puts object.inspect - puts e.message + Rails.logger.error ("web socket view rendering failed for some reason." + v.inspect) + Rails.logger.error("Socketed object was #{object.inspect}") raise e end action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)} diff --git a/app/models/comment.rb b/app/models/comment.rb index 40e31e257..b48a1c228 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -26,12 +26,10 @@ class Comment end def push_upstream - puts "Comment going upstream" push_to([post.person]) end def push_downstream - puts "Comment going downstream" push_to(post.people_with_permissions) end @@ -63,7 +61,6 @@ class Comment def verify_post_creator_signature unless person == User.owner - puts "verifying post creator sig from #{post.person.real_name}" verify_signature(post_creator_signature, post.person) else true diff --git a/app/models/person.rb b/app/models/person.rb index adc7addaa..249552fd1 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -93,7 +93,6 @@ class Person ##profile def update_profile(params) if self.update_attributes(params) - puts self.profile.class self.profile.notify_people! true else diff --git a/app/models/request.rb b/app/models/request.rb index 2665a3693..e8b073aa6 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -32,17 +32,20 @@ class Request person = options[:from] self.new(:destination_url => options[:to], :callback_url => person.url, :person => person, :exported_key => person.export_key) end + + def activate_friend from_user = Person.first(:url => self.callback_url).owner - puts from_user.inspect - from_user.friends << from_user.pending_friends.delete(person) + from_user.pending_friends.delete(person) + + from_user.friends << person + from_user.save end def set_pending_friend p = Person.first(:id => self.person.id) - puts p.inspect self.person.save #save pending friend end diff --git a/app/models/retraction.rb b/app/models/retraction.rb index fcd461059..6ade21ec7 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -5,11 +5,15 @@ class Retraction def self.for(object) retraction = self.new - retraction.post_id= object.id + if object.is_a? User + retraction.post_id = object.person.id + retraction.type = object.person.class.to_s + else + retraction.post_id= object.id + retraction.type = object.class.to_s + end retraction.person_id = person_id_from(object) - retraction.type = object.class.to_s retraction - end xml_accessor :post_id @@ -23,6 +27,7 @@ class Retraction def perform begin return unless signature_valid? + Rails.logger.info("Retracting #{self.type} id: #{self.post_id}") self.type.constantize.destroy(self.post_id) rescue NameError Rails.logger.info("Retraction for unknown type recieved.") diff --git a/app/models/user.rb b/app/models/user.rb index 017d31a05..0a2912d46 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,7 +8,9 @@ class User key :pending_friend_ids, Array one :person, :class_name => 'Person', :foreign_key => :owner_id + many :friends, :in => :friend_ids, :class_name => 'Person' + many :pending_friends, :in => :pending_friend_ids, :class_name => 'Person' before_validation_on_create :assign_key before_validation :do_bad_things @@ -20,10 +22,6 @@ class User self.person.send(method, *args) end - def pending_friends - Person.all(:id => self.pending_friend_ids) - end - def real_name "#{person.profile.first_name.to_s} #{person.profile.last_name.to_s}" @@ -38,13 +36,15 @@ class User if p.save p.push_to_url friend_url end - p + p end end def accept_friend_request(friend_request_id) request = Request.where(:id => friend_request_id).first - request.activate_friend + pending_friends.delete(request.person) + friends << request.person + request.person = self request.exported_key = self.export_key request.destination_url = request.callback_url @@ -55,7 +55,8 @@ class User def ignore_friend_request(friend_request_id) request = Request.first(:id => friend_request_id) person = request.person - person.destroy unless self.friends.include? person + pending_friends.delete(request.person) + person.destroy unless person.user_refs > 0 request.destroy end @@ -65,12 +66,12 @@ class User friend_request.person.serialized_key = friend_request.exported_key if Request.where(:callback_url => friend_request.callback_url).first friend_request.activate_friend + Rails.logger.info("#{self.real_name}'s friend request has been accepted") friend_request.destroy else friend_request.person.save - - friend_request.create_pending_friend - + pending_friends << friend_request.person + Rails.logger.info("#{self.real_name} has received a friend request") friend_request.save end end diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index b404fe3fc..265e44912 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -23,13 +23,12 @@ module Diaspora begin object = post.name.camelize.constantize.from_xml post.to_s if object.is_a? Retraction - elsif object.respond_to? :person - object.person = parse_owner_from_xml post.to_s elsif object.is_a? Profile - puts "got into parse objects from xml PROFILE" person = parse_owner_id_from_xml post person.profile = object person.save + elsif object.respond_to? :person + object.person = parse_owner_from_xml post.to_s end objects << object rescue NameError => e @@ -48,7 +47,7 @@ module Diaspora objects.each do |p| Rails.logger.info("Receiving object:\n#{p.inspect}") if p.is_a? Retraction - puts "Got a retraction for #{p.post_id}" + Rails.logger.info "Got a retraction for #{p.post_id}" p.perform elsif p.is_a? Request User.owner.receive_friend_request(p) diff --git a/lib/message_handler.rb b/lib/message_handler.rb index 17f11368c..4bc54b4c9 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -13,7 +13,6 @@ class MessageHandler end def add_post_request(destinations, body) - puts "sending to: #{destinations.inspect}" b = CGI::escape( body ) [*destinations].each{|dest| @queue.push(Message.new(:post, dest, :body => b))} end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 6b1578e68..91fdd5d99 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -105,7 +105,6 @@ describe Diaspora::Parser do message = Factory.create(:status_message, :person => person) retraction = Retraction.for(message) request = Post.build_xml_for( [retraction] ) - puts request StatusMessage.count.should == 1 store_objects_from_xml( request ) @@ -141,11 +140,14 @@ describe Diaspora::Parser do @person.destroy request_remote.destroy store_objects_from_xml(xml) - Person.first(:url => @person.url).active.should be true + new_person = Person.first(:url => @person.url) + new_person.nil?.should be false + @user.reload + @user.friends.include?(new_person).should be true end - it 'should marshal a retraction for a person' do + it 'should process retraction for a person' do retraction = Retraction.for(@user) request = Retraction.build_xml_for( [retraction] ) @@ -169,7 +171,7 @@ describe Diaspora::Parser do xml = Post.build_xml_for(person.profile) reloaded_person = Person.first(:id => id) reloaded_person.profile = nil - reloaded_person.profile.save + reloaded_person.save(:validate => false) #Make sure profile is cleared Person.first(:id => id).profile.should be nil diff --git a/spec/lib/message_handler_spec.rb b/spec/lib/message_handler_spec.rb index 553135b96..ba13f8fef 100644 --- a/spec/lib/message_handler_spec.rb +++ b/spec/lib/message_handler_spec.rb @@ -138,7 +138,6 @@ class FakeHttpRequest @callback = callback_wanted end def response - "NOTE YOU ARE IN FAKE HTTP" end def post; end diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index 5dc7ca2c2..7418cd4bb 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -46,7 +46,6 @@ describe Comment do it 'should send a user comment on his own post to lots of people' do allowed_urls = @user_status.people_with_permissions.map!{|x| x = x.url + "receive/"} - puts allowed_urls message_queue.should_receive(:add_post_request).with(allowed_urls, anything) @user.comment "yo", :on => @user_status end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 6b57913d4..740d6fe6f 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -59,7 +59,6 @@ describe Photo do it 'should not use the imported filename as the url' do @photo.image.store! File.open(@fixture_name) - puts @photo.image.url(:thumb_medium) @photo.image.url.include?(@fixture_filename).should be false @photo.image.url(:thumb_medium).include?("/" + @fixture_filename).should be false end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index ea24f1bd7..c7435cf03 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,19 +1,18 @@ require File.dirname(__FILE__) + '/../spec_helper' describe User do + before do + @user = Factory.create(:user) + end it "should be a person" do n = Person.count Factory.create(:user) Person.count.should == n+1 end - + describe 'friend requesting' do - before do - @user = Factory.create(:user) - end - - it "should be able to accept a pending friend request" do + it "should be able to accept a pending friend request" do friend = Factory.create(:person) r = Request.instantiate(:to => @user.url, :from => friend) r.save @@ -50,6 +49,35 @@ describe User do @user.terse_url.should == 'example.com' end + it 'should get the pending friends' do + person_one = Factory.create :person + person_two = Factory.create :person + @user.pending_friends.empty?.should be true + @user.friends.empty?.should be true + + request = Request.instantiate(:to => @user.url, :from => person_one) + person_one.destroy + @user.receive_friend_request request + @user.pending_friends.size.should be 1 + @user.friends.size.should be 0 + + request_two = Request.instantiate(:to => @user.url, :from => person_two) + person_two.destroy + @user.receive_friend_request request_two + @user.pending_friends.size.should be 2 + @user.friends.size.should be 0 + + @user.accept_friend_request request.id + @user.pending_friends.size.should be 1 + @user.friends.size.should be 1 + + @user.ignore_friend_request request_two.id + @user.pending_friends.size.should be 0 + @user.friends.size.should be 1 + end + end + + describe 'profiles' do it 'should be able to update their profile and send it to their friends' do Factory.create(:person) @@ -61,5 +89,4 @@ describe User do @user.profile.image_url.should == "http://clown.com" end end - end From 7076097ee454305978350c34d700ee1e590e26fe Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 6 Aug 2010 16:56:13 -0700 Subject: [PATCH 026/198] RS, IZ; The tests are green. --- app/models/comment.rb | 6 +++--- app/models/person.rb | 16 +++++++++++----- lib/encryptable.rb | 10 +--------- spec/models/photo_spec.rb | 8 +------- spec/models/request_spec.rb | 25 ++----------------------- spec/user_encryption_spec.rb | 12 ++++++------ 6 files changed, 24 insertions(+), 53 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index b48a1c228..d374f13ed 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -60,7 +60,7 @@ class Comment end def verify_post_creator_signature - unless person == User.owner + if person.owner.nil? verify_signature(post_creator_signature, post.person) else true @@ -70,8 +70,8 @@ class Comment protected def sign_if_my_post - if self.post.person == User.owner - self.post_creator_signature = sign + unless self.post.person.owner.nil? + self.post_creator_signature = sign_with_key self.post.person.key end end diff --git a/app/models/person.rb b/app/models/person.rb index 249552fd1..7036a85f1 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -69,7 +69,16 @@ class Person raise "must comment on something!" unless options[:on] c = Comment.new(:person_id => self.id, :text => text, :post => options[:on]) if c.save - if self.owner.nil? + send_comment c + true + else + Rails.logger.warn "this failed to save: #{c.inspect}" + end + false + end + + def send_comment c + if self.owner.nil? if c.post.person.owner.nil? #puts "The commenter is not here, and neither is the poster" elsif c.post.person.owner @@ -85,11 +94,8 @@ class Person c.push_upstream end end - true - end - false + end - ##profile def update_profile(params) if self.update_attributes(params) diff --git a/lib/encryptable.rb b/lib/encryptable.rb index 9522f436f..b552a5ab4 100644 --- a/lib/encryptable.rb +++ b/lib/encryptable.rb @@ -25,15 +25,7 @@ protected def sign_if_mine - if self.person == User.owner - - - self.creator_signature = sign - end - end - - def sign - sign_with_key(User.owner.key) + self.creator_signature = sign_with_key(person.key) unless person.owner_id.nil? end def sign_with_key(key) diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 740d6fe6f..3091ed74a 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -58,6 +58,7 @@ describe Photo do end it 'should not use the imported filename as the url' do + pending "Until this passes, duplicate photos will cause errors" @photo.image.store! File.open(@fixture_name) @photo.image.url.include?(@fixture_filename).should be false @photo.image.url(:thumb_medium).include?("/" + @fixture_filename).should be false @@ -72,13 +73,6 @@ describe Photo do }.should raise_error end - it 'should not save' do - pending "We need to figure out the difference between us and the example app" - file = File.open(@fail_fixture_name) - @photo.image.should_receive(:check_whitelist!) - @photo.image = file - @photo.save.should == false - end end describe 'with encryption' do diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index a2f344b22..cafcd8c9d 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -13,27 +13,16 @@ describe Request do it 'should generate xml for the User as a Person' do user = Factory.create(:user) - user.profile.save - - request = Request.instantiate(:to => "http://www.google.com/", :from => user) + request = user.send_friend_request_to "http://www.google.com/" xml = request.to_xml.to_s - xml.include?(user.email).should be true + xml.include?(user.person.email).should be true xml.include?(user.url).should be true xml.include?(user.profile.first_name).should be true xml.include?(user.profile.last_name).should be true end - - it "should should activate a user" do - remote_person = Factory.create(:person, :email => "robert@grimm.com", :url => "http://king.com/") - f = Request.create(:destination_url => remote_person.url, :person => remote_person) - f.activate_friend - Person.where(:id => remote_person.id).first.active.should be true - end - - it 'should allow me to see only friend requests sent to me' do user = Factory.create(:user) remote_person = Factory.build(:person, :email => "robert@grimm.com", :url => "http://king.com/") @@ -46,14 +35,4 @@ describe Request do Request.for_user(user).all.count.should == 1 end - it 'should allow me to see only friend requests sent by me' do - user = Factory.create(:user) - remote_person = Factory.build(:user, :email => "robert@grimm.com", :url => "http://king.com/") - - Request.instantiate(:from => user, :to => remote_person.url).save - Request.instantiate(:from => user, :to => remote_person.url).save - Request.instantiate(:from => user, :to => remote_person.url).save - Request.instantiate(:from => remote_person, :to => user.url).save - end - end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 1506a123d..d112b726b 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -65,7 +65,7 @@ describe 'user encryption' do describe 'signing and verifying' do it 'should sign a message on create' do - message = Factory.create(:status_message, :person => @user) + message = @user.post :status_message, :message => "hi" message.verify_creator_signature.should be true end @@ -102,13 +102,13 @@ describe 'user encryption' do describe 'sending and recieving signatures' do it 'should contain the signature in the xml' do - message = Factory.create(:status_message, :person => @user) + message = @user.post :status_message, :message => "hi" xml = message.to_xml.to_s xml.include?(message.creator_signature).should be true end it 'A message with an invalid signature should be rejected' do message = Factory.build(:status_message, :person => @person) - message.creator_signature = message.send(:sign ) + message.creator_signature = "totally valid" message.save xml = Post.build_xml_for([message]) message.destroy @@ -123,7 +123,7 @@ describe 'user encryption' do @remote_message = Factory.build(:status_message, :person => @person) @remote_message.creator_signature = @remote_message.send(:sign_with_key,@person.key) @remote_message.save - @message = Factory.create(:status_message, :person => @user) + @message = @user.post :status_message, :message => "hi" end it 'should attach the creator signature if the user is commenting' do @user.comment "Yeah, it was great", :on => @remote_message @@ -131,10 +131,10 @@ describe 'user encryption' do end it 'should sign the comment if the user is the post creator' do - message = Factory.create(:status_message, :person => @user) + message = @user.post :status_message, :message => "hi" @user.comment "Yeah, it was great", :on => message message.comments.first.verify_creator_signature.should be true - StatusMessage.first(:message => message.message).comments.first.verify_post_creator_signature.should be true + message.comments.first.verify_post_creator_signature.should be true end it 'should verify a comment made on a remote post by a different friend' do From 214685e5a95dee8ad288ae85cd45eed8b918cbe8 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 6 Aug 2010 17:11:50 -0700 Subject: [PATCH 027/198] Dev seed might now work --- app/models/user.rb | 2 +- db/seeds/dev.rb | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 0a2912d46..243f34a11 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,7 +16,7 @@ class User before_validation :do_bad_things ######## Posting ######## - + delegate :email, :email=, :to => :person def method_missing(method, *args) self.person.send(method, *args) diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index 9bf7adb80..f59cb7848 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -9,5 +9,16 @@ require 'config/environment' # Create seed user -user = User.create( :email => "robert@joindiaspora.com", :password => "evankorth", :profile => Profile.new( :first_name => "bobert", :last_name => "brin" )) +user = User.create( :password => "evankorth", + :person => Person.create( + :email => "robert@joindiaspora.com", + :url => "http://localhost:3000/", + :profile => Profile.new( + :first_name => "bobert", + :last_name => "brin" ))) +puts user.save! +puts user.person.save +puts user.save! +puts user.person.inspect +puts user.inspect From a6f5603dc94e486f674f79e392fdf1212f87d6ed Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 6 Aug 2010 23:54:39 -0700 Subject: [PATCH 028/198] added email field to login screen. strange error won't let me log in? --- app/helpers/sockets_helper.rb | 2 +- app/views/devise/sessions/new.html.haml | 13 ++++++------- app/views/layouts/session_wall.html.haml | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb index cbb913b23..629709402 100644 --- a/app/helpers/sockets_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -13,7 +13,7 @@ module SocketsHelper begin v = render_to_string(:partial => type_partial(object), :locals => {:post => object}) unless object.is_a? Retraction rescue Exception => e - Rails.logger.error ("web socket view rendering failed for some reason." + v.inspect) + Rails.logger.error("web socket view rendering failed for some reason." + v.inspect) Rails.logger.error("Socketed object was #{object.inspect}") raise e end diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 96b9ca9c4..367dc3b5f 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,12 +1,11 @@ = form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %p + = f.text_field :email + %br = f.password_field :password - %p - - if devise_mapping.rememberable? - /= f.check_box :remember_me - /= f.label :remember_me - - = hidden_field_tag "user_email", "#{User.owner.email}", :name => "user[email]" - = f.submit "Sign in" + /- if devise_mapping.rememberable? + /= f.check_box :remember_me + /= f.label :remember_me + = f.submit "Sign in" /= render :partial => "devise/shared/links" diff --git a/app/views/layouts/session_wall.html.haml b/app/views/layouts/session_wall.html.haml index 3b85566bc..b025e419b 100644 --- a/app/views/layouts/session_wall.html.haml +++ b/app/views/layouts/session_wall.html.haml @@ -13,7 +13,7 @@ :javascript $(document).ready(function(){ - $("#user_password").focus(); + $("#user_email").focus(); }); = csrf_meta_tag From 8e6dfe7166c2d69b614c8d4352a7933f5e349d95 Mon Sep 17 00:00:00 2001 From: ilya Date: Sun, 8 Aug 2010 17:00:39 -0700 Subject: [PATCH 029/198] DG IZ having an email key makes devise work, ring to deploy --- app/models/user.rb | 2 +- app/views/layouts/application.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 243f34a11..8b51c20dd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,7 +16,7 @@ class User before_validation :do_bad_things ######## Posting ######## - delegate :email, :email=, :to => :person + key :email, String def method_missing(method, *args) self.person.send(method, *args) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7d069eeec..4eb0281a4 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -18,7 +18,7 @@ = csrf_meta_tag = yield(:head) - = javascript_include_tag 'satisfaction' , 'satisfaction-display' + /= javascript_include_tag 'satisfaction' , 'satisfaction-display' = javascript_include_tag 'jquery.html5_upload' From 27b4c1933749d06a4f96d8fc216c68ead6531afd Mon Sep 17 00:00:00 2001 From: ilya Date: Sun, 8 Aug 2010 21:24:34 -0700 Subject: [PATCH 030/198] Getting the deployment changes from master --- config/sprinkle/packages/scm.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/config/sprinkle/packages/scm.rb b/config/sprinkle/packages/scm.rb index c9f243df5..225c37797 100644 --- a/config/sprinkle/packages/scm.rb +++ b/config/sprinkle/packages/scm.rb @@ -1,20 +1,22 @@ package :git, :provides => :scm do description 'Git Distributed Version Control' - apt %w( git-core ) do - pre :install, "mkdir -p /root/.ssh/" - end + apt %w( git-core ) requires :pubkey - requires :privkey - requires :known_hosts + end package :privkey do description 'checkout from github with it' - transfer "#{File.dirname(__FILE__)}/../deploy_key/id_rsa", '/root/.ssh/id_rsa', :render => false + transfer "#{File.dirname(__FILE__)}/../deploy_key/id_rsa", '/root/.ssh/id_rsa', :render => false do + pre :install, "rm -rf /root/.ssh/ && mkdir -p /root/.ssh/" + post :install, "chmod go-rwx /root/.ssh/id_rsa" + end end package :pubkey do - transfer "#{File.dirname(__FILE__)}/../deploy_key/id_rsa.pub", '/root/.ssh/id_rsa.pub', :render => false + transfer "#{File.dirname(__FILE__)}/../deploy_key/id_rsa.pub", '/root/.ssh/id_rsa.pub', :render => false + requires :privkey + requires :known_hosts end package :known_hosts do From fb4254535d83beaaa38e6c51ce5a447635c06b69 Mon Sep 17 00:00:00 2001 From: ilya Date: Sun, 8 Aug 2010 21:32:09 -0700 Subject: [PATCH 031/198] DG IZ; slashes and http 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 f9f8ba366..a13612e83 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -18,7 +18,7 @@ def create(backer_number) user = User.create( :email => "#{username}@#{username}.joindiaspora.com", :password => "#{username+backer_info[backer_number]['pin'].to_s}", :profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'] ), - :url=> "#{username}.joindiaspora.com") + :url=> "http://#{username}.joindiaspora.com/") # Make connection with Diaspora Tom #Person.create( :email => "tom@joindiaspora.com", :url => "http://tom.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => "Alexander", :last_name => "Hamiltom")) From 6acdde7313168402cad45fd2e64a8fef707144f2 Mon Sep 17 00:00:00 2001 From: ilya Date: Sun, 8 Aug 2010 21:42:08 -0700 Subject: [PATCH 032/198] fixing the seed script for the refactor --- db/seeds/backer.rb | 18 ++++++------------ db/seeds/tom.rb | 9 ++++++++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index a13612e83..3aa28e29d 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -17,17 +17,11 @@ def create(backer_number) username = backer_info[backer_number]['username'].gsub(/ /,'').downcase user = User.create( :email => "#{username}@#{username}.joindiaspora.com", :password => "#{username+backer_info[backer_number]['pin'].to_s}", - :profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'] ), - :url=> "http://#{username}.joindiaspora.com/") - - # Make connection with Diaspora Tom - #Person.create( :email => "tom@joindiaspora.com", :url => "http://tom.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => "Alexander", :last_name => "Hamiltom")) - # Make people - -# (0..10).each { |n| - #domain_name = backer_info[n][2].gsub(/ /,'').downcase - #url = "http://#{domain_name}.joindiaspora.com/" - #User.owner.send_friend_request_to(url) - #} + :person => Person.new( + :email => "#{username}@#{username}.joindiaspora.com", + :profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'] ), + :url=> "http://#{username}.joindiaspora.com/") + ) + user.person.save end diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 4efae222d..d180c3a7d 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -9,5 +9,12 @@ require 'config/environment' # Create seed user -user = User.create( :email => "tom@tom.joindiaspora.com", :password => "evankorth", :url => "http://tom.joindiaspora.com/", :profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" )) +user = User.create( :email => "tom@tom.joindiaspora.com", + :password => "evankorth", + :person => Person.new( + :email => "tom@tom.joindiaspora.com", + :url => "http://tom.joindiaspora.com/", + :profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" )) + ) +user.person.save From 890f9274925964da63d55d6eac0f6a0a4ed61e21 Mon Sep 17 00:00:00 2001 From: ilya Date: Sun, 8 Aug 2010 22:53:23 -0700 Subject: [PATCH 034/198] removed references of mine? method in all views --- app/helpers/sockets_helper.rb | 3 +-- app/models/person.rb | 1 + app/views/albums/_album.html.haml | 2 +- app/views/albums/show.html.haml | 6 +++--- app/views/blogs/_blog.html.haml | 4 ++-- app/views/bookmarks/_bookmark.html.haml | 4 ++-- app/views/photos/edit.html.haml | 2 +- app/views/photos/show.html.haml | 2 +- app/views/shared/_post_wrapper.haml | 4 ++-- app/views/status_messages/_status_message.html.haml | 4 ++-- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb index 629709402..194f321ff 100644 --- a/app/helpers/sockets_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -13,8 +13,7 @@ module SocketsHelper begin v = render_to_string(:partial => type_partial(object), :locals => {:post => object}) unless object.is_a? Retraction rescue Exception => e - Rails.logger.error("web socket view rendering failed for some reason." + v.inspect) - Rails.logger.error("Socketed object was #{object.inspect}") + Rails.logger.error("web socket view rendering failed for object #{object.inspect}.") raise e end action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)} diff --git a/app/models/person.rb b/app/models/person.rb index 7036a85f1..196a249fa 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -107,6 +107,7 @@ class Person end def owns?(post) + puts self.class self.id == post.person.id end diff --git a/app/views/albums/_album.html.haml b/app/views/albums/_album.html.haml index d4a629ba0..52cb7fe4a 100644 --- a/app/views/albums/_album.html.haml +++ b/app/views/albums/_album.html.haml @@ -1,4 +1,4 @@ -.album{:id => post.id, :class => ("mine" if mine?(post))} +.album{:id => post.id, :class => ("mine" if current_user.owns?(post))} %div.name = link_to post.name, object_path(post) diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index 253d94d19..92b3c2756 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -4,7 +4,7 @@ = @album.name - -if mine? @album + -if current_user.owns? @album .button.right#add_photos_button = link_to 'Add Photos', '#' @@ -14,7 +14,7 @@ .sub_header ="updated #{how_long_ago(@album)}" --unless mine? @album +-unless current_user.owns? @album %h4= "by #{@album.person.real_name}" #thumbnails @@ -25,6 +25,6 @@ #content_bottom .back = link_to "⇧ albums", albums_path - -if mine? @album + -if current_user.owns? @album .button.right = link_to 'Edit Album', edit_album_path(@album) diff --git a/app/views/blogs/_blog.html.haml b/app/views/blogs/_blog.html.haml index 79d0612b3..0a4f79feb 100644 --- a/app/views/blogs/_blog.html.haml +++ b/app/views/blogs/_blog.html.haml @@ -1,4 +1,4 @@ -%li.message{:id => post.id, :class => ("mine" if mine?(post))} +%li.message{:id => post.id, :class => ("mine" if current_user.owns?(post))} = person_image_tag(post.person) @@ -15,6 +15,6 @@ = link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments" = render "comments/comments", :post => post - - if mine?(post) + - if current_user.owns?(post) .destroy_link = link_to 'Delete', blog_path(post), :confirm => 'Are you sure?', :method => :delete, :remote=> true diff --git a/app/views/bookmarks/_bookmark.html.haml b/app/views/bookmarks/_bookmark.html.haml index 8356bf91d..dd0dffce9 100644 --- a/app/views/bookmarks/_bookmark.html.haml +++ b/app/views/bookmarks/_bookmark.html.haml @@ -1,4 +1,4 @@ -%li.message{:id => post.id, :class => ("mine" if mine?(post))} +%li.message{:id => post.id, :class => ("mine" if current_user.owns?(post))} = person_image_tag(post.person) @@ -16,6 +16,6 @@ = link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments" = render "comments/comments", :post => post - - if mine?(post) + - if current_user.owns?(post) .destroy_link = link_to 'Delete', bookmark_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true diff --git a/app/views/photos/edit.html.haml b/app/views/photos/edit.html.haml index c849b43b7..baeb82a3d 100644 --- a/app/views/photos/edit.html.haml +++ b/app/views/photos/edit.html.haml @@ -15,7 +15,7 @@ #content_bottom .back = link_to "⇧ #{@album.name}", album_path(@album) - -if mine? @album + -if current_user.owns? @album .button.right = link_to 'Delete Photo', @photo, :confirm => 'Are you sure?', :method => :delete diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index d08790650..f1956ee4d 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -25,7 +25,7 @@ #content_bottom .back = link_to "⇧ #{@album.name}", album_path(@album) - -if mine? @album + -if current_user.owns? @album .button.right = link_to 'Delete Photo', @photo, :confirm => 'Are you sure?', :method => :delete diff --git a/app/views/shared/_post_wrapper.haml b/app/views/shared/_post_wrapper.haml index bdba9db70..a65866a08 100644 --- a/app/views/shared/_post_wrapper.haml +++ b/app/views/shared/_post_wrapper.haml @@ -1,4 +1,4 @@ -%li.message{:id => post.id, :class => ("mine" if mine?(post))} +%li.message{:id => post.id, :class => ("mine" if current_user.owns?(post))} = person_image_link(post.person) = yield post_yield_tag(post) - = = render type_partial(post), :post => post \ No newline at end of file + = = render type_partial(post), :post => post diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index 5681e9753..adb774cd6 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -1,4 +1,4 @@ -%li.message{:id => post.id, :class => ("mine" if mine?(post))} +%li.message{:id => post.id, :class => ("mine" if current_user.owns?(post))} = person_image_link(post.person) @@ -12,6 +12,6 @@ = link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments" = render "comments/comments", :post => post - - if mine?(post) + - if current_user.owns?(post) .destroy_link = link_to 'Delete', status_message_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true From 7be374ac480d312208140d55f91cc16b57cc7592 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 9 Aug 2010 10:10:41 -0700 Subject: [PATCH 035/198] MS IZ fixed a couple of view things as well as the dev db seed script --- app/controllers/people_controller.rb | 5 +++-- app/helpers/application_helper.rb | 4 +++- db/seeds/dev.rb | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 25fcdf2af..b93a9f059 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -2,14 +2,15 @@ class PeopleController < ApplicationController before_filter :authenticate_user! def index - @people = Person.friends.paginate :page => params[:page], :order => 'created_at DESC' + @people = current_user.friends.paginate :page => params[:page], :order => 'created_at DESC' end def show @person= Person.where(:id => params[:id]).first + @person_profile = @person.profile @person_posts = Post.where(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC' - @latest_status_message = StatusMessage.newest(@person) + @latest_status_message = StatusMessage.newest_for(@person) @post_count = @person_posts.count end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 69011b563..bd0ede89b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -31,7 +31,9 @@ module ApplicationHelper end end - def link_to_person(person) + def link_to_person(user) + person = user.person + puts person.inspect link_to person.real_name, person_path(person) end diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index f59cb7848..dfc4d1c14 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -9,7 +9,8 @@ require 'config/environment' # Create seed user -user = User.create( :password => "evankorth", +user = User.create( :email => "robert@joindiaspora.com", + :password => "evankorth", :person => Person.create( :email => "robert@joindiaspora.com", :url => "http://localhost:3000/", From 544f7f08e5fe2ca289404013444c3ea1680082ba Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 9 Aug 2010 10:38:13 -0700 Subject: [PATCH 036/198] MS IZ doesn't delete from pending friends since there is nothing in it --- app/models/request.rb | 1 - app/models/user.rb | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/request.rb b/app/models/request.rb index e8b073aa6..6827ef32f 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -37,7 +37,6 @@ class Request def activate_friend from_user = Person.first(:url => self.callback_url).owner - from_user.pending_friends.delete(person) from_user.friends << person from_user.save diff --git a/app/models/user.rb b/app/models/user.rb index 8b51c20dd..3f7f73bc7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -71,6 +71,7 @@ class User else friend_request.person.save pending_friends << friend_request.person + save Rails.logger.info("#{self.real_name} has received a friend request") friend_request.save end From 73a6cd911bbda5e881f86a67cfd54969cec0f540 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 10:46:02 -0700 Subject: [PATCH 037/198] DG, RS; User person delegation fixed --- app/models/comment.rb | 2 +- app/models/person.rb | 7 +++---- app/models/user.rb | 3 ++- db/seeds/dev.rb | 19 ++++++++++--------- lib/encryptable.rb | 6 +++--- spec/user_encryption_spec.rb | 20 ++++++++++---------- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index d374f13ed..f2b6aface 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -71,7 +71,7 @@ class Comment protected def sign_if_my_post unless self.post.person.owner.nil? - self.post_creator_signature = sign_with_key self.post.person.key + self.post_creator_signature = sign_with_key self.post.person.encryption_key end end diff --git a/app/models/person.rb b/app/models/person.rb index 196a249fa..e10a4bbfb 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -40,16 +40,16 @@ class Person "#{profile.first_name.to_s} #{profile.last_name.to_s}" end - def key + def encryption_key OpenSSL::PKey::RSA.new( serialized_key ) end - def key= new_key + def encryption_key= new_key raise TypeError unless new_key.class == OpenSSL::PKey::RSA serialized_key = new_key.export end def export_key - key.public_key.export + encryption_key.public_key.export end @@ -107,7 +107,6 @@ class Person end def owns?(post) - puts self.class self.id == post.person.id end diff --git a/app/models/user.rb b/app/models/user.rb index 8b51c20dd..8744699bc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -15,7 +15,8 @@ class User before_validation_on_create :assign_key before_validation :do_bad_things - ######## Posting ######## + ######## Making things work ######## + key :email, String def method_missing(method, *args) diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index f59cb7848..f13e27f4c 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -9,16 +9,17 @@ require 'config/environment' # Create seed user -user = User.create( :password => "evankorth", - :person => Person.create( - :email => "robert@joindiaspora.com", - :url => "http://localhost:3000/", - :profile => Profile.new( - :first_name => "bobert", - :last_name => "brin" ))) +user = User.create( :email => "robert@joindiaspora.com", + :password => "evankorth", + :person => Person.new( + :email => "robert@joindiaspora.com", + :url => "http://localhost:3000/", + :profile => Profile.new( + :first_name => "bobert", + :last_name => "brin" ))) -puts user.save! -puts user.person.save +puts user.save +puts user.person.save! puts user.save! puts user.person.inspect puts user.inspect diff --git a/lib/encryptable.rb b/lib/encryptable.rb index b552a5ab4..6925b4cd0 100644 --- a/lib/encryptable.rb +++ b/lib/encryptable.rb @@ -10,7 +10,7 @@ if person.nil? Rails.logger.info("Verifying sig on #{signable_string} but no person is here") return false - elsif person.key.nil? + elsif person.encryption_key.nil? Rails.logger.info("Verifying sig on #{signable_string} but #{person.real_name} has no key") return false elsif signature.nil? @@ -18,14 +18,14 @@ return false end Rails.logger.info("Verifying sig on #{signable_string} from person #{person.real_name}") - validity = person.key.verify "SHA", Base64.decode64(signature), signable_string + validity = person.encryption_key.verify "SHA", Base64.decode64(signature), signable_string Rails.logger.info("Validity: #{validity}") validity end protected def sign_if_mine - self.creator_signature = sign_with_key(person.key) unless person.owner_id.nil? + self.creator_signature = sign_with_key(person.encryption_key) unless person.owner_id.nil? end def sign_with_key(key) diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index d112b726b..2c7b8963b 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -33,7 +33,7 @@ describe 'user encryption' do #keys.each{|k| ctx.delete_key(k, true)} end it 'should have a key' do - @user.key.should_not be nil + @user.encryption_key.should_not be nil end describe 'key exchange on friending' do it 'should send over a public key' do @@ -44,7 +44,7 @@ describe 'user encryption' do it 'should receive and marshal a public key from a request' do person = Factory.build(:person, :url => "http://test.url/" ) - person.key.nil?.should== false + person.encryption_key.nil?.should== false #should move this to friend request, but i found it here id = person.id original_key = person.export_key @@ -78,7 +78,7 @@ describe 'user encryption' do it 'should verify a remote signature' do message = Factory.build(:status_message, :person => @person) - message.creator_signature = message.send(:sign_with_key,@person.key) + message.creator_signature = message.send(:sign_with_key,@person.encryption_key) message.save(:validate => false) message.verify_creator_signature.should be true end @@ -86,14 +86,14 @@ describe 'user encryption' do it 'should know if the signature is from the wrong person' do message = Factory.build(:status_message, :person => @person) message.save(:validate => false) - message.creator_signature = message.send(:sign_with_key,@person.key) + message.creator_signature = message.send(:sign_with_key,@person.encryption_key) message.person = @user message.verify_creator_signature.should be false end it 'should know if the signature is for the wrong text' do message = Factory.build(:status_message, :person => @person) - message.creator_signature = message.send(:sign_with_key,@person.key) + message.creator_signature = message.send(:sign_with_key,@person.encryption_key) message.message = 'I love VENISON' message.save(:validate => false) message.verify_creator_signature.should be false @@ -121,7 +121,7 @@ describe 'user encryption' do describe 'comments' do before do @remote_message = Factory.build(:status_message, :person => @person) - @remote_message.creator_signature = @remote_message.send(:sign_with_key,@person.key) + @remote_message.creator_signature = @remote_message.send(:sign_with_key,@person.encryption_key) @remote_message.save @message = @user.post :status_message, :message => "hi" end @@ -139,17 +139,17 @@ describe 'user encryption' do it 'should verify a comment made on a remote post by a different friend' do comment = Comment.new(:person => @person2, :text => "balls", :post => @remote_message) - comment.creator_signature = comment.send(:sign_with_key,@person2.key) + comment.creator_signature = comment.send(:sign_with_key,@person2.encryption_key) comment.verify_creator_signature.should be true comment.valid?.should be false - comment.post_creator_signature = comment.send(:sign_with_key,@person.key) + comment.post_creator_signature = comment.send(:sign_with_key,@person.encryption_key) comment.verify_post_creator_signature.should be true comment.valid?.should be true end it 'should reject comments on a remote post with only a creator sig' do comment = Comment.new(:person => @person2, :text => "balls", :post => @remote_message) - comment.creator_signature = comment.send(:sign_with_key,@person2.key) + comment.creator_signature = comment.send(:sign_with_key,@person2.encryption_key) comment.verify_creator_signature.should be true comment.verify_post_creator_signature.should be false comment.save.should be false @@ -157,7 +157,7 @@ describe 'user encryption' do it 'should receive remote comments on a user post with a creator sig' do comment = Comment.new(:person => @person2, :text => "balls", :post => @message) - comment.creator_signature = comment.send(:sign_with_key,@person2.key) + comment.creator_signature = comment.send(:sign_with_key,@person2.encryption_key) comment.save.should be true end From 0a40efdaf7c7dacf88495db0374062ed4709cc86 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 10:47:45 -0700 Subject: [PATCH 038/198] Removing unused messages --- app/controllers/sockets_controller.rb | 4 ---- config/initializers/socket.rb | 5 ----- 2 files changed, 9 deletions(-) diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb index e25472d52..02c28421a 100644 --- a/app/controllers/sockets_controller.rb +++ b/app/controllers/sockets_controller.rb @@ -8,10 +8,6 @@ class SocketsController < ApplicationController puts "#{msg} connected!" end - def new_subscriber - WebSocket.subscribe - end - def outgoing(object) @_request = ActionDispatch::Request.new({}) WebSocket.push_to_clients(action_hash(object)) diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index aebf023f3..e0019b452 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -32,10 +32,5 @@ module WebSocket @channel.unsubscribe(sid) end - - def self.subscribe - @channel.subscribe{ |msg| ws.send msg } - end - end From 67843a21e20e06565248315ebbbc3f521d5f465b Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 9 Aug 2010 10:50:49 -0700 Subject: [PATCH 039/198] MS IZ saving the person in accept of FR --- app/models/user.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/user.rb b/app/models/user.rb index 3f7f73bc7..ab61ca837 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -44,6 +44,7 @@ class User request = Request.where(:id => friend_request_id).first pending_friends.delete(request.person) friends << request.person + save request.person = self request.exported_key = self.export_key From 8532be130741b7e780d3ad1175d8e647503573e9 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 9 Aug 2010 11:03:16 -0700 Subject: [PATCH 040/198] MS IZ moved activate_friend to user --- app/models/request.rb | 6 ------ app/models/user.rb | 7 ++++++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/models/request.rb b/app/models/request.rb index 6827ef32f..1db410bbc 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -35,12 +35,6 @@ class Request - def activate_friend - from_user = Person.first(:url => self.callback_url).owner - - from_user.friends << person - from_user.save - end def set_pending_friend p = Person.first(:id => self.person.id) diff --git a/app/models/user.rb b/app/models/user.rb index ab61ca837..accda855d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -66,7 +66,7 @@ class User friend_request.person.serialized_key = friend_request.exported_key if Request.where(:callback_url => friend_request.callback_url).first - friend_request.activate_friend + activate_friend friend_request.person Rails.logger.info("#{self.real_name}'s friend request has been accepted") friend_request.destroy else @@ -98,6 +98,11 @@ class User raise "you can't do anything to that url" end end + + def activate_friend (person) + friends << person + save + end ###Helpers############ From 921ee029b6d220a0bf46492a830792589f58a0ed Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 9 Aug 2010 11:12:15 -0700 Subject: [PATCH 041/198] MS IZ putting the person in the return trip --- 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 accda855d..15b5c7182 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -46,7 +46,7 @@ class User friends << request.person save - request.person = self + request.person = self.person request.exported_key = self.export_key request.destination_url = request.callback_url request.push_to_url(request.callback_url) From f4428679efe1d5c6126997db0b3d97fe5c451fe6 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 9 Aug 2010 11:44:13 -0700 Subject: [PATCH 042/198] First attempt at fixing warzombie friendingw --- app/controllers/dev_utilities_controller.rb | 4 ++-- app/models/user.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index f5f96683f..d8936e689 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -23,9 +23,9 @@ def warzombie def zombiefriends render :nothing => true - backer_info + bkr_info = backer_info if User.owner.email == "tom@tom.joindiaspora.com" && Person.friends.first.nil? - backer_info.each do |backer| + bkr_info.each do |backer| logger.info "Zombefriending #{backer['given_name']} #{backer['family_name']}" User.owner.send_friend_request_to("http://#{backer['username']}.joindiaspora.com/") end diff --git a/app/models/user.rb b/app/models/user.rb index 15b5c7182..b9199fcf7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -42,7 +42,8 @@ class User def accept_friend_request(friend_request_id) request = Request.where(:id => friend_request_id).first - pending_friends.delete(request.person) + n = pending_friends.delete(request.person) + friends << request.person save From ac7530d17f66db0948d39c53594dff2b114f4d1c Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 9 Aug 2010 11:51:32 -0700 Subject: [PATCH 043/198] MS IZ person doesn't have friends user does --- app/controllers/dev_utilities_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index d8936e689..f45be992b 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -24,7 +24,8 @@ def warzombie def zombiefriends render :nothing => true bkr_info = backer_info - if User.owner.email == "tom@tom.joindiaspora.com" && Person.friends.first.nil? + + if User.owner.email == "tom@tom.joindiaspora.com" && User.owner.friends.first.nil? bkr_info.each do |backer| logger.info "Zombefriending #{backer['given_name']} #{backer['family_name']}" User.owner.send_friend_request_to("http://#{backer['username']}.joindiaspora.com/") From 4243d8efca3197d139ddfbe21c25b71a8bde2829 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 9 Aug 2010 12:19:26 -0700 Subject: [PATCH 044/198] MS IZ using the particular user's friends in the send_friend_request_to --- app/models/user.rb | 2 +- db/seeds/tom.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index b9199fcf7..a520a579f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -31,7 +31,7 @@ class User ######### Friend Requesting def send_friend_request_to(friend_url) - unless Person.where(:url => friend_url).first + unless self.friends.where(:url => friend_url).first p = Request.instantiate(:to => friend_url, :from => self.person) if p.save p.push_to_url friend_url diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index d180c3a7d..17b9375ca 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -18,3 +18,10 @@ user = User.create( :email => "tom@tom.joindiaspora.com", ) user.person.save +user2 = User.create( :email => "korth@tom.joindiaspora.com", + :password => "evankorth", + :person => Person.new( :email => "korth@tom.joindiaspora.com", + :url => "http://tom.joindiaspora.com/", + :profile => Profile.new( :first_name => "Evan", + :last_name => "Korth"))) +user2.person.save From 82578ad80cd50d99bfc00f611e24fd8c36d33007 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 9 Aug 2010 12:25:36 -0700 Subject: [PATCH 045/198] MS IZ doing the friend querying correctly 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 a520a579f..73c8987f3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -31,7 +31,7 @@ class User ######### Friend Requesting def send_friend_request_to(friend_url) - unless self.friends.where(:url => friend_url).first + unless self.friends.find{ |x| x.url == friend_url} p = Request.instantiate(:to => friend_url, :from => self.person) if p.save p.push_to_url friend_url From 33a827c33a74084a4d0d7e874183eb597b229f3a Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 13:02:08 -0700 Subject: [PATCH 046/198] RS, DG; Websocket is now working again, users have a channel --- app/controllers/dashboards_controller.rb | 3 +-- app/controllers/sockets_controller.rb | 10 +++------ app/helpers/sockets_helper.rb | 5 +++-- app/models/post.rb | 5 ++++- app/views/js/_websocket_js.haml | 4 +++- config/app_config.yml | 2 +- config/initializers/socket.rb | 27 +++++++++++++++--------- spec/lib/socket_renderer_spec.rb | 24 --------------------- 8 files changed, 32 insertions(+), 48 deletions(-) delete mode 100644 spec/lib/socket_renderer_spec.rb diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index 438163fff..882cdca50 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -5,5 +5,4 @@ class DashboardsController < ApplicationController def index @posts = Post.paginate :page => params[:page], :order => 'created_at DESC' end - - end +end diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb index 02c28421a..eb4f57fc9 100644 --- a/app/controllers/sockets_controller.rb +++ b/app/controllers/sockets_controller.rb @@ -2,18 +2,14 @@ class SocketsController < ApplicationController include ApplicationHelper include SocketsHelper include Rails.application.routes.url_helpers - before_filter :authenticate_user! def incoming(msg) - puts "#{msg} connected!" + puts "Got a connection to: #{msg}" end - def outgoing(object) + def outgoing(uid,object) @_request = ActionDispatch::Request.new({}) - WebSocket.push_to_clients(action_hash(object)) + WebSocket.push_to_user(uid, action_hash(uid, object)) end - def delete_subscriber(sid) - WebSocket.unsubscribe(sid) - end end diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb index 194f321ff..749de4b41 100644 --- a/app/helpers/sockets_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -9,9 +9,10 @@ module SocketsHelper {:host => ""} end - def action_hash(object) + def action_hash(uid, object) begin - v = render_to_string(:partial => type_partial(object), :locals => {:post => object}) unless object.is_a? Retraction + user = User.first(:id => uid) + v = render_to_string(:partial => type_partial(object), :locals => {:post => object, :current_user => user}) unless object.is_a? Retraction rescue Exception => e Rails.logger.error("web socket view rendering failed for object #{object.inspect}.") raise e diff --git a/app/models/post.rb b/app/models/post.rb index 74fce8881..b5c61f492 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -76,7 +76,10 @@ protected end def send_to_view - SocketsController.new.outgoing(self) + people_with_permissions.each{|f| + SocketsController.new.outgoing(f.owner_id, self) if f.owner_id + } + SocketsController.new.outgoing(person.owner_id, self) if person.owner_id end def remove_from_view diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml index 768c03cb7..793aea9db 100644 --- a/app/views/js/_websocket_js.haml +++ b/app/views/js/_websocket_js.haml @@ -7,7 +7,9 @@ $(document).ready(function(){ function debug(str){ $("#debug").append("

" + str); }; - ws = new WebSocket("ws://#{request.host}:8080/"); + ws = new WebSocket("ws://#{request.host}:8080/#{CGI::escape(current_user.id.to_s)}"); + + //Attach onmessage to websocket ws.onmessage = function(evt) { var obj = jQuery.parseJSON(evt.data); debug("got a " + obj['class']); diff --git a/config/app_config.yml b/config/app_config.yml index 0c87b6b4c..02f2b1420 100644 --- a/config/app_config.yml +++ b/config/app_config.yml @@ -1,5 +1,5 @@ development: - debug: false + debug: true socket_port: 8080 pubsub_server: 'https://pubsubhubbub.appspot.com/' diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index e0019b452..711883ae3 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -3,33 +3,40 @@ require 'eventmachine' module WebSocket EM.next_tick { - initialize_channel + initialize_channels EventMachine::WebSocket.start( :host => "0.0.0.0", :port => APP_CONFIG[:socket_port], :debug =>APP_CONFIG[:debug]) do |ws| ws.onopen { - @ws = ws - sid = @channel.subscribe{ |msg| ws.send msg }#SocketsController.new.new_subscriber + + sid = self.subscribe(ws.request['Path'].gsub('/',''), ws) ws.onmessage { |msg| SocketsController.new.incoming(msg) }#@channel.push msg; puts msg} - ws.onclose { SocketsController.new.delete_subscriber(sid) } + ws.onclose { unsubscribe(ws.request['Path'].gsub('/',''), sid) } } end } - def self.initialize_channel - @channel = EM::Channel.new + def self.initialize_channels + @channels = {} end - def self.push_to_clients(html) - @channel.push(html) + def self.push_to_user(uid, data) + puts "Pushing to #{uid}" + @channels[uid.to_s].push(data) if @channels[uid.to_s] end - def self.unsubscribe(sid) - @channel.unsubscribe(sid) + def self.subscribe(uid, ws) + puts "Subscribing #{uid}" + @channels[uid] ||= EM::Channel.new + @channels[uid].subscribe{ |msg| ws.send msg } + end + + def self.unsubscribe(uid,sid) + @channels[uid].unsubscribe(sid) if @channels[uid] end end diff --git a/spec/lib/socket_renderer_spec.rb b/spec/lib/socket_renderer_spec.rb deleted file mode 100644 index 009de8b78..000000000 --- a/spec/lib/socket_renderer_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -=begin - require File.dirname(__FILE__) + '/../spec_helper' - -describe SocketRenderer do - before do - SocketRenderer.instantiate_view - @user = Factory.create(:user, :email => "bob@jones.com") - @user.profile = Factory.create(:profile, :person => @user) - end - - it 'should render a partial for a status message' do - message = Factory.create(:status_message, :person => @user) - html = SocketRenderer.view_for message - html.include? message.message - end - - it 'should prepare a class/view hash' do - message = Factory.create(:status_message, :person => @user) - - hash = SocketRenderer.view_hash(message) - hash[:class].should == "status_messages" - end -end -=end From 088da2544b0ddcdffb0ba78d1a08e172d127ef4d Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 14:11:46 -0700 Subject: [PATCH 047/198] RS, DG; We now delete channels when there is nobody subscribed to them --- config/initializers/socket.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index 711883ae3..9223b5148 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -26,17 +26,26 @@ module WebSocket def self.push_to_user(uid, data) puts "Pushing to #{uid}" - @channels[uid.to_s].push(data) if @channels[uid.to_s] + @channels[uid.to_s][0].push(data) if @channels[uid.to_s] end def self.subscribe(uid, ws) puts "Subscribing #{uid}" - @channels[uid] ||= EM::Channel.new - @channels[uid].subscribe{ |msg| ws.send msg } + self.ensure_channel(uid) + @channels[uid][0].subscribe{ |msg| ws.send msg } + @channels[uid][1] += 1 + end + + def self.ensure_channel(uid) + @channels[uid] ||= [EM::Channel.new, 0 ] end def self.unsubscribe(uid,sid) - @channels[uid].unsubscribe(sid) if @channels[uid] + @channels[uid][0].unsubscribe(sid) if @channels[uid] + @channels[uid][1] -= 1 + if @channels[uid][1] <= 0 + @channels[uid] = nil + end end end From 614c8c72baeb51acdf257c377d14b9f42106a9f3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 14:27:17 -0700 Subject: [PATCH 048/198] RS, DG; Log files should now rotate --- config/app_config.yml | 2 +- config/initializers/logging.rb | 2 ++ config/initializers/socket.rb | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 config/initializers/logging.rb diff --git a/config/app_config.yml b/config/app_config.yml index 02f2b1420..0c87b6b4c 100644 --- a/config/app_config.yml +++ b/config/app_config.yml @@ -1,5 +1,5 @@ development: - debug: true + debug: false socket_port: 8080 pubsub_server: 'https://pubsubhubbub.appspot.com/' diff --git a/config/initializers/logging.rb b/config/initializers/logging.rb new file mode 100644 index 000000000..447ec5c17 --- /dev/null +++ b/config/initializers/logging.rb @@ -0,0 +1,2 @@ +Rails.logger = Logger.new( + Rails.root.join("log",Rails.env + ".log"),3,5*1024*1024) diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index 9223b5148..068c50e14 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -25,12 +25,13 @@ module WebSocket end def self.push_to_user(uid, data) - puts "Pushing to #{uid}" + puts @channels.size + Rails.logger.info "Pushing to #{uid}" @channels[uid.to_s][0].push(data) if @channels[uid.to_s] end def self.subscribe(uid, ws) - puts "Subscribing #{uid}" + puts "Subscribing socket to #{User.first(:id => uid).email}" self.ensure_channel(uid) @channels[uid][0].subscribe{ |msg| ws.send msg } @channels[uid][1] += 1 @@ -41,6 +42,7 @@ module WebSocket end def self.unsubscribe(uid,sid) + puts "Unsubscribing socket #{sid} from #{User.first(:id => uid).email}" @channels[uid][0].unsubscribe(sid) if @channels[uid] @channels[uid][1] -= 1 if @channels[uid][1] <= 0 From c14bb5a4f875b0d9bcb301d5f423a0a17efd42d6 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 14:39:37 -0700 Subject: [PATCH 049/198] Changed info logging to debug logging almost everywhere --- app/controllers/dev_utilities_controller.rb | 38 ++++++++++----------- app/controllers/publics_controller.rb | 2 +- app/controllers/requests_controller.rb | 2 +- app/models/photo.rb | 2 -- app/models/post.rb | 4 +-- app/models/retraction.rb | 2 +- app/models/user.rb | 6 ++-- config/initializers/socket.rb | 9 +++-- lib/diaspora/parser.rb | 6 ++-- lib/diaspora/webhooks.rb | 4 +-- lib/encryptable.rb | 6 ++-- 11 files changed, 39 insertions(+), 42 deletions(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index f45be992b..d1b2d9995 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -3,21 +3,21 @@ class DevUtilitiesController < ApplicationController include ApplicationHelper def warzombie render :nothing => true - if User.owner.email == "tom@tom.joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil - StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => User.owner) - Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => User.owner ) - StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => User.owner, :created_at => Time.now-930) - StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => User.owner, :created_at => Time.now-43990) - StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => User.owner, :created_at => Time.now-4390) - Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => User.owner, :created_at => Time.now-54390) - Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :person => User.owner, :created_at => Time.now-3090) - StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => User.owner, :created_at => Time.now-30900) - Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => User.owner, :created_at => Time.now-9090) - StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => User.owner, :created_at => Time.now-590000) - StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => User.owner, :created_at => Time.now-503900) - StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => User.owner, :created_at => Time.now-4400) - StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => User.owner, :created_at => Time.now-400239) - StatusMessage.create(:message => "A cool, cool morning for once.", :person => User.owner, :created_at => Time.now-150000) + if current_user.email == "tom@tom.joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil + StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => current_user) + Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => current_user ) + StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => current_user, :created_at => Time.now-930) + StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => current_user, :created_at => Time.now-43990) + StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => current_user, :created_at => Time.now-4390) + Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => current_user, :created_at => Time.now-54390) + Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :person => current_user, :created_at => Time.now-3090) + StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => current_user, :created_at => Time.now-30900) + Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => current_user, :created_at => Time.now-9090) + StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => current_user, :created_at => Time.now-590000) + StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => current_user, :created_at => Time.now-503900) + StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => current_user, :created_at => Time.now-4400) + StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => current_user, :created_at => Time.now-400239) + StatusMessage.create(:message => "A cool, cool morning for once.", :person => current_user, :created_at => Time.now-150000) end end @@ -25,10 +25,10 @@ def warzombie render :nothing => true bkr_info = backer_info - if User.owner.email == "tom@tom.joindiaspora.com" && User.owner.friends.first.nil? + if current_user.email == "tom@tom.joindiaspora.com" && current_user.friends.first.nil? bkr_info.each do |backer| - logger.info "Zombefriending #{backer['given_name']} #{backer['family_name']}" - User.owner.send_friend_request_to("http://#{backer['username']}.joindiaspora.com/") + logger.debug "Zombefriending #{backer['given_name']} #{backer['family_name']}" + current_user.send_friend_request_to("http://#{backer['username']}.joindiaspora.com/") end end end @@ -36,7 +36,7 @@ def warzombie def zombiefriendaccept render :nothing => true Request.all.each{|r| - User.owner.accept_friend_request(r.id) + current_user.accept_friend_request(r.id) } end diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index 0582e4571..1b05532f9 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -18,7 +18,7 @@ class PublicsController < ApplicationController end def receive - Rails.logger.info "PublicsController has received: #{params[:xml]}" + Rails.logger.debug "PublicsController has received: #{params[:xml]}" store_objects_from_xml params[:xml] render :nothing => true end diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 39f9c8376..38714034f 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -26,7 +26,7 @@ class RequestsController < ApplicationController def create rel_hash = relationship_flow(params[:request][:destination_url]) - Rails.logger.info("Sending request: #{rel_hash}") + Rails.logger.debug("Sending request: #{rel_hash}") @request = current_user.send_request(rel_hash) if @request diff --git a/app/models/photo.rb b/app/models/photo.rb index e57e2f78d..c06ceb62c 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -41,11 +41,9 @@ class Photo < Post end def remote_photo= remote_path - Rails.logger.info("Setting remote photo with id #{id}") @remote_photo = remote_path image.download! remote_path image.store! - Rails.logger.info("Setting remote photo with id #{id}") end def ensure_user_picture diff --git a/app/models/post.rb b/app/models/post.rb index b5c61f492..0768a91c8 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -59,10 +59,10 @@ class Post end def log_inspection - Rails.logger.info self.inspect + Rails.logger.debug self.inspect end def log_save_inspection - Rails.logger.info "After saving, object is:" + Rails.logger.debug "After saving, object is:" log_inspection end diff --git a/app/models/retraction.rb b/app/models/retraction.rb index 6ade21ec7..dff72b767 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -27,7 +27,7 @@ class Retraction def perform begin return unless signature_valid? - Rails.logger.info("Retracting #{self.type} id: #{self.post_id}") + Rails.logger.debug("Retracting #{self.type} id: #{self.post_id}") self.type.constantize.destroy(self.post_id) rescue NameError Rails.logger.info("Retraction for unknown type recieved.") diff --git a/app/models/user.rb b/app/models/user.rb index e2d1a5773..7a73971ab 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -64,18 +64,18 @@ class User end def receive_friend_request(friend_request) - Rails.logger.info("receiving friend request #{friend_request.to_json}") + Rails.logger.debug("receiving friend request #{friend_request.to_json}") friend_request.person.serialized_key = friend_request.exported_key if Request.where(:callback_url => friend_request.callback_url).first activate_friend friend_request.person - Rails.logger.info("#{self.real_name}'s friend request has been accepted") + Rails.logger.debug("#{self.real_name}'s friend request has been accepted") friend_request.destroy else friend_request.person.save pending_friends << friend_request.person save - Rails.logger.info("#{self.real_name} has received a friend request") + Rails.logger.debug("#{self.real_name} has received a friend request") friend_request.save end end diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index 068c50e14..2fec8a328 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -25,13 +25,12 @@ module WebSocket end def self.push_to_user(uid, data) - puts @channels.size - Rails.logger.info "Pushing to #{uid}" + Rails.logger.debug "Websocketing to #{uid}" @channels[uid.to_s][0].push(data) if @channels[uid.to_s] end def self.subscribe(uid, ws) - puts "Subscribing socket to #{User.first(:id => uid).email}" + Rails.logger.debug "Subscribing socket to #{User.first(:id => uid).email}" self.ensure_channel(uid) @channels[uid][0].subscribe{ |msg| ws.send msg } @channels[uid][1] += 1 @@ -42,11 +41,11 @@ module WebSocket end def self.unsubscribe(uid,sid) - puts "Unsubscribing socket #{sid} from #{User.first(:id => uid).email}" + Rails.logger.debug "Unsubscribing socket #{sid} from #{User.first(:id => uid).email}" @channels[uid][0].unsubscribe(sid) if @channels[uid] @channels[uid][1] -= 1 if @channels[uid][1] <= 0 - @channels[uid] = nil + @channels.delete(uid) end end diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index 265e44912..9feb07cdc 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -45,16 +45,16 @@ module Diaspora def store_objects_from_xml(xml) objects = parse_objects_from_xml(xml) objects.each do |p| - Rails.logger.info("Receiving object:\n#{p.inspect}") + Rails.logger.debug("Receiving object:\n#{p.inspect}") if p.is_a? Retraction - Rails.logger.info "Got a retraction for #{p.post_id}" + Rails.logger.debug "Got a retraction for #{p.post_id}" p.perform elsif p.is_a? Request User.owner.receive_friend_request(p) elsif p.is_a? Profile p.save elsif p.respond_to?(:person) && !(p.person.nil?) && !(p.person.is_a? User) - Rails.logger.info("Saving object with success: #{p.save}") + Rails.logger.debug("Saving object with success: #{p.save}") end end end diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index 929dff515..423800459 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -20,7 +20,7 @@ module Diaspora unless recipients.empty? recipients.map!{|x| x = x.url + "receive/"} xml = Post.build_xml_for(self) - Rails.logger.info("Adding xml for #{self} to message queue to #{recipients}") + Rails.logger.debug("Adding xml for #{self} to message queue to #{recipients}") @@queue.add_post_request( recipients, xml ) end @@queue.process @@ -29,7 +29,7 @@ module Diaspora def push_to_url(url) hook_url = url + "receive/" xml = self.class.build_xml_for(self) - Rails.logger.info("Adding xml for #{self} to message queue to #{url}") + Rails.logger.debug("Adding xml for #{self} to message queue to #{url}") @@queue.add_post_request( hook_url, xml ) @@queue.process end diff --git a/lib/encryptable.rb b/lib/encryptable.rb index 6925b4cd0..850499bff 100644 --- a/lib/encryptable.rb +++ b/lib/encryptable.rb @@ -17,9 +17,9 @@ Rails.logger.info("Verifying sig on #{signable_string} but #{person.real_name} did not sign") return false end - Rails.logger.info("Verifying sig on #{signable_string} from person #{person.real_name}") + Rails.logger.debug("Verifying sig on #{signable_string} from person #{person.real_name}") validity = person.encryption_key.verify "SHA", Base64.decode64(signature), signable_string - Rails.logger.info("Validity: #{validity}") + Rails.logger.debug("Validity: #{validity}") validity end @@ -29,7 +29,7 @@ end def sign_with_key(key) - Rails.logger.info("Signing #{signable_string}") + Rails.logger.debug("Signing #{signable_string}") Base64.encode64(key.sign "SHA", signable_string) end From 039ec0d06e00307e32021610f5c03b98664c39e4 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 15:05:54 -0700 Subject: [PATCH 050/198] warzombie is now more friendly --- app/controllers/dev_utilities_controller.rb | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index d1b2d9995..7a1021b09 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -4,20 +4,20 @@ class DevUtilitiesController < ApplicationController def warzombie render :nothing => true if current_user.email == "tom@tom.joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil - StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => current_user) - Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => current_user ) - StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => current_user, :created_at => Time.now-930) - StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => current_user, :created_at => Time.now-43990) - StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => current_user, :created_at => Time.now-4390) - Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => current_user, :created_at => Time.now-54390) - Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :person => current_user, :created_at => Time.now-3090) - StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => current_user, :created_at => Time.now-30900) - Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => current_user, :created_at => Time.now-9090) - StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => current_user, :created_at => Time.now-590000) - StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => current_user, :created_at => Time.now-503900) - StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => current_user, :created_at => Time.now-4400) - StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => current_user, :created_at => Time.now-400239) - StatusMessage.create(:message => "A cool, cool morning for once.", :person => current_user, :created_at => Time.now-150000) + current_user.post(:status_message, :message => "There's a bomb in the lasagna!?") + current_user.post(:bookmark, :title => "xkcd", :link => "http://xkcd.com/743/" ) + current_user.post(:status_message, :message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :created_at => Time.now-930) + current_user.post(:status_message, :message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :created_at => Time.now-43990) + current_user.post(:status_message, :message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :created_at => Time.now-4390) + current_user.post(:bookmark, :title => "Reddit", :link => "http://reddit.com", :created_at => Time.now-54390) + current_user.post(:blog, :title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :created_at => Time.now-3090) + current_user.post(:status_message, :message => "Commercials for IE make me SO MAD and my friends just don't get why.", :created_at => Time.now-30900) + current_user.post(:bookmark, :title => "Zombo.com", :link => "http://zombo.com", :created_at => Time.now-9090) + current_user.post(:status_message, :message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :created_at => Time.now-590000) + current_user.post(:status_message, :message => "Mmm. Friday night. Acknowledged.", :created_at => Time.now-503900) + current_user.post(:status_message, :message => "Getting a universal remote is the epitome of laziness, I do declare.", :created_at => Time.now-4400) + current_user.post(:status_message, :message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :created_at => Time.now-400239) + current_user.post(:status_message, :message => "A cool, cool morning for once.", :created_at => Time.now-150000) end end From aebe7b97c0835fc19e39639f323e73564ce7fccd Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 15:58:53 -0700 Subject: [PATCH 051/198] DG RS; added groups. can't delete, but can make new ones --- app/controllers/application_controller.rb | 1 + app/controllers/groups_controller.rb | 44 +++++++++++++++++++++++ app/models/group.rb | 12 +++++++ app/models/user.rb | 9 ++++- app/views/groups/_new_group.haml | 6 ++++ app/views/groups/edit.html.haml | 25 +++++++++++++ app/views/groups/new.html.haml | 14 ++++++++ app/views/shared/_group_nav.haml | 9 +++-- config/routes.rb | 1 + public/stylesheets/application.css | 2 ++ public/stylesheets/sass/application.sass | 2 ++ spec/models/group_spec.rb | 32 +++++++++++++++++ 12 files changed, 151 insertions(+), 6 deletions(-) create mode 100644 app/controllers/groups_controller.rb create mode 100644 app/models/group.rb create mode 100644 app/views/groups/_new_group.haml create mode 100644 app/views/groups/edit.html.haml create mode 100644 app/views/groups/new.html.haml create mode 100644 spec/models/group_spec.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bb091706b..a36a8c873 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base end def set_friends_and_status + @groups = current_user.groups @friends = current_user.friends if current_user @latest_status_message = StatusMessage.newest_for(current_user) if current_user end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb new file mode 100644 index 000000000..e12809fb6 --- /dev/null +++ b/app/controllers/groups_controller.rb @@ -0,0 +1,44 @@ +class GroupsController < ApplicationController + before_filter :authenticate_user! + + def create + @group = current_user.group(params[:group]) + + if @group.created_at + flash[:notice] = "Successfully created group." + redirect_to root_url + else + render :action => 'new' + end + end + + def new + @group = Group.new + end + + def destroy + @group = Group.first(:id => params[:id]) + @group.destroy + flash[:notice] = "Successfully destroyed group." + redirect_to groups_url + end + + def show + @group = Group.first(:id => params[:id]) + end + + def edit + @group = Group.first(:id => params[:id]) + end + + def update + @group = Group.first(:id => params[:id]) + if @group.update_attributes(params[:group]) + flash[:notice] = "Successfully updated group." + redirect_to @group + else + render :action => 'edit' + end + end + +end diff --git a/app/models/group.rb b/app/models/group.rb new file mode 100644 index 000000000..885e471cc --- /dev/null +++ b/app/models/group.rb @@ -0,0 +1,12 @@ +class Group + include MongoMapper::Document + + key :name, String + + many :people, :class_name => 'Person' + belongs_to :user, :class_name => 'User' + + timestamps! + +end + diff --git a/app/models/user.rb b/app/models/user.rb index 7a73971ab..794c7970a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -12,6 +12,8 @@ class User many :friends, :in => :friend_ids, :class_name => 'Person' many :pending_friends, :in => :pending_friend_ids, :class_name => 'Person' + many :groups, :class_name => 'Group' + before_validation_on_create :assign_key before_validation :do_bad_things @@ -28,9 +30,14 @@ class User "#{person.profile.first_name.to_s} #{person.profile.last_name.to_s}" end + ######### Groups ###################### + def group( opts = {} ) + opts[:user] = self + Group.create(opts) + end - ######### Friend Requesting + ######### Friend Requesting ########### def send_friend_request_to(friend_url) unless self.friends.find{ |x| x.url == friend_url} p = Request.instantiate(:to => friend_url, :from => self.person) diff --git a/app/views/groups/_new_group.haml b/app/views/groups/_new_group.haml new file mode 100644 index 000000000..755223fd8 --- /dev/null +++ b/app/views/groups/_new_group.haml @@ -0,0 +1,6 @@ += form_for Group.new do |f| + = f.error_messages + %p + = f.label :name + = f.text_field :name + = f.submit 'create', :class => 'button' diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml new file mode 100644 index 000000000..461bff1db --- /dev/null +++ b/app/views/groups/edit.html.haml @@ -0,0 +1,25 @@ +%h1.big_text + .back + = link_to "⇧ #{@group.name}", @group + + = "Editing #{@group.name}" + +.sub_header + ="updated #{how_long_ago(@group)}" + +- form_for @group do |a| + = a.error_messages + %p + = a.text_field :name + + #submit_block + = link_to "Cancel", root_path + or + = a.submit + +.button.delete + = link_to 'Delete Album', @group, :confirm => 'Are you sure?', :method => :delete + +#content_bottom + .back + = link_to "⇧ #{@group.name}", @group diff --git a/app/views/groups/new.html.haml b/app/views/groups/new.html.haml new file mode 100644 index 000000000..c899fd9ae --- /dev/null +++ b/app/views/groups/new.html.haml @@ -0,0 +1,14 @@ +%h1.big_text + =link_to 'groups', groups_path + >> + new group + += form_for @group do |f| + = f.error_messages + %p + = f.label :name + = f.text_field :name + %p + = f.submit + +%p= link_to "Back to List", groups_path diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index 9ba2f6d67..c61712038 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -1,14 +1,13 @@ #group %ul - %li.other_presidents= link_to "OTHER PRESIDENTS", root_path(:g => "other_presidents") - %li.ostatus= link_to "OSTATUS", ostatus_path(:g => "ostatus") - %li.new_circle= link_to "NEW CIRCLE", "#" + - for group in @groups + %li= link_to group.name, group_path(group) + + %li.new_group= link_to "NEW GROUP", new_group_path #friend_pictures - for friend in @friends = person_image_link(friend) - -for author in @subscribed_persons - = link_to (image_tag author.avatar_thumbnail, :class => "person_picture"), author_path(author) .add_new = link_to "+", requests_path diff --git a/config/routes.rb b/config/routes.rb index 3726f5bf4..8d0cd5c01 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,6 +8,7 @@ Diaspora::Application.routes.draw do |map| resources :requests resources :photos resources :albums + resources :groups match "/images/files/*path" => "gridfs#serve" diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 157423bba..ad207bf50 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -70,6 +70,7 @@ header { color: #555555; background-color: #2b2726; background-color: black; + background-color: white; border-bottom: 3px solid #333333; padding: 6px 0; padding-top: 0; } @@ -436,6 +437,7 @@ h1.big_text { margin-right: 10px; } #group ul > li.selected, #group ul > li.selected a { color: white; + color: black; font-weight: bold; font-size: 18px; } #group a { diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index df7530904..75b14624e 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -75,6 +75,7 @@ header :background :color #2B2726 :color #000 + :color #fff :border :bottom 3px solid #333 :padding 6px 0 @@ -546,6 +547,7 @@ h1.big_text &.selected, &.selected a :color #fff + :color #000 :font :weight bold :size 18px diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb new file mode 100644 index 000000000..a40a9be11 --- /dev/null +++ b/spec/models/group_spec.rb @@ -0,0 +1,32 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Group do + before do + @user = Factory.create(:user) + @friend = Factory.create(:person) + end + + describe 'creation' do + it 'should have a name' do + group = @user.group(:name => 'losers') + group.name.should == "losers" + end + end + + describe 'querying' do + before do + @group = @user.group(:name => 'losers', :people => [@friend]) + end + + it 'belong to a user' do + @group.user.id.should == @user.id + @user.groups.size.should == 1 + @user.groups.first.id.should == @group.id + end + + it 'should have people' do + @group.people.all.include?(@friend).should be true + @group.people.size.should == 1 + end + end +end From 838fec4921fce9df104aa8ad00632e4086f349a8 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 16:34:06 -0700 Subject: [PATCH 052/198] RS, DG; Working on group nav, fixed some stuff in photo --- app/helpers/application_helper.rb | 6 ------ app/models/album.rb | 4 ++-- app/views/albums/index.html.haml | 2 +- app/views/albums/show.html.haml | 4 ++-- app/views/layouts/application.html.haml | 2 +- app/views/photos/_photo.haml | 2 +- app/views/shared/_group_nav.haml | 5 ++++- public/javascripts/view.js | 18 ++++++++---------- 8 files changed, 19 insertions(+), 24 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bd0ede89b..d6913a9e5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -31,12 +31,6 @@ module ApplicationHelper end end - def link_to_person(user) - person = user.person - puts person.inspect - link_to person.real_name, person_path(person) - end - def owner_image_tag person_image_tag(User.owner) end diff --git a/app/models/album.rb b/app/models/album.rb index 3fb8917c4..302cb3b07 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -26,9 +26,9 @@ class Album def self.mine_or_friends(friend_param, current_user) if friend_param - Album.where(:person_id.ne => current_user.id) + Album.where(:person_id.ne => current_user.person.id) else - Album.where(:person_id => current_user.id) + Album.where(:person_id => current_user.person.id) end end diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 2e47295d6..735ec809f 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -5,7 +5,7 @@ .right#add_album_button = link_to 'New Album', "#", :class => "button" - #add_album_box.contextual_pane + #add_album_pane.contextual_pane = render "albums/new_album" .sub_header diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index 6911d2555..6bdcafb6b 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -5,10 +5,10 @@ = @album.name -if current_user.owns? @album - .button.right#add_photos_button + .button.right#add_photo_button = link_to 'Add Photos', '#' - #add_photo_box.contextual_pane + #add_photo_pane.contextual_pane = render "photos/new_photo", :photo => @photo, :album => @album .sub_header diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 02568e239..cb06b10f9 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -33,7 +33,7 @@ #session_action - if user_signed_in? - = link_to_person current_user + = link_to current_user.real_name, current_user.person | = link_to "requests (#{@request_count})", requests_path, :class => new_request(@request_count) | diff --git a/app/views/photos/_photo.haml b/app/views/photos/_photo.haml index 9b663531a..e6734639a 100644 --- a/app/views/photos/_photo.haml +++ b/app/views/photos/_photo.haml @@ -2,7 +2,7 @@ = person_image_tag(post.person) %span.from - = link_to_person post.person + = link_to post.person.real_name, post.person %b posted a new photo to = link_to post.album.name, object_path(post.album) diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index c61712038..47810c9c3 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -3,7 +3,10 @@ - for group in @groups %li= link_to group.name, group_path(group) - %li.new_group= link_to "NEW GROUP", new_group_path + %li#add_group_button.new_group= link_to "NEW GROUP", "#" + + #add_group_pane.contextual_pane + = render "groups/new_group" #friend_pictures - for friend in @friends diff --git a/public/javascripts/view.js b/public/javascripts/view.js index c181e3bcc..0c14d431e 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -81,21 +81,19 @@ $(document).ready(function(){ }); //buttons////// - $("#add_photos_button").toggle( + function pane_toggler_button( name ) { + $("#add_" + name + "_button").toggle( function(){ - $("#add_photo_box").fadeIn(300); + $("#add_" + name + "_pane").fadeIn(300); },function(){ - $("#add_photo_box").fadeOut(200); + $("#add_" + name +"_pane").fadeOut(200); } ); + } - $("#add_album_button").toggle( - function(){ - $("#add_album_box").fadeIn(300); - },function(){ - $("#add_album_box").fadeOut(200); - } - ); + pane_toggler_button("album"); + pane_toggler_button("group"); + pane_toggler_button("photo"); $("input[type='submit']").addClass("button"); From 56d7c67bbb266d41b9eec067f2beea1e7ca93e9f Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 9 Aug 2010 17:21:41 -0700 Subject: [PATCH 053/198] Going toward pending requests --- app/controllers/publics_controller.rb | 3 +- app/helpers/requests_helper.rb | 1 - app/models/person.rb | 2 -- app/models/request.rb | 4 +-- app/models/user.rb | 18 +++++++---- config/routes.rb | 2 +- lib/diaspora/parser.rb | 4 +-- spec/controllers/publics_controller_spec.rb | 33 +++++++++++++++++---- spec/models/user_spec.rb | 14 +++++---- 9 files changed, 56 insertions(+), 25 deletions(-) diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index 0582e4571..9192f064e 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -18,8 +18,9 @@ class PublicsController < ApplicationController end def receive + user = User.first(:id => params[:id]) Rails.logger.info "PublicsController has received: #{params[:xml]}" - store_objects_from_xml params[:xml] + store_objects_from_xml params[:xml], user render :nothing => true end diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb index 4404ec223..99f73be66 100644 --- a/app/helpers/requests_helper.rb +++ b/app/helpers/requests_helper.rb @@ -29,7 +29,6 @@ module RequestsHelper f = Redfinger.finger(identifier) action = subscription_mode(f) url = subscription_url(action, f) - { action => url } end diff --git a/app/models/person.rb b/app/models/person.rb index 196a249fa..477c091ca 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -5,7 +5,6 @@ class Person xml_accessor :_id xml_accessor :email xml_accessor :url - xml_accessor :serialized_key xml_accessor :profile, :as => Profile @@ -107,7 +106,6 @@ class Person end def owns?(post) - puts self.class self.id == post.person.id end diff --git a/app/models/request.rb b/app/models/request.rb index 1db410bbc..d55d1efb8 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -44,8 +44,8 @@ class Request end #ENCRYPTION - before_validation :sign_if_mine - validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature} + #before_validation :sign_if_mine + #validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature} xml_accessor :creator_signature key :creator_signature, String diff --git a/app/models/user.rb b/app/models/user.rb index 73c8987f3..2e43ecd00 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,12 +5,12 @@ class User :recoverable, :rememberable, :trackable, :validatable key :friend_ids, Array - key :pending_friend_ids, Array + key :pending_request_ids, Array one :person, :class_name => 'Person', :foreign_key => :owner_id many :friends, :in => :friend_ids, :class_name => 'Person' - many :pending_friends, :in => :pending_friend_ids, :class_name => 'Person' + many :pending_requests, :in => :pending_request_ids, :class_name => 'Request' before_validation_on_create :assign_key before_validation :do_bad_things @@ -31,9 +31,12 @@ class User ######### Friend Requesting def send_friend_request_to(friend_url) - unless self.friends.find{ |x| x.url == friend_url} + + unless self.friends.detect{ |x| x.url == friend_url} p = Request.instantiate(:to => friend_url, :from => self.person) if p.save + self.pending_requests << p + self.save p.push_to_url friend_url end p @@ -42,7 +45,7 @@ class User def accept_friend_request(friend_request_id) request = Request.where(:id => friend_request_id).first - n = pending_friends.delete(request.person) + n = pending_requests.delete(request) friends << request.person save @@ -57,12 +60,15 @@ class User def ignore_friend_request(friend_request_id) request = Request.first(:id => friend_request_id) person = request.person - pending_friends.delete(request.person) + pending_requests.delete(request) + save person.destroy unless person.user_refs > 0 request.destroy end def receive_friend_request(friend_request) + + puts friend_request.inspect Rails.logger.info("receiving friend request #{friend_request.to_json}") friend_request.person.serialized_key = friend_request.exported_key @@ -72,7 +78,7 @@ class User friend_request.destroy else friend_request.person.save - pending_friends << friend_request.person + pending_requests << friend_request save Rails.logger.info("#{self.real_name} has received a friend request") friend_request.save diff --git a/config/routes.rb b/config/routes.rb index 3726f5bf4..274eaa86a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -25,7 +25,7 @@ Diaspora::Application.routes.draw do |map| #public routes - match 'receive', :to => 'publics#receive' + match 'receive/users/:id', :to => 'publics#receive' match '.well-known/host-meta',:to => 'publics#host_meta' match 'webfinger', :to => 'publics#webfinger' match 'hcard', :to => 'publics#hcard' diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index 265e44912..3737e5c25 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -42,7 +42,7 @@ module Diaspora objects end - def store_objects_from_xml(xml) + def store_objects_from_xml(xml, user) objects = parse_objects_from_xml(xml) objects.each do |p| Rails.logger.info("Receiving object:\n#{p.inspect}") @@ -50,7 +50,7 @@ module Diaspora Rails.logger.info "Got a retraction for #{p.post_id}" p.perform elsif p.is_a? Request - User.owner.receive_friend_request(p) + user.receive_friend_request(p) elsif p.is_a? Profile p.save elsif p.respond_to?(:person) && !(p.person.nil?) && !(p.person.is_a? User) diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 5b84098a4..1fca9f278 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -10,15 +10,38 @@ describe PublicsController do end describe 'receive endpoint' do + it 'should have a and endpoint and return a 200 on successful receipt of a request' do + post :receive, :id =>@user.id + response.code.should == '200' + end + + it 'should accept a post from another node and save the information' do - it 'should accept a post from anohter node and save the information' do - person = Factory.create(:person) message = StatusMessage.new(:message => 'foo', :person => person) - StatusMessage.all.count.should == 0 - post :receive, {:xml => Post.build_xml_for(message)} - StatusMessage.all.count.should == 1 + StatusMessage.all.count.should be 0 + post :receive, :id => @user.id, :xml => Post.build_xml_for(message) + StatusMessage.all.count.should be 1 end end + + + it 'should save requests for the specified user (LOCAL)' do + @user2 = Factory.create(:user) + @user2.person.save + + req = Request.instantiate(:from => @user2.person, :to => @user.person.url) + xml = Request.build_xml_for [req] + + puts xml + + + req.delete + post :receive, :id =>@user.id, :xml => xml + + @user2.pending_requests.count.should be 1 + @user.pending_requests.count.should be 1 + end + end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c7435cf03..bcc977505 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -39,6 +39,10 @@ describe User do it 'should not be able to friend request an existing friend' do friend = Factory.create(:person) + + @user.friends << friend + @user.save + @user.send_friend_request_to( friend.url ).should be nil end @@ -52,27 +56,27 @@ describe User do it 'should get the pending friends' do person_one = Factory.create :person person_two = Factory.create :person - @user.pending_friends.empty?.should be true + @user.pending_requests.empty?.should be true @user.friends.empty?.should be true request = Request.instantiate(:to => @user.url, :from => person_one) person_one.destroy @user.receive_friend_request request - @user.pending_friends.size.should be 1 + @user.pending_requests.size.should be 1 @user.friends.size.should be 0 request_two = Request.instantiate(:to => @user.url, :from => person_two) person_two.destroy @user.receive_friend_request request_two - @user.pending_friends.size.should be 2 + @user.pending_requests.size.should be 2 @user.friends.size.should be 0 @user.accept_friend_request request.id - @user.pending_friends.size.should be 1 + @user.pending_requests.size.should be 1 @user.friends.size.should be 1 @user.ignore_friend_request request_two.id - @user.pending_friends.size.should be 0 + @user.pending_requests.size.should be 0 @user.friends.size.should be 1 end end From 744693e7fb98cb22d0a978c2008986a2ef883bef Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 17:21:12 -0700 Subject: [PATCH 054/198] RS, DG; There is now a add friend box on the front page that passes group idto the app --- app/controllers/application_controller.rb | 1 + app/controllers/dashboards_controller.rb | 8 +++++++- app/views/blogs/_blog.html.haml | 2 +- app/views/requests/_new_request.haml | 4 +++- app/views/shared/_group_nav.haml | 11 +++++++---- public/javascripts/view.js | 7 +++++-- 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a36a8c873..8a6ab051e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -19,6 +19,7 @@ class ApplicationController < ActionController::Base @groups = current_user.groups @friends = current_user.friends if current_user @latest_status_message = StatusMessage.newest_for(current_user) if current_user + @group = params[:group] ? Group.first(:id => params[:group]) : Group.first end def count_requests diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index 882cdca50..6801f734f 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -3,6 +3,12 @@ class DashboardsController < ApplicationController include ApplicationHelper def index - @posts = Post.paginate :page => params[:page], :order => 'created_at DESC' + if params[:group] + @people_ids = @group.people.map {|p| p.id} + + @posts = Post.paginate :person_id => @people_ids, :order => 'created_at DESC' + else + @posts = Post.paginate :page => params[:page], :order => 'created_at DESC' + end end end diff --git a/app/views/blogs/_blog.html.haml b/app/views/blogs/_blog.html.haml index 0a4f79feb..0896d7d6b 100644 --- a/app/views/blogs/_blog.html.haml +++ b/app/views/blogs/_blog.html.haml @@ -3,7 +3,7 @@ = person_image_tag(post.person) %span.from - = link_to_person post.person + = link_to post.person.real_name, post.person %b wrote a new blog post %br %b= post.title diff --git a/app/views/requests/_new_request.haml b/app/views/requests/_new_request.haml index 714168fd2..40555ba98 100644 --- a/app/views/requests/_new_request.haml +++ b/app/views/requests/_new_request.haml @@ -1,8 +1,10 @@ -= form_for @request do |f| += form_for Request.new do |f| = f.error_messages + Enter a Diaspora URL, Diaspora username, or random email address: .field_with_submit = f.text_field :destination_url + = f.hidden_field :group, :value => @group.id = f.submit diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index 47810c9c3..bd6af2ca2 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -1,7 +1,7 @@ #group %ul - for group in @groups - %li= link_to group.name, group_path(group) + %li= link_to group.name, root_path(:group =>group.id) %li#add_group_button.new_group= link_to "NEW GROUP", "#" @@ -9,8 +9,11 @@ = render "groups/new_group" #friend_pictures - - for friend in @friends + - for friend in @group.people = person_image_link(friend) - .add_new - = link_to "+", requests_path + #add_request_button.add_new + = link_to "+", "#" + + #add_request_pane.contextual_pane + = render "requests/new_request" diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 0c14d431e..399521156 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -83,9 +83,11 @@ $(document).ready(function(){ //buttons////// function pane_toggler_button( name ) { $("#add_" + name + "_button").toggle( - function(){ + function(evt){ + evt.preventDefault(); $("#add_" + name + "_pane").fadeIn(300); - },function(){ + },function(evt){ + evt.preventDefault(); $("#add_" + name +"_pane").fadeOut(200); } ); @@ -94,6 +96,7 @@ $(document).ready(function(){ pane_toggler_button("album"); pane_toggler_button("group"); pane_toggler_button("photo"); + pane_toggler_button("request"); $("input[type='submit']").addClass("button"); From 91b42ac0e2638512c894dfb66caef04e1ebd3271 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 18:06:09 -0700 Subject: [PATCH 055/198] Specs now mostly pass again, one is failing --- app/views/shared/_group_nav.haml | 7 ++++--- lib/diaspora/webhooks.rb | 8 +++++++- spec/controllers/sockets_controller_spec.rb | 10 +++------- spec/models/comments_spec.rb | 2 +- spec/models/post_spec.rb | 4 ++-- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index bd6af2ca2..281aa96c9 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -8,9 +8,10 @@ #add_group_pane.contextual_pane = render "groups/new_group" - #friend_pictures - - for friend in @group.people - = person_image_link(friend) + - if @group + #friend_pictures + - for friend in @group.people + = person_image_link(friend) #add_request_button.add_new = link_to "+", "#" diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index 423800459..fc26c5c95 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -39,7 +39,13 @@ module Diaspora end def people_with_permissions - self.person.owner.friends.all + begin + friends = self.person.owner.friends + friends ||= [] + rescue + Rails.logger.fatal("IOUASDVJOISDNVPOIJSDVOUIDSGPUOID") + [] + end end def self.build_xml_for(posts) diff --git a/spec/controllers/sockets_controller_spec.rb b/spec/controllers/sockets_controller_spec.rb index 6c4dac866..84188be25 100644 --- a/spec/controllers/sockets_controller_spec.rb +++ b/spec/controllers/sockets_controller_spec.rb @@ -13,28 +13,24 @@ describe 'SocketsController' do end it 'should unstub the websockets' do - WebSocket.initialize_channel + WebSocket.initialize_channels @controller.class.should == SocketsController end - it 'should add a new subscriber to the websockets channel' do - WebSocket.initialize_channel - @controller.new_subscriber.should == 1 - end describe 'actionhash' do before do @message = @user.post :status_message, :message => "post through user for victory" end it 'should actionhash posts' do - json = @controller.action_hash(@message) + json = @controller.action_hash(@user.id, @message) json.include?(@message.message).should be_true json.include?('status_message').should be_true end it 'should actionhash retractions' do retraction = Retraction.for @message - json = @controller.action_hash(retraction) + json = @controller.action_hash(@user.id, retraction) json.include?('retraction').should be_true json.include?("html\":null").should be_true end diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index 7418cd4bb..810b6dfc5 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -45,7 +45,7 @@ describe Comment do end it 'should send a user comment on his own post to lots of people' do - allowed_urls = @user_status.people_with_permissions.map!{|x| x = x.url + "receive/"} + allowed_urls = @user_status.people_with_permissions.map{|x| x = x.url + "receive/"} message_queue.should_receive(:add_post_request).with(allowed_urls, anything) @user.comment "yo", :on => @user_status end diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index c03e2c61c..f013e1583 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -25,8 +25,8 @@ describe Post do (5..8).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @user.person)} (9..11).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @person_two)} - Factory.create(:status_message) - Factory.create(:bookmark) + Factory.create(:status_message, :person => @user) + Factory.create(:bookmark, :person => @user) end it "should give the most recent blog title and body from owner" do From acd00c2a59cba3ab316db94a2fa259145b71be5d Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 9 Aug 2010 20:14:03 -0700 Subject: [PATCH 056/198] fixed top right buttons on album page, etc. also, made the image loader simpler. --- app/views/albums/show.html.haml | 10 ++++++---- app/views/photos/_new_photo.haml | 15 ++++++++++----- app/views/shared/_group_nav.haml | 4 ++-- public/images/ajax-loader.gif | Bin 0 -> 1737 bytes public/stylesheets/application.css | 17 ++++++++++++++--- public/stylesheets/sass/application.sass | 17 ++++++++++++++--- 6 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 public/images/ajax-loader.gif diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index 6bdcafb6b..e916b14d1 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -5,8 +5,10 @@ = @album.name -if current_user.owns? @album - .button.right#add_photo_button - = link_to 'Add Photos', '#' + .right#add_photo_button + #add_photo_loader + = image_tag 'ajax-loader.gif' + = link_to 'Add Photos', '#', :class => 'button' #add_photo_pane.contextual_pane = render "photos/new_photo", :photo => @photo, :album => @album @@ -27,5 +29,5 @@ = link_to "⇧ albums", albums_path -if current_user.owns? @album - .button.right - = link_to 'Edit Album', edit_album_path(@album) + .right + = link_to 'Edit Album', edit_album_path(@album), :class => 'button' diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index 23e4ad68c..ef9396ac7 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -8,10 +8,10 @@ return confirm("You are about to upload " + total + " photos. Are you sure?"); }, setName: function(text) { - $("#progress_report_name").text(text); + //$("#progress_report_name").text(text); }, setStatus: function(text) { - $("#progress_report_status").text(text); + //$("#progress_report_status").text(text); }, setProgress: function(val) { //$("#progress_report_bar").css('width', Math.ceil(val*100)+"%"); @@ -20,11 +20,16 @@ //alert(response); }, onFinish: function(event, total){ - $("#progress_report").delay(600).slideUp(200); - $("#add_photo_box").delay(600).fadeOut(200); + //$("#progress_report").delay(600).slideUp(200); + //$("#add_photo_pane").delay(600).fadeOut(200); + $("#add_photo_button .button").html( "Add Photos" ); + $("#add_photo_loader").fadeOut(0); }, onStart: function(event, total){ - $("#progress_report").slideDown(600); + $("#add_photo_pane").fadeOut(400); + $("#add_photo_button .button").html( "Uploading Photos" ); + //$("#add_photo_button").prepend( "Loader" ); + $("#add_photo_loader").fadeIn(400); return true; } }); diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index 281aa96c9..bee73edf7 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -8,8 +8,8 @@ #add_group_pane.contextual_pane = render "groups/new_group" - - if @group - #friend_pictures + #friend_pictures + - if @group - for friend in @group.people = person_image_link(friend) diff --git a/public/images/ajax-loader.gif b/public/images/ajax-loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..e40f19a2818e4c81726bf965fc8dc108d52dc599 GIT binary patch literal 1737 zcmaLXX;2eq7{Kv0&>Vn}$SzS*LjVQjj4a)RTx3buK+piXQbnW$OoR{;K?KiH-(^=F z(X3ZJ7!}8BR6qf1)S^^W>NTR)t6t+ZUgK4-@tWG&+HXvskMBJ5&Tr;F^O&*-WvW#O z38A+T^!f8=yWM{8-n~PI4sF=5p`oE+$&w}8wr%U_>3Q_%(edNQXU?2Cd-iMq0K+hg z7A@McWy{5j7i(*4ckI~l>eZ{)uU}uidUfBveJfY4T)%$(<;$1v+_|%0!GbAMrtIIp z|J12d>(;H?y?gi5r%(6p-Rp9>HgDd1L+4f8OKqR8&;-_V#vlb=B0=l$V#k zc=6)h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zAxQ`dDG+r`mcCxDRWYV8GXfN7Gn;3}+c6dx<29W$DzzQ1M^mJLoA?XM86E|aV~aWq zcp@MPEEF>u%dAFFP?0dL6h=bwXA~)Ee$Mpj+Q1;kOhd12P!KmzmRWpytgNrLi~hwi z3KfAM1jbMpO28#Xqn3_hRB(nGrttoW9un7~ATrkCfdnB&kUb=>6*i;-|3b1AGnayZ zghL)x*j{MTxR_RBfe6_Ar?!gXalpwQTg8Nk`8|+3w Date: Mon, 9 Aug 2010 20:18:20 -0700 Subject: [PATCH 057/198] removed commented out stuff on photo_new partial. also, fixed the delete button in photo show. --- app/views/photos/_new_photo.haml | 27 --------------------------- app/views/photos/show.html.haml | 4 ++-- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index ef9396ac7..83547fdaa 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -7,47 +7,20 @@ onStart: function(event, total) { return confirm("You are about to upload " + total + " photos. Are you sure?"); }, - setName: function(text) { - //$("#progress_report_name").text(text); - }, - setStatus: function(text) { - //$("#progress_report_status").text(text); - }, - setProgress: function(val) { - //$("#progress_report_bar").css('width', Math.ceil(val*100)+"%"); - }, - onFinishOne: function(event, response, name, number, total) { - //alert(response); - }, onFinish: function(event, total){ - //$("#progress_report").delay(600).slideUp(200); - //$("#add_photo_pane").delay(600).fadeOut(200); $("#add_photo_button .button").html( "Add Photos" ); $("#add_photo_loader").fadeOut(0); }, onStart: function(event, total){ $("#add_photo_pane").fadeOut(400); $("#add_photo_button .button").html( "Uploading Photos" ); - //$("#add_photo_button").prepend( "Loader" ); $("#add_photo_loader").fadeIn(400); return true; } }); }); -:css - #progress_report, #progress_report_name, #progress_report_status{ - font-size: 12px; - padding: 0; - line-height: auto; - } - = form_for photo, :html => {:multipart => true} do |f| = f.error_messages = f.hidden_field :album_id, :value => album.id = f.file_field :image, :multiple => 'multiple' - - #progress_report{ :style => "display:none;" } - = image_tag "loader.gif" - #progress_report_name - #progress_report_status{ :style => "font-style: italic;" } diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index bf5a8f01d..e27988446 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -27,8 +27,8 @@ = link_to "⇧ #{@album.name}", album_path(@album) -if current_user.owns? @album - .button.right - = link_to 'Delete Photo', @photo, :confirm => 'Are you sure?', :method => :delete + .right + = link_to 'Delete Photo', @photo, :confirm => 'Are you sure?', :method => :delete, :class => 'button' %h4{:class => "show_post_comments"} = "comments (#{@photo.comments.count})" From fd8d92a09573cc4ade0bda98cc2840cb7680325d Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 9 Aug 2010 20:23:01 -0700 Subject: [PATCH 058/198] moved next/prev links in photo show to be inline with full size link. --- app/helpers/photos_helper.rb | 2 +- app/views/photos/show.html.haml | 11 ++++------- public/stylesheets/application.css | 3 --- public/stylesheets/sass/application.sass | 4 ---- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index b858aaf7e..b9231fe94 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -5,7 +5,7 @@ module PhotosHelper end def link_to_prev(photo, album) - link_to "<< previous", photo_path(album.prev_photo(photo)), :rel => "prefetch" + link_to "<< prev", photo_path(album.prev_photo(photo)), :rel => "prefetch" end def link_to_next(photo, album) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index e27988446..9cae263dd 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -7,21 +7,18 @@ = link_to 'Edit Photo', edit_photo_path(@photo), :class => "button" .sub_header + = link_to_prev @photo, @album + | = link_to "full size", @photo.image.url + | + = link_to_next @photo, @album %div{:id => @photo.id} - #show_photo = linked_scaled_photo @photo, @album - .caption = @photo.caption - #next_prev_links - = link_to_prev @photo, @album - | - = link_to_next @photo, @album - #content_bottom .back = link_to "⇧ #{@album.name}", album_path(@album) diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 6867646cb..0e4fa22ef 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -414,9 +414,6 @@ h1.big_text { margin-bottom: 20px; color: #999999; } -#next_prev_links { - text-align: center; } - .image_thumb { display: inline-block; width: 100px; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 0db9a9a97..66c7101f6 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -516,10 +516,6 @@ h1.big_text :bottom 20px :color #999 -#next_prev_links - :text-align center - - .image_thumb :display inline-block :width 100px From 38abd5166659792c2a900182d10696e19c95ae21 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 9 Aug 2010 21:09:51 -0700 Subject: [PATCH 059/198] MS IZ fixed a couple of failing specs in the parser --- app/controllers/publics_controller.rb | 2 +- app/models/person.rb | 2 +- lib/diaspora/parser.rb | 7 ++++ spec/controllers/publics_controller_spec.rb | 45 +++++++++++++-------- spec/lib/diaspora_parser_spec.rb | 39 +++++++++++++----- 5 files changed, 65 insertions(+), 30 deletions(-) diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index 0df200efa..acbe5e814 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -18,7 +18,7 @@ class PublicsController < ApplicationController end def receive - user = User.first(:id => params[:id]) + user = Person.first(:id => params[:id]).owner Rails.logger.debug "PublicsController has received: #{params[:xml]}" store_objects_from_xml params[:xml], user render :nothing => true diff --git a/app/models/person.rb b/app/models/person.rb index a82dd56cf..f633d04c7 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -28,7 +28,7 @@ class Person before_validation :clean_url - validates_presence_of :email, :url, :serialized_key, :profile + validates_presence_of :email, :url, :profile, :serialized_key validates_format_of :url, :with => /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index 59d7f45d4..719264f2f 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -27,6 +27,13 @@ module Diaspora person = parse_owner_id_from_xml post person.profile = object person.save + elsif object.is_a? Request + person_string = Nokogiri::XML(xml) { |cfg| cfg.noblanks }.xpath("/XML/posts/post/request/person").to_s + person = Person.from_xml person_string + person.serialized_key ||= object.exported_key + object.person = person + object.person.save + elsif object.respond_to? :person object.person = parse_owner_from_xml post.to_s end diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 1fca9f278..e63601d6a 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -11,37 +11,48 @@ describe PublicsController do describe 'receive endpoint' do it 'should have a and endpoint and return a 200 on successful receipt of a request' do - post :receive, :id =>@user.id + post :receive, :id =>@user.person.id response.code.should == '200' end it 'should accept a post from another node and save the information' do - + pending person = Factory.create(:person) message = StatusMessage.new(:message => 'foo', :person => person) StatusMessage.all.count.should be 0 - post :receive, :id => @user.id, :xml => Post.build_xml_for(message) + post :receive, :id => @user.person.id, :xml => Post.build_xml_for(message) StatusMessage.all.count.should be 1 end end + describe 'friend requests' do + before do + @user2 = Factory.create(:user) + @user2.person.save - it 'should save requests for the specified user (LOCAL)' do - @user2 = Factory.create(:user) - @user2.person.save + req = Request.instantiate(:from => @user2.person, :to => @user.person.url) + @xml = Request.build_xml_for [req] + + req.delete + end + + it 'should save requests for the specified user (LOCAL)' do + post :receive, :id => @user.person.id, :xml => @xml + + @user.reload + @user.pending_requests.size.should be 1 + end + + it 'should save requests for the specified user (REMOTE)' do + @user2.person.delete + @user2.delete + post :receive, :id => @user.person.id, :xml => @xml + + @user.reload + @user.pending_requests.size.should be 1 + end - req = Request.instantiate(:from => @user2.person, :to => @user.person.url) - xml = Request.build_xml_for [req] - - puts xml - - req.delete - post :receive, :id =>@user.id, :xml => xml - - @user2.pending_requests.count.should be 1 - @user.pending_requests.count.should be 1 end - end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 91fdd5d99..f4cd09cc9 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -6,14 +6,14 @@ include Diaspora::Parser describe Diaspora::Parser do before do @user = Factory.create(:user, :email => "bob@aol.com") - @person = Factory.create(:person, :email => "bill@gates.com") + @person = Factory.create(:person_with_private_key, :email => "bill@gates.com") end it "should not store posts from me" do status_messages = [] 10.times { status_messages << Factory.build(:status_message, :person => @user)} xml = Post.build_xml_for(status_messages) - store_objects_from_xml(xml) + store_objects_from_xml(xml, @user) StatusMessage.count.should == 0 end @@ -25,7 +25,7 @@ describe Diaspora::Parser do \n HEY DUDE\n a@a.com\n a@a.com\n a@a.com\n
" - store_objects_from_xml(xml) + store_objects_from_xml(xml, @user) Post.count.should == 0 end @@ -41,7 +41,7 @@ describe Diaspora::Parser do \n HEY DUDE\n a@a.com\n a@a.com\n a@a.com\n " - store_objects_from_xml(xml) + store_objects_from_xml(xml, @user) Post.count.should == 0 end @@ -56,7 +56,7 @@ describe Diaspora::Parser do " - store_objects_from_xml(xml) + store_objects_from_xml(xml, @user) Post.count.should == 0 end @@ -107,7 +107,7 @@ describe Diaspora::Parser do request = Post.build_xml_for( [retraction] ) StatusMessage.count.should == 1 - store_objects_from_xml( request ) + store_objects_from_xml( request, @user ) StatusMessage.count.should == 0 end @@ -116,15 +116,32 @@ describe Diaspora::Parser do original_person_id = @person.id xml = Request.build_xml_for [request] - + @person.destroy Person.all.count.should be 1 - store_objects_from_xml(xml) + store_objects_from_xml(xml, @user) Person.all.count.should be 2 Person.where(:url => request.callback_url).first.id.should == original_person_id end + it "should not create a new person if the person is already here" do + @user2 = Factory.create(:user) + request = Request.instantiate(:to =>"http://www.google.com/", :from => @user2.person) + + original_person_id = @user2.person.id + xml = Request.build_xml_for [request] + + + Person.all.count.should be 3 + store_objects_from_xml(xml, @user) + Person.all.count.should be 3 + + @user2.reload + @user2.person.serialized_key.include?("PRIVATE").should be true + + Person.where(:url => request.callback_url).first.id.should == original_person_id + end it "should activate the Person if I initiated a request to that url" do request = Request.instantiate(:to => @person.url, :from => @user).save @@ -139,7 +156,7 @@ describe Diaspora::Parser do @person.destroy request_remote.destroy - store_objects_from_xml(xml) + store_objects_from_xml(xml, @user) new_person = Person.first(:url => @person.url) new_person.nil?.should be false @user.reload @@ -152,7 +169,7 @@ describe Diaspora::Parser do request = Retraction.build_xml_for( [retraction] ) Person.count.should == 2 - store_objects_from_xml( request ) + store_objects_from_xml( request , @user) Person.count.should == 1 end @@ -178,7 +195,7 @@ describe Diaspora::Parser do old_profile.first_name.should == 'bob' #Marshal profile - store_objects_from_xml xml + store_objects_from_xml xml, @user #Check that marshaled profile is the same as old profile person = Person.first(:id => person.id) From 96fa34ea605eed60af343d85b5a589561ee498b8 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 9 Aug 2010 21:10:11 -0700 Subject: [PATCH 060/198] changed the pop-up boxes. going to probably switch to fancybox jquery plugin... also, fixed the user page so viewing it doesn't throw an error. --- app/controllers/users_controller.rb | 4 +-- app/views/albums/edit.html.haml | 4 +++ app/views/groups/_new_group.haml | 4 ++- app/views/photos/_new_photo.haml | 3 ++- app/views/requests/_new_request.haml | 10 ++++---- app/views/shared/_group_nav.haml | 3 ++- app/views/users/show.html.haml | 4 +-- public/stylesheets/application.css | 1 - public/stylesheets/sass/application.sass | 2 +- public/stylesheets/sass/ui.sass | 32 ++++++------------------ public/stylesheets/ui.css | 28 ++++++--------------- 11 files changed, 37 insertions(+), 58 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9b4411c7a..1e3f79102 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -5,8 +5,8 @@ class UsersController < ApplicationController @users = User.sort(:created_at.desc).all end def show - @user= Person.first(:id => params[:id]) - @user_profile = @user.profile + @user= User.first(:id => params[:id]) + @user_profile = @user.person.profile end def edit diff --git a/app/views/albums/edit.html.haml b/app/views/albums/edit.html.haml index 3843685e0..1580c9cae 100644 --- a/app/views/albums/edit.html.haml +++ b/app/views/albums/edit.html.haml @@ -12,6 +12,10 @@ %p = a.text_field :name + %ul + - for photo in @album.photos + %li.photo_edit_block= image_tag photo.image.url(:thumb_large) + #submit_block = link_to "Cancel", root_path or diff --git a/app/views/groups/_new_group.haml b/app/views/groups/_new_group.haml index 755223fd8..af61105f8 100644 --- a/app/views/groups/_new_group.haml +++ b/app/views/groups/_new_group.haml @@ -1,6 +1,8 @@ +%h1 Add a new group = form_for Group.new do |f| = f.error_messages %p = f.label :name = f.text_field :name - = f.submit 'create', :class => 'button' + .right + = f.submit 'create', :class => 'button' diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index 83547fdaa..e0a4cc57c 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -9,7 +9,7 @@ }, onFinish: function(event, total){ $("#add_photo_button .button").html( "Add Photos" ); - $("#add_photo_loader").fadeOut(0); + $("#add_photo_loader").fadeOut(400); }, onStart: function(event, total){ $("#add_photo_pane").fadeOut(400); @@ -20,6 +20,7 @@ }); }); +%h1= "Add photos to #{album.name}" = form_for photo, :html => {:multipart => true} do |f| = f.error_messages = f.hidden_field :album_id, :value => album.id diff --git a/app/views/requests/_new_request.haml b/app/views/requests/_new_request.haml index 40555ba98..e336357ae 100644 --- a/app/views/requests/_new_request.haml +++ b/app/views/requests/_new_request.haml @@ -1,10 +1,10 @@ +%h1= "Add a new friend to #{@group.name}" + = form_for Request.new do |f| = f.error_messages - Enter a Diaspora URL, Diaspora username, or random email address: - .field_with_submit - = f.text_field :destination_url - = f.hidden_field :group, :value => @group.id - = f.submit + = f.text_field :destination_url + = f.hidden_field :group, :value => @group.id + = f.submit diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index bee73edf7..467011a4e 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -1,7 +1,8 @@ #group %ul - for group in @groups - %li= link_to group.name, root_path(:group =>group.id) + %li{:class => ("selected" if group.id.to_s == params[:group])} + = link_to group.name, root_path(:group =>group.id) %li#add_group_button.new_group= link_to "NEW GROUP", "#" diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 9182161a3..b678b4377 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -6,6 +6,6 @@ %p = @user.url %p - %b Key Fingerprint + %b Serialized Key %p - = @user.key_fingerprint + = @user.serialized_key diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 0e4fa22ef..3a7d246c0 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -439,7 +439,6 @@ h1.big_text { margin-right: 10px; } #group ul > li.selected, #group ul > li.selected a { color: white; - color: black; font-weight: bold; font-size: 18px; } #group a { diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 66c7101f6..38d2f0ac2 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -548,7 +548,6 @@ h1.big_text &.selected, &.selected a :color #fff - :color #000 :font :weight bold :size 18px @@ -582,3 +581,4 @@ h1.big_text :display none :left -25px :top 4px + diff --git a/public/stylesheets/sass/ui.sass b/public/stylesheets/sass/ui.sass index 7a64e4ce6..5863632b3 100644 --- a/public/stylesheets/sass/ui.sass +++ b/public/stylesheets/sass/ui.sass @@ -98,33 +98,17 @@ ul.button_set :display none - :right 0 :background - :color rgba( 30,30,30,0.95 ) + :color #fff - :border 2px solid #999 + :border 4px solid #000 - :border-radius 5px - :-moz-border-radius 5px - :-webkit-border-radius 5px + :border-radius 3px + :-moz-border-radius 3px + :-webkit-border-radius 3px - :color #999 + :box-shadow 0 0 5px #000 + :-webkit-box-shadow 0 0 10px #000 - :font - :size 12px - :weight normal + :padding 2em - :line-height auto - - form - :margin 0 - :padding 10px - :color #999 - - input[type='text'] - :width 80% - :display block - - p - :padding 10px - :display inline diff --git a/public/stylesheets/ui.css b/public/stylesheets/ui.css index f83cc7957..dd791bafb 100644 --- a/public/stylesheets/ui.css +++ b/public/stylesheets/ui.css @@ -64,23 +64,11 @@ ul.button_set { z-index: 20; position: absolute; display: none; - right: 0; - background-color: rgba(30, 30, 30, 0.95); - border: 2px solid #999999; - border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - color: #999999; - font-size: 12px; - font-weight: normal; - line-height: auto; } - .contextual_pane form { - margin: 0; - padding: 10px; - color: #999999; } - .contextual_pane form input[type='text'] { - width: 80%; - display: block; } - .contextual_pane form p { - padding: 10px; - display: inline; } + background-color: white; + border: 4px solid black; + border-radius: 3px; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + box-shadow: 0 0 5px black; + -webkit-box-shadow: 0 0 10px black; + padding: 2em; } From 36e3cff1b69866caeff9fd8a7b5240e4651da23c Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 9 Aug 2010 21:16:43 -0700 Subject: [PATCH 061/198] resized default user picture to a square and compressed it. --- public/images/user/default.jpg | Bin 54589 -> 7418 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/public/images/user/default.jpg b/public/images/user/default.jpg index 788fd4f1d0d5a90933eb736a74c4f03c86049c97..b242c1e1c3ce1c06b7452a2fc93f74c05dea1950 100644 GIT binary patch delta 7006 zcmb7| zysqajc+Ttd?p)XB-1q6Mz`2u2#-WGd;Xc88f{Tau1P>n{kAUbI5fLFF5!F*Nl4rD3 zbab>-G&Bs%T&xU?985GcYyxZ?+&sK|y!5PsB7)CFxSsPq|GNNq^#~sypNN2nl8A`% zIRg#D^Z$p){?GgO2Y{Ra&;{tKFU1*r1iL-_`NTLW&LZ_0-zOCAOdhGOiQ179XuA-M ze%$=ctd(*)1Fa87)WOyGc~vyhF_@vr3W3xT4`7w0g`n7!$m6em+lA-e>SjUXg*GkQ zlGbY5I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jYE)%7GlS_T(~N~Ae#Vseg^R=(PHK|g1eH%Z1=sC?g`wDl5>=44@sphH zPfzcqWj^hr`edi)Lm%(V=7g17DjR`Zh*L`^ZcstM=ttwG8$LezV^Nv|b!e4L(Bh?N z&yKeXD)SHlz#{|$x#q{yO%}Xr-PC}w2A6Jla+Ik~W7gFYd5MtJL#-%a7j#u0rPu|Ysq2F31hE$U&6)16Oz%=6mp*1oa#D_Oh0UHoT z$8bl_Rc>vV?8(wLHITK)%~+c{Y^Ai{Gs-;y$WHjjU9>*IYi;6$7y_+~jM0WGt5amD zT*MU-kPl3I>9vI@fhTkNSB_vB&mn5UxBmcYI}Yj@#;gK$N3H6kp6RH?No(X*_}HC* z7&y+@(EIfrG38ZMNy(;YPPkr3<~Ua_dVjkl>1Edzl&TM3v8|320IsRLGl0Gs*kM2` zn%SWPkULYD1NJrfi^Y`{@(g>~Qv@{{U0}0BNmS+chc6Za7qh zt0ZS3Kl-0yz0lPWbK^n2_+*rBd_D5*2*qF0nScAK_@x+>O!Jx zEaC+%^3bU3%0a*w>_%~&#=M{bfl~r>%`{ADvy7oXbe^60Go5Pa00`$%$?VDVs7+oh zb*Bnt1SmQVM_e7h=Tsg@h^lH*l!-JGxv9`km<(pf2_24iM>kyi=yT1XTaHy#(m=)CoSi1|J7yd~)_{E)rt*{lgH_7xqtj!lWtfe&diqN7oDRhN z&XDes7Wngw@Jnd}m=C~=k-mspxV=fwBUOkReRQY{= Date: Mon, 9 Aug 2010 21:21:35 -0700 Subject: [PATCH 062/198] fixed comment view bug --- app/views/comments/_comment.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml index 8783b4502..0c7fe954d 100644 --- a/app/views/comments/_comment.html.haml +++ b/app/views/comments/_comment.html.haml @@ -1,7 +1,7 @@ %li.comment{:id => post.id} = person_image_tag(post.person) %span.from - = link_to_person post.person + = link_to post.person.real_name, post.person = auto_link post.text %div.time = "#{time_ago_in_words(post.updated_at)} ago" From d207c8b9555269c8bda5fe65bf934d30f40304e0 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 9 Aug 2010 21:27:17 -0700 Subject: [PATCH 063/198] fixed way too high z-index in album div --- app/views/albums/index.html.haml | 4 ++-- app/views/requests/_new_request.haml | 4 +++- public/stylesheets/application.css | 2 +- public/stylesheets/sass/application.sass | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 735ec809f..0c3ba03c6 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -5,8 +5,8 @@ .right#add_album_button = link_to 'New Album', "#", :class => "button" - #add_album_pane.contextual_pane - = render "albums/new_album" +#add_album_pane.contextual_pane + = render "albums/new_album" .sub_header %ul.button_set diff --git a/app/views/requests/_new_request.haml b/app/views/requests/_new_request.haml index e336357ae..42cd8b5e5 100644 --- a/app/views/requests/_new_request.haml +++ b/app/views/requests/_new_request.haml @@ -1,4 +1,6 @@ -%h1= "Add a new friend to #{@group.name}" +%h1 + Add a new friend to + %i= @group.name = form_for Request.new do |f| = f.error_messages diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 3a7d246c0..000432b85 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -357,7 +357,7 @@ ul#publisher_content_pickers li { display: inline-block; } .album .name { position: absolute; - z-index: 600; + z-index: 6; padding: 1em; background: rgba(0, 0, 0, 0.8); bottom: 20px; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 38d2f0ac2..43b118183 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -438,7 +438,7 @@ ul#publisher_content_pickers li .name :position absolute - :z-index 600 + :z-index 6 :padding 1em :background rgba(0,0,0,0.8) :bottom 20px From 4e062c143b88db6ad9736c0e89ec68bfccb70599 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 9 Aug 2010 21:29:19 -0700 Subject: [PATCH 064/198] new album partial has a title. album title is in italics in new photo partial --- app/views/albums/_new_album.haml | 2 ++ app/views/photos/_new_photo.haml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/albums/_new_album.haml b/app/views/albums/_new_album.haml index ae83e0e99..a52f0c9ec 100644 --- a/app/views/albums/_new_album.haml +++ b/app/views/albums/_new_album.haml @@ -1,3 +1,5 @@ +%h1 Add a new album + = form_for Album.new do |f| = f.error_messages %p diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index e0a4cc57c..76106246d 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -20,7 +20,9 @@ }); }); -%h1= "Add photos to #{album.name}" +%h1 + Add photos to + %i= album.name = form_for photo, :html => {:multipart => true} do |f| = f.error_messages = f.hidden_field :album_id, :value => album.id From d7d9c8aac55b3effbeef2728012f03b4535b7893 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 9 Aug 2010 21:30:56 -0700 Subject: [PATCH 065/198] MS put some current users checks into a single one --- app/controllers/application_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8a6ab051e..c36ebc0b3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,10 +16,12 @@ class ApplicationController < ActionController::Base end def set_friends_and_status - @groups = current_user.groups - @friends = current_user.friends if current_user - @latest_status_message = StatusMessage.newest_for(current_user) if current_user - @group = params[:group] ? Group.first(:id => params[:group]) : Group.first + if current_user + @groups = current_user.groups + @friends = current_user.friends + @latest_status_message = StatusMessage.newest_for(current_user) + @group = params[:group] ? Group.first(:id => params[:group]) : Group.first + end end def count_requests From d1bedeb9931aad69bf1c2e5b09400b2b55546511 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 10:11:13 -0700 Subject: [PATCH 066/198] RS, DG; don't show the group-specific nav if there is no group --- app/views/shared/_group_nav.haml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index 467011a4e..a98690150 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -9,13 +9,13 @@ #add_group_pane.contextual_pane = render "groups/new_group" - #friend_pictures - - if @group + - if @group + #friend_pictures - for friend in @group.people = person_image_link(friend) - #add_request_button.add_new - = link_to "+", "#" + #add_request_button.add_new + = link_to "+", "#" - #add_request_pane.contextual_pane - = render "requests/new_request" + #add_request_pane.contextual_pane + = render "requests/new_request" From 4308f35b4bfaf8f96ca7e2bf5bdb416561fe7a17 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 10:18:16 -0700 Subject: [PATCH 067/198] Changed partial on request index --- app/views/requests/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/requests/index.html.haml b/app/views/requests/index.html.haml index 8278719ee..cc33576cd 100644 --- a/app/views/requests/index.html.haml +++ b/app/views/requests/index.html.haml @@ -3,7 +3,7 @@ = link_to "⇧ home", root_path Requests -= render "requests/new_request", :request => @request += render "form", :request => @request %h3= "currently #{@request_count} requests" From aa4d428ab78ac3be12c04f8bafb0afd655968a3a Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 11:02:04 -0700 Subject: [PATCH 068/198] RS, DG; Groups can now include other users, the user's first group is displayed by default, never use many without :in => --- app/controllers/application_controller.rb | 2 +- app/models/group.rb | 4 +++- db/seeds/tom.rb | 11 +++++++++++ spec/models/group_spec.rb | 23 +++++++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c36ebc0b3..18e1280df 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -20,7 +20,7 @@ class ApplicationController < ActionController::Base @groups = current_user.groups @friends = current_user.friends @latest_status_message = StatusMessage.newest_for(current_user) - @group = params[:group] ? Group.first(:id => params[:group]) : Group.first + @group = params[:group] ? current_user.groups.first(:id => params[:group]) : current_user.groups.first end end diff --git a/app/models/group.rb b/app/models/group.rb index 885e471cc..5c228448d 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -3,7 +3,9 @@ class Group key :name, String - many :people, :class_name => 'Person' + key :person_ids, Array + + many :people, :in => :person_ids, :class_name => 'Person' belongs_to :user, :class_name => 'User' timestamps! diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 17b9375ca..c716ad8fa 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -24,4 +24,15 @@ user2 = User.create( :email => "korth@tom.joindiaspora.com", :url => "http://tom.joindiaspora.com/", :profile => Profile.new( :first_name => "Evan", :last_name => "Korth"))) + user2.person.save + +# friending users +user.friends << user2.person +user.group(:name => "other dudes", :people => [user2.person]) +user.save + +user2.friends << user.person +user2.group(:name => "some dudes", :people => [user.person]) +user2.save + diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index a40a9be11..1d0f400d5 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -4,6 +4,8 @@ describe Group do before do @user = Factory.create(:user) @friend = Factory.create(:person) + @user2 = Factory.create(:user) + @friend_2 = Factory.create(:person) end describe 'creation' do @@ -11,6 +13,27 @@ describe Group do group = @user.group(:name => 'losers') group.name.should == "losers" end + + it 'should be able to have people' do + group = @user.group(:name => 'losers', :people => [@friend, @friend_2]) + group.people.size.should == 2 + end + + it 'should be able to have other users' do + group = @user.group(:name => 'losers', :people => [@user2.person]) + group.people.include?(@user.person).should be false + group.people.include?(@user2.person).should be true + group.people.size.should == 1 + end + + it 'should be able to have users and people' do + group = @user.group(:name => 'losers', :people => [@user2.person, @friend_2]) + group.people.include?(@user.person).should be false + group.people.include?(@user2.person).should be true + group.people.include?(@friend_2).should be true + group.people.size.should == 2 + end + end describe 'querying' do From b645eb3f3dac1311d058beddefbb36a06ea99739 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 11:05:29 -0700 Subject: [PATCH 069/198] RS, DG, comments socket again --- app/models/comment.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index f2b6aface..79adbb49e 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -74,8 +74,12 @@ class Comment self.post_creator_signature = sign_with_key self.post.person.encryption_key end end - + def send_to_view - SocketsController.new.outgoing(self) + people_with_permissions.each{|f| + SocketsController.new.outgoing(f.owner_id, self) if f.owner_id + } + SocketsController.new.outgoing(person.owner_id, self) if person.owner_id end + end From cd875d06db700139cf0615021d41be46c5aa9e01 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 11:13:37 -0700 Subject: [PATCH 070/198] RS, DG; DB purge now deletes tmp folder --- lib/tasks/db.rake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 8c3bd2376..2563372e1 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -27,6 +27,9 @@ namespace :db do # Specifiy what models to remove # No! Drop the fucking database. MongoMapper::connection.drop_database(MongoMapper::database.name) + + puts 'Deleting tmp folder...' + `rm -rf #{File.dirname(__FILE__)}/../../public/uploads/tmp` end desc 'Purge and seed the current RAILS_ENV database using information from db/seeds.rb' From 95c4de5d6c0e5bd06edcc5f0c15bcd26871a8f8d Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 11:26:32 -0700 Subject: [PATCH 071/198] MS IZ fixed all of the request specs zomg --- app/models/user.rb | 6 ++++-- lib/diaspora/parser.rb | 17 ++++++++++++++--- spec/controllers/publics_controller_spec.rb | 3 ++- spec/lib/diaspora_parser_spec.rb | 4 ++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index c6f7e5476..43fc0c279 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -77,12 +77,14 @@ class User def receive_friend_request(friend_request) Rails.logger.debug("receiving friend request #{friend_request.to_json}") - friend_request.person.serialized_key = friend_request.exported_key - if Request.where(:callback_url => friend_request.callback_url).first + #u am originator + if Request.where(:callback_url => person.url, :destination_url => person.url).first + puts "NOOO!!" activate_friend friend_request.person Rails.logger.debug("#{self.real_name}'s friend request has been accepted") friend_request.destroy else + puts "423423" friend_request.person.save pending_requests << friend_request save diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index 719264f2f..3a12e3a85 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -16,6 +16,13 @@ module Diaspora Person.first(:id => id) end + def get_or_create_person_object_from_xml(doc) + person_xml = doc.xpath("//request/person").to_s + person_id = doc.xpath("//request/person/_id").text.to_s + person = Person.first(:_id => person_id) + person ? person : Person.from_xml( person_xml) + end + def parse_objects_from_xml(xml) objects = [] body = parse_body_contents_from_xml(xml) @@ -28,15 +35,15 @@ module Diaspora person.profile = object person.save elsif object.is_a? Request - person_string = Nokogiri::XML(xml) { |cfg| cfg.noblanks }.xpath("/XML/posts/post/request/person").to_s - person = Person.from_xml person_string + person = get_or_create_person_object_from_xml(post) person.serialized_key ||= object.exported_key object.person = person object.person.save - + object.save elsif object.respond_to? :person object.person = parse_owner_from_xml post.to_s end + objects << object rescue NameError => e if e.message.include? 'wrong constant name' @@ -56,8 +63,12 @@ module Diaspora if p.is_a? Retraction Rails.logger.debug "Got a retraction for #{p.post_id}" p.perform + elsif p.is_a? Request + puts user.pending_requests.count user.receive_friend_request(p) + puts user.pending_requests.count + elsif p.is_a? Profile p.save elsif p.respond_to?(:person) && !(p.person.nil?) && !(p.person.is_a? User) diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index e63601d6a..976d8900c 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -1,4 +1,5 @@ require File.dirname(__FILE__) + '/../spec_helper' + describe PublicsController do render_views @@ -37,7 +38,7 @@ describe PublicsController do req.delete end - it 'should save requests for the specified user (LOCAL)' do + it 'should save requests for the specified user (LOCAL)' do post :receive, :id => @user.person.id, :xml => @xml @user.reload diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index f4cd09cc9..02d0728e9 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -122,6 +122,7 @@ describe Diaspora::Parser do store_objects_from_xml(xml, @user) Person.all.count.should be 2 + Person.first(:_id => original_person_id).serialized_key.include?("PUBLIC").should be true Person.where(:url => request.callback_url).first.id.should == original_person_id end @@ -138,6 +139,9 @@ describe Diaspora::Parser do Person.all.count.should be 3 @user2.reload + @user2.person.reload + puts @user2.inspect + puts @user2.person.inspect @user2.person.serialized_key.include?("PRIVATE").should be true Person.where(:url => request.callback_url).first.id.should == original_person_id From a48fbaaf5992186f446a0e32d400f3ea55022e58 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 11:36:00 -0700 Subject: [PATCH 072/198] RS, DG; DashboardsController has been eliminated. --- app/controllers/dashboards_controller.rb | 14 -------------- app/controllers/groups_controller.rb | 9 ++++++++- app/controllers/photos_controller.rb | 4 ++-- app/views/{dashboards => groups}/index.html.haml | 0 app/views/shared/_group_nav.haml | 4 ++-- config/routes.rb | 2 +- 6 files changed, 13 insertions(+), 20 deletions(-) delete mode 100644 app/controllers/dashboards_controller.rb rename app/views/{dashboards => groups}/index.html.haml (100%) diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb deleted file mode 100644 index 6801f734f..000000000 --- a/app/controllers/dashboards_controller.rb +++ /dev/null @@ -1,14 +0,0 @@ -class DashboardsController < ApplicationController - before_filter :authenticate_user! - include ApplicationHelper - - def index - if params[:group] - @people_ids = @group.people.map {|p| p.id} - - @posts = Post.paginate :person_id => @people_ids, :order => 'created_at DESC' - else - @posts = Post.paginate :page => params[:page], :order => 'created_at DESC' - end - end -end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index e12809fb6..27f5ae782 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,12 +1,16 @@ class GroupsController < ApplicationController before_filter :authenticate_user! + def index + @posts = Post.paginate :page => params[:page], :order => 'created_at DESC' + end + def create @group = current_user.group(params[:group]) if @group.created_at flash[:notice] = "Successfully created group." - redirect_to root_url + redirect_to @group else render :action => 'new' end @@ -24,7 +28,10 @@ class GroupsController < ApplicationController end def show + @people_ids = @group.people.map {|p| p.id} + @posts = Post.paginate :person_id => @people_ids, :order => 'created_at DESC' @group = Group.first(:id => params[:id]) + render :index end def edit diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 128115d6a..995690213 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -25,14 +25,14 @@ class PhotosController < ApplicationController end def destroy - @photo = Photo.where(:id => params[:id]).first + @photo = Photo.first(:id => params[:id]) @photo.destroy flash[:notice] = "Successfully deleted photo." redirect_to @photo.album end def show - @photo = Photo.where(:id => params[:id]).first + @photo = Photo.first(:id => params[:id]) @album = @photo.album end diff --git a/app/views/dashboards/index.html.haml b/app/views/groups/index.html.haml similarity index 100% rename from app/views/dashboards/index.html.haml rename to app/views/groups/index.html.haml diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index a98690150..782025581 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -1,8 +1,8 @@ #group %ul - for group in @groups - %li{:class => ("selected" if group.id.to_s == params[:group])} - = link_to group.name, root_path(:group =>group.id) + %li{:class => ("selected" if group.id.to_s == params[:id])} + = link_to group.name, group %li#add_group_button.new_group= link_to "NEW GROUP", "#" diff --git a/config/routes.rb b/config/routes.rb index 50811fa73..fb7d71fc6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,5 +32,5 @@ Diaspora::Application.routes.draw do |map| match 'hcard', :to => 'publics#hcard' #root - root :to => 'dashboards#index' + root :to => 'groups#index' end From 9947a2abb87ecfa8aa5595bddde5535851a06ca5 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 12:26:43 -0700 Subject: [PATCH 073/198] RS, DG; latest_status thing now works, started putting signup back in --- app/controllers/application_controller.rb | 2 +- app/controllers/users_controller.rb | 16 +++++++++++ app/helpers/sockets_helper.rb | 1 + app/models/status_message.rb | 2 +- app/views/js/_websocket_js.haml | 1 + app/views/layouts/application.html.haml | 6 ++-- app/views/layouts/session_wall.html.haml | 16 ++++------- config/routes.rb | 13 ++++----- public/javascripts/publisher.js | 34 ++++++++++------------- 9 files changed, 49 insertions(+), 42 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 18e1280df..89c637b13 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -19,7 +19,7 @@ class ApplicationController < ActionController::Base if current_user @groups = current_user.groups @friends = current_user.friends - @latest_status_message = StatusMessage.newest_for(current_user) + @latest_status_message = StatusMessage.newest_for(current_user.person) @group = params[:group] ? current_user.groups.first(:id => params[:group]) : current_user.groups.first end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1e3f79102..97f8b31bc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -25,4 +25,20 @@ class UsersController < ApplicationController render :action => 'edit' end end + + def create + @user = User.new(params[:user]) + + if @user.save! + flash[:notice] = "Successfully signed up." + redirect_to root_path + else + render :action => 'new' + end + end + + def new + @user = User.new + end + end diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb index 749de4b41..27a083bdf 100644 --- a/app/helpers/sockets_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -23,6 +23,7 @@ module SocketsHelper action_hash[:photo_hash] = object.thumb_hash elsif object.is_a? StatusMessage action_hash[:status_message_hash] = object.latest_hash + action_hash[:status_message_hash][:mine?] = true if object.person.owner_id == uid end action_hash.to_json diff --git a/app/models/status_message.rb b/app/models/status_message.rb index fe641bdb2..bf56410be 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -22,7 +22,7 @@ class StatusMessage < Post end def latest_hash - {:mine? => self.person == User.owner, :text => message} + { :text => message} end end diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml index 793aea9db..9bf737e11 100644 --- a/app/views/js/_websocket_js.haml +++ b/app/views/js/_websocket_js.haml @@ -64,6 +64,7 @@ function processStatusMessage(className, html, messageHash){ processPost(className, html); + console.log(messageHash) if(messageHash['mine?']){ updateMyLatestStatus(messageHash); } diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index cb06b10f9..6f9884712 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -52,9 +52,9 @@ = link_to current_user.real_name, root_path %span#latest_message = my_latest_message - - unless @latest_status_message.nil? - %span{:style => "font-size: small", :id => 'latest_message_time'} - = " - #{how_long_ago @latest_status_message}" + %span{:style => "font-size: small", :id => 'latest_message_time'} + - unless @latest_status_message.nil? + = "- #{how_long_ago @latest_status_message}" %ul.nav %li= link_to "home", root_path diff --git a/app/views/layouts/session_wall.html.haml b/app/views/layouts/session_wall.html.haml index b025e419b..72603fbce 100644 --- a/app/views/layouts/session_wall.html.haml +++ b/app/views/layouts/session_wall.html.haml @@ -44,14 +44,8 @@ - flash.each do |name, msg| = content_tag :div, msg, :id => "flash_#{name}" - - if User.owner - %div#huge_text - welcome back, - %span - = User.owner.real_name.downcase - = yield - -else - %div#huge_text - %span - you need to add a user first! - + %div#huge_text + diaspora + = yield + + = link_to "signup", "/signup" diff --git a/config/routes.rb b/config/routes.rb index fb7d71fc6..501ac2f00 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,21 +12,20 @@ Diaspora::Application.routes.draw do |map| match "/images/files/*path" => "gridfs#serve" - match 'warzombie', :to => "dev_utilities#warzombie" - match 'zombiefriends', :to => "dev_utilities#zombiefriends" + match 'warzombie', :to => "dev_utilities#warzombie" + match 'zombiefriends', :to => "dev_utilities#zombiefriends" match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept" #routes for devise, not really sure you will need to mess with this in the future, lets put default, #non mutable stuff in anohter file devise_for :users, :path_names => {:sign_up => "signup", :sign_in => "login", :sign_out => "logout"} - match 'login', :to => 'devise/sessions#new', :as => "new_user_session" - match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" - #match 'signup', :to => 'devise/registrations#new', :as => "new_user_registration" - resources :users + match 'login', :to => 'devise/sessions#new', :as => "new_user_session" + match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" + match 'signup', :to => 'devise/registrations#new', :as => "new_user_registration" #public routes - match 'receive/users/:id', :to => 'publics#receive' + match 'receive/users/:id', :to => 'publics#receive' match '.well-known/host-meta',:to => 'publics#host_meta' match 'webfinger', :to => 'publics#webfinger' match 'hcard', :to => 'publics#hcard' diff --git a/public/javascripts/publisher.js b/public/javascripts/publisher.js index f8e0f369d..28d902098 100644 --- a/public/javascripts/publisher.js +++ b/public/javascripts/publisher.js @@ -1,24 +1,20 @@ - $(document).ready( function() { +$(document).ready( function() { - $("#publisher_content_pickers .status_message").click(selectPublisherTab); - $("#publisher_content_pickers .bookmark").click(selectPublisherTab); - $("#publisher_content_pickers .blog").click(selectPublisherTab); - $("#publisher_content_pickers .photo").click(selectPublisherTab); - - $("#new_status_message").submit(function() { - - }); + $("#publisher_content_pickers .status_message").click(selectPublisherTab); + $("#publisher_content_pickers .bookmark").click(selectPublisherTab); + $("#publisher_content_pickers .blog").click(selectPublisherTab); + $("#publisher_content_pickers .photo").click(selectPublisherTab); - function selectPublisherTab(evt){ - evt.preventDefault(); - var form_id = "#new_" + this.className - if( $(form_id).css("display") == "none" ) { - $("#publisher_content_pickers").children("li").removeClass("selected"); - $("#publisher_form form").fadeOut(50); + function selectPublisherTab(evt){ + evt.preventDefault(); + var form_id = "#new_" + this.className + if( $(form_id).css("display") == "none" ) { + $("#publisher_content_pickers").children("li").removeClass("selected"); + $("#publisher_form form").fadeOut(50); - $(this).toggleClass("selected"); - $(form_id).delay(50).fadeIn(200); - } + $(this).toggleClass("selected"); + $(form_id).delay(50).fadeIn(200); } + } - }); +}); From ac2f82c3d7354c9ab40ad97a6422b9a9250d806f Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 12:28:36 -0700 Subject: [PATCH 074/198] Renamed dashboards spec to groups --- ...{dashboards_controller_spec.rb => groups_controller_spec.rb} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename spec/controllers/{dashboards_controller_spec.rb => groups_controller_spec.rb} (94%) diff --git a/spec/controllers/dashboards_controller_spec.rb b/spec/controllers/groups_controller_spec.rb similarity index 94% rename from spec/controllers/dashboards_controller_spec.rb rename to spec/controllers/groups_controller_spec.rb index 6e1138a35..6bfce5434 100644 --- a/spec/controllers/dashboards_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -1,6 +1,6 @@ require File.dirname(__FILE__) + '/../spec_helper' include ApplicationHelper -describe DashboardsController do +describe GroupsController do render_views before do @user = Factory.create(:user) From 71612ba33d7cc45f2df424d9ba4a897e400a5a7c Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 12:36:00 -0700 Subject: [PATCH 075/198] changing some webfinger resources --- app/controllers/publics_controller.rb | 13 +++++++++---- app/helpers/publics_helper.rb | 9 ++++++++- app/models/person.rb | 3 +++ app/models/user.rb | 3 --- app/views/publics/hcard.erb | 8 ++++---- app/views/publics/host_meta.erb | 4 ++-- app/views/publics/webfinger.erb | 10 +++++----- config/routes.rb | 12 ++++++------ spec/models/person_spec.rb | 2 ++ 9 files changed, 39 insertions(+), 25 deletions(-) diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index acbe5e814..3c7a2af8f 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -3,8 +3,11 @@ class PublicsController < ApplicationController include Diaspora::Parser def hcard - @user = User.owner - render 'hcard' + @person = Person.first(:_id => params[:id]) + + unless @person.nil? || @person.owner.nil? + render 'hcard' + end end def host_meta @@ -13,8 +16,10 @@ class PublicsController < ApplicationController end def webfinger - @user = Person.first(:email => params[:q].gsub('acct:', '')) - render 'webfinger', :layout => false, :content_type => 'application/xrd+xml' + @person = Person.first(:email => params[:q].gsub('acct:', '')) + unless @person.nil? || @person.owner.nil? + render 'webfinger', :layout => false, :content_type => 'application/xrd+xml' + end end def receive diff --git a/app/helpers/publics_helper.rb b/app/helpers/publics_helper.rb index e694adef9..1e8ecac8f 100644 --- a/app/helpers/publics_helper.rb +++ b/app/helpers/publics_helper.rb @@ -14,4 +14,11 @@ module PublicsHelper 400 end end -end \ No newline at end of file + + def terse_url(full_url) + terse = full_url.gsub(/https?:\/\//, '') + terse.gsub!(/www\./, '') + terse = terse.chop! if terse[-1, 1] == '/' + terse + end +end diff --git a/app/models/person.rb b/app/models/person.rb index f633d04c7..3eaebd8d2 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -109,6 +109,9 @@ class Person self.id == post.person.id end + def recieve_url + "#{self.url}user/#{self.owner.id}" + end protected def clean_url diff --git a/app/models/user.rb b/app/models/user.rb index 43fc0c279..df7483c22 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -77,14 +77,11 @@ class User def receive_friend_request(friend_request) Rails.logger.debug("receiving friend request #{friend_request.to_json}") - #u am originator if Request.where(:callback_url => person.url, :destination_url => person.url).first - puts "NOOO!!" activate_friend friend_request.person Rails.logger.debug("#{self.real_name}'s friend request has been accepted") friend_request.destroy else - puts "423423" friend_request.person.save pending_requests << friend_request save diff --git a/app/views/publics/hcard.erb b/app/views/publics/hcard.erb index 34f88866e..7cfbe5604 100644 --- a/app/views/publics/hcard.erb +++ b/app/views/publics/hcard.erb @@ -1,24 +1,24 @@
-

<%=@user.real_name%>

+

<%=@person.real_name%>

User profile

Nickname
- <%= @user.real_name%> + <%= @person.real_name%>
Full name
- <%= @user.real_name %> + <%= @person.real_name %>
URL
- <%= @user.url%> + <%= @person.url%>
diff --git a/app/views/publics/host_meta.erb b/app/views/publics/host_meta.erb index 53d8aeba4..e28fb6211 100644 --- a/app/views/publics/host_meta.erb +++ b/app/views/publics/host_meta.erb @@ -1,9 +1,9 @@ - <%= @user.terse_url %> + <%= terse_url(root_url) %> + template='<%= root_url %>webfinger?q={uri}'> Resource Descriptor diff --git a/app/views/publics/webfinger.erb b/app/views/publics/webfinger.erb index bafd58acb..db4cd3a1c 100644 --- a/app/views/publics/webfinger.erb +++ b/app/views/publics/webfinger.erb @@ -1,8 +1,8 @@ - acct:<%=@user.email%> - "<%=@user.url%>hcard" - - - + acct:<%=@person.email%> + "<%= @person.url %>users/#{@user.id}/hcard" + + + diff --git a/config/routes.rb b/config/routes.rb index 50811fa73..7e830ecc5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -24,13 +24,13 @@ Diaspora::Application.routes.draw do |map| #match 'signup', :to => 'devise/registrations#new', :as => "new_user_registration" resources :users - #public routes - match 'receive/users/:id', :to => 'publics#receive' - match '.well-known/host-meta',:to => 'publics#host_meta' - match 'webfinger', :to => 'publics#webfinger' - match 'hcard', :to => 'publics#hcard' - + # + match 'webfinger', :to => 'publics#webfinger' + match 'users/:id/hcard', :to => 'publics#hcard' + + match '.well-known/host-meta',:to => 'publics#host_meta' + match 'receive/users/:id', :to => 'publics#receive' #root root :to => 'dashboards#index' end diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 6fcd775d3..41046b932 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -4,6 +4,8 @@ describe Person do before do @person = Factory.create(:person) end + + it 'should not allow two people with the same email' do person_two = Factory.build(:person, :url => @person.email) person_two.valid?.should == false From 3607601ea3c1bb2a5c99c2614b1213c8aea7349d Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 13:32:26 -0700 Subject: [PATCH 076/198] addded the right url to the push to method --- lib/diaspora/webhooks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index fc26c5c95..26cddc01a 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -18,7 +18,7 @@ module Diaspora def push_to(recipients) unless recipients.empty? - recipients.map!{|x| x = x.url + "receive/"} + recipients.map!{|x| x = x.receive_url } xml = Post.build_xml_for(self) Rails.logger.debug("Adding xml for #{self} to message queue to #{recipients}") @@queue.add_post_request( recipients, xml ) From b5f962c7259d38585eebef2c35fca6b34e5d03ca Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 13:58:17 -0700 Subject: [PATCH 077/198] trying root path in host meta --- app/views/publics/host_meta.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/publics/host_meta.erb b/app/views/publics/host_meta.erb index e28fb6211..b657a440f 100644 --- a/app/views/publics/host_meta.erb +++ b/app/views/publics/host_meta.erb @@ -1,9 +1,9 @@ - <%= terse_url(root_url) %> + <%= terse_url(root_path) %> + template='<%= root_path %>webfinger?q={uri}'> Resource Descriptor From 016c8fa471c0d03aea752011554aa8bf4e77fc09 Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 14:11:41 -0700 Subject: [PATCH 078/198] MS IZ taking out URL options in sockets helper. hopefully the websocket doesnt blow up --- app/helpers/sockets_helper.rb | 6 +++--- app/views/publics/host_meta.erb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb index 27a083bdf..b35780399 100644 --- a/app/helpers/sockets_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -5,9 +5,9 @@ module SocketsHelper (object.is_a? Post) ? object.id : object.post_id end - def url_options - {:host => ""} - end + #def url_options + # {:host => ""} + #end def action_hash(uid, object) begin diff --git a/app/views/publics/host_meta.erb b/app/views/publics/host_meta.erb index b657a440f..e28fb6211 100644 --- a/app/views/publics/host_meta.erb +++ b/app/views/publics/host_meta.erb @@ -1,9 +1,9 @@ - <%= terse_url(root_path) %> + <%= terse_url(root_url) %> + template='<%= root_url %>webfinger?q={uri}'> Resource Descriptor From 7ff25ef81aec3da03556520c76f8b9a22c501274 Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 15:10:11 -0700 Subject: [PATCH 079/198] MS IZ saved the person model --- app/models/person.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/person.rb b/app/models/person.rb index 3eaebd8d2..0b31cbc0a 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -110,7 +110,7 @@ class Person end def recieve_url - "#{self.url}user/#{self.owner.id}" + "#{self.url}user/#{self.id}" end protected From 487de2d8651a0c2e2af9acbbf4bf9e7ab47e7d9f Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 15:17:12 -0700 Subject: [PATCH 080/198] MS IZ receive, not recieve --- app/models/person.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/person.rb b/app/models/person.rb index 0b31cbc0a..005037d5e 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -109,7 +109,7 @@ class Person self.id == post.person.id end - def recieve_url + def receive_url "#{self.url}user/#{self.id}" end From da4de20ce11d673256c348e0174f3b74ae3ed063 Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 15:24:51 -0700 Subject: [PATCH 081/198] IZ MS made things push to the receive url --- app/models/request.rb | 2 +- app/models/user.rb | 2 +- lib/diaspora/webhooks.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/request.rb b/app/models/request.rb index d55d1efb8..e3fad0606 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -30,7 +30,7 @@ class Request def self.instantiate(options = {}) person = options[:from] - self.new(:destination_url => options[:to], :callback_url => person.url, :person => person, :exported_key => person.export_key) + self.new(:destination_url => options[:to], :callback_url => person.receive_url, :person => person, :exported_key => person.export_key) end diff --git a/app/models/user.rb b/app/models/user.rb index df7483c22..8fb73dc55 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -97,7 +97,7 @@ class User self.save if bad_friend - Retraction.for(self).push_to_url(bad_friend.url) + Retraction.for(self).push_to_url(bad_friend.receive_url) bad_friend.update_attributes(:user_refs => bad_friend.user_refs - 1) bad_friend.destroy if bad_friend.user_refs == 0 end diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index 26cddc01a..ba78ed81a 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -27,7 +27,7 @@ module Diaspora end def push_to_url(url) - hook_url = url + "receive/" + hook_url = url xml = self.class.build_xml_for(self) Rails.logger.debug("Adding xml for #{self} to message queue to #{url}") @@queue.add_post_request( hook_url, xml ) From a8b77cf868de63c054aa86046e3c21ef5de66ce9 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 15:35:27 -0700 Subject: [PATCH 082/198] DG RS; made an instantiate method for user which makes a person and profile --- app/controllers/users_controller.rb | 4 ++-- app/helpers/status_messages_helper.rb | 4 ---- app/models/user.rb | 12 +++++++++++- spec/models/user_spec.rb | 12 ++++++++++++ 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 97f8b31bc..45c80bc5a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,6 @@ class UsersController < ApplicationController + before_filter :authenticate_user!, :except => [:new, :create] - before_filter :authenticate_user! def index @users = User.sort(:created_at.desc).all end @@ -29,7 +29,7 @@ class UsersController < ApplicationController def create @user = User.new(params[:user]) - if @user.save! + if @user.person.save! && @user.save! flash[:notice] = "Successfully signed up." redirect_to root_path else diff --git a/app/helpers/status_messages_helper.rb b/app/helpers/status_messages_helper.rb index 57d0f2f17..840e789a0 100644 --- a/app/helpers/status_messages_helper.rb +++ b/app/helpers/status_messages_helper.rb @@ -1,5 +1,4 @@ module StatusMessagesHelper - def my_latest_message unless @latest_status_message.nil? return @latest_status_message.message @@ -7,7 +6,4 @@ module StatusMessagesHelper return "No message to display." end end - - - end diff --git a/app/models/user.rb b/app/models/user.rb index df7483c22..8981fbee0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -118,7 +118,17 @@ class User ###Helpers############ - + def self.instantiate( opts = {} ) + User.create( + :email => opts[:email], + :password => opts[:password], + :password_confirmation => opts[:password_confirmation], + :person => Person.new( + :email => opts[:email], + :profile => Profile.new( + :first_name => opts[:first_name], + :last_name => opts[:last_name]))) + end def terse_url terse= self.url.gsub(/https?:\/\//, '') diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index bcc977505..bcdf97db7 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -11,6 +11,18 @@ describe User do Person.count.should == n+1 end + it 'should instantiate with a person and be valid' do + user = User.instantiate(:email => "bob@bob.com", + :password => "password", + :password_confirmation => "password", + :first_name => "bob", + :last_name => "grimm") + + user.save.should be true + user.person.should_not be nil + user.person.profile.should_not be nil + end + describe 'friend requesting' do it "should be able to accept a pending friend request" do friend = Factory.create(:person) From 432ce02a14ef8f13e04c1b3601dd2e88ff1d4b87 Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 15:35:40 -0700 Subject: [PATCH 083/198] MS IZ receive url is better --- app/models/person.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/person.rb b/app/models/person.rb index 005037d5e..4d6cf9454 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -110,7 +110,7 @@ class Person end def receive_url - "#{self.url}user/#{self.id}" + "#{self.url}receive/users/#{self.id}" end protected From 8b9cd3453dd7650de5961b28460cf35843873579 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 15:44:14 -0700 Subject: [PATCH 084/198] RS, DG; User.instatntiate simplified --- app/models/user.rb | 11 ++--------- spec/models/user_spec.rb | 6 ++++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 8981fbee0..b026458da 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -119,15 +119,8 @@ class User ###Helpers############ def self.instantiate( opts = {} ) - User.create( - :email => opts[:email], - :password => opts[:password], - :password_confirmation => opts[:password_confirmation], - :person => Person.new( - :email => opts[:email], - :profile => Profile.new( - :first_name => opts[:first_name], - :last_name => opts[:last_name]))) + opts[:person][:email] = opts[:email] + User.create( opts) end def terse_url diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index bcdf97db7..b32581afc 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -15,8 +15,10 @@ describe User do user = User.instantiate(:email => "bob@bob.com", :password => "password", :password_confirmation => "password", - :first_name => "bob", - :last_name => "grimm") + :person => + {:profile => { + :first_name => "bob", + :last_name => "grimm"}}) user.save.should be true user.person.should_not be nil From 89c54d1a63d037c8023ccef99be41f3f59251994 Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 15:56:34 -0700 Subject: [PATCH 085/198] MS IZ receive url in the request and a slash in person --- app/models/person.rb | 2 +- app/models/request.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 4d6cf9454..ad3991959 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -110,7 +110,7 @@ class Person end def receive_url - "#{self.url}receive/users/#{self.id}" + "#{self.url}receive/users/#{self.id}/" end protected diff --git a/app/models/request.rb b/app/models/request.rb index e3fad0606..31dcd162e 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -25,8 +25,8 @@ class Request before_validation :clean_link - scope :for_user, lambda{ |user| where(:destination_url => user.url) } - scope :from_user, lambda{ |user| where(:destination_url.ne => user.url) } + scope :for_user, lambda{ |user| where(:destination_url => user.receive_url) } + scope :from_user, lambda{ |user| where(:destination_url.ne => user.receive_url) } def self.instantiate(options = {}) person = options[:from] From 0fb55be7a09b8c3e262ff0c6cdcf2564a980f000 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 16:03:38 -0700 Subject: [PATCH 086/198] RS, DG; You can now sign up to be a user on a seed --- app/controllers/users_controller.rb | 6 +++--- app/models/user.rb | 5 +++++ app/views/devise/registrations/new.html.haml | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 45c80bc5a..12f87c481 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -27,9 +27,9 @@ class UsersController < ApplicationController end def create - @user = User.new(params[:user]) - - if @user.person.save! && @user.save! + @user = User.instantiate(params[:user]) + + if @user.created_at && @user.person.created_at flash[:notice] = "Successfully signed up." redirect_to root_path else diff --git a/app/models/user.rb b/app/models/user.rb index b026458da..fc04f2dc6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -120,6 +120,7 @@ class User ###Helpers############ def self.instantiate( opts = {} ) opts[:person][:email] = opts[:email] + opts[:person][:serialized_key] = generate_key User.create( opts) end @@ -148,4 +149,8 @@ class User OpenSSL::PKey::RSA::generate 1024 end + def self.generate_key + OpenSSL::PKey::RSA::generate 1024 + end + end diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index b03da3518..6ea93b780 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -3,15 +3,24 @@ = devise_error_messages! %p = f.label :email - %br/ = f.text_field :email %p = f.label :password - %br/ = f.password_field :password %p = f.label :password_confirmation - %br/ = f.password_field :password_confirmation + + = f.fields_for :person do |p| + = p.hidden_field :url, :value => "http://google.com/" + + = p.fields_for :profile do |pr| + %p + = pr.label :first_name + = pr.text_field :first_name + %p + = pr.label :last_name + = pr.text_field :last_name + %p= f.submit "Sign up" = render :partial => "devise/shared/links" From 8a3eb9f6cf3c8f786d79f252b76ec917b997c143 Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 16:04:08 -0700 Subject: [PATCH 087/198] IZ MS one last receive url...i think... --- 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 8fb73dc55..f30feadf0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -77,7 +77,7 @@ class User def receive_friend_request(friend_request) Rails.logger.debug("receiving friend request #{friend_request.to_json}") - if Request.where(:callback_url => person.url, :destination_url => person.url).first + if Request.where(:callback_url => person.receive_url, :destination_url => person.receive_url).first activate_friend friend_request.person Rails.logger.debug("#{self.real_name}'s friend request has been accepted") friend_request.destroy From 3104eeebc9fc9c3ac8c470d7f2959170f3910ae3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 16:40:15 -0700 Subject: [PATCH 088/198] RS, DG; Photo websocket margins fixed --- app/views/js/_websocket_js.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml index 9bf737e11..e65962761 100644 --- a/app/views/js/_websocket_js.haml +++ b/app/views/js/_websocket_js.haml @@ -79,7 +79,7 @@ if (location.href.indexOf(photoHash['album_id']) == -1){ return ; } - html = "
\ + html = "" From 37bf5b45f1e24a844d1d1698edbbead81a9c6dd4 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 16:56:19 -0700 Subject: [PATCH 089/198] RS, DG; You now can't open the photo upload form while photos are uploading --- app/views/photos/_new_photo.haml | 2 ++ public/javascripts/view.js | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index 76106246d..09b0230ee 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -10,11 +10,13 @@ onFinish: function(event, total){ $("#add_photo_button .button").html( "Add Photos" ); $("#add_photo_loader").fadeOut(400); + pane_toggler_button("photo"); }, onStart: function(event, total){ $("#add_photo_pane").fadeOut(400); $("#add_photo_button .button").html( "Uploading Photos" ); $("#add_photo_loader").fadeIn(400); + $("#add_photo_button").unbind(); return true; } }); diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 399521156..994d77872 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -81,17 +81,7 @@ $(document).ready(function(){ }); //buttons////// - function pane_toggler_button( name ) { - $("#add_" + name + "_button").toggle( - function(evt){ - evt.preventDefault(); - $("#add_" + name + "_pane").fadeIn(300); - },function(evt){ - evt.preventDefault(); - $("#add_" + name +"_pane").fadeOut(200); - } - ); - } + pane_toggler_button("album"); pane_toggler_button("group"); @@ -113,3 +103,16 @@ $(document).ready(function(){ }); });//end document ready + + +function pane_toggler_button( name ) { + $("#add_" + name + "_button").toggle( + function(evt){ + evt.preventDefault(); + $("#add_" + name + "_pane").fadeIn(300); + },function(evt){ + evt.preventDefault(); + $("#add_" + name +"_pane").fadeOut(200); + } + ); +} From bd7ce5250f48cd038536aef81595e6ef6e671e7d Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 17:14:58 -0700 Subject: [PATCH 090/198] renamed the route for signup. also, removed the link from the login page: get_to_the_choppa --- app/views/devise/registrations/new.html.haml | 3 +++ app/views/devise/sessions/new.html.haml | 12 +++++++----- app/views/layouts/session_wall.html.haml | 4 +--- config/routes.rb | 4 ++-- public/javascripts/view.js | 2 -- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 6ea93b780..8e268c926 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -1,3 +1,6 @@ += image_tag "http://needcoffee.cachefly.net/needcoffee/uploads/2009/02/predator-arnold-schwarzenegger.jpg" + + %h2 Sign up = form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| = devise_error_messages! diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 367dc3b5f..a36917c7b 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,11 +1,13 @@ = form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %p = f.text_field :email - %br + %br = f.password_field :password + /%p /- if devise_mapping.rememberable? - /= f.check_box :remember_me - /= f.label :remember_me - = f.submit "Sign in" -/= render :partial => "devise/shared/links" + / = f.check_box :remember_me + / = f.label :remember_me + %p + = f.submit "Sign in" += render :partial => "devise/shared/links" diff --git a/app/views/layouts/session_wall.html.haml b/app/views/layouts/session_wall.html.haml index 72603fbce..95d0f7e34 100644 --- a/app/views/layouts/session_wall.html.haml +++ b/app/views/layouts/session_wall.html.haml @@ -40,12 +40,10 @@
- - - flash.each do |name, msg| = content_tag :div, msg, :id => "flash_#{name}" %div#huge_text diaspora = yield - = link_to "signup", "/signup" + /= link_to "signup", "/signup" diff --git a/config/routes.rb b/config/routes.rb index 6ac6330a0..8a2a972ee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,10 +18,10 @@ Diaspora::Application.routes.draw do |map| #routes for devise, not really sure you will need to mess with this in the future, lets put default, #non mutable stuff in anohter file - devise_for :users, :path_names => {:sign_up => "signup", :sign_in => "login", :sign_out => "logout"} + devise_for :users, :path_names => {:sign_up => "get_to_the_choppa", :sign_in => "login", :sign_out => "logout"} match 'login', :to => 'devise/sessions#new', :as => "new_user_session" match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" - match 'signup', :to => 'devise/registrations#new', :as => "new_user_registration" + match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration" #public routes # diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 994d77872..59d324306 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -81,8 +81,6 @@ $(document).ready(function(){ }); //buttons////// - - pane_toggler_button("album"); pane_toggler_button("group"); pane_toggler_button("photo"); From a45d852f301ef2c2f7a80f71e5f84721298711f6 Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 17:36:25 -0700 Subject: [PATCH 091/198] MS IZ request specs now PASS --- app/models/user.rb | 5 ++--- lib/diaspora/parser.rb | 4 ++-- spec/helpers/requests_helper_spec.rb | 2 +- spec/lib/diaspora_parser_spec.rb | 22 +++++++++++++++------- spec/models/comments_spec.rb | 2 +- spec/models/request_spec.rb | 8 ++++---- spec/models/user_spec.rb | 10 +++++----- 7 files changed, 30 insertions(+), 23 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 1896af90c..d7184cf8f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -40,7 +40,7 @@ class User ######### Friend Requesting ########### def send_friend_request_to(friend_url) - unless self.friends.detect{ |x| x.url == friend_url} + unless self.friends.detect{ |x| x.receive_url == friend_url} p = Request.instantiate(:to => friend_url, :from => self.person) if p.save self.pending_requests << p @@ -76,8 +76,7 @@ class User def receive_friend_request(friend_request) Rails.logger.debug("receiving friend request #{friend_request.to_json}") - - if Request.where(:callback_url => person.receive_url, :destination_url => person.receive_url).first + if pending_requests.detect{|req| (req.callback_url == person.receive_url) && (req.destination_url == person.receive_url)} activate_friend friend_request.person Rails.logger.debug("#{self.real_name}'s friend request has been accepted") friend_request.destroy diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index 3a12e3a85..c5fdf3ccb 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -60,17 +60,17 @@ module Diaspora objects = parse_objects_from_xml(xml) objects.each do |p| Rails.logger.debug("Receiving object:\n#{p.inspect}") + if p.is_a? Retraction Rails.logger.debug "Got a retraction for #{p.post_id}" p.perform elsif p.is_a? Request - puts user.pending_requests.count user.receive_friend_request(p) - puts user.pending_requests.count elsif p.is_a? Profile p.save + elsif p.respond_to?(:person) && !(p.person.nil?) && !(p.person.is_a? User) Rails.logger.debug("Saving object with success: #{p.save}") end diff --git a/spec/helpers/requests_helper_spec.rb b/spec/helpers/requests_helper_spec.rb index 6f5b37442..8419bd566 100644 --- a/spec/helpers/requests_helper_spec.rb +++ b/spec/helpers/requests_helper_spec.rb @@ -20,7 +20,7 @@ describe RequestsHelper do end it 'should return the correct tag and url for a given address' do - relationship_flow('tom@tom.joindiaspora.com')[:friend].should == 'http://tom.joindiaspora.com/' + relationship_flow('tom@tom.joindiaspora.com')[:friend].include?("receive/user").should == true end end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 02d0728e9..4ec4815c7 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -3,6 +3,8 @@ require File.dirname(__FILE__) + '/../spec_helper' include ApplicationHelper include Diaspora::Parser + + describe Diaspora::Parser do before do @user = Factory.create(:user, :email => "bob@aol.com") @@ -123,7 +125,8 @@ describe Diaspora::Parser do Person.all.count.should be 2 Person.first(:_id => original_person_id).serialized_key.include?("PUBLIC").should be true - Person.where(:url => request.callback_url).first.id.should == original_person_id + url = "http://" + request.callback_url.split("/")[2] + "/" + Person.where(:url => url).first.id.should == original_person_id end it "should not create a new person if the person is already here" do @@ -140,19 +143,23 @@ describe Diaspora::Parser do @user2.reload @user2.person.reload - puts @user2.inspect - puts @user2.person.inspect @user2.person.serialized_key.include?("PRIVATE").should be true - Person.where(:url => request.callback_url).first.id.should == original_person_id + url = "http://" + request.callback_url.split("/")[2] + "/" + Person.where(:url => url).first.id.should == original_person_id end it "should activate the Person if I initiated a request to that url" do - request = Request.instantiate(:to => @person.url, :from => @user).save + request = Request.instantiate(:to => @person.receive_url, :from => @user) + request.save + @user.pending_requests << request + @user.save + request_remote = Request.new - request_remote.destination_url = @user.url - request_remote.callback_url = @user.url + request_remote.id = request.id + request_remote.destination_url = @user.receive_url + request_remote.callback_url = @user.receive_url request_remote.person = @person request_remote.exported_key = @person.export_key @@ -163,6 +170,7 @@ describe Diaspora::Parser do store_objects_from_xml(xml, @user) new_person = Person.first(:url => @person.url) new_person.nil?.should be false + @user.reload @user.friends.include?(new_person).should be true end diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index 810b6dfc5..3be395644 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -45,7 +45,7 @@ describe Comment do end it 'should send a user comment on his own post to lots of people' do - allowed_urls = @user_status.people_with_permissions.map{|x| x = x.url + "receive/"} + allowed_urls = @user_status.people_with_permissions.map{|x| x = x.receive_url} message_queue.should_receive(:add_post_request).with(allowed_urls, anything) @user.comment "yo", :on => @user_status end diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index cafcd8c9d..f3fd9c4a5 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -27,10 +27,10 @@ describe Request do user = Factory.create(:user) remote_person = Factory.build(:person, :email => "robert@grimm.com", :url => "http://king.com/") - Request.instantiate(:from => user.person, :to => remote_person.url).save - Request.instantiate(:from => user.person, :to => remote_person.url).save - Request.instantiate(:from => user.person, :to => remote_person.url).save - Request.instantiate(:from => remote_person, :to => user.url).save + Request.instantiate(:from => user.person, :to => remote_person.receive_url).save + Request.instantiate(:from => user.person, :to => remote_person.receive_url).save + Request.instantiate(:from => user.person, :to => remote_person.receive_url).save + Request.instantiate(:from => remote_person, :to => user.receive_url).save Request.for_user(user).all.count.should == 1 end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b32581afc..2102344b8 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -28,7 +28,7 @@ describe User do describe 'friend requesting' do it "should be able to accept a pending friend request" do friend = Factory.create(:person) - r = Request.instantiate(:to => @user.url, :from => friend) + r = Request.instantiate(:to => @user.receive_url, :from => friend) r.save Person.all.count.should == 2 Request.for_user(@user).all.count.should == 1 @@ -39,7 +39,7 @@ describe User do it 'should be able to ignore a pending friend request' do friend = Factory.create(:person) - r = Request.instantiate(:to => @user.url, :from => friend) + r = Request.instantiate(:to => @user.receive_url, :from => friend) r.save Person.count.should == 2 @@ -58,7 +58,7 @@ describe User do @user.save - @user.send_friend_request_to( friend.url ).should be nil + @user.send_friend_request_to( friend.receive_url ).should be nil end it 'should be able to give me the terse url for webfinger' do @@ -73,13 +73,13 @@ describe User do @user.pending_requests.empty?.should be true @user.friends.empty?.should be true - request = Request.instantiate(:to => @user.url, :from => person_one) + request = Request.instantiate(:to => @user.receive_url, :from => person_one) person_one.destroy @user.receive_friend_request request @user.pending_requests.size.should be 1 @user.friends.size.should be 0 - request_two = Request.instantiate(:to => @user.url, :from => person_two) + request_two = Request.instantiate(:to => @user.receive_url, :from => person_two) person_two.destroy @user.receive_friend_request request_two @user.pending_requests.size.should be 2 From 8d986a207e285af9a2cad3c11aee756c336d5e89 Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 10 Aug 2010 17:50:17 -0700 Subject: [PATCH 092/198] IZ MS; Socket test now passes --- lib/diaspora/parser.rb | 1 - spec/controllers/sockets_controller_spec.rb | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index c5fdf3ccb..9636bbe22 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -70,7 +70,6 @@ module Diaspora elsif p.is_a? Profile p.save - elsif p.respond_to?(:person) && !(p.person.nil?) && !(p.person.is_a? User) Rails.logger.debug("Saving object with success: #{p.save}") end diff --git a/spec/controllers/sockets_controller_spec.rb b/spec/controllers/sockets_controller_spec.rb index 84188be25..19673cb24 100644 --- a/spec/controllers/sockets_controller_spec.rb +++ b/spec/controllers/sockets_controller_spec.rb @@ -23,6 +23,12 @@ describe 'SocketsController' do end it 'should actionhash posts' do + class SocketsController + def url_options + {:host => ""} + end + end + json = @controller.action_hash(@user.id, @message) json.include?(@message.message).should be_true json.include?('status_message').should be_true From a201390123ec560f7c4126e49eb63523fc76c382 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 17:59:22 -0700 Subject: [PATCH 093/198] DG, RS; Added fancybox, made the contextual panes fancyboxes, photo adding is all broken --- app/views/albums/index.html.haml | 9 +- app/views/albums/show.html.haml | 11 +- app/views/groups/_new_group.haml | 3 +- app/views/layouts/application.html.haml | 6 + app/views/photos/_new_photo.haml | 3 - app/views/shared/_group_nav.haml | 17 +- public/javascripts/fancybox/blank.gif | Bin 0 -> 43 bytes public/javascripts/fancybox/fancy_close.png | Bin 0 -> 1517 bytes public/javascripts/fancybox/fancy_loading.png | Bin 0 -> 10195 bytes .../javascripts/fancybox/fancy_nav_left.png | Bin 0 -> 1446 bytes .../javascripts/fancybox/fancy_nav_right.png | Bin 0 -> 1454 bytes .../javascripts/fancybox/fancy_shadow_e.png | Bin 0 -> 107 bytes .../javascripts/fancybox/fancy_shadow_n.png | Bin 0 -> 106 bytes .../javascripts/fancybox/fancy_shadow_ne.png | Bin 0 -> 347 bytes .../javascripts/fancybox/fancy_shadow_nw.png | Bin 0 -> 324 bytes .../javascripts/fancybox/fancy_shadow_s.png | Bin 0 -> 111 bytes .../javascripts/fancybox/fancy_shadow_se.png | Bin 0 -> 352 bytes .../javascripts/fancybox/fancy_shadow_sw.png | Bin 0 -> 340 bytes .../javascripts/fancybox/fancy_shadow_w.png | Bin 0 -> 103 bytes .../javascripts/fancybox/fancy_title_left.png | Bin 0 -> 503 bytes .../javascripts/fancybox/fancy_title_main.png | Bin 0 -> 96 bytes .../javascripts/fancybox/fancy_title_over.png | Bin 0 -> 70 bytes .../fancybox/fancy_title_right.png | Bin 0 -> 506 bytes public/javascripts/fancybox/fancybox-x.png | Bin 0 -> 203 bytes public/javascripts/fancybox/fancybox-y.png | Bin 0 -> 176 bytes public/javascripts/fancybox/fancybox.png | Bin 0 -> 15287 bytes .../fancybox/jquery.easing-1.3.pack.js | 72 ++ .../fancybox/jquery.fancybox-1.3.1.css | 363 ++++++ .../fancybox/jquery.fancybox-1.3.1.js | 1077 +++++++++++++++++ .../fancybox/jquery.fancybox-1.3.1.pack.js | 44 + .../fancybox/jquery.mousewheel-3.0.2.pack.js | 13 + public/javascripts/view.js | 5 + 32 files changed, 1601 insertions(+), 22 deletions(-) create mode 100644 public/javascripts/fancybox/blank.gif create mode 100644 public/javascripts/fancybox/fancy_close.png create mode 100644 public/javascripts/fancybox/fancy_loading.png create mode 100644 public/javascripts/fancybox/fancy_nav_left.png create mode 100644 public/javascripts/fancybox/fancy_nav_right.png create mode 100644 public/javascripts/fancybox/fancy_shadow_e.png create mode 100644 public/javascripts/fancybox/fancy_shadow_n.png create mode 100644 public/javascripts/fancybox/fancy_shadow_ne.png create mode 100644 public/javascripts/fancybox/fancy_shadow_nw.png create mode 100644 public/javascripts/fancybox/fancy_shadow_s.png create mode 100644 public/javascripts/fancybox/fancy_shadow_se.png create mode 100644 public/javascripts/fancybox/fancy_shadow_sw.png create mode 100644 public/javascripts/fancybox/fancy_shadow_w.png create mode 100644 public/javascripts/fancybox/fancy_title_left.png create mode 100644 public/javascripts/fancybox/fancy_title_main.png create mode 100644 public/javascripts/fancybox/fancy_title_over.png create mode 100644 public/javascripts/fancybox/fancy_title_right.png create mode 100644 public/javascripts/fancybox/fancybox-x.png create mode 100644 public/javascripts/fancybox/fancybox-y.png create mode 100644 public/javascripts/fancybox/fancybox.png create mode 100644 public/javascripts/fancybox/jquery.easing-1.3.pack.js create mode 100644 public/javascripts/fancybox/jquery.fancybox-1.3.1.css create mode 100644 public/javascripts/fancybox/jquery.fancybox-1.3.1.js create mode 100644 public/javascripts/fancybox/jquery.fancybox-1.3.1.pack.js create mode 100644 public/javascripts/fancybox/jquery.mousewheel-3.0.2.pack.js diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 0c3ba03c6..5ff653e37 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -2,11 +2,12 @@ .back = link_to "⇧ home", root_path Albums - .right#add_album_button - = link_to 'New Album', "#", :class => "button" + .right + = link_to 'New Album', '#new_album_pane', {:class => "button", :id => "add_album_button"} -#add_album_pane.contextual_pane - = render "albums/new_album" +.yo{:style => "display:none;" } + #new_album_pane + = render "albums/new_album" .sub_header %ul.button_set diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index e916b14d1..b049f44e8 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -5,13 +5,14 @@ = @album.name -if current_user.owns? @album - .right#add_photo_button + .right #add_photo_loader = image_tag 'ajax-loader.gif' - = link_to 'Add Photos', '#', :class => 'button' - - #add_photo_pane.contextual_pane - = render "photos/new_photo", :photo => @photo, :album => @album + = link_to 'Add Photos', '#add_photo_pane', {:class => 'button', :id => 'add_photo_button'} + + .yo{:style => 'display:none;'} + #add_photo_pane + = render "photos/new_photo", :photo => @photo, :album => @album .sub_header ="updated #{how_long_ago(@album)}" diff --git a/app/views/groups/_new_group.haml b/app/views/groups/_new_group.haml index af61105f8..5ac136eae 100644 --- a/app/views/groups/_new_group.haml +++ b/app/views/groups/_new_group.haml @@ -4,5 +4,4 @@ %p = f.label :name = f.text_field :name - .right - = f.submit 'create', :class => 'button' + = f.submit 'create', :class => 'button' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 6f9884712..2f8fd4060 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,9 +8,15 @@ = stylesheet_link_tag "blueprint/screen", :media => 'screen' = stylesheet_link_tag "application", "ui", 'bubble' + + = stylesheet_link_tag "/../javascripts/fancybox/jquery.fancybox-1.3.1" + /= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" = javascript_include_tag 'jquery142', 'rails', 'google' = javascript_include_tag 'tiny_mce/tiny_mce', 'jquery.infieldlabel', 'jquery.cycle/jquery.cycle.min.js' + + = javascript_include_tag 'fancybox/jquery.fancybox-1.3.1.pack' + = javascript_include_tag 'view', 'publisher', 'image_picker', 'group_nav' = render 'js/websocket_js' diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index 09b0230ee..4a7023687 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -10,13 +10,10 @@ onFinish: function(event, total){ $("#add_photo_button .button").html( "Add Photos" ); $("#add_photo_loader").fadeOut(400); - pane_toggler_button("photo"); }, onStart: function(event, total){ - $("#add_photo_pane").fadeOut(400); $("#add_photo_button .button").html( "Uploading Photos" ); $("#add_photo_loader").fadeIn(400); - $("#add_photo_button").unbind(); return true; } }); diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index 782025581..479e1b967 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -4,18 +4,19 @@ %li{:class => ("selected" if group.id.to_s == params[:id])} = link_to group.name, group - %li#add_group_button.new_group= link_to "NEW GROUP", "#" + %li.new_group= link_to("NEW GROUP", "#add_group_pane", :id => "add_group_button") - #add_group_pane.contextual_pane - = render "groups/new_group" + .yo{ :style => "display:none;"} + #add_group_pane + = render "groups/new_group" - if @group #friend_pictures - for friend in @group.people = person_image_link(friend) - #add_request_button.add_new - = link_to "+", "#" - - #add_request_pane.contextual_pane - = render "requests/new_request" + .add_new + = link_to "+", "#add_request_pane", :id => 'add_request_button' + .yo{:style => 'display:none'} + #add_request_pane + = render "requests/new_request" diff --git a/public/javascripts/fancybox/blank.gif b/public/javascripts/fancybox/blank.gif new file mode 100644 index 0000000000000000000000000000000000000000..35d42e808f0a8017b8d52a06be2f8fec0b466a66 GIT binary patch literal 43 scmZ?wbhEHbWMp7uXkcLY|NlP&1B2pE7Dgb&paUX6G7L;iE{qJ;0LZEa`2YX_ literal 0 HcmV?d00001 diff --git a/public/javascripts/fancybox/fancy_close.png b/public/javascripts/fancybox/fancy_close.png new file mode 100644 index 0000000000000000000000000000000000000000..07035307ad435f8f2f8eedf0bce50f7ec8a858c2 GIT binary patch liter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7{3S{Bb#j7?T~OCi+pq$fP9eGqJ%Evk~i}B@#8tcAnk_QAg)9f z!qn81MJO5W0n6>}?Q|$y25QL`+uU$0x?KbSI<(UOBavf=wCW!^J3Ie)^yty-8!yk& z($YLG4fjwT{k&5mHL@*_7Xi1c4?x$HT^y5qc2zyPPCG3CUKl!f@Zj&~&!7K?fD>&z zDk^G(=74sN=`q$#Wm{gaK5myi7K~vRQ8s=CoB+NC8j<}iKpXzI(SMmt*2r@wST=`s zW7t-}X4hPqXy3W00000NkvXXu0mjftFGKG literal 0 HcmV?d00001 diff --git a/public/javascripts/fancybox/fancy_loading.png b/public/javascripts/fancybox/fancy_loading.png new file mode 100644 index 0000000000000000000000000000000000000000..2503017960b3972499d3aa92f89953935ae40934 GIT binary patch literal 10195 zcmZvCRa6{Z)GRK+A-I#l3GNJT8Egn7KyZS)ySwY)GC**5cXtmOAh^3rfXjE+eY*eu zvb$HWe&}AO&aSFmCtO)c7UKiS2N)O_4A2)TmG>(H3=HfB3ex-CA}8B>rB4S*iGOoj zIbB0`GB%#)yQsNe_Z(XHJVzvTksi>+`6l(%$`7%p5{2L+{tq=VJ?V0JL-5DetdIHF|rZRGiB+~M$cAs!3L4m1WqS5m4Uut{B{sus$nl}9N zp#?4R@YNv8YM{JrwP-Li8Ynr~UO3E8cBsK321T79L4oqq#7><+nH-uo4c3S zzbjdhtN2LE+Wk$ypLztVwTlowGQqng!^I&U`;KFsDxwwAwF4PR(`@g%I}B1@?aN<; z9cJzX7khkNkJG|u_OY88t2=a(9k|tRF|O^~620}B74q3{|Mu}rUKMRU=5i@t4rH}t zWMo)9&m6ObjvNsA;yz~`O>f^l&kjH&j=Aexy0cfmC&I>@QU7`Ql zPU3_q?7Cqi%{r7|wPeZc`_s9mfR2B_K39;>*-yWV=qR41Ls>bqydL@}bse|D>1|L> zSvMFEQ2vnWJKlHRcZAw{ZIfc@+_x^0qqpf`uaLP9OH$Mxyno5YuLvbooxn?EWW9?3 z!YB&gf0xHo{M%6#q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L_2eajT1&)NB+^q2@D9b{MUY_>TNQpZi%SO_bqXjyXHB;Ui$Sf9@s+j;Wb z{id0A9C(t~>E@^vPF(@ScmscJxOc7zNXd^Oh>_aW(3u(xR)buk9$q9y|pmKaV!1QFxCztuHO}!PY}!G@y49mJ z0cZk6!rr+O$%3(;B?-}K84!e8{>9v~L;P_$0eQ4}M1oXBfsT{~ZTR)Ko%2eWMnbKn zb5q1ekkgw_RUy#!uXEEL9eB2&?El4NCZmw3r1hMX#a}lk-dBMCPR4OgqRj$-M;-^< hjOQhwL*8E5RB0mfPrR|R-jC_QfTWeADkby-{tw&r+hqU% literal 0 HcmV?d00001 diff --git a/public/javascripts/fancybox/fancy_nav_left.png b/public/javascripts/fancybox/fancy_nav_left.png new file mode 100644 index 0000000000000000000000000000000000000000..ebaa6a4fd34e51575a01da366312c20618985cbc GIT binary patch literal 1446 zcmV;X1zGxuP)R`@usIzf?P{x4#0gFqr~|(;IJySuwjr=+Ar78e&sHZ(Lu;P)*wKU%|U#jmpg5~Q6= zNl8{#mZGz>Q!_F$qJ8n=#Z9x>Jn_n|ZEtTsSzllOW_Wn`!@Rt_=!l4jAl`tKb-5%L zv7js_CMF<1KR>Fcr{|nbr~AR4Y-MG|y0EZdwI6@^^5yrikSZ}TQ5hH*C?{R4Q{?KT zKD6U2SFWfB2M0g0TCEGD5GUP%Y0a>J0W!M1fVuVU?d@ix(YV91PjUK7@OzY8E)OJ~ z&Q30n%8njA8kC)#t?uvd&xMXHQZzI)WQmTB-n1vQM_gQ-{_*3-7UA?*_bJ9=m|W(F zT+IHE$H&L3T3T8zSS*%BTHM>)YZi;eI#;9uNVch|X-go#ckf=VQmKq2-ORBYaGo52 zejyg&!SS;_ltMX3~N9_#ORsfn&tMTp}T$j*yAd)6-A(_4O6g z0=-^ug|9bVkxorbSsNQ0x9sPG&EF`laq6qgf=!d ztnQGKnVtDqz_Vx1Y=Kr=TU+Vx?;nS;5H`1m#Lv%9fqI)#T3Y%!3C+yRSpE-E!h;77 zwm7Z1{&Y;%TkkIqz&m9sAKBbnCkzsHry#@vbY{a-wI?zu7 zloV4Q9NtQWLUAT7Ev=G-*4EZ6|HZd^F*!MDB>C#<>PDGN_5sGi_Yq4ZlG7@css!ck z9};wyN`LrygSGPaaLVfqXl2Z+Nkm;ygvo12>(Bf+YwDwC`Hbwy5foiCI>(Z2*F z+nZVe;)K}P*aF#9Y8tUS3{lK|w(!NULrkdP#x17leSb zXU`h&IIwaw4`8eqNV6{>BDOh|vjhZ0E{e&QDDu0Pe|>%Zmb;{dg@s0w$z&rPA0K~+ zu^J$UblaCq5g(ljxEe?Y`8AmFYt-vOfqZ&;+Eh?bV07kp3Z#jN34Zfk3!OW_7k zM!Hz%fopN!Lja&lI}y+lIZjBszTeT&@!Ra|?DQ)q4Us*EN5ey8M=zh0NVTlX;X`2G z(+8kuN)-Dfn@v@Ns?$arfE9ks%*_0?uCDGc0&cYN@bK_KngiO{r&oDx0_$@6^x5~= zW5Gx^5k=$2z;)mYpdQiR47B2ZEBzOVMD;v(on_N_Z6xdRarMj=Ped`)=n zv4Dh?$k=SYcJSdjDa(58`F?t%ZzxBbaRs;9zaA#)un(S!5dZ)H07*qoM6N<$g4RXF AD*ylh literal 0 HcmV?d00001 diff --git a/public/javascripts/fancybox/fancy_nav_right.png b/public/javascripts/fancybox/fancy_nav_right.png new file mode 100644 index 0000000000000000000000000000000000000000..873294e969db9160f5ddd4e1ab498ff60b080e3f GIT binary patch literal 1454 zcmV;f1yTBmP)Wa6`&Z+!IVkxf`V#(j>y7#5eg z5*PD+C=wGBwT+F9xi*_^fd=>X_FBba@wz8b0c3ma+OG#c&LYnSBp_4S(*6BG8m#QpsI))yBSw}|WBy?ft)>pk?VIMu|0u-xC@UxO$< zHa9o-0~vR8bXeVyB61x;@W6T@vgyO$TgWvPslhu zJ>BGvFeN3$D2UT9wO!c-2M2E;RvddB6cm(&J}nRg`1!DUaA;_#J})n?kc`&W*6f~w z$XoI8@o`6>)z;Ql1O^7iqc4Qr?IQ^Y2vDQmrd_^#`AagIo}RXO6Tw=o)=2K&OZ?8A zJDVKcH{^2p2j~ms)bf#Ff5Y^8{ZZ7~8Zw%koV0nHJ||9`FbS!%u(0sL`TfAafI}Du zN;}#qfQDkqhr?T=R;!O@W@c89(aOq-SHe5pO)Do4INRL6f8R{+tE;Q)Wir`E=nLN^ zERjf#VBjT`yZ^}0T`IW~brs!I17PDwDHNtJpz(@u7&_Ci&*x`nXGh4eva-_hHlhTo z>wKX6jrLg})!Ef*2q(qH#unh5y~V~`*!#E25W2>+0$@y%jAkE;d^% z7KiBQ=;#CV)c|?K?OZZNymTtyIv@+;=i$b0QLhID@u{gPOF=<_+1^cd)FbceJt|Pr3Z2#UW)pC9hbbpr%#_w3xu>9DucKZSqKjwKC}oa!!=;B zxw)ARh3h~maWUsB$KtMw06>R!GGHKatdM5?eS3TRA2TyEQ!m{-s9LkQG(13d^zuqc z)WBRWF9N%+J^)=)qIgeo*i|*CI?Xfzc;V-hCr|!<<;s9veooizpgD1ug<#0dV!Z literal 0 HcmV?d00001 diff --git a/public/javascripts/fancybox/fancy_shadow_e.png b/public/javascripts/fancybox/fancy_shadow_e.png new file mode 100644 index 0000000000000000000000000000000000000000..2eda0893649371f8d92b92976d8542cdd1b601ed GIT binary patch literal 107 zcmeAS@N?(olHy`uVBq!ia0vp^B0$W@!3HGnP3ltxQbwLGjv*Y^lSRZuwe#}JO|p{EaWGAM`~zK|Yh zF7SQ+m+Ig>B0@o-N8?trihfzZ+Vp1~`{zf0o*#X0$hUAi%N$P)W1wCJ22WQ%mvv4F FO#q)zAp-ya literal 0 HcmV?d00001 diff --git a/public/javascripts/fancybox/fancy_shadow_ne.png b/public/javascripts/fancybox/fancy_shadow_ne.png new file mode 100644 index 0000000000000000000000000000000000000000..79f6980a3ba5c43de120d963dbba2516b8f27ac7 GIT binary patch literal 347 zcmV-h0i^zkP)dR9Yb&V8f!h)aDezHAsc|y@|hdQ zYJb}?8~~zFbQ)ku!Ey)KSukutuvdZ@MKMX|x|A3tPyx?YVhN^6z!Mi4Mj2f#%<;nh z2{>?YAzu|{u^;Oq!;f7Z4tPBpJEmZ+^GZ#$=9nz(K+UmK7}|u&EPi%aRt_C3qOFB_ zHc`~N>51%{?ijG?xsHt>MwRChgk=x_z0gh3O2xSL)-6?+2LKZL74~Q>MZjWtwukkA tvjRC=&j+0R$&bLyT7MhBcTXDISHC&xXU0&5CWHV0002ovPDHLkV1fX+la~Mh literal 0 HcmV?d00001 diff --git a/public/javascripts/fancybox/fancy_shadow_nw.png b/public/javascripts/fancybox/fancy_shadow_nw.png new file mode 100644 index 0000000000000000000000000000000000000000..7182cd938ae98e7e28c65a0bc55df576042ff9f5 GIT binary patch literal 324 zcmV-K0lWT*P)2-&4CO{qhKP$XKD&mgeXEM77>~`RA}h@U^Z##eQZVtM>a-K?QT4 z&(8BFf(rD5V61)2I__wHYuRwoaDIqw5Vdr_JSDVr){#J@r;{vbDL|tRyCiirf~4OF zX-l=Ecm>@yR)1nSMt~dy90Zb`^`)TQbhf8jR@fA!l6V$musRyB9Y{p$SCW}!$3==V zk)fW)Xo{s^ez$t+XhmZj;ts)!kTokvmM>z)zt70000 literal 0 HcmV?d00001 diff --git a/public/javascripts/fancybox/fancy_shadow_se.png b/public/javascripts/fancybox/fancy_shadow_se.png new file mode 100644 index 0000000000000000000000000000000000000000..541e3ffd3e88224b34a4d2097c66a780e6060aeb GIT binary patch literal 352 zcmV-m0iXVfP){pM9=`y8<_IvWD02WY@RZ<9dgjNmAB|sYF}Xw>7Sq@O0000eMf9z;FC21=)67q_`W0*0KnS4AR00W2`RGn3i8UfsEegLO@ zPhds?2e1Tm)FK3=bymIAx?X=YFo3Mdh7W?@I#8s#svp!&PB> zwah@Ngd|l0N4SCfzvjtQnd$dZ0yM)N$X+lqdtN!Pt{Wn*_`0U}m1^#r1 mwpaW{;a?9KKt^WrpTAEd?0j1W(3L*`0000P{ho=rRL|66mGO)=r*Hk83F#~lnc)I$ztaD0e0sy?& B8X5oq literal 0 HcmV?d00001 diff --git a/public/javascripts/fancybox/fancy_title_left.png b/public/javascripts/fancybox/fancy_title_left.png new file mode 100644 index 0000000000000000000000000000000000000000..6049223d1ec6af46e100499c01f6489c9e2c6240 GIT binary patch literal 503 zcmV+)0005LNklqcp9&~$uJw{{rUub~E?-XJ#Upm4Fe%-Gl z!u%tb0N102a|s5;SPlQvJlFCTBbvYaK@wIW6Gjx@?i20AlVDJcHNfh25WRlbF6CIq zv9_ZnqOH`}ppaUR0@%ZcM9zpDt2uQM>f+Z#wIMmyuui3DeoYXWE|hQ{D$te=Yhgkq zIvyj+$t8T|S1wITzUftNOe(E+Qjn$kDotY;I5}1lRgwi=?K26ke)djLR5W2|!7CVH zJ-`tuAq|`lK978y+CnqGNCkUke_%Gig ukvFM-ftpWh!il7Wg7kz7Y?7xB@G*olNlgoj4E_Yv!rmdKI;Vst0Ha3^zyJUM literal 0 HcmV?d00001 diff --git a/public/javascripts/fancybox/fancy_title_right.png b/public/javascripts/fancybox/fancy_title_right.png new file mode 100644 index 0000000000000000000000000000000000000000..e36d9db2a7c6e570aec993d3665cbc13620115e2 GIT binary patch literal 506 zcmV+)0005ONklxjQB-g>5=x46nGBwseihc$zfzvTFh(=tCRj6cJ4M&ASrCAq-HbokPnRBAHVa2(-|l wYU(UxfYLN;KDSr z1<%~X^wgl##FWaylc_d9MY*0Xjv*Ddw)7kFH5l+P-xcE$W)3=fYI&uMKVzWNT*W|n zhqlRY)q0r(8Mg&Fu_zpISivgz+b7g)c6G&O{~njE??Y{u-MM!p^=9_W+X-j8mhfK? zj`H2Yy;kp%)!V-M3;EVThyB(Z@o88wpMja-vy^g)SgE!<&|(HpS3j3^P6|6H_V+Po~-c6$N>^IEGZ*^681?Yf#{6Zf~e!I`r4y-J+3m*Ue*gH=cNZ zzpU%p61aCO%jt%FHUKW&bEWLcUAGzK?;SYE)E{9#W9O8@uj{O@89qzNU(dkI YVCW(7-@(*!CeU;SPgg&ebxsLQ07`N|KL7v# literal 0 HcmV?d00001 diff --git a/public/javascripts/fancybox/fancybox.png b/public/javascripts/fancybox/fancybox.png new file mode 100644 index 0000000000000000000000000000000000000000..65e14f68fd83b87f75c22c0c074e7b20bf20a133 GIT binary patch literal 15287 zcmaKTWn3G5&@B{~;%>#=DG;={yF10TIJA^Ni@Q6dxD|J62@u>uaf*A8(n3=TLErSb z_x;^(_f!7a-E4NVIcLtyoQc=dQGJd}gNuTK@?2d_$pHDPf`Wp&gN=z?QPI&3p`b{G zsVm7Fy<0o~g!9hI>FTLkeXUCSdR`&CQ|`OGxubq*0?(JYNfXC5{*R2zWF6(Xx-T>T2>J&K|Eil&n6Lix zEi`275C{!+X!)7CS*e}=H>=RA%jh4XH)T6XDeap>QZ zuCvB3f1j3`!i;@?^<5L}xzP0QOB^9?Eo@W0)j~`y+S=c{by#*Uoo$DiKILjfWNDo7 zGyqd&{!#&d_P|oW`zcaEy@;d2w|y57JdXR@m44ad$Gcyz{_I2&GK4@SU`c&Hd(VQh zn#vD^;#Q75G(~U%V%iDZL@L=Tw9hMZzCDFM9j?16?PmU()egI=v!xGRv3`4gH%jYG z*XB5pVfpH2C-V9c_8xe%8@rGrVEZ`G|9I83-+!6xowV&cMz2~U_i)uGJ@S3*cKE#^ znI+w0?#cY$pob>5_bg~ZYi`wc9G?Q_yI;!^xaByQ6*CF-F7!LoI6}!W%HOm zn)78kmGgzB<<3%Ss~TX_waZ9m05q-1AFMtfR>_#;a^F#k^#p)TMJWuMY$%F z%=%jUAKs6$O@3rjj7b9g9%p$QdV5l>n-#J#o(%rG=J6u=#jCJnOQN^y{2O0)x&Yqprl%*#!!_|zCVEW-yaI3-X52yuJ!c9 zz6iUCoS&ax%2yIfhCSZHUTwP$BhI})gzWuY_kNXgz1*K3Fz$UQmp8oH;@~mz(&g{T z0*5JN@$_j~RW(h1-Lq}xFRb{(q)D{SX3WtO`gObC;WQ9!DO#{`WS)_(*3(jJ3Lmxc)?Yc*Af>4 zXe$gst9FHmyt#7KrhMt(-!b86S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te+`6jy-v##`Q86b z6jG|SjsPcT{TA5e7iAKdP`-O5snH$Fp#~DWi2dP+tDEgGywPnPkgPeJ+9QTdTzE{X z88~L0W4K4`f9Q5Q<}Oh(JfaAvN+0-dgE;%?(P*qXNwpB_)-Zzm*mP zcex|GZO8(LWj!(h`(I@JpSU%%%+bka+4p#^=Li0xSy-m?t6ws8mE^qtzmeB(XQ@wU ZMt7F5hocMxav&E)U0Fw|QQ>vO{{ZOG+C=~W literal 0 HcmV?d00001 diff --git a/public/javascripts/fancybox/jquery.easing-1.3.pack.js b/public/javascripts/fancybox/jquery.easing-1.3.pack.js new file mode 100644 index 000000000..9028179e7 --- /dev/null +++ b/public/javascripts/fancybox/jquery.easing-1.3.pack.js @@ -0,0 +1,72 @@ +/* + * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ + * + * Uses the built in easing capabilities added In jQuery 1.1 + * to offer multiple easing options + * + * TERMS OF USE - jQuery Easing + * + * Open source under the BSD License. + * + * Copyright © 2008 George McGinley Smith + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * Neither the name of the author nor the names of contributors may be used to endorse + * or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * +*/ + +// t: current time, b: begInnIng value, c: change In value, d: duration +eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h.i[\'1a\']=h.i[\'z\'];h.O(h.i,{y:\'D\',z:9(x,t,b,c,d){6 h.i[h.i.y](x,t,b,c,d)},17:9(x,t,b,c,d){6 c*(t/=d)*t+b},D:9(x,t,b,c,d){6-c*(t/=d)*(t-2)+b},13:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t+b;6-c/2*((--t)*(t-2)-1)+b},X:9(x,t,b,c,d){6 c*(t/=d)*t*t+b},U:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t+1)+b},R:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t+b;6 c/2*((t-=2)*t*t+2)+b},N:9(x,t,b,c,d){6 c*(t/=d)*t*t*t+b},M:9(x,t,b,c,d){6-c*((t=t/d-1)*t*t*t-1)+b},L:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t+b;6-c/2*((t-=2)*t*t*t-2)+b},K:9(x,t,b,c,d){6 c*(t/=d)*t*t*t*t+b},J:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t*t*t+1)+b},I:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t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F:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*(t/=d)*t*((s+1)*t-s)+b},E:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},16:9(x,t,b,c,d,s){e(s==u)s=1.l;e((t/=d/2)<1)6 c/2*(t*t*(((s*=(1.B))+1)*t-s))+b;6 c/2*((t-=2)*t*(((s*=(1.B))+1)*t+s)+2)+b},A:9(x,t,b,c,d){6 c-h.i.v(x,d-t,0,c,d)+b},v:9(x,t,b,c,d){e((t/=d)<(1/2.k)){6 c*(7.q*t*t)+b}m e(t<(2/2.k)){6 c*(7.q*(t-=(1.5/2.k))*t+.k)+b}m e(t<(2.5/2.k)){6 c*(7.q*(t-=(2.14/2.k))*t+.11)+b}m{6 c*(7.q*(t-=(2.18/2.k))*t+.19)+b}},1b:9(x,t,b,c,d){e(t')[0], { prop: 0 }), titleh = 0, + + isIE6 = !$.support.opacity && !window.XMLHttpRequest, + + /* + * Private methods + */ + + fancybox_abort = function() { + loading.hide(); + + imgPreloader.onerror = imgPreloader.onload = null; + + if (ajaxLoader) { + ajaxLoader.abort(); + } + + tmp.empty(); + }, + + fancybox_error = function() { + $.fancybox('

The requested content cannot be loaded.
Please try again later.

', { + 'scrolling' : 'no', + 'padding' : 20, + 'transitionIn' : 'none', + 'transitionOut' : 'none' + }); + }, + + fancybox_get_viewport = function() { + return [ $(window).width(), $(window).height(), $(document).scrollLeft(), $(document).scrollTop() ]; + }, + + fancybox_get_zoom_to = function () { + var view = fancybox_get_viewport(), + to = {}, + + margin = currentOpts.margin, + resize = currentOpts.autoScale, + + horizontal_space = (shadow + margin) * 2, + vertical_space = (shadow + margin) * 2, + double_padding = (currentOpts.padding * 2), + + ratio; + + if (currentOpts.width.toString().indexOf('%') > -1) { + to.width = ((view[0] * parseFloat(currentOpts.width)) / 100) - (shadow * 2) ; + resize = false; + + } else { + to.width = currentOpts.width + double_padding; + } + + if (currentOpts.height.toString().indexOf('%') > -1) { + to.height = ((view[1] * parseFloat(currentOpts.height)) / 100) - (shadow * 2); + resize = false; + + } else { + to.height = currentOpts.height + double_padding; + } + + if (resize && (to.width > (view[0] - horizontal_space) || to.height > (view[1] - vertical_space))) { + if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') { + horizontal_space += double_padding; + vertical_space += double_padding; + + ratio = Math.min(Math.min( view[0] - horizontal_space, currentOpts.width) / currentOpts.width, Math.min( view[1] - vertical_space, currentOpts.height) / currentOpts.height); + + to.width = Math.round(ratio * (to.width - double_padding)) + double_padding; + to.height = Math.round(ratio * (to.height - double_padding)) + double_padding; + + } else { + to.width = Math.min(to.width, (view[0] - horizontal_space)); + to.height = Math.min(to.height, (view[1] - vertical_space)); + } + } + + to.top = view[3] + ((view[1] - (to.height + (shadow * 2 ))) * 0.5); + to.left = view[2] + ((view[0] - (to.width + (shadow * 2 ))) * 0.5); + + if (currentOpts.autoScale === false) { + to.top = Math.max(view[3] + margin, to.top); + to.left = Math.max(view[2] + margin, to.left); + } + + return to; + }, + + fancybox_format_title = function(title) { + if (title && title.length) { + switch (currentOpts.titlePosition) { + case 'inside': + return title; + case 'over': + return '' + title + ''; + default: + return '' + title + ''; + } + } + + return false; + }, + + fancybox_process_title = function() { + var title = currentOpts.title, + width = final_pos.width - (currentOpts.padding * 2), + titlec = 'fancybox-title-' + currentOpts.titlePosition; + + $('#fancybox-title').remove(); + + titleh = 0; + + if (currentOpts.titleShow === false) { + return; + } + + title = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(title, currentArray, currentIndex, currentOpts) : fancybox_format_title(title); + + if (!title || title === '') { + return; + } + + $('
').css({ + 'width' : width, + 'paddingLeft' : currentOpts.padding, + 'paddingRight' : currentOpts.padding + }).html(title).appendTo('body'); + + switch (currentOpts.titlePosition) { + case 'inside': + titleh = $("#fancybox-title").outerHeight(true) - currentOpts.padding; + final_pos.height += titleh; + break; + + case 'over': + $('#fancybox-title').css('bottom', currentOpts.padding); + break; + + default: + $('#fancybox-title').css('bottom', $("#fancybox-title").outerHeight(true) * -1); + break; + } + + $('#fancybox-title').appendTo( outer ).hide(); + }, + + fancybox_set_navigation = function() { + $(document).unbind('keydown.fb').bind('keydown.fb', function(e) { + if (e.keyCode == 27 && currentOpts.enableEscapeButton) { + e.preventDefault(); + $.fancybox.close(); + + } else if (e.keyCode == 37) { + e.preventDefault(); + $.fancybox.prev(); + + } else if (e.keyCode == 39) { + e.preventDefault(); + $.fancybox.next(); + } + }); + + if ($.fn.mousewheel) { + wrap.unbind('mousewheel.fb'); + + if (currentArray.length > 1) { + wrap.bind('mousewheel.fb', function(e, delta) { + e.preventDefault(); + + if (busy || delta === 0) { + return; + } + + if (delta > 0) { + $.fancybox.prev(); + } else { + $.fancybox.next(); + } + }); + } + } + + if (!currentOpts.showNavArrows) { return; } + + if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) { + nav_left.show(); + } + + if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) { + nav_right.show(); + } + }, + + fancybox_preload_images = function() { + var href, + objNext; + + if ((currentArray.length -1) > currentIndex) { + href = currentArray[ currentIndex + 1 ].href; + + if (typeof href !== 'undefined' && href.match(imgRegExp)) { + objNext = new Image(); + objNext.src = href; + } + } + + if (currentIndex > 0) { + href = currentArray[ currentIndex - 1 ].href; + + if (typeof href !== 'undefined' && href.match(imgRegExp)) { + objNext = new Image(); + objNext.src = href; + } + } + }, + + _finish = function () { + inner.css('overflow', (currentOpts.scrolling == 'auto' ? (currentOpts.type == 'image' || currentOpts.type == 'iframe' || currentOpts.type == 'swf' ? 'hidden' : 'auto') : (currentOpts.scrolling == 'yes' ? 'auto' : 'visible'))); + + if (!$.support.opacity) { + inner.get(0).style.removeAttribute('filter'); + wrap.get(0).style.removeAttribute('filter'); + } + + $('#fancybox-title').show(); + + if (currentOpts.hideOnContentClick) { + inner.one('click', $.fancybox.close); + } + if (currentOpts.hideOnOverlayClick) { + overlay.one('click', $.fancybox.close); + } + + if (currentOpts.showCloseButton) { + close.show(); + } + + fancybox_set_navigation(); + + $(window).bind("resize.fb", $.fancybox.center); + + if (currentOpts.centerOnScroll) { + $(window).bind("scroll.fb", $.fancybox.center); + } else { + $(window).unbind("scroll.fb"); + } + + if ($.isFunction(currentOpts.onComplete)) { + currentOpts.onComplete(currentArray, currentIndex, currentOpts); + } + + busy = false; + + fancybox_preload_images(); + }, + + fancybox_draw = function(pos) { + var width = Math.round(start_pos.width + (final_pos.width - start_pos.width) * pos), + height = Math.round(start_pos.height + (final_pos.height - start_pos.height) * pos), + + top = Math.round(start_pos.top + (final_pos.top - start_pos.top) * pos), + left = Math.round(start_pos.left + (final_pos.left - start_pos.left) * pos); + + wrap.css({ + 'width' : width + 'px', + 'height' : height + 'px', + 'top' : top + 'px', + 'left' : left + 'px' + }); + + width = Math.max(width - currentOpts.padding * 2, 0); + height = Math.max(height - (currentOpts.padding * 2 + (titleh * pos)), 0); + + inner.css({ + 'width' : width + 'px', + 'height' : height + 'px' + }); + + if (typeof final_pos.opacity !== 'undefined') { + wrap.css('opacity', (pos < 0.5 ? 0.5 : pos)); + } + }, + + fancybox_get_obj_pos = function(obj) { + var pos = obj.offset(); + + pos.top += parseFloat( obj.css('paddingTop') ) || 0; + pos.left += parseFloat( obj.css('paddingLeft') ) || 0; + + pos.top += parseFloat( obj.css('border-top-width') ) || 0; + pos.left += parseFloat( obj.css('border-left-width') ) || 0; + + pos.width = obj.width(); + pos.height = obj.height(); + + return pos; + }, + + fancybox_get_zoom_from = function() { + var orig = selectedOpts.orig ? $(selectedOpts.orig) : false, + from = {}, + pos, + view; + + if (orig && orig.length) { + pos = fancybox_get_obj_pos(orig); + + from = { + width : (pos.width + (currentOpts.padding * 2)), + height : (pos.height + (currentOpts.padding * 2)), + top : (pos.top - currentOpts.padding - shadow), + left : (pos.left - currentOpts.padding - shadow) + }; + + } else { + view = fancybox_get_viewport(); + + from = { + width : 1, + height : 1, + top : view[3] + view[1] * 0.5, + left : view[2] + view[0] * 0.5 + }; + } + + return from; + }, + + fancybox_show = function() { + loading.hide(); + + if (wrap.is(":visible") && $.isFunction(currentOpts.onCleanup)) { + if (currentOpts.onCleanup(currentArray, currentIndex, currentOpts) === false) { + $.event.trigger('fancybox-cancel'); + + busy = false; + return; + } + } + + currentArray = selectedArray; + currentIndex = selectedIndex; + currentOpts = selectedOpts; + + inner.get(0).scrollTop = 0; + inner.get(0).scrollLeft = 0; + + if (currentOpts.overlayShow) { + if (isIE6) { + $('select:not(#fancybox-tmp select)').filter(function() { + return this.style.visibility !== 'hidden'; + }).css({'visibility':'hidden'}).one('fancybox-cleanup', function() { + this.style.visibility = 'inherit'; + }); + } + + overlay.css({ + 'background-color' : currentOpts.overlayColor, + 'opacity' : currentOpts.overlayOpacity + }).unbind().show(); + } + + final_pos = fancybox_get_zoom_to(); + + fancybox_process_title(); + + if (wrap.is(":visible")) { + $( close.add( nav_left ).add( nav_right ) ).hide(); + + var pos = wrap.position(), + equal; + + start_pos = { + top : pos.top , + left : pos.left, + width : wrap.width(), + height : wrap.height() + }; + + equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height); + + inner.fadeOut(currentOpts.changeFade, function() { + var finish_resizing = function() { + inner.html( tmp.contents() ).fadeIn(currentOpts.changeFade, _finish); + }; + + $.event.trigger('fancybox-change'); + + inner.empty().css('overflow', 'hidden'); + + if (equal) { + inner.css({ + top : currentOpts.padding, + left : currentOpts.padding, + width : Math.max(final_pos.width - (currentOpts.padding * 2), 1), + height : Math.max(final_pos.height - (currentOpts.padding * 2) - titleh, 1) + }); + + finish_resizing(); + + } else { + inner.css({ + top : currentOpts.padding, + left : currentOpts.padding, + width : Math.max(start_pos.width - (currentOpts.padding * 2), 1), + height : Math.max(start_pos.height - (currentOpts.padding * 2), 1) + }); + + fx.prop = 0; + + $(fx).animate({ prop: 1 }, { + duration : currentOpts.changeSpeed, + easing : currentOpts.easingChange, + step : fancybox_draw, + complete : finish_resizing + }); + } + }); + + return; + } + + wrap.css('opacity', 1); + + if (currentOpts.transitionIn == 'elastic') { + start_pos = fancybox_get_zoom_from(); + + inner.css({ + top : currentOpts.padding, + left : currentOpts.padding, + width : Math.max(start_pos.width - (currentOpts.padding * 2), 1), + height : Math.max(start_pos.height - (currentOpts.padding * 2), 1) + }) + .html( tmp.contents() ); + + wrap.css(start_pos).show(); + + if (currentOpts.opacity) { + final_pos.opacity = 0; + } + + fx.prop = 0; + + $(fx).animate({ prop: 1 }, { + duration : currentOpts.speedIn, + easing : currentOpts.easingIn, + step : fancybox_draw, + complete : _finish + }); + + } else { + inner.css({ + top : currentOpts.padding, + left : currentOpts.padding, + width : Math.max(final_pos.width - (currentOpts.padding * 2), 1), + height : Math.max(final_pos.height - (currentOpts.padding * 2) - titleh, 1) + }) + .html( tmp.contents() ); + + wrap.css( final_pos ).fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish ); + } + }, + + fancybox_process_inline = function() { + tmp.width( selectedOpts.width ); + tmp.height( selectedOpts.height ); + + if (selectedOpts.width == 'auto') { + selectedOpts.width = tmp.width(); + } + if (selectedOpts.height == 'auto') { + selectedOpts.height = tmp.height(); + } + + fancybox_show(); + }, + + fancybox_process_image = function() { + busy = true; + + selectedOpts.width = imgPreloader.width; + selectedOpts.height = imgPreloader.height; + + $("").attr({ + 'id' : 'fancybox-img', + 'src' : imgPreloader.src, + 'alt' : selectedOpts.title + }).appendTo( tmp ); + + fancybox_show(); + }, + + fancybox_start = function() { + fancybox_abort(); + + var obj = selectedArray[ selectedIndex ], + href, + type, + title, + str, + emb, + selector, + data; + + selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox'))); + title = obj.title || $(obj).title || selectedOpts.title || ''; + + if (obj.nodeName && !selectedOpts.orig) { + selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj); + } + + if (title === '' && selectedOpts.orig) { + title = selectedOpts.orig.attr('alt'); + } + + if (obj.nodeName && (/^(?:javascript|#)/i).test(obj.href)) { + href = selectedOpts.href || null; + } else { + href = selectedOpts.href || obj.href || null; + } + + if (selectedOpts.type) { + type = selectedOpts.type; + + if (!href) { + href = selectedOpts.content; + } + + } else if (selectedOpts.content) { + type = 'html'; + + } else if (href) { + if (href.match(imgRegExp)) { + type = 'image'; + + } else if (href.match(swfRegExp)) { + type = 'swf'; + + } else if ($(obj).hasClass("iframe")) { + type = 'iframe'; + + } else if (href.match(/#/)) { + obj = href.substr(href.indexOf("#")); + + type = $(obj).length > 0 ? 'inline' : 'ajax'; + } else { + type = 'ajax'; + } + } else { + type = 'inline'; + } + + selectedOpts.type = type; + selectedOpts.href = href; + selectedOpts.title = title; + + if (selectedOpts.autoDimensions && selectedOpts.type !== 'iframe' && selectedOpts.type !== 'swf') { + selectedOpts.width = 'auto'; + selectedOpts.height = 'auto'; + } + + if (selectedOpts.modal) { + selectedOpts.overlayShow = true; + selectedOpts.hideOnOverlayClick = false; + selectedOpts.hideOnContentClick = false; + selectedOpts.enableEscapeButton = false; + selectedOpts.showCloseButton = false; + } + + if ($.isFunction(selectedOpts.onStart)) { + if (selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts) === false) { + busy = false; + return; + } + } + + tmp.css('padding', (shadow + selectedOpts.padding + selectedOpts.margin)); + + $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() { + $(this).replaceWith(inner.children()); + }); + + switch (type) { + case 'html' : + tmp.html( selectedOpts.content ); + fancybox_process_inline(); + break; + + case 'inline' : + $('
').hide().insertBefore( $(obj) ).bind('fancybox-cleanup', function() { + $(this).replaceWith(inner.children()); + }).bind('fancybox-cancel', function() { + $(this).replaceWith(tmp.children()); + }); + + $(obj).appendTo(tmp); + + fancybox_process_inline(); + break; + + case 'image': + busy = false; + + $.fancybox.showActivity(); + + imgPreloader = new Image(); + + imgPreloader.onerror = function() { + fancybox_error(); + }; + + imgPreloader.onload = function() { + imgPreloader.onerror = null; + imgPreloader.onload = null; + fancybox_process_image(); + }; + + imgPreloader.src = href; + + break; + + case 'swf': + str = ''; + emb = ''; + + $.each(selectedOpts.swf, function(name, val) { + str += ''; + emb += ' ' + name + '="' + val + '"'; + }); + + str += ''; + + tmp.html(str); + + fancybox_process_inline(); + break; + + case 'ajax': + selector = href.split('#', 2); + data = selectedOpts.ajax.data || {}; + + if (selector.length > 1) { + href = selector[0]; + + if (typeof data == "string") { + data += '&selector=' + selector[1]; + } else { + data.selector = selector[1]; + } + } + + busy = false; + $.fancybox.showActivity(); + + ajaxLoader = $.ajax($.extend(selectedOpts.ajax, { + url : href, + data : data, + error : fancybox_error, + success : function(data, textStatus, XMLHttpRequest) { + if (ajaxLoader.status == 200) { + tmp.html( data ); + fancybox_process_inline(); + } + } + })); + + break; + + case 'iframe' : + $('').appendTo(tmp); + fancybox_show(); + break; + } + }, + + fancybox_animate_loading = function() { + if (!loading.is(':visible')){ + clearInterval(loadingTimer); + return; + } + + $('div', loading).css('top', (loadingFrame * -40) + 'px'); + + loadingFrame = (loadingFrame + 1) % 12; + }, + + fancybox_init = function() { + if ($("#fancybox-wrap").length) { + return; + } + + $('body').append( + tmp = $('
'), + loading = $('
'), + overlay = $('
'), + wrap = $('
') + ); + + if (!$.support.opacity) { + wrap.addClass('fancybox-ie'); + loading.addClass('fancybox-ie'); + } + + outer = $('
') + .append('
') + .appendTo( wrap ); + + outer.append( + inner = $('
'), + close = $(''), + + nav_left = $(''), + nav_right = $('') + ); + + close.click($.fancybox.close); + loading.click($.fancybox.cancel); + + nav_left.click(function(e) { + e.preventDefault(); + $.fancybox.prev(); + }); + + nav_right.click(function(e) { + e.preventDefault(); + $.fancybox.next(); + }); + + if (isIE6) { + overlay.get(0).style.setExpression('height', "document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'"); + loading.get(0).style.setExpression('top', "(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'"); + + outer.prepend(''); + } + }; + + /* + * Public methods + */ + + $.fn.fancybox = function(options) { + $(this) + .data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {}))) + .unbind('click.fb').bind('click.fb', function(e) { + e.preventDefault(); + + if (busy) { + return; + } + + busy = true; + + $(this).blur(); + + selectedArray = []; + selectedIndex = 0; + + var rel = $(this).attr('rel') || ''; + + if (!rel || rel == '' || rel === 'nofollow') { + selectedArray.push(this); + + } else { + selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]"); + selectedIndex = selectedArray.index( this ); + } + + fancybox_start(); + + return false; + }); + + return this; + }; + + $.fancybox = function(obj) { + if (busy) { + return; + } + + busy = true; + + var opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {}; + + selectedArray = []; + selectedIndex = opts.index || 0; + + if ($.isArray(obj)) { + for (var i = 0, j = obj.length; i < j; i++) { + if (typeof obj[i] == 'object') { + $(obj[i]).data('fancybox', $.extend({}, opts, obj[i])); + } else { + obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts)); + } + } + + selectedArray = jQuery.merge(selectedArray, obj); + + } else { + if (typeof obj == 'object') { + $(obj).data('fancybox', $.extend({}, opts, obj)); + } else { + obj = $({}).data('fancybox', $.extend({content : obj}, opts)); + } + + selectedArray.push(obj); + } + + if (selectedIndex > selectedArray.length || selectedIndex < 0) { + selectedIndex = 0; + } + + fancybox_start(); + }; + + $.fancybox.showActivity = function() { + clearInterval(loadingTimer); + + loading.show(); + loadingTimer = setInterval(fancybox_animate_loading, 66); + }; + + $.fancybox.hideActivity = function() { + loading.hide(); + }; + + $.fancybox.next = function() { + return $.fancybox.pos( currentIndex + 1); + }; + + $.fancybox.prev = function() { + return $.fancybox.pos( currentIndex - 1); + }; + + $.fancybox.pos = function(pos) { + if (busy) { + return; + } + + pos = parseInt(pos, 10); + + if (pos > -1 && currentArray.length > pos) { + selectedIndex = pos; + fancybox_start(); + } + + if (currentOpts.cyclic && currentArray.length > 1 && pos < 0) { + selectedIndex = currentArray.length - 1; + fancybox_start(); + } + + if (currentOpts.cyclic && currentArray.length > 1 && pos >= currentArray.length) { + selectedIndex = 0; + fancybox_start(); + } + + return; + }; + + $.fancybox.cancel = function() { + if (busy) { + return; + } + + busy = true; + + $.event.trigger('fancybox-cancel'); + + fancybox_abort(); + + if (selectedOpts && $.isFunction(selectedOpts.onCancel)) { + selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts); + } + + busy = false; + }; + + // Note: within an iframe use - parent.$.fancybox.close(); + $.fancybox.close = function() { + if (busy || wrap.is(':hidden')) { + return; + } + + busy = true; + + if (currentOpts && $.isFunction(currentOpts.onCleanup)) { + if (currentOpts.onCleanup(currentArray, currentIndex, currentOpts) === false) { + busy = false; + return; + } + } + + fancybox_abort(); + + $(close.add( nav_left ).add( nav_right )).hide(); + + $('#fancybox-title').remove(); + + wrap.add(inner).add(overlay).unbind(); + + $(window).unbind("resize.fb scroll.fb"); + $(document).unbind('keydown.fb'); + + function _cleanup() { + overlay.fadeOut('fast'); + + wrap.hide(); + + $.event.trigger('fancybox-cleanup'); + + inner.empty(); + + if ($.isFunction(currentOpts.onClosed)) { + currentOpts.onClosed(currentArray, currentIndex, currentOpts); + } + + currentArray = selectedOpts = []; + currentIndex = selectedIndex = 0; + currentOpts = selectedOpts = {}; + + busy = false; + } + + inner.css('overflow', 'hidden'); + + if (currentOpts.transitionOut == 'elastic') { + start_pos = fancybox_get_zoom_from(); + + var pos = wrap.position(); + + final_pos = { + top : pos.top , + left : pos.left, + width : wrap.width(), + height : wrap.height() + }; + + if (currentOpts.opacity) { + final_pos.opacity = 1; + } + + fx.prop = 1; + + $(fx).animate({ prop: 0 }, { + duration : currentOpts.speedOut, + easing : currentOpts.easingOut, + step : fancybox_draw, + complete : _cleanup + }); + + } else { + wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup); + } + }; + + $.fancybox.resize = function() { + var c, h; + + if (busy || wrap.is(':hidden')) { + return; + } + + busy = true; + + c = inner.wrapInner("
").children(); + h = c.height(); + + wrap.css({height: h + (currentOpts.padding * 2) + titleh}); + inner.css({height: h}); + + c.replaceWith(c.children()); + + $.fancybox.center(); + }; + + $.fancybox.center = function() { + busy = true; + + var view = fancybox_get_viewport(), + margin = currentOpts.margin, + to = {}; + + to.top = view[3] + ((view[1] - ((wrap.height() - titleh) + (shadow * 2 ))) * 0.5); + to.left = view[2] + ((view[0] - (wrap.width() + (shadow * 2 ))) * 0.5); + + to.top = Math.max(view[3] + margin, to.top); + to.left = Math.max(view[2] + margin, to.left); + + wrap.css(to); + + busy = false; + }; + + $.fn.fancybox.defaults = { + padding : 10, + margin : 20, + opacity : false, + modal : false, + cyclic : false, + scrolling : 'auto', // 'auto', 'yes' or 'no' + + width : 560, + height : 340, + + autoScale : true, + autoDimensions : true, + centerOnScroll : false, + + ajax : {}, + swf : { wmode: 'transparent' }, + + hideOnOverlayClick : true, + hideOnContentClick : false, + + overlayShow : true, + overlayOpacity : 0.3, + overlayColor : '#666', + + titleShow : true, + titlePosition : 'outside', // 'outside', 'inside' or 'over' + titleFormat : null, + + transitionIn : 'fade', // 'elastic', 'fade' or 'none' + transitionOut : 'fade', // 'elastic', 'fade' or 'none' + + speedIn : 300, + speedOut : 300, + + changeSpeed : 300, + changeFade : 'fast', + + easingIn : 'swing', + easingOut : 'swing', + + showCloseButton : true, + showNavArrows : true, + enableEscapeButton : true, + + onStart : null, + onCancel : null, + onComplete : null, + onCleanup : null, + onClosed : null + }; + + $(document).ready(function() { + fancybox_init(); + }); + +})(jQuery); \ No newline at end of file diff --git a/public/javascripts/fancybox/jquery.fancybox-1.3.1.pack.js b/public/javascripts/fancybox/jquery.fancybox-1.3.1.pack.js new file mode 100644 index 000000000..8421d53a6 --- /dev/null +++ b/public/javascripts/fancybox/jquery.fancybox-1.3.1.pack.js @@ -0,0 +1,44 @@ +/* + * FancyBox - jQuery Plugin + * Simple and fancy lightbox alternative + * + * Examples and documentation at: http://fancybox.net + * + * Copyright (c) 2008 - 2010 Janis Skarnelis + * + * Version: 1.3.1 (05/03/2010) + * Requires: jQuery v1.3+ + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + */ + +(function(b){var m,u,x,g,D,i,z,A,B,p=0,e={},q=[],n=0,c={},j=[],E=null,s=new Image,G=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,S=/[^\.]\.(swf)\s*$/i,H,I=1,k,l,h=false,y=b.extend(b("
")[0],{prop:0}),v=0,O=!b.support.opacity&&!window.XMLHttpRequest,J=function(){u.hide();s.onerror=s.onload=null;E&&E.abort();m.empty()},P=function(){b.fancybox('

The requested content cannot be loaded.
Please try again later.

',{scrolling:"no",padding:20,transitionIn:"none",transitionOut:"none"})}, +K=function(){return[b(window).width(),b(window).height(),b(document).scrollLeft(),b(document).scrollTop()]},T=function(){var a=K(),d={},f=c.margin,o=c.autoScale,t=(20+f)*2,w=(20+f)*2,r=c.padding*2;if(c.width.toString().indexOf("%")>-1){d.width=a[0]*parseFloat(c.width)/100-40;o=false}else d.width=c.width+r;if(c.height.toString().indexOf("%")>-1){d.height=a[1]*parseFloat(c.height)/100-40;o=false}else d.height=c.height+r;if(o&&(d.width>a[0]-t||d.height>a[1]-w))if(e.type=="image"||e.type=="swf"){t+=r; +w+=r;o=Math.min(Math.min(a[0]-t,c.width)/c.width,Math.min(a[1]-w,c.height)/c.height);d.width=Math.round(o*(d.width-r))+r;d.height=Math.round(o*(d.height-r))+r}else{d.width=Math.min(d.width,a[0]-t);d.height=Math.min(d.height,a[1]-w)}d.top=a[3]+(a[1]-(d.height+40))*0.5;d.left=a[2]+(a[0]-(d.width+40))*0.5;if(c.autoScale===false){d.top=Math.max(a[3]+f,d.top);d.left=Math.max(a[2]+f,d.left)}return d},U=function(a){if(a&&a.length)switch(c.titlePosition){case "inside":return a;case "over":return''+ +a+"";default:return''+a+''}return false},V=function(){var a=c.title,d=l.width-c.padding*2,f="fancybox-title-"+c.titlePosition;b("#fancybox-title").remove();v=0;if(c.titleShow!==false){a=b.isFunction(c.titleFormat)?c.titleFormat(a,j,n,c):U(a);if(!(!a||a==="")){b('
').css({width:d,paddingLeft:c.padding, +paddingRight:c.padding}).html(a).appendTo("body");switch(c.titlePosition){case "inside":v=b("#fancybox-title").outerHeight(true)-c.padding;l.height+=v;break;case "over":b("#fancybox-title").css("bottom",c.padding);break;default:b("#fancybox-title").css("bottom",b("#fancybox-title").outerHeight(true)*-1);break}b("#fancybox-title").appendTo(D).hide()}}},W=function(){b(document).unbind("keydown.fb").bind("keydown.fb",function(a){if(a.keyCode==27&&c.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if(a.keyCode== +37){a.preventDefault();b.fancybox.prev()}else if(a.keyCode==39){a.preventDefault();b.fancybox.next()}});if(b.fn.mousewheel){g.unbind("mousewheel.fb");j.length>1&&g.bind("mousewheel.fb",function(a,d){a.preventDefault();h||d===0||(d>0?b.fancybox.prev():b.fancybox.next())})}if(c.showNavArrows){if(c.cyclic&&j.length>1||n!==0)A.show();if(c.cyclic&&j.length>1||n!=j.length-1)B.show()}},X=function(){var a,d;if(j.length-1>n){a=j[n+1].href;if(typeof a!=="undefined"&&a.match(G)){d=new Image;d.src=a}}if(n>0){a= +j[n-1].href;if(typeof a!=="undefined"&&a.match(G)){d=new Image;d.src=a}}},L=function(){i.css("overflow",c.scrolling=="auto"?c.type=="image"||c.type=="iframe"||c.type=="swf"?"hidden":"auto":c.scrolling=="yes"?"auto":"visible");if(!b.support.opacity){i.get(0).style.removeAttribute("filter");g.get(0).style.removeAttribute("filter")}b("#fancybox-title").show();c.hideOnContentClick&&i.one("click",b.fancybox.close);c.hideOnOverlayClick&&x.one("click",b.fancybox.close);c.showCloseButton&&z.show();W();b(window).bind("resize.fb", +b.fancybox.center);c.centerOnScroll?b(window).bind("scroll.fb",b.fancybox.center):b(window).unbind("scroll.fb");b.isFunction(c.onComplete)&&c.onComplete(j,n,c);h=false;X()},M=function(a){var d=Math.round(k.width+(l.width-k.width)*a),f=Math.round(k.height+(l.height-k.height)*a),o=Math.round(k.top+(l.top-k.top)*a),t=Math.round(k.left+(l.left-k.left)*a);g.css({width:d+"px",height:f+"px",top:o+"px",left:t+"px"});d=Math.max(d-c.padding*2,0);f=Math.max(f-(c.padding*2+v*a),0);i.css({width:d+"px",height:f+ +"px"});if(typeof l.opacity!=="undefined")g.css("opacity",a<0.5?0.5:a)},Y=function(a){var d=a.offset();d.top+=parseFloat(a.css("paddingTop"))||0;d.left+=parseFloat(a.css("paddingLeft"))||0;d.top+=parseFloat(a.css("border-top-width"))||0;d.left+=parseFloat(a.css("border-left-width"))||0;d.width=a.width();d.height=a.height();return d},Q=function(){var a=e.orig?b(e.orig):false,d={};if(a&&a.length){a=Y(a);d={width:a.width+c.padding*2,height:a.height+c.padding*2,top:a.top-c.padding-20,left:a.left-c.padding- +20}}else{a=K();d={width:1,height:1,top:a[3]+a[1]*0.5,left:a[2]+a[0]*0.5}}return d},N=function(){u.hide();if(g.is(":visible")&&b.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){b.event.trigger("fancybox-cancel");h=false;return}j=q;n=p;c=e;i.get(0).scrollTop=0;i.get(0).scrollLeft=0;if(c.overlayShow){O&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"}); +x.css({"background-color":c.overlayColor,opacity:c.overlayOpacity}).unbind().show()}l=T();V();if(g.is(":visible")){b(z.add(A).add(B)).hide();var a=g.position(),d;k={top:a.top,left:a.left,width:g.width(),height:g.height()};d=k.width==l.width&&k.height==l.height;i.fadeOut(c.changeFade,function(){var f=function(){i.html(m.contents()).fadeIn(c.changeFade,L)};b.event.trigger("fancybox-change");i.empty().css("overflow","hidden");if(d){i.css({top:c.padding,left:c.padding,width:Math.max(l.width-c.padding* +2,1),height:Math.max(l.height-c.padding*2-v,1)});f()}else{i.css({top:c.padding,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*2,1)});y.prop=0;b(y).animate({prop:1},{duration:c.changeSpeed,easing:c.easingChange,step:M,complete:f})}})}else{g.css("opacity",1);if(c.transitionIn=="elastic"){k=Q();i.css({top:c.padding,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*2,1)}).html(m.contents());g.css(k).show();if(c.opacity)l.opacity= +0;y.prop=0;b(y).animate({prop:1},{duration:c.speedIn,easing:c.easingIn,step:M,complete:L})}else{i.css({top:c.padding,left:c.padding,width:Math.max(l.width-c.padding*2,1),height:Math.max(l.height-c.padding*2-v,1)}).html(m.contents());g.css(l).fadeIn(c.transitionIn=="none"?0:c.speedIn,L)}}},F=function(){m.width(e.width);m.height(e.height);if(e.width=="auto")e.width=m.width();if(e.height=="auto")e.height=m.height();N()},Z=function(){h=true;e.width=s.width;e.height=s.height;b("").attr({id:"fancybox-img", +src:s.src,alt:e.title}).appendTo(m);N()},C=function(){J();var a=q[p],d,f,o,t,w;e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));o=a.title||b(a).title||e.title||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(o===""&&e.orig)o=e.orig.attr("alt");d=a.nodeName&&/^(?:javascript|#)/i.test(a.href)?e.href||null:e.href||a.href||null;if(e.type){f=e.type;if(!d)d=e.content}else if(e.content)f="html";else if(d)if(d.match(G))f= +"image";else if(d.match(S))f="swf";else if(b(a).hasClass("iframe"))f="iframe";else if(d.match(/#/)){a=d.substr(d.indexOf("#"));f=b(a).length>0?"inline":"ajax"}else f="ajax";else f="inline";e.type=f;e.href=d;e.title=o;if(e.autoDimensions&&e.type!=="iframe"&&e.type!=="swf"){e.width="auto";e.height="auto"}if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=false;e.enableEscapeButton=false;e.showCloseButton=false}if(b.isFunction(e.onStart))if(e.onStart(q,p,e)===false){h=false; +return}m.css("padding",20+e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(i.children())});switch(f){case "html":m.html(e.content);F();break;case "inline":b('
').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(i.children())}).bind("fancybox-cancel",function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity(); +s=new Image;s.onerror=function(){P()};s.onload=function(){s.onerror=null;s.onload=null;Z()};s.src=d;break;case "swf":t='';w="";b.each(e.swf,function(r,R){t+='';w+=" "+r+'="'+R+'"'});t+='";m.html(t); +F();break;case "ajax":a=d.split("#",2);f=e.ajax.data||{};if(a.length>1){d=a[0];if(typeof f=="string")f+="&selector="+a[1];else f.selector=a[1]}h=false;b.fancybox.showActivity();E=b.ajax(b.extend(e.ajax,{url:d,data:f,error:P,success:function(r){if(E.status==200){m.html(r);F()}}}));break;case "iframe":b('').appendTo(m);N();break}},$=function(){if(u.is(":visible")){b("div", +u).css("top",I*-40+"px");I=(I+1)%12}else clearInterval(H)},aa=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('
'),u=b('
'),x=b('
'),g=b('
'));if(!b.support.opacity){g.addClass("fancybox-ie");u.addClass("fancybox-ie")}D=b('
').append('
').appendTo(g); +D.append(i=b('
'),z=b(''),A=b(''),B=b(''));z.click(b.fancybox.close);u.click(b.fancybox.cancel);A.click(function(a){a.preventDefault();b.fancybox.prev()});B.click(function(a){a.preventDefault();b.fancybox.next()});if(O){x.get(0).style.setExpression("height", +"document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");u.get(0).style.setExpression("top","(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'");D.prepend('')}}}; +b.fn.fancybox=function(a){b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(d){d.preventDefault();if(!h){h=true;b(this).blur();q=[];p=0;d=b(this).attr("rel")||"";if(!d||d==""||d==="nofollow")q.push(this);else{q=b("a[rel="+d+"], area[rel="+d+"]");p=q.index(this)}C();return false}});return this};b.fancybox=function(a,d){if(!h){h=true;d=typeof d!=="undefined"?d:{};q=[];p=d.index||0;if(b.isArray(a)){for(var f=0,o=a.length;fq.length||p<0)p=0;C()}};b.fancybox.showActivity=function(){clearInterval(H);u.show();H=setInterval($,66)};b.fancybox.hideActivity=function(){u.hide()};b.fancybox.next=function(){return b.fancybox.pos(n+1)};b.fancybox.prev=function(){return b.fancybox.pos(n- +1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a,10);if(a>-1&&j.length>a){p=a;C()}if(c.cyclic&&j.length>1&&a<0){p=j.length-1;C()}if(c.cyclic&&j.length>1&&a>=j.length){p=0;C()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");J();e&&b.isFunction(e.onCancel)&&e.onCancel(q,p,e);h=false}};b.fancybox.close=function(){function a(){x.fadeOut("fast");g.hide();b.event.trigger("fancybox-cleanup");i.empty();b.isFunction(c.onClosed)&&c.onClosed(j,n,c);j=e=[];n=p=0;c=e={};h=false} +if(!(h||g.is(":hidden"))){h=true;if(c&&b.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){h=false;return}J();b(z.add(A).add(B)).hide();b("#fancybox-title").remove();g.add(i).add(x).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");i.css("overflow","hidden");if(c.transitionOut=="elastic"){k=Q();var d=g.position();l={top:d.top,left:d.left,width:g.width(),height:g.height()};if(c.opacity)l.opacity=1;y.prop=1;b(y).animate({prop:0},{duration:c.speedOut,easing:c.easingOut, +step:M,complete:a})}else g.fadeOut(c.transitionOut=="none"?0:c.speedOut,a)}};b.fancybox.resize=function(){var a,d;if(!(h||g.is(":hidden"))){h=true;a=i.wrapInner("
").children();d=a.height();g.css({height:d+c.padding*2+v});i.css({height:d});a.replaceWith(a.children());b.fancybox.center()}};b.fancybox.center=function(){h=true;var a=K(),d=c.margin,f={};f.top=a[3]+(a[1]-(g.height()-v+40))*0.5;f.left=a[2]+(a[0]-(g.width()+40))*0.5;f.top=Math.max(a[3]+d,f.top);f.left=Math.max(a[2]+ +d,f.left);g.css(f);h=false};b.fn.fancybox.defaults={padding:10,margin:20,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.3,overlayColor:"#666",titleShow:true,titlePosition:"outside",titleFormat:null,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast", +easingIn:"swing",easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,onStart:null,onCancel:null,onComplete:null,onCleanup:null,onClosed:null};b(document).ready(function(){aa()})})(jQuery); \ No newline at end of file diff --git a/public/javascripts/fancybox/jquery.mousewheel-3.0.2.pack.js b/public/javascripts/fancybox/jquery.mousewheel-3.0.2.pack.js new file mode 100644 index 000000000..b950db1a2 --- /dev/null +++ b/public/javascripts/fancybox/jquery.mousewheel-3.0.2.pack.js @@ -0,0 +1,13 @@ +/*! Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net) + * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) + * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. + * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. + * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. + * + * Version: 3.0.2 + * + * Requires: 1.2.2+ + */ + +(function(b){function d(a){var f=[].slice.call(arguments,1),e=0;a=b.event.fix(a||window.event);a.type="mousewheel";if(a.wheelDelta)e=a.wheelDelta/120;if(a.detail)e=-a.detail/3;f.unshift(a,e);return b.event.handle.apply(this,f)}var c=["DOMMouseScroll","mousewheel"];b.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=c.length;a;)this.addEventListener(c[--a],d,false);else this.onmousewheel=d},teardown:function(){if(this.removeEventListener)for(var a=c.length;a;)this.removeEventListener(c[--a], +d,false);else this.onmousewheel=null}};b.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery); \ No newline at end of file diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 59d324306..d5a1cc51e 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -81,6 +81,7 @@ $(document).ready(function(){ }); //buttons////// + pane_toggler_button("album"); pane_toggler_button("group"); pane_toggler_button("photo"); @@ -104,6 +105,9 @@ $(document).ready(function(){ function pane_toggler_button( name ) { + + $("#add_" + name + "_button").fancybox(); + /* $("#add_" + name + "_button").toggle( function(evt){ evt.preventDefault(); @@ -113,4 +117,5 @@ function pane_toggler_button( name ) { $("#add_" + name +"_pane").fadeOut(200); } ); + */ } From cc070ba168d240ffdc5b536b374870960ecd5ab8 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 18:08:27 -0700 Subject: [PATCH 094/198] RS, DG; Removed fancybox gone mad from photo adder --- app/views/albums/show.html.haml | 8 ++++---- app/views/photos/_new_photo.haml | 3 +++ public/javascripts/view.js | 11 +++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index b049f44e8..e2048daf3 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -8,11 +8,11 @@ .right #add_photo_loader = image_tag 'ajax-loader.gif' - = link_to 'Add Photos', '#add_photo_pane', {:class => 'button', :id => 'add_photo_button'} + #add_photo_button + = link_to 'Add Photos', '#', :class => 'button' - .yo{:style => 'display:none;'} - #add_photo_pane - = render "photos/new_photo", :photo => @photo, :album => @album + #add_photo_pane.contextual_pane + = render "photos/new_photo", :photo => @photo, :album => @album .sub_header ="updated #{how_long_ago(@album)}" diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index 4a7023687..cd83d648d 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -10,10 +10,13 @@ onFinish: function(event, total){ $("#add_photo_button .button").html( "Add Photos" ); $("#add_photo_loader").fadeOut(400); + pane_toggler_button("photo") }, onStart: function(event, total){ + $("#add_photo_pane").fadeOut(400); $("#add_photo_button .button").html( "Uploading Photos" ); $("#add_photo_loader").fadeIn(400); + $("#add_photo_button").unbind(); return true; } }); diff --git a/public/javascripts/view.js b/public/javascripts/view.js index d5a1cc51e..e91e6a912 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -82,10 +82,12 @@ $(document).ready(function(){ //buttons////// - pane_toggler_button("album"); - pane_toggler_button("group"); + + $("#add_album_button").fancybox(); + $("#add_group_button").fancybox(); + $("#add_request_button").fancybox(); + pane_toggler_button("photo"); - pane_toggler_button("request"); $("input[type='submit']").addClass("button"); @@ -106,8 +108,6 @@ $(document).ready(function(){ function pane_toggler_button( name ) { - $("#add_" + name + "_button").fancybox(); - /* $("#add_" + name + "_button").toggle( function(evt){ evt.preventDefault(); @@ -117,5 +117,4 @@ function pane_toggler_button( name ) { $("#add_" + name +"_pane").fadeOut(200); } ); - */ } From 355aba75df2dc8e269d7b1df4ff48e6f49b76da2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 10:02:45 -0700 Subject: [PATCH 095/198] RS, DG; removing the last link_to_person --- app/views/bookmarks/_bookmark.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/bookmarks/_bookmark.html.haml b/app/views/bookmarks/_bookmark.html.haml index dd0dffce9..5df9f1a25 100644 --- a/app/views/bookmarks/_bookmark.html.haml +++ b/app/views/bookmarks/_bookmark.html.haml @@ -3,7 +3,7 @@ = person_image_tag(post.person) %span.from - = link_to_person post.person + = link_to post.person.real_name, post.person %b shared a link %br = post.title From 683bb0dbef3ff9491484995c1a88fad5f25f5d7e Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 10:52:01 -0700 Subject: [PATCH 096/198] Took out create redirects on ajaxy things, authenticating statusmessages --- app/controllers/blogs_controller.rb | 1 - app/controllers/bookmarks_controller.rb | 1 - app/controllers/photos_controller.rb | 1 - app/controllers/status_messages_controller.rb | 3 +-- lib/diaspora/webhooks.rb | 5 +++-- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index a74b12e43..4075e04ed 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -24,7 +24,6 @@ class BlogsController < ApplicationController if @blog.created_at flash[:notice] = "Successfully created blog." - redirect_to @blog else render :action => 'new' end diff --git a/app/controllers/bookmarks_controller.rb b/app/controllers/bookmarks_controller.rb index 79bf76d12..760a3255c 100644 --- a/app/controllers/bookmarks_controller.rb +++ b/app/controllers/bookmarks_controller.rb @@ -34,7 +34,6 @@ class BookmarksController < ApplicationController if @bookmark.created_at flash[:notice] = "Successfully created bookmark." - redirect_to @bookmark else render :action => 'new' end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 995690213..2996a23ec 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -7,7 +7,6 @@ class PhotosController < ApplicationController if @photo.created_at flash[:notice] = "Successfully uploaded photo." - redirect_to @photo.album else render :action => 'album#new' end diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index f499492e8..8cc73bac1 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -1,5 +1,5 @@ class StatusMessagesController < ApplicationController - #before_filter :authenticate_user! + before_filter :authenticate_user! def index @status_messages = StatusMessage.paginate :page => params[:page], :order => 'created_at DESC' @@ -16,7 +16,6 @@ class StatusMessagesController < ApplicationController if @status_message.created_at flash[:notice] = "Successfully created status message." - redirect_to status_messages_url else render :action => 'new' end diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index ba78ed81a..959010e61 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -40,10 +40,11 @@ module Diaspora def people_with_permissions begin - friends = self.person.owner.friends + friends = self.person.owner.friends.all + Rails.logger.error("Dan is wrong!") if friends.nil? friends ||= [] rescue - Rails.logger.fatal("IOUASDVJOISDNVPOIJSDVOUIDSGPUOID") + Rails.logger.fatal("Called people_with_permissions on a post from a remote user. We need to implement this shit.") [] end end From 144e9ed439653eaf58365c291f6a28be96b49794 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 11:18:40 -0700 Subject: [PATCH 097/198] Bookmarks now clean link in instantiate, posting them should work right again --- app/controllers/bookmarks_controller.rb | 5 -- app/models/bookmark.rb | 16 ++++--- spec/models/bookmark_spec.rb | 62 ++++++++++++++----------- 3 files changed, 44 insertions(+), 39 deletions(-) diff --git a/app/controllers/bookmarks_controller.rb b/app/controllers/bookmarks_controller.rb index 760a3255c..5d9959732 100644 --- a/app/controllers/bookmarks_controller.rb +++ b/app/controllers/bookmarks_controller.rb @@ -4,11 +4,6 @@ class BookmarksController < ApplicationController def index @bookmark = Bookmark.new @bookmarks = Bookmark.paginate :page => params[:page], :order => 'created_at DESC' - - - respond_to do |format| - format.html - end end def edit diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb index 8f793fd47..de1eb9258 100644 --- a/app/models/bookmark.rb +++ b/app/models/bookmark.rb @@ -12,8 +12,6 @@ class Bookmark < Post validates_format_of :link, :with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix - before_validation :clean_link - def to_activity <<-XML @@ -27,12 +25,18 @@ class Bookmark < Post XML end + + def self.instantiate params + params[:link] = clean_link(params[:link]) + create params + end protected - def clean_link - if self.link - self.link = 'http://' + self.link unless self.link.match('https?://') - self.link = self.link + '/' if self.link[-1,1] != '/' + def self.clean_link link + if link + link = 'http://' + link unless link.match('https?://') + link = link + '/' if link[-1,1] != '/' + link end end end diff --git a/spec/models/bookmark_spec.rb b/spec/models/bookmark_spec.rb index f583e0844..ae4567bc1 100644 --- a/spec/models/bookmark_spec.rb +++ b/spec/models/bookmark_spec.rb @@ -10,34 +10,6 @@ describe Bookmark do it 'should validate its link' do bookmark = Factory.build(:bookmark) - - #links changed valid - bookmark.link = "google.com" - bookmark.valid?.should == true - bookmark.link.should == "http://google.com/" - - bookmark.link = "www.google.com" - bookmark.valid?.should == true - bookmark.link.should == "http://www.google.com/" - - bookmark.link = "google.com/" - bookmark.valid?.should == true - bookmark.link.should == "http://google.com/" - - bookmark.link = "www.google.com/" - bookmark.valid?.should == true - bookmark.link.should == "http://www.google.com/" - - bookmark.link = "http://google.com" - bookmark.valid?.should == true - bookmark.link.should == "http://google.com/" - - bookmark.link = "http://www.google.com" - bookmark.valid?.should == true - - #bookmark.link = "http://babycakes.sofaer.net:3000" - #bookmark.valid?.should == true - #invalid links bookmark.link = "zsdvzxdg" bookmark.valid?.should == false @@ -54,6 +26,24 @@ describe Bookmark do bookmark.link = "http:///www.asodij.com/" bookmark.valid?.should == false end + + it 'should clean links' do + bad_links = [ + "google.com", + "www.google.com", + "google.com/", + "www.google.com/", + "http://google.com", + "http://www.google.com" + ] + + bad_links.each{ |link| + Bookmark.clean_link(link).should satisfy{ |link| + /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix.match(link) + } + } + + end describe "XML" do it 'should serialize to XML' do @@ -71,4 +61,20 @@ describe Bookmark do parsed.valid?.should be_true end end + + describe 'with encryption' do + before do + unstub_mocha_stubs + @user = Factory.create(:user) + end + + after do + stub_signature_verification + end + + it 'should save a signed bookmark' do + bookmark = @user.post(:bookmark, :title => "I love cryptography", :link => "http://pgp.mit.edu/") + bookmark.created_at.should_not be nil + end + end end From 599d1da6207f4ce96060f894a82fc78bdd8dd072 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 12:03:26 -0700 Subject: [PATCH 098/198] Moved socket code out to lib, unsocketing from view should now work again --- app/controllers/sockets_controller.rb | 2 +- app/models/comment.rb | 8 +-- app/models/post.rb | 12 +--- .../status_messages/_status_message.html.haml | 2 +- config/initializers/socket.rb | 40 ++----------- lib/diaspora/websocket.rb | 56 +++++++++++++++++++ 6 files changed, 65 insertions(+), 55 deletions(-) create mode 100644 lib/diaspora/websocket.rb diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb index eb4f57fc9..802aa9cb5 100644 --- a/app/controllers/sockets_controller.rb +++ b/app/controllers/sockets_controller.rb @@ -9,7 +9,7 @@ class SocketsController < ApplicationController def outgoing(uid,object) @_request = ActionDispatch::Request.new({}) - WebSocket.push_to_user(uid, action_hash(uid, object)) + Diaspora::WebSocket.push_to_user(uid, action_hash(uid, object)) end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 79adbb49e..8c66ac62a 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -3,6 +3,7 @@ class Comment include ROXML include Diaspora::Webhooks include Encryptable + include Diaspora::Socketable xml_accessor :text xml_accessor :person, :as => Person @@ -75,11 +76,4 @@ class Comment end end - def send_to_view - people_with_permissions.each{|f| - SocketsController.new.outgoing(f.owner_id, self) if f.owner_id - } - SocketsController.new.outgoing(person.owner_id, self) if person.owner_id - end - end diff --git a/app/models/post.rb b/app/models/post.rb index 0768a91c8..61fe5821a 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -5,6 +5,7 @@ class Post include ROXML include Diaspora::Webhooks include Encryptable + include Diaspora::Socketable xml_accessor :_id xml_accessor :person, :as => Person @@ -75,16 +76,7 @@ protected Retraction.for(self).notify_people end - def send_to_view - people_with_permissions.each{|f| - SocketsController.new.outgoing(f.owner_id, self) if f.owner_id - } - SocketsController.new.outgoing(person.owner_id, self) if person.owner_id - end - - def remove_from_view - SocketsController.new.outgoing(Retraction.for(self)) - end + end diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index ac0f55c34..c6099504e 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -4,7 +4,7 @@ %span.from = link_to post.person.real_name, post.person - = auto_link post.message + = auto_link sanitize post.message %div.time = link_to(how_long_ago(post), object_path(post)) diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index 2fec8a328..0f4e68f7b 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -1,9 +1,8 @@ require 'em-websocket' require 'eventmachine' - -module WebSocket +require "lib/diaspora/websocket" EM.next_tick { - initialize_channels + Diaspora::WebSocket.initialize_channels EventMachine::WebSocket.start( :host => "0.0.0.0", @@ -11,43 +10,12 @@ module WebSocket :debug =>APP_CONFIG[:debug]) do |ws| ws.onopen { - sid = self.subscribe(ws.request['Path'].gsub('/',''), ws) + sid = Diaspora::WebSocket.subscribe(ws.request['Path'].gsub('/',''), ws) ws.onmessage { |msg| SocketsController.new.incoming(msg) }#@channel.push msg; puts msg} - ws.onclose { unsubscribe(ws.request['Path'].gsub('/',''), sid) } + ws.onclose { Diaspora::WebSocket.unsubscribe(ws.request['Path'].gsub('/',''), sid) } } end } - def self.initialize_channels - @channels = {} - end - - def self.push_to_user(uid, data) - Rails.logger.debug "Websocketing to #{uid}" - @channels[uid.to_s][0].push(data) if @channels[uid.to_s] - end - - def self.subscribe(uid, ws) - Rails.logger.debug "Subscribing socket to #{User.first(:id => uid).email}" - self.ensure_channel(uid) - @channels[uid][0].subscribe{ |msg| ws.send msg } - @channels[uid][1] += 1 - end - - def self.ensure_channel(uid) - @channels[uid] ||= [EM::Channel.new, 0 ] - end - - def self.unsubscribe(uid,sid) - Rails.logger.debug "Unsubscribing socket #{sid} from #{User.first(:id => uid).email}" - @channels[uid][0].unsubscribe(sid) if @channels[uid] - @channels[uid][1] -= 1 - if @channels[uid][1] <= 0 - @channels.delete(uid) - end - end - -end - diff --git a/lib/diaspora/websocket.rb b/lib/diaspora/websocket.rb new file mode 100644 index 000000000..4ff1fff1a --- /dev/null +++ b/lib/diaspora/websocket.rb @@ -0,0 +1,56 @@ +module Diaspora + module WebSocket + def self.initialize_channels + @channels = {} + end + + def self.push_to_user(uid, data) + Rails.logger.debug "Websocketing to #{uid}" + @channels[uid.to_s][0].push(data) if @channels[uid.to_s] + end + + def self.subscribe(uid, ws) + Rails.logger.debug "Subscribing socket to #{User.first(:id => uid).email}" + self.ensure_channel(uid) + @channels[uid][0].subscribe{ |msg| ws.send msg } + @channels[uid][1] += 1 + end + + def self.ensure_channel(uid) + @channels[uid] ||= [EM::Channel.new, 0 ] + end + + def self.unsubscribe(uid,sid) + Rails.logger.debug "Unsubscribing socket #{sid} from #{User.first(:id => uid).email}" + @channels[uid][0].unsubscribe(sid) if @channels[uid] + @channels[uid][1] -= 1 + if @channels[uid][1] <= 0 + @channels.delete(uid) + end + end + end + + module Socketable + def socket_to_uid id + SocketsController.new.outgoing(id, self) + end + + def unsocket_from_uid id + SocketsController.new.outgoing(id, Retraction.for(self)) + end + + def send_to_view + people_with_permissions.each{|f| + socket_to_uid f.owner_id if f.owner_id + } + socket_to_uid person.owner_id if person.owner_id + end + + def remove_from_view + people_with_permissions.each{|f| + unsocket_from_uid f.owner_id if f.owner_id + } + unsocket_from_uid person.owner_id if person.owner_id + end + end +end From 11a8b8f3d4d2cbdbdc3fdc824ed52b103690d38c Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 11 Aug 2010 12:28:48 -0700 Subject: [PATCH 099/198] MS IZ testing many the friend request user methods --- app/controllers/publics_controller.rb | 4 +- app/models/user.rb | 7 +- spec/controllers/publics_controller_spec.rb | 26 ++- spec/models/user_spec.rb | 170 ++++++++++++++++---- 4 files changed, 165 insertions(+), 42 deletions(-) diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index 3c7a2af8f..a41d73a23 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -23,9 +23,9 @@ class PublicsController < ApplicationController end def receive - user = Person.first(:id => params[:id]).owner + @user = Person.first(:id => params[:id]).owner Rails.logger.debug "PublicsController has received: #{params[:xml]}" - store_objects_from_xml params[:xml], user + store_objects_from_xml params[:xml], @user render :nothing => true end diff --git a/app/models/user.rb b/app/models/user.rb index d7184cf8f..d40ab77a0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -68,9 +68,10 @@ class User def ignore_friend_request(friend_request_id) request = Request.first(:id => friend_request_id) person = request.person + person.user_refs -= 1 pending_requests.delete(request) save - person.destroy unless person.user_refs > 0 + (person.user_refs > 0 || person.owner.nil? == false) ? person.save : person.destroy request.destroy end @@ -81,6 +82,8 @@ class User Rails.logger.debug("#{self.real_name}'s friend request has been accepted") friend_request.destroy else + + friend_request.person.user_refs += 1 friend_request.person.save pending_requests << friend_request save @@ -98,7 +101,7 @@ class User if bad_friend Retraction.for(self).push_to_url(bad_friend.receive_url) bad_friend.update_attributes(:user_refs => bad_friend.user_refs - 1) - bad_friend.destroy if bad_friend.user_refs == 0 + (bad_friend.user_refs > 0 || bad_friend.owner.nil? == false) ? bad_friend.save : bad_friend.destroy end end diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 976d8900c..f0d65b525 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../spec_helper' - describe PublicsController do render_views @@ -32,26 +31,37 @@ describe PublicsController do @user2 = Factory.create(:user) @user2.person.save - req = Request.instantiate(:from => @user2.person, :to => @user.person.url) + @user3 = Factory.create(:user) + @user3.person.save + + + req = @user2.send_friend_request_to(@user.person.url) + #req = Request.instantiate(:from => @user2.person, :to => @user.person.url) @xml = Request.build_xml_for [req] req.delete + @user2.reload + puts @user2.inspect + @user2.pending_requests.count.should be 1 end - it 'should save requests for the specified user (LOCAL)' do + it 'should add the pending request to the right user, person exists locally' do + @user2.delete post :receive, :id => @user.person.id, :xml => @xml - @user.reload - @user.pending_requests.size.should be 1 + assigns(:user).should eq(@user) + + end - it 'should save requests for the specified user (REMOTE)' do + it 'should add the pending request to the right user, person does not exist locally' do @user2.person.delete @user2.delete post :receive, :id => @user.person.id, :xml => @xml - @user.reload - @user.pending_requests.size.should be 1 + + assigns(:user).should eq(@user) + end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2102344b8..f6fee9be0 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,16 +1,12 @@ require File.dirname(__FILE__) + '/../spec_helper' +include Diaspora::Parser + describe User do before do @user = Factory.create(:user) end - it "should be a person" do - n = Person.count - Factory.create(:user) - Person.count.should == n+1 - end - it 'should instantiate with a person and be valid' do user = User.instantiate(:email => "bob@bob.com", :password => "password", @@ -34,7 +30,6 @@ describe User do Request.for_user(@user).all.count.should == 1 @user.accept_friend_request(r.id) Request.for_user(@user).all.count.should == 0 - #Person.where(:id => friend.id).first.active.should == true end it 'should be able to ignore a pending friend request' do @@ -43,7 +38,6 @@ describe User do r.save Person.count.should == 2 - #friend.active.should == false @user.ignore_friend_request(r.id) @@ -67,31 +61,147 @@ describe User do @user.terse_url.should == 'example.com' end - it 'should get the pending friends' do - person_one = Factory.create :person - person_two = Factory.create :person - @user.pending_requests.empty?.should be true - @user.friends.empty?.should be true - - request = Request.instantiate(:to => @user.receive_url, :from => person_one) - person_one.destroy - @user.receive_friend_request request - @user.pending_requests.size.should be 1 - @user.friends.size.should be 0 + describe 'multiple users accepting/rejecting the same person' do + before do + @person_one = Factory.create :person + @person_one.save - request_two = Request.instantiate(:to => @user.receive_url, :from => person_two) - person_two.destroy - @user.receive_friend_request request_two - @user.pending_requests.size.should be 2 - @user.friends.size.should be 0 + @user2 = Factory.create :user - @user.accept_friend_request request.id - @user.pending_requests.size.should be 1 - @user.friends.size.should be 1 + @user.pending_requests.empty?.should be true + @user.friends.empty?.should be true + @user2.pending_requests.empty?.should be true + @user2.friends.empty?.should be true + + @request = Request.instantiate(:to => @user.receive_url, :from => @person_one) + @request_two = Request.instantiate(:to => @user2.receive_url, :from => @person_one) + @request_three = Request.instantiate(:to => @user2.receive_url, :from => @user.person) + + + @req_xml = Request.build_xml_for [@request] + @req_two_xml = Request.build_xml_for [@request_two] + @req_three_xml = Request.build_xml_for [@request_three] + + + @request.destroy + @request_two.destroy + @request_three.destroy + end + + it 'should befriend the user other user on the same pod' do + + store_objects_from_xml @req_three_xml, @user2 + @user2.pending_requests.size.should be 1 + @user2.accept_friend_request @request_three.id + @user2.friends.include?(@user.person).should be true + Person.all.count.should be 3 + end + + it 'should not delete the ignored user on the same pod' do + + store_objects_from_xml @req_three_xml, @user2 + @user2.pending_requests.size.should be 1 + @user2.ignore_friend_request @request_three.id + @user2.friends.include?(@user.person).should be false + Person.all.count.should be 3 + end + + it 'should both users should befriend the same person' do + + store_objects_from_xml @req_xml, @user + @user.pending_requests.size.should be 1 + @user.accept_friend_request @request.id + @user.friends.include?(@person_one).should be true + + store_objects_from_xml @req_two_xml, @user2 + @user2.pending_requests.size.should be 1 + @user2.accept_friend_request @request_two.id + @user2.friends.include?(@person_one).should be true + Person.all.count.should be 3 + end + + it 'should keep the person around if one of the users rejects him' do + + store_objects_from_xml @req_xml, @user + @user.pending_requests.size.should be 1 + @user.accept_friend_request @request.id + @user.friends.include?(@person_one).should be true + + store_objects_from_xml @req_two_xml, @user2 + @user2.pending_requests.size.should be 1 + @user2.ignore_friend_request @request_two.id + @user2.friends.include?(@person_one).should be false + Person.all.count.should be 3 + end + + it 'should not keep the person around if the users ignores them' do + store_objects_from_xml @req_xml, @user + @user.pending_requests.size.should be 1 + @user.ignore_friend_request @user.pending_requests.first.id + @user.friends.include?(@person_one).should be false + + store_objects_from_xml @req_two_xml, @user2 + @user2.pending_requests.size.should be 1 + @user2.ignore_friend_request @user2.pending_requests.first.id#@request_two.id + @user2.friends.include?(@person_one).should be false + Person.all.count.should be 2 + end + + + end + + describe 'a user accepting rejecting multiple people' do + before do + @person_one = Factory.create :person + @person_two = Factory.create :person + + @user.pending_requests.empty?.should be true + @user.friends.empty?.should be true + + @request = Request.instantiate(:to => @user.receive_url, :from => @person_one) + @request_two = Request.instantiate(:to => @user.receive_url, :from => @person_two) + end + + after do + @user.receive_friend_request @request + + @person_two.destroy + @user.pending_requests.size.should be 1 + @user.friends.size.should be 0 + + @user.receive_friend_request @request_two + @user.pending_requests.size.should be 2 + @user.friends.size.should be 0 + + @user.accept_friend_request @request.id + @user.pending_requests.size.should be 1 + @user.friends.size.should be 1 + @user.friends.include?(@person_one).should be true + + @user.ignore_friend_request @request_two.id + @user.pending_requests.size.should be 0 + @user.friends.size.should be 1 + @user.friends.include?(@person_two).should be false + + end + it 'should do accept reject for people not on the pod' do + + @person_one.destroy + @person_two.destroy + + end + + it 'should do accept reject for people on the pod' do + + end + + it 'should do accept reject for mixed people on the pod' do + + @person_two.destroy + + end - @user.ignore_friend_request request_two.id - @user.pending_requests.size.should be 0 - @user.friends.size.should be 1 + end end From 9c9ebbf4c7f5b42e1152d34cd5c6e7619368db31 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 13:58:18 -0700 Subject: [PATCH 100/198] build_xml_for is no longer static, we should probably change the name --- app/controllers/status_messages_controller.rb | 2 +- app/models/person.rb | 4 +-- lib/diaspora/webhooks.rb | 8 ++--- spec/controllers/publics_controller_spec.rb | 4 +-- spec/lib/diaspora_parser_spec.rb | 29 +++++++++---------- spec/lib/web_hooks_spec.rb | 13 +-------- spec/user_encryption_spec.rb | 10 +++---- 7 files changed, 27 insertions(+), 43 deletions(-) diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 8cc73bac1..f941389a5 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -37,7 +37,7 @@ class StatusMessagesController < ApplicationController respond_to do |format| format.html - format.xml { render :xml => Post.build_xml_for(@status_message) } + format.xml { render :xml => @status_message.build_xml_for } format.json { render :json => @status_message } end end diff --git a/app/models/person.rb b/app/models/person.rb index ad3991959..75e261496 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -57,9 +57,7 @@ class Person options[:person] = self model_class = class_name.to_s.camelize.constantize post = model_class.instantiate(options) - if owns?(post) - post.notify_people - end + post.notify_people post end diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index 959010e61..6d88ad8c2 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -19,7 +19,7 @@ module Diaspora def push_to(recipients) unless recipients.empty? recipients.map!{|x| x = x.receive_url } - xml = Post.build_xml_for(self) + xml = build_xml_for Rails.logger.debug("Adding xml for #{self} to message queue to #{recipients}") @@queue.add_post_request( recipients, xml ) end @@ -28,7 +28,7 @@ module Diaspora def push_to_url(url) hook_url = url - xml = self.class.build_xml_for(self) + xml = build_xml_for Rails.logger.debug("Adding xml for #{self} to message queue to #{url}") @@queue.add_post_request( hook_url, xml ) @@queue.process @@ -49,10 +49,10 @@ module Diaspora end end - def self.build_xml_for(posts) + def build_xml_for xml = "" xml += "\n " - [*posts].each {|x| xml << x.to_diaspora_xml} + xml << to_diaspora_xml xml += "" xml += "" diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 976d8900c..fedc031ae 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -21,7 +21,7 @@ describe PublicsController do person = Factory.create(:person) message = StatusMessage.new(:message => 'foo', :person => person) StatusMessage.all.count.should be 0 - post :receive, :id => @user.person.id, :xml => Post.build_xml_for(message) + post :receive, :id => @user.person.id, :xml => message.build_xml_for(message) StatusMessage.all.count.should be 1 end end @@ -33,7 +33,7 @@ describe PublicsController do @user2.person.save req = Request.instantiate(:from => @user2.person, :to => @user.person.url) - @xml = Request.build_xml_for [req] + @xml = req.build_xml_for req.delete end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 4ec4815c7..17bc556f4 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -12,10 +12,11 @@ describe Diaspora::Parser do end it "should not store posts from me" do - status_messages = [] - 10.times { status_messages << Factory.build(:status_message, :person => @user)} - xml = Post.build_xml_for(status_messages) - store_objects_from_xml(xml, @user) + 10.times { + message = Factory.build(:status_message, :person => @user) + xml = message.build_xml_for + store_objects_from_xml(xml, @user) + } StatusMessage.count.should == 0 end @@ -65,15 +66,11 @@ describe Diaspora::Parser do describe "parsing compliant XML object" do before do - @status_messages = [] - 10.times { @status_messages << Factory.build(:status_message)} - @xml = Post.build_xml_for(@status_messages) + @xml = Factory.build(:status_message).build_xml_for end it 'should be able to parse the body\'s contents' do body = parse_body_contents_from_xml(@xml).to_s - body.should_not include "" - body.should_not include "" body.should_not include "" body.should_not include "" body.should include "" @@ -83,7 +80,7 @@ describe Diaspora::Parser do it 'should be able to extract all posts to an array' do posts = parse_objects_from_xml(@xml) posts.is_a?(Array).should be true - posts.count.should == 10 + posts.count.should == 1 end it 'should be able to correctly handle comments' do @@ -106,7 +103,7 @@ describe Diaspora::Parser do person = Factory.create(:person) message = Factory.create(:status_message, :person => person) retraction = Retraction.for(message) - request = Post.build_xml_for( [retraction] ) + request = retraction.build_xml_for StatusMessage.count.should == 1 store_objects_from_xml( request, @user ) @@ -117,7 +114,7 @@ describe Diaspora::Parser do request = Request.instantiate(:to =>"http://www.google.com/", :from => @person) original_person_id = @person.id - xml = Request.build_xml_for [request] + xml = request.build_xml_for @person.destroy Person.all.count.should be 1 @@ -134,7 +131,7 @@ describe Diaspora::Parser do request = Request.instantiate(:to =>"http://www.google.com/", :from => @user2.person) original_person_id = @user2.person.id - xml = Request.build_xml_for [request] + xml = request.build_xml_for Person.all.count.should be 3 @@ -163,7 +160,7 @@ describe Diaspora::Parser do request_remote.person = @person request_remote.exported_key = @person.export_key - xml = Request.build_xml_for [request_remote] + xml = request_remote.build_xml_for @person.destroy request_remote.destroy @@ -178,7 +175,7 @@ describe Diaspora::Parser do it 'should process retraction for a person' do retraction = Retraction.for(@user) - request = Retraction.build_xml_for( [retraction] ) + request = retraction.build_xml_for Person.count.should == 2 store_objects_from_xml( request , @user) @@ -197,7 +194,7 @@ describe Diaspora::Parser do old_profile.first_name.should == 'bob' #Build xml for profile, clear profile - xml = Post.build_xml_for(person.profile) + xml = person.profile.build_xml_for reloaded_person = Person.first(:id => id) reloaded_person.profile = nil reloaded_person.save(:validate => false) diff --git a/spec/lib/web_hooks_spec.rb b/spec/lib/web_hooks_spec.rb index 32a8d4cb0..ba62d5ebe 100644 --- a/spec/lib/web_hooks_spec.rb +++ b/spec/lib/web_hooks_spec.rb @@ -43,9 +43,7 @@ describe Diaspora do end it "should check that it does not send a person's post to an owners people" do - Post.stub(:build_xml_for).and_return(true) - Post.should_not_receive(:build_xml_for) - + message_queue.should_not_receive(:add_post_request) Factory.create(:status_message, :person => Factory.create(:person)) end @@ -58,15 +56,6 @@ describe Diaspora do @post.people_with_permissions.size.should == 5 end - it "should build an xml object containing multiple Post types" do - Factory.create(:status_message) - Factory.create(:bookmark) - - stream = Post.stream - xml = Post.build_xml_for(stream) - xml.should include "" - xml.should include "" - end end end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 2c7b8963b..b4a63fc98 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -39,7 +39,7 @@ describe 'user encryption' do it 'should send over a public key' do message_queue.stub!(:add_post_request) request = @user.send_friend_request_to("http://example.com/") - Request.build_xml_for([request]).include?( @user.export_key).should be true + request.build_xml_for.include?( @user.export_key).should be true end it 'should receive and marshal a public key from a request' do @@ -51,10 +51,10 @@ describe 'user encryption' do request = Request.instantiate(:to =>"http://www.google.com/", :from => person) - xml = Request.build_xml_for [request] + xml = request.build_xml_for person.destroy personcount = Person.all.count - store_objects_from_xml(xml) + store_objects_from_xml(xml, @user) Person.all.count.should == personcount + 1 new_person = Person.first(:url => "http://test.url/") new_person.id.should == id @@ -110,10 +110,10 @@ describe 'user encryption' do message = Factory.build(:status_message, :person => @person) message.creator_signature = "totally valid" message.save - xml = Post.build_xml_for([message]) + xml = message.build_xml_for message.destroy Post.count.should be 0 - store_objects_from_xml(xml) + store_objects_from_xml(xml, @user) Post.count.should be 0 end From e94faf89bb7057c34f8adf3e708aab51aa7764a2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 14:05:57 -0700 Subject: [PATCH 101/198] Finishing moving to dynamic build_xml_for --- spec/models/user_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index f6fee9be0..c8ac5d7b4 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -78,9 +78,9 @@ describe User do @request_three = Request.instantiate(:to => @user2.receive_url, :from => @user.person) - @req_xml = Request.build_xml_for [@request] - @req_two_xml = Request.build_xml_for [@request_two] - @req_three_xml = Request.build_xml_for [@request_three] + @req_xml = @request.build_xml_for + @req_two_xml = @request_two.build_xml_for + @req_three_xml = @request_three.build_xml_for @request.destroy From 5abd604dadef09d20d4a413d2e55bd21f532ad85 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 14:21:53 -0700 Subject: [PATCH 102/198] RS, DG; build_xml_for has been eliminated. --- app/models/profile.rb | 5 ----- lib/diaspora/parser.rb | 1 + lib/diaspora/webhooks.rb | 19 +++++++------------ spec/controllers/publics_controller_spec.rb | 4 ++-- spec/lib/diaspora_parser_spec.rb | 18 +++++++++--------- spec/lib/web_hooks_spec.rb | 2 +- spec/models/user_spec.rb | 6 +++--- spec/user_encryption_spec.rb | 6 +++--- 8 files changed, 26 insertions(+), 35 deletions(-) diff --git a/app/models/profile.rb b/app/models/profile.rb index 23f094485..9b4c81005 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -23,9 +23,4 @@ class Profile def person Person.first(:id => self.person_id) end - - def to_diaspora_xml - ""+ self.to_xml.to_s + "" - end - end diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index 9636bbe22..b670c637a 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -48,6 +48,7 @@ module Diaspora rescue NameError => e if e.message.include? 'wrong constant name' Rails.logger.info "Not a real type: #{object.to_s}" + raise e else raise e end diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index 6d88ad8c2..1249cc5bf 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -19,7 +19,7 @@ module Diaspora def push_to(recipients) unless recipients.empty? recipients.map!{|x| x = x.receive_url } - xml = build_xml_for + xml = to_diaspora_xml Rails.logger.debug("Adding xml for #{self} to message queue to #{recipients}") @@queue.add_post_request( recipients, xml ) end @@ -28,14 +28,18 @@ module Diaspora def push_to_url(url) hook_url = url - xml = build_xml_for + xml = to_diaspora_xml Rails.logger.debug("Adding xml for #{self} to message queue to #{url}") @@queue.add_post_request( hook_url, xml ) @@queue.process end def to_diaspora_xml - "#{self.to_xml.to_s}" + xml = "" + xml += "" + xml += "#{self.to_xml.to_s}" + xml += "" + xml += "" end def people_with_permissions @@ -48,15 +52,6 @@ module Diaspora [] end end - - def build_xml_for - xml = "" - xml += "\n " - xml << to_diaspora_xml - xml += "" - xml += "" - - end end end end diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 39db7a28d..0181a2cb4 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -20,7 +20,7 @@ describe PublicsController do person = Factory.create(:person) message = StatusMessage.new(:message => 'foo', :person => person) StatusMessage.all.count.should be 0 - post :receive, :id => @user.person.id, :xml => message.build_xml_for(message) + post :receive, :id => @user.person.id, :xml => message.to_diaspora_xml(message) StatusMessage.all.count.should be 1 end end @@ -37,7 +37,7 @@ describe PublicsController do req = @user2.send_friend_request_to(@user.person.url) #req = Request.instantiate(:from => @user2.person, :to => @user.person.url) - @xml = req.build_xml_for + @xml = req.to_diaspora_xml req.delete @user2.reload diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 17bc556f4..8f90c9cbf 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -14,7 +14,7 @@ describe Diaspora::Parser do it "should not store posts from me" do 10.times { message = Factory.build(:status_message, :person => @user) - xml = message.build_xml_for + xml = message.to_diaspora_xml store_objects_from_xml(xml, @user) } StatusMessage.count.should == 0 @@ -66,7 +66,7 @@ describe Diaspora::Parser do describe "parsing compliant XML object" do before do - @xml = Factory.build(:status_message).build_xml_for + @xml = Factory.build(:status_message).to_diaspora_xml end it 'should be able to parse the body\'s contents' do @@ -103,7 +103,7 @@ describe Diaspora::Parser do person = Factory.create(:person) message = Factory.create(:status_message, :person => person) retraction = Retraction.for(message) - request = retraction.build_xml_for + request = retraction.to_diaspora_xml StatusMessage.count.should == 1 store_objects_from_xml( request, @user ) @@ -114,7 +114,7 @@ describe Diaspora::Parser do request = Request.instantiate(:to =>"http://www.google.com/", :from => @person) original_person_id = @person.id - xml = request.build_xml_for + xml = request.to_diaspora_xml @person.destroy Person.all.count.should be 1 @@ -131,7 +131,7 @@ describe Diaspora::Parser do request = Request.instantiate(:to =>"http://www.google.com/", :from => @user2.person) original_person_id = @user2.person.id - xml = request.build_xml_for + xml = request.to_diaspora_xml Person.all.count.should be 3 @@ -160,7 +160,7 @@ describe Diaspora::Parser do request_remote.person = @person request_remote.exported_key = @person.export_key - xml = request_remote.build_xml_for + xml = request_remote.to_diaspora_xml @person.destroy request_remote.destroy @@ -175,7 +175,7 @@ describe Diaspora::Parser do it 'should process retraction for a person' do retraction = Retraction.for(@user) - request = retraction.build_xml_for + request = retraction.to_diaspora_xml Person.count.should == 2 store_objects_from_xml( request , @user) @@ -194,7 +194,7 @@ describe Diaspora::Parser do old_profile.first_name.should == 'bob' #Build xml for profile, clear profile - xml = person.profile.build_xml_for + xml = person.profile.to_diaspora_xml reloaded_person = Person.first(:id => id) reloaded_person.profile = nil reloaded_person.save(:validate => false) @@ -209,7 +209,7 @@ describe Diaspora::Parser do #Check that marshaled profile is the same as old profile person = Person.first(:id => person.id) person.profile.should_not be nil - person.profile.first_name.should == old_profile.first_name + person.profile.first_name.should == old_profile.first_name person.profile.last_name.should == old_profile.last_name person.profile.image_url.should == old_profile.image_url end diff --git a/spec/lib/web_hooks_spec.rb b/spec/lib/web_hooks_spec.rb index ba62d5ebe..150bacef8 100644 --- a/spec/lib/web_hooks_spec.rb +++ b/spec/lib/web_hooks_spec.rb @@ -23,7 +23,7 @@ describe Diaspora do end it "should convert an object to a proper diaspora entry" do - @post.to_diaspora_xml.should == "#{@post.to_xml.to_s}" + @post.to_diaspora_xml.should == "#{@post.to_xml.to_s}" end it "should retrieve all valid person endpoints" do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c8ac5d7b4..ddb20f095 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -78,9 +78,9 @@ describe User do @request_three = Request.instantiate(:to => @user2.receive_url, :from => @user.person) - @req_xml = @request.build_xml_for - @req_two_xml = @request_two.build_xml_for - @req_three_xml = @request_three.build_xml_for + @req_xml = @request.to_diaspora_xml + @req_two_xml = @request_two.to_diaspora_xml + @req_three_xml = @request_three.to_diaspora_xml @request.destroy diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index b4a63fc98..ac6c96fcb 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -39,7 +39,7 @@ describe 'user encryption' do it 'should send over a public key' do message_queue.stub!(:add_post_request) request = @user.send_friend_request_to("http://example.com/") - request.build_xml_for.include?( @user.export_key).should be true + request.to_diaspora_xml.include?( @user.export_key).should be true end it 'should receive and marshal a public key from a request' do @@ -51,7 +51,7 @@ describe 'user encryption' do request = Request.instantiate(:to =>"http://www.google.com/", :from => person) - xml = request.build_xml_for + xml = request.to_diaspora_xml person.destroy personcount = Person.all.count store_objects_from_xml(xml, @user) @@ -110,7 +110,7 @@ describe 'user encryption' do message = Factory.build(:status_message, :person => @person) message.creator_signature = "totally valid" message.save - xml = message.build_xml_for + xml = message.to_diaspora_xml message.destroy Post.count.should be 0 store_objects_from_xml(xml, @user) From 11758beaf325c8c0989ddd518a2237e51fa737a1 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 14:26:39 -0700 Subject: [PATCH 103/198] RS, DG; Removed from xml --- lib/diaspora/parser.rb | 2 +- lib/diaspora/webhooks.rb | 2 -- spec/lib/diaspora_parser_spec.rb | 26 +++----------------------- spec/lib/web_hooks_spec.rb | 4 ---- 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index b670c637a..5783e3e5d 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -8,7 +8,7 @@ module Diaspora def parse_body_contents_from_xml(xml) doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks } - doc.xpath("/XML/posts/post") + doc.xpath("/XML/post") end def parse_owner_id_from_xml(doc) diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index 1249cc5bf..dba3968e2 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -36,9 +36,7 @@ module Diaspora def to_diaspora_xml xml = "" - xml += "" xml += "#{self.to_xml.to_s}" - xml += "" xml += "" end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 8f90c9cbf..6bbf68b5f 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -23,31 +23,16 @@ describe Diaspora::Parser do it "should reject xml with no sender" do xml = " - + \n Here is another message\n a@a.com\n a@a.com\n a@a.com\n \n HEY DUDE\n a@a.com\n a@a.com\n a@a.com\n - " + " store_objects_from_xml(xml, @user) Post.count.should == 0 end - it "should reject xml with a sender not in the database" do - xml = " - - - foo@example.com - - - \n Here is another message\n a@a.com\n a@a.com\n a@a.com\n - - \n HEY DUDE\n a@a.com\n a@a.com\n a@a.com\n - " - store_objects_from_xml(xml, @user) - Post.count.should == 0 - end - it 'should discard types which are not of type post' do xml = " @@ -71,8 +56,6 @@ describe Diaspora::Parser do it 'should be able to parse the body\'s contents' do body = parse_body_contents_from_xml(@xml).to_s - body.should_not include "" - body.should_not include "" body.should include "" body.should include "" end @@ -87,10 +70,7 @@ describe Diaspora::Parser do person = Factory.create(:person, :email => "test@testing.com") post = Factory.create(:status_message, :person => @user.person) comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!") - xml = " - - #{comment.to_xml} - " + xml = comment.to_diaspora_xml objects = parse_objects_from_xml(xml) comment = objects.first diff --git a/spec/lib/web_hooks_spec.rb b/spec/lib/web_hooks_spec.rb index 150bacef8..63739f636 100644 --- a/spec/lib/web_hooks_spec.rb +++ b/spec/lib/web_hooks_spec.rb @@ -22,10 +22,6 @@ describe Diaspora do @post.respond_to?(:people_with_permissions).should be true end - it "should convert an object to a proper diaspora entry" do - @post.to_diaspora_xml.should == "#{@post.to_xml.to_s}" - end - it "should retrieve all valid person endpoints" do @user.friends << Factory.create(:person, :url => "http://www.bob.com/") @user.friends << Factory.create(:person, :url => "http://www.alice.com/") From 5228e512626d003de9df4555c63ae49962274e55 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 14:40:48 -0700 Subject: [PATCH 104/198] RS, DG; store_from_xml now takes one objects. All talk of arrays and collections has been eliminated. --- app/controllers/publics_controller.rb | 2 +- lib/diaspora/parser.rb | 82 +++++++++++++-------------- spec/lib/diaspora_parser_spec.rb | 35 ++++-------- spec/models/user_spec.rb | 16 +++--- spec/user_encryption_spec.rb | 4 +- 5 files changed, 60 insertions(+), 79 deletions(-) diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index a41d73a23..eac2540ac 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -25,7 +25,7 @@ class PublicsController < ApplicationController def receive @user = Person.first(:id => params[:id]).owner Rails.logger.debug "PublicsController has received: #{params[:xml]}" - store_objects_from_xml params[:xml], @user + store_from_xml params[:xml], @user render :nothing => true end diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index 5783e3e5d..471a4fbed 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -23,57 +23,51 @@ module Diaspora person ? person : Person.from_xml( person_xml) end - def parse_objects_from_xml(xml) - objects = [] - body = parse_body_contents_from_xml(xml) - body.children.each do |post| - begin - object = post.name.camelize.constantize.from_xml post.to_s - if object.is_a? Retraction - elsif object.is_a? Profile - person = parse_owner_id_from_xml post - person.profile = object - person.save - elsif object.is_a? Request - person = get_or_create_person_object_from_xml(post) - person.serialized_key ||= object.exported_key - object.person = person - object.person.save - object.save - elsif object.respond_to? :person - object.person = parse_owner_from_xml post.to_s - end + def parse_from_xml(xml) - objects << object - rescue NameError => e - if e.message.include? 'wrong constant name' - Rails.logger.info "Not a real type: #{object.to_s}" - raise e - else - raise e - end + return unless body = parse_body_contents_from_xml(xml).children.first + + begin + object = body.name.camelize.constantize.from_xml body.to_s + if object.is_a? Retraction + elsif object.is_a? Profile + person = parse_owner_id_from_xml body + person.profile = object + person.save + elsif object.is_a? Request + person = get_or_create_person_object_from_xml(body) + person.serialized_key ||= object.exported_key + object.person = person + object.person.save + object.save + elsif object.respond_to? :person + object.person = parse_owner_from_xml body.to_s end + object + rescue NameError => e + if e.message.include? 'wrong constant name' + Rails.logger.info "Not a real type: #{object.to_s}" + end + raise e end - objects end - def store_objects_from_xml(xml, user) - objects = parse_objects_from_xml(xml) - objects.each do |p| - Rails.logger.debug("Receiving object:\n#{p.inspect}") + def store_from_xml(xml, user) + object = parse_from_xml(xml) + Rails.logger.debug("Receiving object:\n#{object.inspect}") - if p.is_a? Retraction - Rails.logger.debug "Got a retraction for #{p.post_id}" - p.perform - - elsif p.is_a? Request - user.receive_friend_request(p) + if object.is_a? Retraction + Rails.logger.debug "Got a retraction for #{object.post_id}" + object.perform + + elsif object.is_a? Request + user.receive_friend_request(object) - elsif p.is_a? Profile - p.save - elsif p.respond_to?(:person) && !(p.person.nil?) && !(p.person.is_a? User) - Rails.logger.debug("Saving object with success: #{p.save}") - end + elsif object.is_a? Profile + object.save + + elsif object.respond_to?(:person) && !(object.person.nil?) && !(object.person.is_a? User) + Rails.logger.debug("Saving object with success: #{object.save}") end end end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 6bbf68b5f..c4d56fc11 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -15,7 +15,7 @@ describe Diaspora::Parser do 10.times { message = Factory.build(:status_message, :person => @user) xml = message.to_diaspora_xml - store_objects_from_xml(xml, @user) + store_from_xml(xml, @user) } StatusMessage.count.should == 0 end @@ -28,23 +28,17 @@ describe Diaspora::Parser do \n HEY DUDE\n a@a.com\n a@a.com\n a@a.com\n " - store_objects_from_xml(xml, @user) + store_from_xml(xml, @user) Post.count.should == 0 end it 'should discard types which are not of type post' do xml = " - - - #{Person.first.email} - - - - " + " - store_objects_from_xml(xml, @user) + store_from_xml(xml, @user) Post.count.should == 0 end @@ -59,12 +53,6 @@ describe Diaspora::Parser do body.should include "" body.should include "" end - - it 'should be able to extract all posts to an array' do - posts = parse_objects_from_xml(@xml) - posts.is_a?(Array).should be true - posts.count.should == 1 - end it 'should be able to correctly handle comments' do person = Factory.create(:person, :email => "test@testing.com") @@ -72,8 +60,7 @@ describe Diaspora::Parser do comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!") xml = comment.to_diaspora_xml - objects = parse_objects_from_xml(xml) - comment = objects.first + comment = parse_from_xml(xml) comment.text.should == "Freedom!" comment.person.should == person comment.post.should == post @@ -86,7 +73,7 @@ describe Diaspora::Parser do request = retraction.to_diaspora_xml StatusMessage.count.should == 1 - store_objects_from_xml( request, @user ) + store_from_xml( request, @user ) StatusMessage.count.should == 0 end @@ -98,7 +85,7 @@ describe Diaspora::Parser do @person.destroy Person.all.count.should be 1 - store_objects_from_xml(xml, @user) + store_from_xml(xml, @user) Person.all.count.should be 2 Person.first(:_id => original_person_id).serialized_key.include?("PUBLIC").should be true @@ -115,7 +102,7 @@ describe Diaspora::Parser do Person.all.count.should be 3 - store_objects_from_xml(xml, @user) + store_from_xml(xml, @user) Person.all.count.should be 3 @user2.reload @@ -144,7 +131,7 @@ describe Diaspora::Parser do @person.destroy request_remote.destroy - store_objects_from_xml(xml, @user) + store_from_xml(xml, @user) new_person = Person.first(:url => @person.url) new_person.nil?.should be false @@ -158,7 +145,7 @@ describe Diaspora::Parser do request = retraction.to_diaspora_xml Person.count.should == 2 - store_objects_from_xml( request , @user) + store_from_xml( request , @user) Person.count.should == 1 end @@ -184,7 +171,7 @@ describe Diaspora::Parser do old_profile.first_name.should == 'bob' #Marshal profile - store_objects_from_xml xml, @user + store_from_xml xml, @user #Check that marshaled profile is the same as old profile person = Person.first(:id => person.id) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index ddb20f095..b1ae2df6a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -90,7 +90,7 @@ describe User do it 'should befriend the user other user on the same pod' do - store_objects_from_xml @req_three_xml, @user2 + store_from_xml @req_three_xml, @user2 @user2.pending_requests.size.should be 1 @user2.accept_friend_request @request_three.id @user2.friends.include?(@user.person).should be true @@ -99,7 +99,7 @@ describe User do it 'should not delete the ignored user on the same pod' do - store_objects_from_xml @req_three_xml, @user2 + store_from_xml @req_three_xml, @user2 @user2.pending_requests.size.should be 1 @user2.ignore_friend_request @request_three.id @user2.friends.include?(@user.person).should be false @@ -108,12 +108,12 @@ describe User do it 'should both users should befriend the same person' do - store_objects_from_xml @req_xml, @user + store_from_xml @req_xml, @user @user.pending_requests.size.should be 1 @user.accept_friend_request @request.id @user.friends.include?(@person_one).should be true - store_objects_from_xml @req_two_xml, @user2 + store_from_xml @req_two_xml, @user2 @user2.pending_requests.size.should be 1 @user2.accept_friend_request @request_two.id @user2.friends.include?(@person_one).should be true @@ -122,12 +122,12 @@ describe User do it 'should keep the person around if one of the users rejects him' do - store_objects_from_xml @req_xml, @user + store_from_xml @req_xml, @user @user.pending_requests.size.should be 1 @user.accept_friend_request @request.id @user.friends.include?(@person_one).should be true - store_objects_from_xml @req_two_xml, @user2 + store_from_xml @req_two_xml, @user2 @user2.pending_requests.size.should be 1 @user2.ignore_friend_request @request_two.id @user2.friends.include?(@person_one).should be false @@ -135,12 +135,12 @@ describe User do end it 'should not keep the person around if the users ignores them' do - store_objects_from_xml @req_xml, @user + store_from_xml @req_xml, @user @user.pending_requests.size.should be 1 @user.ignore_friend_request @user.pending_requests.first.id @user.friends.include?(@person_one).should be false - store_objects_from_xml @req_two_xml, @user2 + store_from_xml @req_two_xml, @user2 @user2.pending_requests.size.should be 1 @user2.ignore_friend_request @user2.pending_requests.first.id#@request_two.id @user2.friends.include?(@person_one).should be false diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index ac6c96fcb..39bfbd2cd 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -54,7 +54,7 @@ describe 'user encryption' do xml = request.to_diaspora_xml person.destroy personcount = Person.all.count - store_objects_from_xml(xml, @user) + store_from_xml(xml, @user) Person.all.count.should == personcount + 1 new_person = Person.first(:url => "http://test.url/") new_person.id.should == id @@ -113,7 +113,7 @@ describe 'user encryption' do xml = message.to_diaspora_xml message.destroy Post.count.should be 0 - store_objects_from_xml(xml, @user) + store_from_xml(xml, @user) Post.count.should be 0 end From c6a620c7dda059e3cd22c088c23919081d782975 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 15:05:05 -0700 Subject: [PATCH 105/198] RS, DG; store_from_xml is gone, use user.receive --- app/controllers/publics_controller.rb | 2 +- app/models/user.rb | 23 ++++++++++-- lib/diaspora/parser.rb | 19 +--------- spec/lib/diaspora_parser_spec.rb | 18 +++++----- spec/models/user_spec.rb | 51 +++++++++++++++++---------- spec/user_encryption_spec.rb | 4 +-- 6 files changed, 66 insertions(+), 51 deletions(-) diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index eac2540ac..d6182a6eb 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -25,7 +25,7 @@ class PublicsController < ApplicationController def receive @user = Person.first(:id => params[:id]).owner Rails.logger.debug "PublicsController has received: #{params[:xml]}" - store_from_xml params[:xml], @user + @user.receive params[:xml] render :nothing => true end diff --git a/app/models/user.rb b/app/models/user.rb index d40ab77a0..2e82b0904 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -113,12 +113,31 @@ class User end end - def activate_friend (person) + def activate_friend(person) friends << person save end - + ###### Receiving ####### + def receive xml + object = Diaspora::Parser.parse_from_xml(xml) + Rails.logger.debug("Receiving object:\n#{object.inspect}") + + if object.is_a? Retraction + Rails.logger.debug "Got a retraction for #{object.post_id}" + object.perform + + elsif object.is_a? Request + receive_friend_request(object) + + elsif object.is_a? Profile + object.save + + elsif object.respond_to?(:person) && !(object.person.nil?) && !(object.person.is_a? User) + Rails.logger.debug("Saving object with success: #{object.save}") + end + end + ###Helpers############ def self.instantiate( opts = {} ) opts[:person][:email] = opts[:email] diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index 471a4fbed..883859151 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -29,6 +29,7 @@ module Diaspora begin object = body.name.camelize.constantize.from_xml body.to_s + if object.is_a? Retraction elsif object.is_a? Profile person = parse_owner_id_from_xml body @@ -52,23 +53,5 @@ module Diaspora end end - def store_from_xml(xml, user) - object = parse_from_xml(xml) - Rails.logger.debug("Receiving object:\n#{object.inspect}") - - if object.is_a? Retraction - Rails.logger.debug "Got a retraction for #{object.post_id}" - object.perform - - elsif object.is_a? Request - user.receive_friend_request(object) - - elsif object.is_a? Profile - object.save - - elsif object.respond_to?(:person) && !(object.person.nil?) && !(object.person.is_a? User) - Rails.logger.debug("Saving object with success: #{object.save}") - end - end end end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index c4d56fc11..1afd93ead 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -15,7 +15,7 @@ describe Diaspora::Parser do 10.times { message = Factory.build(:status_message, :person => @user) xml = message.to_diaspora_xml - store_from_xml(xml, @user) + @user.receive xml } StatusMessage.count.should == 0 end @@ -28,7 +28,7 @@ describe Diaspora::Parser do \n HEY DUDE\n a@a.com\n a@a.com\n a@a.com\n " - store_from_xml(xml, @user) + @user.receive xml Post.count.should == 0 end @@ -38,7 +38,7 @@ describe Diaspora::Parser do " - store_from_xml(xml, @user) + @user.receive xml Post.count.should == 0 end @@ -73,7 +73,7 @@ describe Diaspora::Parser do request = retraction.to_diaspora_xml StatusMessage.count.should == 1 - store_from_xml( request, @user ) + @user.receive request StatusMessage.count.should == 0 end @@ -85,7 +85,7 @@ describe Diaspora::Parser do @person.destroy Person.all.count.should be 1 - store_from_xml(xml, @user) + @user.receive xml Person.all.count.should be 2 Person.first(:_id => original_person_id).serialized_key.include?("PUBLIC").should be true @@ -102,7 +102,7 @@ describe Diaspora::Parser do Person.all.count.should be 3 - store_from_xml(xml, @user) + @user.receive xml Person.all.count.should be 3 @user2.reload @@ -131,7 +131,7 @@ describe Diaspora::Parser do @person.destroy request_remote.destroy - store_from_xml(xml, @user) + @user.receive xml new_person = Person.first(:url => @person.url) new_person.nil?.should be false @@ -145,7 +145,7 @@ describe Diaspora::Parser do request = retraction.to_diaspora_xml Person.count.should == 2 - store_from_xml( request , @user) + @user.receive request Person.count.should == 1 end @@ -171,7 +171,7 @@ describe Diaspora::Parser do old_profile.first_name.should == 'bob' #Marshal profile - store_from_xml xml, @user + @user.receive xml #Check that marshaled profile is the same as old profile person = Person.first(:id => person.id) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b1ae2df6a..ae9be2083 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -90,7 +90,7 @@ describe User do it 'should befriend the user other user on the same pod' do - store_from_xml @req_three_xml, @user2 + @user2.receive @req_three_xml @user2.pending_requests.size.should be 1 @user2.accept_friend_request @request_three.id @user2.friends.include?(@user.person).should be true @@ -99,7 +99,7 @@ describe User do it 'should not delete the ignored user on the same pod' do - store_from_xml @req_three_xml, @user2 + @user2.receive @req_three_xml @user2.pending_requests.size.should be 1 @user2.ignore_friend_request @request_three.id @user2.friends.include?(@user.person).should be false @@ -108,12 +108,12 @@ describe User do it 'should both users should befriend the same person' do - store_from_xml @req_xml, @user + @user.receive @req_xml @user.pending_requests.size.should be 1 @user.accept_friend_request @request.id @user.friends.include?(@person_one).should be true - store_from_xml @req_two_xml, @user2 + @user2.receive @req_two_xml @user2.pending_requests.size.should be 1 @user2.accept_friend_request @request_two.id @user2.friends.include?(@person_one).should be true @@ -122,12 +122,12 @@ describe User do it 'should keep the person around if one of the users rejects him' do - store_from_xml @req_xml, @user + @user.receive @req_xml @user.pending_requests.size.should be 1 @user.accept_friend_request @request.id @user.friends.include?(@person_one).should be true - store_from_xml @req_two_xml, @user2 + @user2.receive @req_two_xml @user2.pending_requests.size.should be 1 @user2.ignore_friend_request @request_two.id @user2.friends.include?(@person_one).should be false @@ -135,12 +135,12 @@ describe User do end it 'should not keep the person around if the users ignores them' do - store_from_xml @req_xml, @user + @user.receive @req_xml @user.pending_requests.size.should be 1 @user.ignore_friend_request @user.pending_requests.first.id @user.friends.include?(@person_one).should be false - store_from_xml @req_two_xml, @user2 + @user2.receive @req_two_xml @user2.pending_requests.size.should be 1 @user2.ignore_friend_request @user2.pending_requests.first.id#@request_two.id @user2.friends.include?(@person_one).should be false @@ -184,23 +184,14 @@ describe User do @user.friends.include?(@person_two).should be false end +=begin it 'should do accept reject for people not on the pod' do - - @person_one.destroy - @person_two.destroy - end - it 'should do accept reject for people on the pod' do - end - it 'should do accept reject for mixed people on the pod' do - - @person_two.destroy - end - +=end end end @@ -217,4 +208,26 @@ describe User do @user.profile.image_url.should == "http://clown.com" end end + + describe 'receiving' do + before do + @user2 = Factory.create(:user) + @user.friends << @user2.person + @user2.friends << @user.person + @user.person.user_refs += 1 + @user2.person.user_refs += 1 + @user.save + @user2.save + end + + it 'should be able to parse and store a status message from xml' do + status_message = @user2.post :status_message, :message => 'store this!' + xml = status_message.to_diaspora_xml + @user2.destroy + status_message.destroy + StatusMessage.all.size.should == 0 + @user.receive( xml ) + StatusMessage.all.size.should == 1 + end + end end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 39bfbd2cd..437c9124e 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -54,7 +54,7 @@ describe 'user encryption' do xml = request.to_diaspora_xml person.destroy personcount = Person.all.count - store_from_xml(xml, @user) + @user.receive xml Person.all.count.should == personcount + 1 new_person = Person.first(:url => "http://test.url/") new_person.id.should == id @@ -113,7 +113,7 @@ describe 'user encryption' do xml = message.to_diaspora_xml message.destroy Post.count.should be 0 - store_from_xml(xml, @user) + @user.receive xml Post.count.should be 0 end From bee71c5a23eb714eec7bf8bf34148e7f9870903e Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 15:22:06 -0700 Subject: [PATCH 106/198] RS, DG; All saving moved to user --- app/models/user.rb | 10 +++++-- lib/diaspora/parser.rb | 30 ++++----------------- spec/controllers/publics_controller_spec.rb | 1 - spec/models/user_spec.rb | 4 +++ 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 2e82b0904..35acbd2f0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -128,11 +128,17 @@ class User object.perform elsif object.is_a? Request + person = get_or_create_person_object_from_xml( xml ) + person.serialized_key ||= object.exported_key + object.person = person + object.person.save + object.save receive_friend_request(object) elsif object.is_a? Profile - object.save - + person = Diaspora::Parser.parse_owner_id_from_xml xml + person.profile = object + person.save elsif object.respond_to?(:person) && !(object.person.nil?) && !(object.person.is_a? User) Rails.logger.debug("Saving object with success: #{object.save}") end diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index 883859151..a82fd722c 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -1,22 +1,18 @@ module Diaspora module Parser - def parse_owner_from_xml(xml) - doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks } - email = doc.xpath("//person/email").text.to_s - Person.first(:email => email) - end - def parse_body_contents_from_xml(xml) doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks } doc.xpath("/XML/post") end - def parse_owner_id_from_xml(doc) + def parse_owner_id_from_xml(xml) + doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks } id = doc.xpath("//person_id").text.to_s Person.first(:id => id) end - def get_or_create_person_object_from_xml(doc) + def get_or_create_person_object_from_xml(xml) + doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks } person_xml = doc.xpath("//request/person").to_s person_id = doc.xpath("//request/person/_id").text.to_s person = Person.first(:_id => person_id) @@ -28,23 +24,7 @@ module Diaspora return unless body = parse_body_contents_from_xml(xml).children.first begin - object = body.name.camelize.constantize.from_xml body.to_s - - if object.is_a? Retraction - elsif object.is_a? Profile - person = parse_owner_id_from_xml body - person.profile = object - person.save - elsif object.is_a? Request - person = get_or_create_person_object_from_xml(body) - person.serialized_key ||= object.exported_key - object.person = person - object.person.save - object.save - elsif object.respond_to? :person - object.person = parse_owner_from_xml body.to_s - end - object + body.name.camelize.constantize.from_xml body.to_s rescue NameError => e if e.message.include? 'wrong constant name' Rails.logger.info "Not a real type: #{object.to_s}" diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 0181a2cb4..c3455d462 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -41,7 +41,6 @@ describe PublicsController do req.delete @user2.reload - puts @user2.inspect @user2.pending_requests.count.should be 1 end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index ae9be2083..bb54daeb6 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -222,11 +222,15 @@ describe User do it 'should be able to parse and store a status message from xml' do status_message = @user2.post :status_message, :message => 'store this!' + person = @user2.person + xml = status_message.to_diaspora_xml @user2.destroy status_message.destroy StatusMessage.all.size.should == 0 @user.receive( xml ) + + person.posts.first.message.should == 'store this!' StatusMessage.all.size.should == 1 end end From 0907d7a9fdb7a4c6e23c1b9462e262671369541a Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 16:01:16 -0700 Subject: [PATCH 107/198] RS, DG; Cleaned up the switch in user.receive --- app/controllers/publics_controller.rb | 2 +- app/models/user.rb | 8 ++-- lib/diaspora/parser.rb | 14 +++---- spec/lib/diaspora_parser_spec.rb | 58 +++++++++++++-------------- spec/models/user_spec.rb | 2 - 5 files changed, 39 insertions(+), 45 deletions(-) diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index d6182a6eb..e6506c55e 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -25,7 +25,7 @@ class PublicsController < ApplicationController def receive @user = Person.first(:id => params[:id]).owner Rails.logger.debug "PublicsController has received: #{params[:xml]}" - @user.receive params[:xml] + @user.receive params[:xml] if params[:xml] render :nothing => true end diff --git a/app/models/user.rb b/app/models/user.rb index 35acbd2f0..d54422445 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -120,7 +120,7 @@ class User ###### Receiving ####### def receive xml - object = Diaspora::Parser.parse_from_xml(xml) + object = Diaspora::Parser.from_xml(xml) Rails.logger.debug("Receiving object:\n#{object.inspect}") if object.is_a? Retraction @@ -128,7 +128,7 @@ class User object.perform elsif object.is_a? Request - person = get_or_create_person_object_from_xml( xml ) + person = Diaspora::Parser.get_or_create_person_object_from_xml( xml ) person.serialized_key ||= object.exported_key object.person = person object.person.save @@ -136,10 +136,10 @@ class User receive_friend_request(object) elsif object.is_a? Profile - person = Diaspora::Parser.parse_owner_id_from_xml xml + person = Diaspora::Parser.owner_id_from_xml xml person.profile = object person.save - elsif object.respond_to?(:person) && !(object.person.nil?) && !(object.person.is_a? User) + else Rails.logger.debug("Saving object with success: #{object.save}") end end diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index a82fd722c..8835bd83b 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -1,17 +1,12 @@ module Diaspora module Parser - def parse_body_contents_from_xml(xml) - doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks } - doc.xpath("/XML/post") - end - - def parse_owner_id_from_xml(xml) + def self.owner_id_from_xml(xml) doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks } id = doc.xpath("//person_id").text.to_s Person.first(:id => id) end - def get_or_create_person_object_from_xml(xml) + def self.get_or_create_person_object_from_xml(xml) doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks } person_xml = doc.xpath("//request/person").to_s person_id = doc.xpath("//request/person/_id").text.to_s @@ -19,9 +14,10 @@ module Diaspora person ? person : Person.from_xml( person_xml) end - def parse_from_xml(xml) + def self.from_xml(xml) - return unless body = parse_body_contents_from_xml(xml).children.first + doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks } + return unless body = doc.xpath("/XML/post").children.first begin body.name.camelize.constantize.from_xml body.to_s diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 1afd93ead..da96e80d9 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -10,29 +10,35 @@ describe Diaspora::Parser do @user = Factory.create(:user, :email => "bob@aol.com") @person = Factory.create(:person_with_private_key, :email => "bill@gates.com") end + describe 'with encryption' do + before do + unstub_mocha_stubs + end + after do + stub_signature_verification + end + it "should not store posts from me" do + 10.times { + message = Factory.build(:status_message, :person => @user) + xml = message.to_diaspora_xml + @user.receive xml + } + StatusMessage.count.should == 0 + end + + it "should reject xml with no sender" do + xml = " + + + \n Here is another message\n a@a.com\n a@a.com\n a@a.com\n + + \n HEY DUDE\n a@a.com\n a@a.com\n a@a.com\n + " + @user.receive xml + Post.count.should == 0 - it "should not store posts from me" do - 10.times { - message = Factory.build(:status_message, :person => @user) - xml = message.to_diaspora_xml - @user.receive xml - } - StatusMessage.count.should == 0 - end - - it "should reject xml with no sender" do - xml = " - - - \n Here is another message\n a@a.com\n a@a.com\n a@a.com\n - - \n HEY DUDE\n a@a.com\n a@a.com\n a@a.com\n - " - @user.receive xml - Post.count.should == 0 - - end - + end + end it 'should discard types which are not of type post' do xml = " @@ -47,12 +53,6 @@ describe Diaspora::Parser do before do @xml = Factory.build(:status_message).to_diaspora_xml end - - it 'should be able to parse the body\'s contents' do - body = parse_body_contents_from_xml(@xml).to_s - body.should include "" - body.should include "" - end it 'should be able to correctly handle comments' do person = Factory.create(:person, :email => "test@testing.com") @@ -60,7 +60,7 @@ describe Diaspora::Parser do comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!") xml = comment.to_diaspora_xml - comment = parse_from_xml(xml) + comment = Diaspora::Parser.from_xml(xml) comment.text.should == "Freedom!" comment.person.should == person comment.post.should == post diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index bb54daeb6..62cb7dad1 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,7 +1,5 @@ require File.dirname(__FILE__) + '/../spec_helper' -include Diaspora::Parser - describe User do before do @user = Factory.create(:user) From 2d14f647456fd9e03f7e65a186075f0e3e7eb5d6 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 16:10:27 -0700 Subject: [PATCH 108/198] RS, DG; Socketing moved to user --- app/models/comment.rb | 3 --- app/models/post.rb | 2 -- app/models/retraction.rb | 1 + app/models/user.rb | 5 +++-- lib/diaspora/websocket.rb | 13 ------------- 5 files changed, 4 insertions(+), 20 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 8c66ac62a..b62164075 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -19,9 +19,6 @@ class Comment key :person_id, ObjectId belongs_to :person, :class_name => "Person" - after_save :send_to_view - - def ==(other) (self.message == other.message) && (self.person.email == other.person.email) end diff --git a/app/models/post.rb b/app/models/post.rb index 61fe5821a..f41120698 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -21,8 +21,6 @@ class Post timestamps! - after_save :send_to_view - before_destroy :propagate_retraction after_destroy :destroy_comments, :remove_from_view diff --git a/app/models/retraction.rb b/app/models/retraction.rb index dff72b767..5f506e61d 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -25,6 +25,7 @@ class Retraction attr_accessor :type def perform + Rails.logger.debug "Performing retraction for #{object.post_id}" begin return unless signature_valid? Rails.logger.debug("Retracting #{self.type} id: #{self.post_id}") diff --git a/app/models/user.rb b/app/models/user.rb index d54422445..56a939fc7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -124,8 +124,8 @@ class User Rails.logger.debug("Receiving object:\n#{object.inspect}") if object.is_a? Retraction - Rails.logger.debug "Got a retraction for #{object.post_id}" - object.perform + object.post.unsocket_from_uid self.id + object.perform elsif object.is_a? Request person = Diaspora::Parser.get_or_create_person_object_from_xml( xml ) @@ -141,6 +141,7 @@ class User person.save else Rails.logger.debug("Saving object with success: #{object.save}") + object.socket_to_uid id end end diff --git a/lib/diaspora/websocket.rb b/lib/diaspora/websocket.rb index 4ff1fff1a..fcdcc9744 100644 --- a/lib/diaspora/websocket.rb +++ b/lib/diaspora/websocket.rb @@ -39,18 +39,5 @@ module Diaspora SocketsController.new.outgoing(id, Retraction.for(self)) end - def send_to_view - people_with_permissions.each{|f| - socket_to_uid f.owner_id if f.owner_id - } - socket_to_uid person.owner_id if person.owner_id - end - - def remove_from_view - people_with_permissions.each{|f| - unsocket_from_uid f.owner_id if f.owner_id - } - unsocket_from_uid person.owner_id if person.owner_id - end end end From 4b5071ec05173170650da1f59eff46f7e2b76675 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 16:12:55 -0700 Subject: [PATCH 109/198] DG, RS; socketing back in for your own posts --- app/models/person.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/person.rb b/app/models/person.rb index 75e261496..c903e2db4 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -58,6 +58,7 @@ class Person model_class = class_name.to_s.camelize.constantize post = model_class.instantiate(options) post.notify_people + post.socket_to_uid person.owner.id if person.owner_id post end @@ -67,6 +68,7 @@ class Person c = Comment.new(:person_id => self.id, :text => text, :post => options[:on]) if c.save send_comment c + c.socket_to_uid person.owner.id if person.owner_id true else Rails.logger.warn "this failed to save: #{c.inspect}" From d8959326d52e0fef57385d6e9c7579cab2bd255a Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 16:24:05 -0700 Subject: [PATCH 110/198] RS, DG; unsocketing is back in --- app/models/person.rb | 4 ++-- app/models/post.rb | 2 +- app/models/retraction.rb | 8 +++++--- app/models/user.rb | 5 ++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index c903e2db4..9c629ddf7 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -58,7 +58,7 @@ class Person model_class = class_name.to_s.camelize.constantize post = model_class.instantiate(options) post.notify_people - post.socket_to_uid person.owner.id if person.owner_id + post.socket_to_uid owner.id if owner_id post end @@ -68,7 +68,7 @@ class Person c = Comment.new(:person_id => self.id, :text => text, :post => options[:on]) if c.save send_comment c - c.socket_to_uid person.owner.id if person.owner_id + c.socket_to_uid owner.id if owner_id true else Rails.logger.warn "this failed to save: #{c.inspect}" diff --git a/app/models/post.rb b/app/models/post.rb index f41120698..e35b028cd 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -22,7 +22,7 @@ class Post timestamps! before_destroy :propagate_retraction - after_destroy :destroy_comments, :remove_from_view + after_destroy :destroy_comments def self.instantiate params self.create params diff --git a/app/models/retraction.rb b/app/models/retraction.rb index 5f506e61d..a42624bd2 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -24,12 +24,14 @@ class Retraction attr_accessor :person_id attr_accessor :type - def perform - Rails.logger.debug "Performing retraction for #{object.post_id}" + def perform receiving_user_id + Rails.logger.debug "Performing retraction for #{post_id}" begin return unless signature_valid? Rails.logger.debug("Retracting #{self.type} id: #{self.post_id}") - self.type.constantize.destroy(self.post_id) + target = self.type.constantize.first(self.post_id) + target.unsocket_from_uid receiving_user_id if target.respond_to? :unsocket_from_uid + target.destroy rescue NameError Rails.logger.info("Retraction for unknown type recieved.") end diff --git a/app/models/user.rb b/app/models/user.rb index 56a939fc7..730f3099a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -124,8 +124,7 @@ class User Rails.logger.debug("Receiving object:\n#{object.inspect}") if object.is_a? Retraction - object.post.unsocket_from_uid self.id - object.perform + object.perform self.id elsif object.is_a? Request person = Diaspora::Parser.get_or_create_person_object_from_xml( xml ) @@ -141,7 +140,7 @@ class User person.save else Rails.logger.debug("Saving object with success: #{object.save}") - object.socket_to_uid id + object.socket_to_uid( id) if object.respond_to? :socket_to_uid end end From ab25e35a714dd893faa05679dd7904149bd57c63 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 16:31:12 -0700 Subject: [PATCH 111/198] Comment guids now serialize --- app/models/comment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index b62164075..66ce23b55 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -8,7 +8,7 @@ class Comment xml_accessor :text xml_accessor :person, :as => Person xml_accessor :post_id - + xml_accessor :_id key :text, String timestamps! From cf5476f6019e1ddfae31015b9a5dd735ecc46ef2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 16:40:08 -0700 Subject: [PATCH 112/198] RS, DG; stop crashing trying to socket albums --- app/models/person.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/person.rb b/app/models/person.rb index 9c629ddf7..ace5c8e87 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -58,7 +58,7 @@ class Person model_class = class_name.to_s.camelize.constantize post = model_class.instantiate(options) post.notify_people - post.socket_to_uid owner.id if owner_id + post.socket_to_uid owner.id if (owner_id && post.respond_to?( :socket_to_uid)) post end From 3d46a49b970ad9e7d65b3afb08a9c676e1399270 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 16:50:22 -0700 Subject: [PATCH 113/198] RS, DG; fixing Album.mine_or_friends --- app/models/album.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/album.rb b/app/models/album.rb index 302cb3b07..7c5b05884 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -26,9 +26,9 @@ class Album def self.mine_or_friends(friend_param, current_user) if friend_param - Album.where(:person_id.ne => current_user.person.id) + Album.where(:person_id.ne => current_user.person.id.to_s) else - Album.where(:person_id => current_user.person.id) + Album.where(:person_id => current_user.person.id.to_s) end end From 144d673dac89d83a2a717ace32403c418176edef Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 17:16:20 -0700 Subject: [PATCH 114/198] DG, RS; album button looks better --- app/views/albums/index.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 5ff653e37..59db9c376 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -11,8 +11,8 @@ .sub_header %ul.button_set - %li.selected= friends_albums_link - %li= your_albums_link + %li{:class => ("selected" if params[:friends])}= friends_albums_link + %li{:class => ("selected" if not params[:friends])}= your_albums_link %div - for album in @albums From a19e29f2c2089ddb22f618ee024ee5400e872c55 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 17:33:37 -0700 Subject: [PATCH 115/198] RS, DG; Album.mine_or_friends actually fixed --- app/models/album.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/album.rb b/app/models/album.rb index 7c5b05884..03dc5ed1a 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -26,9 +26,9 @@ class Album def self.mine_or_friends(friend_param, current_user) if friend_param - Album.where(:person_id.ne => current_user.person.id.to_s) + Album.where(:person_id => current_user.friend_ids) else - Album.where(:person_id => current_user.person.id.to_s) + current_user.person.albums end end From dd3fb1677b8bcad54a2ac88376a2d356df84748a Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 11 Aug 2010 17:44:43 -0700 Subject: [PATCH 116/198] MS IZ continuiung to squash failing tests --- app/models/retraction.rb | 13 ++++++++++--- app/models/user.rb | 4 +--- spec/lib/diaspora_parser_spec.rb | 9 --------- spec/models/retraction_spec.rb | 2 ++ spec/user_encryption_spec.rb | 31 +++++++++++++++++++++++-------- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/app/models/retraction.rb b/app/models/retraction.rb index a42624bd2..748e1ca1a 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -9,10 +9,11 @@ class Retraction retraction.post_id = object.person.id retraction.type = object.person.class.to_s else - retraction.post_id= object.id + retraction.post_id = object.id retraction.type = object.class.to_s end retraction.person_id = person_id_from(object) + retraction.send(:sign_if_mine) retraction end @@ -27,7 +28,7 @@ class Retraction def perform receiving_user_id Rails.logger.debug "Performing retraction for #{post_id}" begin - return unless signature_valid? + return unless signature_valid?creator_signature Rails.logger.debug("Retracting #{self.type} id: #{self.post_id}") target = self.type.constantize.first(self.post_id) target.unsocket_from_uid receiving_user_id if target.respond_to? :unsocket_from_uid @@ -62,7 +63,13 @@ class Retraction xml_reader :creator_signature def creator_signature - @creator_signature ||= sign if person_id == User.owner.id + object = self.type.constantize.first(:id => post_id) + + if object.class == Person && person_id == object.id + @creator_signature || sign_with_key(object.key) + elsif person_id == object.person.id + @creator_signature || sign_if_mine + end end def creator_signature= input diff --git a/app/models/user.rb b/app/models/user.rb index 730f3099a..9fef4edfb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -125,7 +125,6 @@ class User if object.is_a? Retraction object.perform self.id - elsif object.is_a? Request person = Diaspora::Parser.get_or_create_person_object_from_xml( xml ) person.serialized_key ||= object.exported_key @@ -133,12 +132,11 @@ class User object.person.save object.save receive_friend_request(object) - elsif object.is_a? Profile person = Diaspora::Parser.owner_id_from_xml xml person.profile = object person.save - else + elsif object.verify_creator_signature == true Rails.logger.debug("Saving object with success: #{object.save}") object.socket_to_uid( id) if object.respond_to? :socket_to_uid end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index da96e80d9..d3ab854ed 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -39,15 +39,6 @@ describe Diaspora::Parser do end end - it 'should discard types which are not of type post' do - xml = " - - " - - @user.receive xml - Post.count.should == 0 - end - describe "parsing compliant XML object" do before do diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index da11dbfae..5c8695fea 100644 --- a/spec/models/retraction_spec.rb +++ b/spec/models/retraction_spec.rb @@ -22,4 +22,6 @@ describe Retraction do @post.destroy end end + + end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 437c9124e..92a47d6bc 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -3,12 +3,6 @@ include ApplicationHelper include Diaspora::Parser describe 'user encryption' do - before :all do - #ctx = GPGME::Ctx.new - #keys = ctx.keys - #keys.each{|k| ctx.delete_key(k, true)} - - end before do unstub_mocha_stubs @user = Factory.create(:user) @@ -54,6 +48,7 @@ describe 'user encryption' do xml = request.to_diaspora_xml person.destroy personcount = Person.all.count + puts xml @user.receive xml Person.all.count.should == personcount + 1 new_person = Person.first(:url => "http://test.url/") @@ -68,6 +63,19 @@ describe 'user encryption' do message = @user.post :status_message, :message => "hi" message.verify_creator_signature.should be true end + + it 'should sign a retraction on create' do + + unstub_mocha_stubs + message = @user.post :status_message, :message => "hi" + + + puts "foo" + retraction = Retraction.for(message) + puts retraction.inspect + retraction.verify_creator_signature.should be true + + end it 'should not be able to verify a message from a person without a key' do person = Factory.create(:person, :serialized_key => "lskdfhdlfjnh;klsf") @@ -106,12 +114,19 @@ describe 'user encryption' do xml = message.to_xml.to_s xml.include?(message.creator_signature).should be true end + it 'A message with an invalid signature should be rejected' do - message = Factory.build(:status_message, :person => @person) + @user2 = Factory.create :user + + message = @user2.post :status_message, :message => "hey" message.creator_signature = "totally valid" - message.save + puts message.inspect + message.save(:validate => false) + + puts message.inspect xml = message.to_diaspora_xml message.destroy + puts xml Post.count.should be 0 @user.receive xml Post.count.should be 0 From 283b4a40b5b9b4389d794080dcaf71f063f05fcf Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 11 Aug 2010 17:51:46 -0700 Subject: [PATCH 117/198] IZ MS tests now pass --- app/models/retraction.rb | 2 +- spec/user_encryption_spec.rb | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/models/retraction.rb b/app/models/retraction.rb index 748e1ca1a..c9cf8dd77 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -28,7 +28,7 @@ class Retraction def perform receiving_user_id Rails.logger.debug "Performing retraction for #{post_id}" begin - return unless signature_valid?creator_signature + return unless signature_valid? Rails.logger.debug("Retracting #{self.type} id: #{self.post_id}") target = self.type.constantize.first(self.post_id) target.unsocket_from_uid receiving_user_id if target.respond_to? :unsocket_from_uid diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 92a47d6bc..f03a1edab 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -48,7 +48,6 @@ describe 'user encryption' do xml = request.to_diaspora_xml person.destroy personcount = Person.all.count - puts xml @user.receive xml Person.all.count.should == personcount + 1 new_person = Person.first(:url => "http://test.url/") @@ -70,9 +69,7 @@ describe 'user encryption' do message = @user.post :status_message, :message => "hi" - puts "foo" retraction = Retraction.for(message) - puts retraction.inspect retraction.verify_creator_signature.should be true end @@ -120,13 +117,10 @@ describe 'user encryption' do message = @user2.post :status_message, :message => "hey" message.creator_signature = "totally valid" - puts message.inspect message.save(:validate => false) - puts message.inspect xml = message.to_diaspora_xml message.destroy - puts xml Post.count.should be 0 @user.receive xml Post.count.should be 0 From eb361901881f0bc206ac3f3314438502a022db99 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Aug 2010 18:13:23 -0700 Subject: [PATCH 118/198] DG, RS; Albums create failure prettier --- app/controllers/albums_controller.rb | 3 ++- app/views/albums/new.html.haml | 14 -------------- 2 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 app/views/albums/new.html.haml diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index 2fb5ac47f..fe33376f3 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -12,7 +12,8 @@ class AlbumsController < ApplicationController flash[:notice] = "Successfully created album." redirect_to @album else - render :action => 'new' + flash[:error] = "Successfully failed." + redirect_to albums_path end end diff --git a/app/views/albums/new.html.haml b/app/views/albums/new.html.haml deleted file mode 100644 index 2f4450cd9..000000000 --- a/app/views/albums/new.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -%h1.big_text - =link_to 'albums', albums_path - >> - new album - -= form_for @album do |f| - = f.error_messages - %p - = f.label :name - = f.text_field :name - %p - = f.submit - -%p= link_to "Back to List", albums_path From 3e1081acaa502555e6a27b75cce163ad5fbd3d14 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 11 Aug 2010 20:09:16 -0700 Subject: [PATCH 120/198] commented out tinyMCE js for the time being --- app/views/layouts/application.html.haml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2f8fd4060..c5b1bb74b 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -13,9 +13,8 @@ /= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" = javascript_include_tag 'jquery142', 'rails', 'google' - = javascript_include_tag 'tiny_mce/tiny_mce', 'jquery.infieldlabel', 'jquery.cycle/jquery.cycle.min.js' - - = javascript_include_tag 'fancybox/jquery.fancybox-1.3.1.pack' + /= javascript_include_tag 'tiny_mce/tiny_mce' + = javascript_include_tag 'jquery.infieldlabel', 'jquery.cycle/jquery.cycle.min.js', 'fancybox/jquery.fancybox-1.3.1.pack' = javascript_include_tag 'view', 'publisher', 'image_picker', 'group_nav' = render 'js/websocket_js' From 97b04fc0d79dbb87db7f01522b42df23d2fb6c58 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 11 Aug 2010 20:12:10 -0700 Subject: [PATCH 121/198] nevermind --- app/views/layouts/application.html.haml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index c5b1bb74b..979538d54 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -13,8 +13,10 @@ /= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" = javascript_include_tag 'jquery142', 'rails', 'google' - /= javascript_include_tag 'tiny_mce/tiny_mce' - = javascript_include_tag 'jquery.infieldlabel', 'jquery.cycle/jquery.cycle.min.js', 'fancybox/jquery.fancybox-1.3.1.pack' + = javascript_include_tag 'tiny_mce/tiny_mce' + = javascript_include_tag 'jquery.infieldlabel', 'jquery.cycle/jquery.cycle.min.js' + + = javascript_include_tag 'fancybox/jquery.fancybox-1.3.1.pack' = javascript_include_tag 'view', 'publisher', 'image_picker', 'group_nav' = render 'js/websocket_js' From 352b9f65e0ce346c2483f05b3d40722b9af76f09 Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 11 Aug 2010 20:23:28 -0700 Subject: [PATCH 122/198] MS IZ unfriending maybe works --- app/models/user.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 9fef4edfb..35a68cd7d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -124,7 +124,11 @@ class User Rails.logger.debug("Receiving object:\n#{object.inspect}") if object.is_a? Retraction - object.perform self.id + if object.type == 'Person' + unfriend object.person_id + else + object.perform self.id + end elsif object.is_a? Request person = Diaspora::Parser.get_or_create_person_object_from_xml( xml ) person.serialized_key ||= object.exported_key From 013a6d084915e4de0d6704337d65f14868fefeee Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 11 Aug 2010 20:45:57 -0700 Subject: [PATCH 123/198] add photo is now in a fancy-pancy box --- app/views/albums/show.html.haml | 8 ++++---- app/views/photos/_new_photo.haml | 6 ++---- public/javascripts/view.js | 3 ++- public/stylesheets/application.css | 2 +- public/stylesheets/sass/application.sass | 2 +- public/stylesheets/sass/ui.sass | 1 + 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index e2048daf3..a2cded0c9 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -8,10 +8,10 @@ .right #add_photo_loader = image_tag 'ajax-loader.gif' - #add_photo_button - = link_to 'Add Photos', '#', :class => 'button' - - #add_photo_pane.contextual_pane + = link_to 'Add Photos', '#new_photo_pane', :class => 'button', :id => "add_photo_button" + + .yo{:style => "display:none;"} + #new_photo_pane = render "photos/new_photo", :photo => @photo, :album => @album .sub_header diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index cd83d648d..81366ccd7 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -8,15 +8,13 @@ return confirm("You are about to upload " + total + " photos. Are you sure?"); }, onFinish: function(event, total){ - $("#add_photo_button .button").html( "Add Photos" ); + $("#add_photo_button").html( "Add Photos" ); $("#add_photo_loader").fadeOut(400); - pane_toggler_button("photo") }, onStart: function(event, total){ $("#add_photo_pane").fadeOut(400); - $("#add_photo_button .button").html( "Uploading Photos" ); + $("#add_photo_button").html( "Uploading Photos" ); $("#add_photo_loader").fadeIn(400); - $("#add_photo_button").unbind(); return true; } }); diff --git a/public/javascripts/view.js b/public/javascripts/view.js index e91e6a912..6648c1714 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -86,8 +86,9 @@ $(document).ready(function(){ $("#add_album_button").fancybox(); $("#add_group_button").fancybox(); $("#add_request_button").fancybox(); + $("#add_photo_button").fancybox(); - pane_toggler_button("photo"); + //pane_toggler_button("photo"); $("input[type='submit']").addClass("button"); diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 000432b85..2369cd6d2 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -408,9 +408,9 @@ h1.big_text { width: 100%; } .sub_header { + position: relative; text-align: center; font-style: italic; - margin-top: -5px; margin-bottom: 20px; color: #999999; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 43b118183..6f02b8da7 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -507,12 +507,12 @@ h1.big_text :width 100% .sub_header + :position relative :text :align center :font :style italic :margin - :top -5px :bottom 20px :color #999 diff --git a/public/stylesheets/sass/ui.sass b/public/stylesheets/sass/ui.sass index 5863632b3..ee01e08bc 100644 --- a/public/stylesheets/sass/ui.sass +++ b/public/stylesheets/sass/ui.sass @@ -48,6 +48,7 @@ :border :top 1px solid #ccc + ul.button_set :padding From f7e43ee3d03a7912f4556f869864056bc634fb73 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 12 Aug 2010 00:27:26 -0700 Subject: [PATCH 124/198] photo fancybox indicates progress. unfortunately, it doesn't reset after you close it right now... --- app/views/photos/_new_photo.haml | 22 +++++++++++++++++----- public/stylesheets/application.css | 2 -- public/stylesheets/sass/application.sass | 4 ---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index 81366ccd7..b57731596 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -4,26 +4,38 @@ // WE INSERT ALBUM_ID PARAM HERE url: "/photos?album_id=#{album.id}", sendBoundary: window.FormData || $.browser.mozilla, - onStart: function(event, total) { - return confirm("You are about to upload " + total + " photos. Are you sure?"); + setName: function(text) { + $("#progress_report_name").text(text); }, onFinish: function(event, total){ $("#add_photo_button").html( "Add Photos" ); $("#add_photo_loader").fadeOut(400); + + $("#photo_title_status").text("Done!"); + $("#progress_report").html("Great job!"); }, onStart: function(event, total){ - $("#add_photo_pane").fadeOut(400); $("#add_photo_button").html( "Uploading Photos" ); $("#add_photo_loader").fadeIn(400); + + $("form").fadeOut(0); + $("#progress_report").fadeIn(0); + $("#photo_title_status").text("Uploading..."); return true; } }); }); %h1 - Add photos to - %i= album.name + %span{:id=>"photo_title_status"} + Add photos to + %i= album.name = form_for photo, :html => {:multipart => true} do |f| = f.error_messages = f.hidden_field :album_id, :value => album.id = f.file_field :image, :multiple => 'multiple' + +#progress_report{ :style => "display:none;text-align:center;" } + = image_tag "ajax-loader.gif" + #progress_report_name + #progress_report_status diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 2369cd6d2..7ce7663ea 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -422,8 +422,6 @@ h1.big_text { min-height: 100px; } .image_thumb img { display: none; } - .image_thumb img:hover { - border-bottom: 2px solid #666666; } .image_cycle img { display: none; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 6f02b8da7..841f12a97 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -526,10 +526,6 @@ h1.big_text img :display none - &:hover - :border - :bottom 2px solid #666 - .image_cycle img :display none From 26bebbe393ffa31792de54a0a6673ec18642a0be Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 12 Aug 2010 10:04:56 -0700 Subject: [PATCH 125/198] MS IZ changing it back --- app/models/user.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 35a68cd7d..9fef4edfb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -124,11 +124,7 @@ class User Rails.logger.debug("Receiving object:\n#{object.inspect}") if object.is_a? Retraction - if object.type == 'Person' - unfriend object.person_id - else - object.perform self.id - end + object.perform self.id elsif object.is_a? Request person = Diaspora::Parser.get_or_create_person_object_from_xml( xml ) person.serialized_key ||= object.exported_key From 3d12e9ab51e356e6b4b33f2f9e6adb1a99cd9abc Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 12 Aug 2010 21:30:16 -0700 Subject: [PATCH 126/198] DG RS; friending through groups --- app/controllers/requests_controller.rb | 2 +- app/models/group.rb | 3 ++ app/models/request.rb | 14 +++++- app/models/user.rb | 51 ++++++++++++++------- spec/controllers/publics_controller_spec.rb | 16 ++----- spec/lib/diaspora_parser_spec.rb | 20 +++----- spec/models/user_spec.rb | 38 ++++++++------- 7 files changed, 82 insertions(+), 62 deletions(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 38714034f..9e1fb5cf8 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -27,7 +27,7 @@ class RequestsController < ApplicationController def create rel_hash = relationship_flow(params[:request][:destination_url]) Rails.logger.debug("Sending request: #{rel_hash}") - @request = current_user.send_request(rel_hash) + @request = current_user.send_request(rel_hash, params[:request][:group]) if @request flash[:notice] = "a friend request was sent to #{@request.destination_url}" diff --git a/app/models/group.rb b/app/models/group.rb index 5c228448d..0f40d6d9b 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -4,8 +4,11 @@ class Group key :name, String key :person_ids, Array + key :request_ids, Array many :people, :in => :person_ids, :class_name => 'Person' + many :requests, :in => :request_ids, :class_name => 'Request' + belongs_to :user, :class_name => 'User' timestamps! diff --git a/app/models/request.rb b/app/models/request.rb index 31dcd162e..f1aae6ea8 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -15,6 +15,7 @@ class Request key :callback_url, String key :person_id, ObjectId key :exported_key, String + key :group_id, ObjectId belongs_to :person @@ -30,10 +31,19 @@ class Request def self.instantiate(options = {}) person = options[:from] - self.new(:destination_url => options[:to], :callback_url => person.receive_url, :person => person, :exported_key => person.export_key) + self.new(:destination_url => options[:to], + :callback_url => person.receive_url, + :person => person, + :exported_key => person.export_key, + :group_id => options[:into]) end - + def reverse accepting_user + self.person = accepting_user.person + self.exported_key = accepting_user.export_key + self.destination_url = self.callback_url + save + end def set_pending_friend diff --git a/app/models/user.rb b/app/models/user.rb index 9fef4edfb..6eaeacc4d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -38,30 +38,39 @@ class User end ######### Friend Requesting ########### - def send_friend_request_to(friend_url) - + def send_friend_request_to(friend_url, group_id) unless self.friends.detect{ |x| x.receive_url == friend_url} - p = Request.instantiate(:to => friend_url, :from => self.person) - if p.save - self.pending_requests << p + request = Request.instantiate(:to => friend_url, :from => self.person, :into => group_id) + if request.save + self.pending_requests << request self.save - p.push_to_url friend_url + + group = self.groups.first(:id => group_id) + + group.requests << request + group.save + + request.push_to_url friend_url end - p + request end end - def accept_friend_request(friend_request_id) + def accept_friend_request(friend_request_id, group_id) request = Request.where(:id => friend_request_id).first n = pending_requests.delete(request) friends << request.person save - request.person = self.person - request.exported_key = self.export_key - request.destination_url = request.callback_url + group = self.groups.first(:id => group_id) + group.people << request.person + group.save + + request.reverse self + request.push_to_url(request.callback_url) + request.destroy end @@ -77,8 +86,9 @@ class User def receive_friend_request(friend_request) Rails.logger.debug("receiving friend request #{friend_request.to_json}") - if pending_requests.detect{|req| (req.callback_url == person.receive_url) && (req.destination_url == person.receive_url)} - activate_friend friend_request.person + if request_from_me?(friend_request) + activate_friend(friend_request.person, friend_request.group_id) + Rails.logger.debug("#{self.real_name}'s friend request has been accepted") friend_request.destroy else @@ -105,17 +115,22 @@ class User end end - def send_request(rel_hash) + def send_request(rel_hash, group) if rel_hash[:friend] - self.send_friend_request_to(rel_hash[:friend]) + self.send_friend_request_to(rel_hash[:friend], group) else raise "you can't do anything to that url" end end - def activate_friend(person) + def activate_friend(person, group) + group.people << person friends << person - save + group.save + end + + def request_from_me?(request) + pending_requests.detect{|req| (req.callback_url == person.receive_url) && (req.destination_url == person.receive_url)} end ###### Receiving ####### @@ -126,6 +141,8 @@ class User if object.is_a? Retraction object.perform self.id elsif object.is_a? Request + puts object.inspect + old_request = person = Diaspora::Parser.get_or_create_person_object_from_xml( xml ) person.serialized_key ||= object.exported_key object.person = person diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index c3455d462..8ef2a30c8 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -30,13 +30,13 @@ describe PublicsController do before do @user2 = Factory.create(:user) @user2.person.save + group = @user2.group(:name => 'disciples') @user3 = Factory.create(:user) @user3.person.save - - req = @user2.send_friend_request_to(@user.person.url) - #req = Request.instantiate(:from => @user2.person, :to => @user.person.url) + req = @user2.send_friend_request_to(@user.person.url, group.id) + @xml = req.to_diaspora_xml req.delete @@ -44,25 +44,19 @@ describe PublicsController do @user2.pending_requests.count.should be 1 end - it 'should add the pending request to the right user, person exists locally' do + it 'should add the pending request to the right user if the target person exists locally' do @user2.delete post :receive, :id => @user.person.id, :xml => @xml assigns(:user).should eq(@user) - - end - it 'should add the pending request to the right user, person does not exist locally' do + it 'should add the pending request to the right user if the target person does not exist locally' do @user2.person.delete @user2.delete post :receive, :id => @user.person.id, :xml => @xml - assigns(:user).should eq(@user) - end - - end end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index d3ab854ed..ec6aa9966 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -8,6 +8,7 @@ include Diaspora::Parser describe Diaspora::Parser do before do @user = Factory.create(:user, :email => "bob@aol.com") + @group = @user.group(:name => 'spies') @person = Factory.create(:person_with_private_key, :email => "bill@gates.com") end describe 'with encryption' do @@ -105,23 +106,14 @@ describe Diaspora::Parser do end it "should activate the Person if I initiated a request to that url" do - request = Request.instantiate(:to => @person.receive_url, :from => @user) - request.save - @user.pending_requests << request - @user.save - + request = @user.send_friend_request_to( @person.receive_url, @group.id) - request_remote = Request.new - request_remote.id = request.id - request_remote.destination_url = @user.receive_url - request_remote.callback_url = @user.receive_url - request_remote.person = @person - request_remote.exported_key = @person.export_key + request.reverse @user + + xml = request.to_diaspora_xml - xml = request_remote.to_diaspora_xml - @person.destroy - request_remote.destroy + @user.receive xml new_person = Person.first(:url => @person.url) new_person.nil?.should be false diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 62cb7dad1..1c75dc188 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper' describe User do before do @user = Factory.create(:user) + @group = @user.group(:name => 'heroes') end it 'should instantiate with a person and be valid' do @@ -20,13 +21,25 @@ describe User do end describe 'friend requesting' do + it "should assign a request to a group" do + friend = Factory.create(:person) + group = @user.group(:name => "Dudes") + group.requests.size.should == 0 + + @user.send_friend_request_to(friend.receive_url, group.id) + + group.reload + group.requests.size.should == 1 + end + + it "should be able to accept a pending friend request" do friend = Factory.create(:person) r = Request.instantiate(:to => @user.receive_url, :from => friend) r.save Person.all.count.should == 2 Request.for_user(@user).all.count.should == 1 - @user.accept_friend_request(r.id) + @user.accept_friend_request(r.id, @group.id) Request.for_user(@user).all.count.should == 0 end @@ -50,7 +63,7 @@ describe User do @user.save - @user.send_friend_request_to( friend.receive_url ).should be nil + @user.send_friend_request_to( friend.receive_url, @group.id ).should be nil end it 'should be able to give me the terse url for webfinger' do @@ -65,6 +78,7 @@ describe User do @person_one.save @user2 = Factory.create :user + @group2 = @user2.group(:name => "group two") @user.pending_requests.empty?.should be true @user.friends.empty?.should be true @@ -74,13 +88,11 @@ describe User do @request = Request.instantiate(:to => @user.receive_url, :from => @person_one) @request_two = Request.instantiate(:to => @user2.receive_url, :from => @person_one) @request_three = Request.instantiate(:to => @user2.receive_url, :from => @user.person) - @req_xml = @request.to_diaspora_xml @req_two_xml = @request_two.to_diaspora_xml @req_three_xml = @request_three.to_diaspora_xml - @request.destroy @request_two.destroy @request_three.destroy @@ -90,7 +102,7 @@ describe User do @user2.receive @req_three_xml @user2.pending_requests.size.should be 1 - @user2.accept_friend_request @request_three.id + @user2.accept_friend_request @request_three.id, @group2.id @user2.friends.include?(@user.person).should be true Person.all.count.should be 3 end @@ -108,12 +120,12 @@ describe User do @user.receive @req_xml @user.pending_requests.size.should be 1 - @user.accept_friend_request @request.id + @user.accept_friend_request @request.id, @group.id @user.friends.include?(@person_one).should be true @user2.receive @req_two_xml @user2.pending_requests.size.should be 1 - @user2.accept_friend_request @request_two.id + @user2.accept_friend_request @request_two.id, @group2.id @user2.friends.include?(@person_one).should be true Person.all.count.should be 3 end @@ -122,7 +134,7 @@ describe User do @user.receive @req_xml @user.pending_requests.size.should be 1 - @user.accept_friend_request @request.id + @user.accept_friend_request @request.id, @group.id @user.friends.include?(@person_one).should be true @user2.receive @req_two_xml @@ -171,7 +183,7 @@ describe User do @user.pending_requests.size.should be 2 @user.friends.size.should be 0 - @user.accept_friend_request @request.id + @user.accept_friend_request @request.id, @group.id @user.pending_requests.size.should be 1 @user.friends.size.should be 1 @user.friends.include?(@person_one).should be true @@ -182,14 +194,6 @@ describe User do @user.friends.include?(@person_two).should be false end -=begin - it 'should do accept reject for people not on the pod' do - end - it 'should do accept reject for people on the pod' do - end - it 'should do accept reject for mixed people on the pod' do - end -=end end end From 64c7a87aeb3bb79dee258f611bf549274ac39e30 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 13 Aug 2010 08:57:22 -0700 Subject: [PATCH 127/198] removed two bogus lines from user.receive --- app/models/user.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 6eaeacc4d..d1fdd59f3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -141,8 +141,6 @@ class User if object.is_a? Retraction object.perform self.id elsif object.is_a? Request - puts object.inspect - old_request = person = Diaspora::Parser.get_or_create_person_object_from_xml( xml ) person.serialized_key ||= object.exported_key object.person = person From 5e33de7e5605555435ff130bec3eacb0b03770af Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 09:47:08 -0700 Subject: [PATCH 128/198] unfriended method in the user --- app/models/person.rb | 7 ++-- app/models/user.rb | 17 ++++++--- spec/helpers/application_helper_spec.rb | 6 ++++ spec/models/user_spec.rb | 46 ++++++++++++++++++++++--- 4 files changed, 66 insertions(+), 10 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index ace5c8e87..d703c0479 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -15,7 +15,7 @@ class Person key :owner_id, ObjectId - key :user_refs, Integer, :default => 0 + key :user_refs, Integer, :default => 0 belongs_to :owner, :class_name => 'User' one :profile, :class_name => 'Profile' @@ -27,7 +27,7 @@ class Person timestamps! before_validation :clean_url - + before_create :check_for_owner validates_presence_of :email, :url, :profile, :serialized_key validates_format_of :url, :with => /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix @@ -124,6 +124,9 @@ class Person private + def check_for_owner + self.user_refs += 1 unless self.owner_id.nil? + end def remove_all_traces self.posts.delete_all end diff --git a/app/models/user.rb b/app/models/user.rb index 9fef4edfb..5f341e9da 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -82,7 +82,6 @@ class User Rails.logger.debug("#{self.real_name}'s friend request has been accepted") friend_request.destroy else - friend_request.person.user_refs += 1 friend_request.person.save pending_requests << friend_request @@ -94,15 +93,25 @@ class User def unfriend(friend_id) bad_friend = Person.first(:_id => friend_id) - self.friend_ids.delete( friend_id ) - self.save if bad_friend Retraction.for(self).push_to_url(bad_friend.receive_url) - bad_friend.update_attributes(:user_refs => bad_friend.user_refs - 1) + bad_friend.user_refs -= 1 + (bad_friend.user_refs > 0 || bad_friend.owner.nil? == false) ? bad_friend.save : bad_friend.destroy end + self.save + end + + def unfriended_by friend_id + bad_friend = Person.first(:_id => friend_id) + + self.friend_ids.delete( friend_id ) + bad_friend.user_refs -= 1 + + (bad_friend.user_refs > 0 || bad_friend.owner.nil? == false) ? bad_friend.save : bad_friend.destroy + self.save end def send_request(rel_hash) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index d03987740..639eb254a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -15,4 +15,10 @@ describe ApplicationHelper do it "should provide a correct show path for a given user" do person_url(@user).should == "/users/#{@user.id}" end + + it 'should be able to give me the terse url for webfinger' do + @user.person.url = "http://example.com/" + + terse_url( @user.person.url ).should == 'example.com' + end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 62cb7dad1..e6b22016e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -53,11 +53,7 @@ describe User do @user.send_friend_request_to( friend.receive_url ).should be nil end - it 'should be able to give me the terse url for webfinger' do - @user.person.url = "http://example.com/" - @user.terse_url.should == 'example.com' - end describe 'multiple users accepting/rejecting the same person' do before do @@ -232,4 +228,46 @@ describe User do StatusMessage.all.size.should == 1 end end + + describe 'unfriending' do + before do + @user = Factory.create :user + @user2 = Factory.create :user + + @user.friends << @user2.person + @user.person.user_refs += 1 + @user2.friends << @user.person + + @user2.person.user_refs += 1 + + @user2.person.save + @user.person.save + end + + it 'should unfriend the other user on the same seed' do + person = @user2.person + person.url = @user.person.url + person.save + + @user.friends.count.should == 1 + @user2.friends.count.should == 1 + + @user.person.user_refs.should == 2 + + @user2.person.user_refs.should == 2 + + @user2.unfriend @user.person.id + @user2.friends.count.should be 0 + + @user.person.reload + @user.person.user_refs.should == 1 + + @user.unfriended_by @user2.person.id + + @user2.person.reload + @user2.person.user_refs.should == 1 + end + + + end end From af6c70db47bdc04064e5d0d4b5d204387e6fce2b Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 09:56:18 -0700 Subject: [PATCH 129/198] RS, IZ; hack to test requests, accepted friends go into the first group. --- app/controllers/requests_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 9e1fb5cf8..4caff37f4 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -8,7 +8,7 @@ class RequestsController < ApplicationController def destroy if params[:accept] - @friend = current_user.accept_friend_request params[:id] + @friend = current_user.accept_friend_request( params[:id], current_user.groups.first.id) flash[:notice] = "you are now friends" redirect_to root_url From 23fc799b4decb3811d3b0b861c45eb7984655d28 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 10:04:33 -0700 Subject: [PATCH 130/198] Turning up logging on friend request receive --- app/models/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index dd16118b8..12bc2c249 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -89,14 +89,14 @@ class User if request_from_me?(friend_request) activate_friend(friend_request.person, friend_request.group_id) - Rails.logger.debug("#{self.real_name}'s friend request has been accepted") + Rails.logger.info("#{self.real_name}'s friend request has been accepted") friend_request.destroy else friend_request.person.user_refs += 1 friend_request.person.save pending_requests << friend_request save - Rails.logger.debug("#{self.real_name} has received a friend request") + Rails.logger.info("#{self.real_name} has received a friend request") friend_request.save end end From 1fcb033b685a6d15735cd708c9b0b19738a549ae Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 10:55:18 -0700 Subject: [PATCH 131/198] RS, IZ; receiving a request no longer overwrites the group it is destined for, specs pass --- app/models/request.rb | 1 - app/models/user.rb | 8 +++++-- spec/helpers/application_helper_spec.rb | 5 ----- spec/helpers/publics_helper_spec.rb | 15 +++++++++++++ spec/lib/diaspora_parser_spec.rb | 28 +++++++++++++++---------- spec/models/request_spec.rb | 27 ++++++++++++------------ spec/user_encryption_spec.rb | 4 ++-- 7 files changed, 54 insertions(+), 34 deletions(-) create mode 100644 spec/helpers/publics_helper_spec.rb diff --git a/app/models/request.rb b/app/models/request.rb index f1aae6ea8..99625ad13 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -44,7 +44,6 @@ class Request self.destination_url = self.callback_url save end - def set_pending_friend p = Person.first(:id => self.person.id) diff --git a/app/models/user.rb b/app/models/user.rb index 12bc2c249..0067d6da8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -85,9 +85,10 @@ class User end def receive_friend_request(friend_request) - Rails.logger.debug("receiving friend request #{friend_request.to_json}") + Rails.logger.info("receiving friend request #{friend_request.to_json}") if request_from_me?(friend_request) - activate_friend(friend_request.person, friend_request.group_id) + group = self.groups.first(:id => friend_request.group_id) + activate_friend(friend_request.person, group) Rails.logger.info("#{self.real_name}'s friend request has been accepted") friend_request.destroy @@ -136,6 +137,7 @@ class User group.people << person friends << person group.save + save end def request_from_me?(request) @@ -154,6 +156,8 @@ class User person.serialized_key ||= object.exported_key object.person = person object.person.save + old_request = Request.first(:id => object.id) + object.group_id = old_request.group_id if old_request object.save receive_friend_request(object) elsif object.is_a? Profile diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 639eb254a..bb886bd83 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -15,10 +15,5 @@ describe ApplicationHelper do it "should provide a correct show path for a given user" do person_url(@user).should == "/users/#{@user.id}" end - - it 'should be able to give me the terse url for webfinger' do - @user.person.url = "http://example.com/" - terse_url( @user.person.url ).should == 'example.com' - end end diff --git a/spec/helpers/publics_helper_spec.rb b/spec/helpers/publics_helper_spec.rb new file mode 100644 index 000000000..bdc9c8250 --- /dev/null +++ b/spec/helpers/publics_helper_spec.rb @@ -0,0 +1,15 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +include PublicsHelper +describe PublicsHelper do + before do + @user = Factory.create(:user) + @person = Factory.create(:person) + end + + it 'should be able to give me the terse url for webfinger' do + @user.person.url = "http://example.com/" + + terse_url( @user.person.url ).should == 'example.com' + end +end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index ec6aa9966..d63acc578 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -10,6 +10,7 @@ describe Diaspora::Parser do @user = Factory.create(:user, :email => "bob@aol.com") @group = @user.group(:name => 'spies') @person = Factory.create(:person_with_private_key, :email => "bill@gates.com") + @user2 = Factory.create(:user) end describe 'with encryption' do before do @@ -70,15 +71,16 @@ describe Diaspora::Parser do end it "should create a new person upon getting a person request" do + person_count = Person.all.count request = Request.instantiate(:to =>"http://www.google.com/", :from => @person) original_person_id = @person.id xml = request.to_diaspora_xml @person.destroy - Person.all.count.should be 1 + Person.all.count.should == person_count -1 @user.receive xml - Person.all.count.should be 2 + Person.all.count.should == person_count Person.first(:_id => original_person_id).serialized_key.include?("PUBLIC").should be true url = "http://" + request.callback_url.split("/")[2] + "/" @@ -86,16 +88,16 @@ describe Diaspora::Parser do end it "should not create a new person if the person is already here" do - @user2 = Factory.create(:user) + person_count = Person.all.count request = Request.instantiate(:to =>"http://www.google.com/", :from => @user2.person) original_person_id = @user2.person.id xml = request.to_diaspora_xml - Person.all.count.should be 3 + Person.all.count.should be person_count @user.receive xml - Person.all.count.should be 3 + Person.all.count.should be person_count @user2.reload @user2.person.reload @@ -106,30 +108,34 @@ describe Diaspora::Parser do end it "should activate the Person if I initiated a request to that url" do - request = @user.send_friend_request_to( @person.receive_url, @group.id) + request = @user.send_friend_request_to( @user2.receive_url, @group.id) - request.reverse @user + request.reverse @user2 xml = request.to_diaspora_xml - @person.destroy + @user2.person.destroy + @user2.destroy @user.receive xml - new_person = Person.first(:url => @person.url) + new_person = Person.first(:url => @user2.person.url) new_person.nil?.should be false @user.reload + @group.reload + @group.people.include?(new_person).should be true @user.friends.include?(new_person).should be true end it 'should process retraction for a person' do + person_count = Person.all.count retraction = Retraction.for(@user) request = retraction.to_diaspora_xml - Person.count.should == 2 + Person.count.should == person_count @user.receive request - Person.count.should == 1 + Person.count.should == person_count-1 end it 'should marshal a profile for a person' do diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index f3fd9c4a5..c5b49cc64 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -1,7 +1,10 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Request do - + before do + @user = Factory.create(:user) + @group = @user.group(:name => "dudes") + end it 'should require a destination and callback url' do person_request = Request.new person_request.valid?.should be false @@ -11,28 +14,26 @@ describe Request do end it 'should generate xml for the User as a Person' do - user = Factory.create(:user) - request = user.send_friend_request_to "http://www.google.com/" + request = @user.send_friend_request_to "http://www.google.com/", @group.id xml = request.to_xml.to_s - xml.include?(user.person.email).should be true - xml.include?(user.url).should be true - xml.include?(user.profile.first_name).should be true - xml.include?(user.profile.last_name).should be true + xml.include?(@user.person.email).should be true + xml.include?(@user.url).should be true + xml.include?(@user.profile.first_name).should be true + xml.include?(@user.profile.last_name).should be true end it 'should allow me to see only friend requests sent to me' do - user = Factory.create(:user) remote_person = Factory.build(:person, :email => "robert@grimm.com", :url => "http://king.com/") - Request.instantiate(:from => user.person, :to => remote_person.receive_url).save - Request.instantiate(:from => user.person, :to => remote_person.receive_url).save - Request.instantiate(:from => user.person, :to => remote_person.receive_url).save - Request.instantiate(:from => remote_person, :to => user.receive_url).save + Request.instantiate(:into => @group.id, :from => @user.person, :to => remote_person.receive_url).save + Request.instantiate(:into => @group.id, :from => @user.person, :to => remote_person.receive_url).save + Request.instantiate(:into => @group.id, :from => @user.person, :to => remote_person.receive_url).save + Request.instantiate(:into => @group.id, :from => remote_person, :to => @user.receive_url).save - Request.for_user(user).all.count.should == 1 + Request.for_user(@user).all.count.should == 1 end end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index f03a1edab..fde3cf5a8 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -6,7 +6,7 @@ describe 'user encryption' do before do unstub_mocha_stubs @user = Factory.create(:user) - @user.save + @group = @user.group(:name => 'dudes') @person = Factory.create(:person_with_private_key, :profile => Profile.new(:first_name => 'Remote', :last_name => 'Friend'), @@ -32,7 +32,7 @@ describe 'user encryption' do describe 'key exchange on friending' do it 'should send over a public key' do message_queue.stub!(:add_post_request) - request = @user.send_friend_request_to("http://example.com/") + request = @user.send_friend_request_to("http://example.com/", @group.id) request.to_diaspora_xml.include?( @user.export_key).should be true end From 7bd1193c5e15f4eec9c1da014debdfe09fc9dc5e Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 11:19:20 -0700 Subject: [PATCH 132/198] RS, IZ; wrote and tested user retractions actually removing people from the friend lists on retractions --- app/models/user.rb | 2 +- spec/lib/diaspora_parser_spec.rb | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 0067d6da8..56a0a584e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -150,7 +150,7 @@ class User Rails.logger.debug("Receiving object:\n#{object.inspect}") if object.is_a? Retraction - object.perform self.id + (object.type == 'Person' )? (unfriended_by object.post_id) : (object.perform self.id) elsif object.is_a? Request person = Diaspora::Parser.get_or_create_person_object_from_xml( xml ) person.serialized_key ||= object.exported_key diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index d63acc578..07de46d02 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -130,12 +130,28 @@ describe Diaspora::Parser do it 'should process retraction for a person' do person_count = Person.all.count - retraction = Retraction.for(@user) - request = retraction.to_diaspora_xml + request = @user.send_friend_request_to( @user2.receive_url, @group.id) + request.reverse @user2 + xml = request.to_diaspora_xml + + retraction = Retraction.for(@user2) + retraction_xml = retraction.to_diaspora_xml + + @user2.person.destroy + @user2.destroy + @user.receive xml + + @group.reload + group_people_count = @group.people.size + #They are now friends + Person.count.should == person_count - @user.receive request + @user.receive retraction_xml Person.count.should == person_count-1 + + @group.reload + @group.people.size.should == group_people_count -1 end it 'should marshal a profile for a person' do From ef97b4f19d491c31879a53d5aa6ee5c2234de1e4 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 11:36:59 -0700 Subject: [PATCH 133/198] RS, IZ; updated DB seed to have a group, zombiefriend with a group --- app/controllers/dev_utilities_controller.rb | 4 ++-- db/seeds/backer.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index 7a1021b09..3733eabc5 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -28,7 +28,7 @@ def warzombie if current_user.email == "tom@tom.joindiaspora.com" && current_user.friends.first.nil? bkr_info.each do |backer| logger.debug "Zombefriending #{backer['given_name']} #{backer['family_name']}" - current_user.send_friend_request_to("http://#{backer['username']}.joindiaspora.com/") + current_user.send_friend_request_to("http://#{backer['username']}.joindiaspora.com/", current_user.groups.first.id) end end end @@ -36,7 +36,7 @@ def warzombie def zombiefriendaccept render :nothing => true Request.all.each{|r| - current_user.accept_friend_request(r.id) + current_user.accept_friend_request(r.id, current_user.groups.first.id) } end diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 3aa28e29d..36067bbac 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -23,5 +23,6 @@ def create(backer_number) :url=> "http://#{username}.joindiaspora.com/") ) user.person.save + user.group(:name => "Presidents") end From 085dd61607bc6eae370cd851c08e8823829875d8 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 11:43:30 -0700 Subject: [PATCH 134/198] RS, IZ; changed zombiefriends to use webfinger --- app/controllers/dev_utilities_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index 3733eabc5..8f0af7a97 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -28,7 +28,7 @@ def warzombie if current_user.email == "tom@tom.joindiaspora.com" && current_user.friends.first.nil? bkr_info.each do |backer| logger.debug "Zombefriending #{backer['given_name']} #{backer['family_name']}" - current_user.send_friend_request_to("http://#{backer['username']}.joindiaspora.com/", current_user.groups.first.id) + current_user.send_friend_request_to("#{backer['username']}@#{backer['username']}.joindiaspora.com", current_user.groups.first.id) end end end From 339f1a65e2bd6c9babc7a2bcb462dd80c5549314 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 11:50:43 -0700 Subject: [PATCH 135/198] Removing friends check on zombiefriends --- app/controllers/dev_utilities_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index 8f0af7a97..c804ed329 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -25,9 +25,9 @@ def warzombie render :nothing => true bkr_info = backer_info - if current_user.email == "tom@tom.joindiaspora.com" && current_user.friends.first.nil? + if current_user.email == "tom@tom.joindiaspora.com" bkr_info.each do |backer| - logger.debug "Zombefriending #{backer['given_name']} #{backer['family_name']}" + logger.info "Zombefriending #{backer['given_name']} #{backer['family_name']}" current_user.send_friend_request_to("#{backer['username']}@#{backer['username']}.joindiaspora.com", current_user.groups.first.id) end end From 99eec0426587657f8e9bea1f6e83cb9f0af7c13e Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 11:59:54 -0700 Subject: [PATCH 136/198] Using webfinger in dev_utilities --- app/controllers/dev_utilities_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index c804ed329..5ff7ef1c7 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -27,8 +27,10 @@ def warzombie if current_user.email == "tom@tom.joindiaspora.com" bkr_info.each do |backer| + backer_email = "#{backer['username']}@#{backer['username']}.joindiaspora.com" + rel_hash = relationship_flow(backer_email) logger.info "Zombefriending #{backer['given_name']} #{backer['family_name']}" - current_user.send_friend_request_to("#{backer['username']}@#{backer['username']}.joindiaspora.com", current_user.groups.first.id) + current_user.send_request(rel_hash, current_user.groups.first.id) end end end From 0b23b959b469776c9029185b8583d30bd211ed44 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 12:06:29 -0700 Subject: [PATCH 137/198] Adding parser methods to devutilities, these should probably be in controller helpers --- app/controllers/dev_utilities_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index 5ff7ef1c7..d1e0b7ddf 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -1,4 +1,6 @@ class DevUtilitiesController < ApplicationController + require 'lib/diaspora/parser' + include Diaspora::Parser before_filter :authenticate_user! include ApplicationHelper def warzombie From 5c9a96d245f9a6166b5345fbefb20a47218b4778 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 12:11:10 -0700 Subject: [PATCH 138/198] That last commit was dumb, including the right module --- app/controllers/dev_utilities_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index d1e0b7ddf..28bd361b4 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -1,8 +1,7 @@ class DevUtilitiesController < ApplicationController - require 'lib/diaspora/parser' - include Diaspora::Parser before_filter :authenticate_user! include ApplicationHelper + include RequestsHelper def warzombie render :nothing => true if current_user.email == "tom@tom.joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil From 23c57c653fb17f3ea57a0031f4cd98ee0808e9a8 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 12:34:24 -0700 Subject: [PATCH 140/198] RS, IZ; Trying to speed up cap db reset --- app/controllers/dev_utilities_controller.rb | 7 +++++++ db/seeds/backer.rb | 4 ++-- lib/tasks/db.rake | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index 28bd361b4..c55f0a49c 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -48,4 +48,11 @@ def warzombie config['servers']['backer'] end + def set_backer_seed_number + render :nothing => true + seed_num_hash = {:seed_number => params[:number]} + file = File.new(Rails.root.join('config','backer_number.yml'),'w') + file.write(seed_num_hash.to_yaml) + + end end diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 36067bbac..b9d0a1689 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -8,11 +8,11 @@ require 'config/environment' -def create(backer_number) +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'] # Create seed user username = backer_info[backer_number]['username'].gsub(/ /,'').downcase user = User.create( :email => "#{username}@#{username}.joindiaspora.com", diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 2563372e1..9b78b6855 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -11,10 +11,10 @@ namespace :db do require 'db/seeds/dev' end - task :backer, :num do |t, args| + task :backer do puts "Seeding the database for #{Rails.env}..." require 'db/seeds/backer' - create( Integer(args.num)) + create end end From 7e377fc292f4e645b559f28b50fd8380baaac82f Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 12:37:49 -0700 Subject: [PATCH 141/198] RS, IZ; adding set backer number to routes, not authenticating it --- app/controllers/dev_utilities_controller.rb | 4 ++-- config/routes.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index c55f0a49c..c7bae62bd 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -1,5 +1,5 @@ class DevUtilitiesController < ApplicationController - before_filter :authenticate_user! + before_filter :authenticate_user!, :except => [:set_backer_number] include ApplicationHelper include RequestsHelper def warzombie @@ -48,7 +48,7 @@ def warzombie config['servers']['backer'] end - def set_backer_seed_number + def set_backer_number render :nothing => true seed_num_hash = {:seed_number => params[:number]} file = File.new(Rails.root.join('config','backer_number.yml'),'w') diff --git a/config/routes.rb b/config/routes.rb index 8a2a972ee..88c838d77 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,6 +15,7 @@ Diaspora::Application.routes.draw do |map| match 'warzombie', :to => "dev_utilities#warzombie" match 'zombiefriends', :to => "dev_utilities#zombiefriends" match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept" + match 'set_backer_number', :to => "dev_utilities#set_backer_number" #routes for devise, not really sure you will need to mess with this in the future, lets put default, #non mutable stuff in anohter file From c1d2f271d941d3d873f10f0cc0aa32cf01b80ef2 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 12:43:27 -0700 Subject: [PATCH 142/198] RS, IZ; close the file after writing the backer number --- app/controllers/dev_utilities_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index c7bae62bd..0295e4114 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -53,6 +53,6 @@ def warzombie seed_num_hash = {:seed_number => params[:number]} file = File.new(Rails.root.join('config','backer_number.yml'),'w') file.write(seed_num_hash.to_yaml) - + file.close end end From d32a06c3cba081d1c8bb72e59834c2834971b78e Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 12:47:19 -0700 Subject: [PATCH 143/198] look at the right yaml key --- 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 b9d0a1689..bc5039aa1 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -12,7 +12,7 @@ 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'] + backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i # Create seed user username = backer_info[backer_number]['username'].gsub(/ /,'').downcase user = User.create( :email => "#{username}@#{username}.joindiaspora.com", From 43321213b0fafec85fe5046de802f1ccd7cc2f41 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 17:13:09 -0700 Subject: [PATCH 144/198] rS iZ changed the friending on tom db script --- db/seeds/tom.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index c716ad8fa..c81616950 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -28,11 +28,6 @@ user2 = User.create( :email => "korth@tom.joindiaspora.com", user2.person.save # friending users -user.friends << user2.person -user.group(:name => "other dudes", :people => [user2.person]) -user.save - -user2.friends << user.person -user2.group(:name => "some dudes", :people => [user.person]) -user2.save - +group = user.group(:name => "other dudes") +request = user.send_friend_request_to(user2.receive_url, group_id) +user2.accept_friend_request request.id, user2.group(:name => "presidents").id From bd271b7bec20e921f3d2aa0fd6e8b0ccc1b8ab9a Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 17:33:26 -0700 Subject: [PATCH 145/198] RS, IZ; Refactored the user unfriend and unfriended_by --- app/models/user.rb | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 56a0a584e..2eac6a008 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -103,26 +103,25 @@ class User end def unfriend(friend_id) + Rails.logger.info("#{self.real_name} is unfriending #{bad_friend.inspect}" bad_friend = Person.first(:_id => friend_id) + Retraction.for(self).push_to_url(bad_friend.receive_url) + remove_friend friend_id + end + + def remove_friend friend_id + bad_friend = Person.first(:_id => friend_id) + self.friend_ids.delete( friend_id ) - - if bad_friend - Retraction.for(self).push_to_url(bad_friend.receive_url) - bad_friend.user_refs -= 1 - - (bad_friend.user_refs > 0 || bad_friend.owner.nil? == false) ? bad_friend.save : bad_friend.destroy - end self.save + + bad_friend.user_refs -= 1 + (bad_friend.user_refs > 0 || bad_friend.owner.nil? == false) ? bad_friend.save : bad_friend.destroy end def unfriended_by friend_id - bad_friend = Person.first(:_id => friend_id) - - self.friend_ids.delete( friend_id ) - bad_friend.user_refs -= 1 - - (bad_friend.user_refs > 0 || bad_friend.owner.nil? == false) ? bad_friend.save : bad_friend.destroy - self.save + Rails.logger.info("#{self.real_name} is being unfriended by #{bad_friend.inspect}" + remove_friend friend_id end def send_request(rel_hash, group) From ac40f7974e01f47d9b4cde5592bfce8e138bd6e5 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 18:37:09 -0700 Subject: [PATCH 146/198] RS, IZ; A variety of fixes and some refactoring on unfriending and activate friend --- app/controllers/people_controller.rb | 2 +- app/models/person.rb | 4 -- app/models/user.rb | 31 ++++++--------- spec/models/person_spec.rb | 58 +++++++++++++--------------- spec/models/user_spec.rb | 37 +++++++----------- 5 files changed, 55 insertions(+), 77 deletions(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index b93a9f059..5d0fc35fe 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -15,7 +15,7 @@ class PeopleController < ApplicationController end def destroy - current_user.unfriend(params[:id]) + current_user.unfriend(current_user.friends.first(params[:id])) flash[:notice] = "unfriended person." redirect_to people_url end diff --git a/app/models/person.rb b/app/models/person.rb index d703c0479..cf4899a1e 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -27,7 +27,6 @@ class Person timestamps! before_validation :clean_url - before_create :check_for_owner validates_presence_of :email, :url, :profile, :serialized_key validates_format_of :url, :with => /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix @@ -124,9 +123,6 @@ class Person private - def check_for_owner - self.user_refs += 1 unless self.owner_id.nil? - end def remove_all_traces self.posts.delete_all end diff --git a/app/models/user.rb b/app/models/user.rb index 2eac6a008..54872ce3a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -60,12 +60,7 @@ class User request = Request.where(:id => friend_request_id).first n = pending_requests.delete(request) - friends << request.person - save - - group = self.groups.first(:id => group_id) - group.people << request.person - group.save + activate_friend(request.person, groups.first(:id => group_id)) request.reverse self @@ -102,26 +97,22 @@ class User end end - def unfriend(friend_id) - Rails.logger.info("#{self.real_name} is unfriending #{bad_friend.inspect}" - bad_friend = Person.first(:_id => friend_id) + def unfriend(bad_friend) + Rails.logger.info("#{self.real_name} is unfriending #{bad_friend.inspect}") Retraction.for(self).push_to_url(bad_friend.receive_url) - remove_friend friend_id + remove_friend(bad_friend) end - def remove_friend friend_id - bad_friend = Person.first(:_id => friend_id) - - self.friend_ids.delete( friend_id ) + def remove_friend(bad_friend) + raise "Friend not deleted" unless self.friend_ids.delete( bad_friend.id ) self.save - bad_friend.user_refs -= 1 (bad_friend.user_refs > 0 || bad_friend.owner.nil? == false) ? bad_friend.save : bad_friend.destroy end - def unfriended_by friend_id - Rails.logger.info("#{self.real_name} is being unfriended by #{bad_friend.inspect}" - remove_friend friend_id + def unfriended_by(bad_friend) + Rails.logger.info("#{self.real_name} is being unfriended by #{bad_friend.inspect}") + remove_friend bad_friend end def send_request(rel_hash, group) @@ -133,8 +124,10 @@ class User end def activate_friend(person, group) + person.user_refs += 1 group.people << person friends << person + person.save group.save save end @@ -149,7 +142,7 @@ class User Rails.logger.debug("Receiving object:\n#{object.inspect}") if object.is_a? Retraction - (object.type == 'Person' )? (unfriended_by object.post_id) : (object.perform self.id) + (object.type == 'Person' )? (unfriended_by friends.first(object.post_id)) : (object.perform self.id) elsif object.is_a? Request person = Diaspora::Parser.get_or_create_person_object_from_xml( xml ) person.serialized_key ||= object.exported_key diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 41046b932..c062d396b 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -2,7 +2,11 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Person do before do + @user = Factory.create(:user) + @user2 = Factory.create(:user) @person = Factory.create(:person) + @group = @user.group(:name => "Dudes") + @group2 = @user2.group(:name => "Abscence of Babes") end @@ -33,8 +37,6 @@ describe Person do end it 'should delete all of user except comments upon user deletion' do - Factory.create(:user) - f = Factory.create(:person) Factory.create(:status_message, :person => f) @@ -57,45 +59,39 @@ describe Person do describe "unfriending" do it 'should delete an orphaned friend' do - user = Factory.create(:user) - user.save + request = @user.send_friend_request_to @person.receive_url, @group.id - user.friends << @person - @person.user_refs += 1 - @person.save - + @user.activate_friend(@person, @group) + @user.reload + + Person.all.count.should == 3 + @user.friends.count.should == 1 + @user.unfriend(@person) + @user.reload + @user.friends.count.should == 0 Person.all.count.should == 2 - user.friends.count.should == 1 - user.unfriend(@person.id) - user.friends.count.should == 0 - Person.all.count.should == 1 end it 'should not delete an un-orphaned friend' do - user_one = Factory.create(:user) - user_two = Factory.create(:user) + request = @user.send_friend_request_to @person.receive_url, @group.id + request2 = @user2.send_friend_request_to @person.receive_url, @group2.id - user_one.save - user_two.save - - - user_one.friends << @person - user_two.friends << @person - user_one.save - user_two.save - - @person.user_refs += 2 - @person.save + @user.activate_friend(@person, @group) + @user2.activate_friend(@person, @group2) + @user.reload + @user2.reload + Person.all.count.should == 3 - user_one.friends.count.should == 1 - user_two.friends.count.should == 1 + @user.friends.count.should == 1 + @user2.friends.count.should == 1 - user_one.unfriend(@person.id) - - user_one.friends.count.should == 0 - user_two.friends.count.should == 1 + @user.unfriend(@person) + @user.reload + @user2.reload + @user.friends.count.should == 0 + @user2.friends.count.should == 1 Person.all.count.should == 3 end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 48c70d757..389ec83b5 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -235,43 +235,36 @@ describe User do describe 'unfriending' do before do - @user = Factory.create :user @user2 = Factory.create :user - - @user.friends << @user2.person - @user.person.user_refs += 1 - @user2.friends << @user.person - - @user2.person.user_refs += 1 - - @user2.person.save - @user.person.save + @group2 = @user2.group(:name => "Gross people") + + request = @user.send_friend_request_to( @user2.receive_url, @group.id) + request.reverse @user2 + @user2.activate_friend(@user.person, @group2) + @user.receive request.to_diaspora_xml end it 'should unfriend the other user on the same seed' do - person = @user2.person - person.url = @user.person.url - person.save - + @user.reload + @user2.reload + @user.friends.count.should == 1 @user2.friends.count.should == 1 - @user.person.user_refs.should == 2 + @user.person.user_refs.should == 1 - @user2.person.user_refs.should == 2 + @user2.person.user_refs.should == 1 - @user2.unfriend @user.person.id + @user2.unfriend @user.person @user2.friends.count.should be 0 @user.person.reload - @user.person.user_refs.should == 1 + @user.person.user_refs.should == 0 - @user.unfriended_by @user2.person.id + @user.unfriended_by @user2.person @user2.person.reload - @user2.person.user_refs.should == 1 + @user2.person.user_refs.should == 0 end - - end end From 8d0f65cd76e0fc21e4042a166fadfe911b2ce7a3 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 18:43:34 -0700 Subject: [PATCH 148/198] Bug in tom seed --- db/seeds/tom.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index c81616950..f171eb0f9 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -29,5 +29,5 @@ user2.person.save # friending users group = user.group(:name => "other dudes") -request = user.send_friend_request_to(user2.receive_url, group_id) +request = user.send_friend_request_to(user2.receive_url, group.id) user2.accept_friend_request request.id, user2.group(:name => "presidents").id From 99c8869b8fa07027c284b2e7d7ad8e6b86d74f3e Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 18:56:33 -0700 Subject: [PATCH 149/198] Removing a friend now deletes them from the group(s) they are in --- app/models/user.rb | 1 + spec/models/user_spec.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 54872ce3a..efc4194b5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -105,6 +105,7 @@ class User def remove_friend(bad_friend) raise "Friend not deleted" unless self.friend_ids.delete( bad_friend.id ) + groups.each{|g| g.person_ids.delete( bad_friend.id )} self.save bad_friend.user_refs -= 1 (bad_friend.user_refs > 0 || bad_friend.owner.nil? == false) ? bad_friend.save : bad_friend.destroy diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 389ec83b5..eb77b1f05 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -265,6 +265,11 @@ describe User do @user2.person.reload @user2.person.user_refs.should == 0 + + @group.reload + @group2.reload + @group.people.count.should == 0 + @group2.people.count.should == 0 end end end From 22910ef4ceea68b24e459a2f6e4c4b0e348407fe Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 13 Aug 2010 19:09:55 -0700 Subject: [PATCH 150/198] Check retraction signature on person retraction --- app/models/user.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index efc4194b5..7f353e5ca 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -143,7 +143,11 @@ class User Rails.logger.debug("Receiving object:\n#{object.inspect}") if object.is_a? Retraction - (object.type == 'Person' )? (unfriended_by friends.first(object.post_id)) : (object.perform self.id) + if object.type == 'Person' && object.signature_valid? + unfriended_by friends.first(object.post_id) + else + object.perform self.id + end elsif object.is_a? Request person = Diaspora::Parser.get_or_create_person_object_from_xml( xml ) person.serialized_key ||= object.exported_key From a7eab9e50c7e9951d7ad418dcad9b7ae6996f20a Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 13 Aug 2010 23:20:39 -0700 Subject: [PATCH 151/198] minor section header tweaks (album stuff) --- app/views/albums/edit.html.haml | 3 +-- app/views/albums/index.html.haml | 3 +-- app/views/albums/show.html.haml | 3 +-- app/views/photos/show.html.haml | 3 +-- app/views/shared/_group_nav.haml | 3 +-- public/stylesheets/application.css | 16 +++++++--------- public/stylesheets/sass/application.sass | 15 +++++++-------- 7 files changed, 19 insertions(+), 27 deletions(-) diff --git a/app/views/albums/edit.html.haml b/app/views/albums/edit.html.haml index 1580c9cae..b505cf76b 100644 --- a/app/views/albums/edit.html.haml +++ b/app/views/albums/edit.html.haml @@ -1,6 +1,5 @@ +.back= link_to "⇧ #{@album.name}", @album %h1.big_text - .back - = link_to "⇧ #{@album.name}", @album = "Editing #{@album.name}" diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 59db9c376..47d2f68a9 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -1,6 +1,5 @@ +.back= link_to "⇧ home", root_path %h1.big_text - .back - = link_to "⇧ home", root_path Albums .right = link_to 'New Album', '#new_album_pane', {:class => "button", :id => "add_album_button"} diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index a2cded0c9..b63dea9de 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -1,6 +1,5 @@ +.back= link_to '⇧ albums', albums_path %h1.big_text - .back - = link_to '⇧ albums', albums_path = @album.name diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 9cae263dd..05443591f 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -1,6 +1,5 @@ +.back= link_to "⇧ #{@album.name}", album_path(@album) %h1.big_text - .back - = link_to "⇧ #{@album.name}", album_path(@album) = @photo.image .right diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index 479e1b967..66f4fa0bd 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -14,9 +14,8 @@ #friend_pictures - for friend in @group.people = person_image_link(friend) + = link_to "+", "#add_request_pane", :id => 'add_request_button', :class => "add_new" - .add_new - = link_to "+", "#add_request_pane", :id => 'add_request_button' .yo{:style => 'display:none'} #add_request_pane = render "requests/new_request" diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 7ce7663ea..05a80acf2 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -377,8 +377,7 @@ ul#publisher_content_pickers li { h1.big_text { position: relative; line-height: auto; - border-bottom: 1px solid #666666; - text-align: center; } + border-bottom: 1px solid #666666; } .big_text .right { top: -8px; } @@ -391,7 +390,6 @@ h1.big_text { float: right; } .back { - position: absolute; font-size: 12px; font-weight: normal; } @@ -449,12 +447,12 @@ h1.big_text { width: 40px; background-color: #222222; text-align: center; - font-size: 40px; } - #group #friend_pictures .add_new a { - display: block; - position: absolute; - top: -13px; - left: 7px; } + font-size: 40px; + line-height: 33px; + top: -9px; } + #group #friend_pictures .add_new:hover { + background: #999999; + color: black; } #group #friend_pictures img { display: none; height: 40px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 841f12a97..516d7a566 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -469,8 +469,6 @@ h1.big_text :border //:top 2px solid #666 :bottom 1px solid #666 - :text - :align center .big_text .right @@ -484,7 +482,6 @@ h1.big_text :float right .back - :position absolute :font :size 12px :weight normal @@ -563,11 +560,13 @@ h1.big_text :color #222 :text-align center :font-size 40px - a - :display block - :position absolute - :top -13px - :left 7px + :line-height 33px + :top -9px + + &:hover + :background #999 + :color #000 + img :display none :height 40px From c81ea5a632d160f81b0952bd5c8859f2528c8dfe Mon Sep 17 00:00:00 2001 From: danielvincent Date: Sat, 14 Aug 2010 00:09:49 -0700 Subject: [PATCH 152/198] minor changes --- app/uploaders/image_uploader.rb | 2 +- app/views/layouts/application.html.haml | 45 ++++++++---------------- public/stylesheets/application.css | 34 +++++++++++------- public/stylesheets/sass/application.sass | 33 ++++++++++++----- 4 files changed, 60 insertions(+), 54 deletions(-) diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb index e118e0f84..2a55e3059 100644 --- a/app/uploaders/image_uploader.rb +++ b/app/uploaders/image_uploader.rb @@ -24,7 +24,7 @@ class ImageUploader < CarrierWave::Uploader::Base end version :thumb_large do - process :resize_to_fill => [300,200] + process :resize_to_fill => [300,300] end version :scaled_full do diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 979538d54..62d0c4eb1 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -29,45 +29,28 @@ = javascript_include_tag 'jquery.html5_upload' %body + - flash.each do |name, msg| + = content_tag :div, msg, :id => "flash_#{name}" + %header .container - - flash.each do |name, msg| - = content_tag :div, msg, :id => "flash_#{name}" + #session_action + - if user_signed_in? + %ul#user_menu + %li.name= link_to current_user.real_name, current_user.person + %li= link_to "requests (#{@request_count})", requests_path, :class => new_request(@request_count) + %li= link_to "settings", edit_user_path(current_user) + %li= link_to "logout", destroy_user_session_path + - else + = link_to "login", new_user_session_path + #diaspora_text{:href => root_path} = link_to "DIASPORA*", root_path %span.sub_text PREVIEW - - #session_action - - if user_signed_in? - = link_to current_user.real_name, current_user.person - | - = link_to "requests (#{@request_count})", requests_path, :class => new_request(@request_count) - | - = link_to "logout", destroy_user_session_path - - else - = link_to "login", new_user_session_path - = render "shared/group_nav" - - .container - - if user_signed_in? - #user_name - = link_to(person_image_tag(current_user), root_path) - %h1 - = link_to current_user.real_name, root_path - %span#latest_message - = my_latest_message - %span{:style => "font-size: small", :id => 'latest_message_time'} - - unless @latest_status_message.nil? - = "- #{how_long_ago @latest_status_message}" - - %ul.nav - %li= link_to "home", root_path - %li= link_to "photos", albums_path - %li= "|" - %li= link_to "edit profile", edit_user_path(current_user) + = link_to "photos", albums_path .container .span-24.last diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 05a80acf2..0d8edc7da 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -66,7 +66,7 @@ a { header { position: relative; margin: -2em; - margin-bottom: 30px; + margin-bottom: 20px; color: #555555; background-color: #2b2726; background-color: black; @@ -88,11 +88,8 @@ header { float: right; text-shadow: 0 1px 0 black; padding-right: 10px; } - header #session_action a { - color: #777777; - border: none; } - header #session_action a.new_requests { - color: #df0101; } + header #session_action a.new_requests { + color: #df0101; } #show_filters { z-index: 100; @@ -144,10 +141,9 @@ h1 { font-size: 21px; font-weight: bold; line-height: 36px; } - h1 p.description, h1 span.description { + h1 p.description, h1 span.description, h1 .description { font-weight: 200; - color: #999999; - padding: 0.1em; } + color: #999999; } h3 { position: relativex; @@ -352,7 +348,7 @@ ul#publisher_content_pickers li { /* cycle it! */ .album { position: relative; - height: 200px; + height: 300px; width: 300px; display: inline-block; } .album .name { @@ -378,9 +374,8 @@ h1.big_text { position: relative; line-height: auto; border-bottom: 1px solid #666666; } - -.big_text .right { - top: -8px; } + h1.big_text .right { + top: -6px; } #content_bottom .right { top: -5px; } @@ -462,3 +457,16 @@ h1.big_text { display: none; left: -25px; top: 4px; } + +#user_menu { + background: #333333; + padding: 5px; + margin: 0; + list-style: none; } + #user_menu a { + color: #999999; } + #user_menu > li { + display: inline; + margin-right: 1em; } + #user_menu > li:last-child { + margin-right: 0; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 516d7a566..9ef450368 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -70,7 +70,7 @@ a header :position relative :margin -2em - :bottom 30px + :bottom 20px :color #555 :background :color #2B2726 @@ -101,8 +101,6 @@ header :float right :text-shadow 0 1px 0 #000 a - :color #777 - :border none &.new_requests :color #DF0101 :padding-right 10px @@ -168,11 +166,10 @@ h1 :weight bold :line-height 36px - p.description, span.description + p.description, span.description, .description :font :weight 200 :color #999 - :padding 0.1em h3 :position relativex @@ -432,7 +429,7 @@ ul#publisher_content_pickers li .album :position relative - :height 200px + :height 300px :width 300px :display inline-block @@ -467,12 +464,11 @@ h1.big_text :position relative :line-height auto :border - //:top 2px solid #666 :bottom 1px solid #666 -.big_text .right - :top -8px + :top -6px + #content_bottom .right :top -5px @@ -577,3 +573,22 @@ h1.big_text :left -25px :top 4px +#user_menu + :background #333 + :padding 5px + :margin 0 + :list-style none + + a + :color #999 + + > li + :display inline + :margin + :right 1em + + &:last-child + :margin + :right 0 + + From 18cd4b858aa0b6e8dbbfaef3f2be1684323ed663 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Sat, 14 Aug 2010 00:27:43 -0700 Subject: [PATCH 153/198] broke out group index and show --- app/controllers/groups_controller.rb | 1 - app/views/groups/index.html.haml | 4 ++++ app/views/groups/show.html.haml | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 app/views/groups/show.html.haml diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 27f5ae782..f3da1ec8a 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -31,7 +31,6 @@ class GroupsController < ApplicationController @people_ids = @group.people.map {|p| p.id} @posts = Post.paginate :person_id => @people_ids, :order => 'created_at DESC' @group = Group.first(:id => params[:id]) - render :index end def edit diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml index daaaaaabc..b3b4d2acb 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/index.html.haml @@ -1,3 +1,7 @@ +%h1 + welcome home, + = current_user.profile.first_name + = render "shared/publisher" %ul#stream - for post in @posts diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml new file mode 100644 index 000000000..daaaaaabc --- /dev/null +++ b/app/views/groups/show.html.haml @@ -0,0 +1,7 @@ += render "shared/publisher" +%ul#stream + - for post in @posts + = render type_partial(post), :post => post +#pagination + = will_paginate @posts + From 80b81c1ae1c92607d0f08879ff7f1bf6398c3b6b Mon Sep 17 00:00:00 2001 From: danielvincent Date: Sun, 15 Aug 2010 19:28:59 -0700 Subject: [PATCH 154/198] comment now validates presence of text. also, removed unused method overriding ==. --- app/models/comment.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 66ce23b55..0323b0d6a 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -18,10 +18,8 @@ class Comment key :person_id, ObjectId belongs_to :person, :class_name => "Person" - - def ==(other) - (self.message == other.message) && (self.person.email == other.person.email) - end + + validates_presence_of :text def push_upstream push_to([post.person]) @@ -34,7 +32,6 @@ class Comment #ENCRYPTION before_validation :sign_if_mine, :sign_if_my_post - #validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature} validates_true_for :post_creator_signature, :logic => lambda {self.verify_post_creator_signature} xml_accessor :creator_signature From f1f827120bac45db5be4b0ed4a21519834b9a127 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Sun, 15 Aug 2010 21:03:19 -0700 Subject: [PATCH 155/198] intentional failing test in user for tomorrow. --- app/models/group.rb | 2 ++ app/models/user.rb | 3 ++- spec/lib/diaspora_parser_spec.rb | 24 +++++++++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/models/group.rb b/app/models/group.rb index 0f40d6d9b..6b8f18921 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -5,9 +5,11 @@ class Group key :person_ids, Array key :request_ids, Array + key :post_ids, Array many :people, :in => :person_ids, :class_name => 'Person' many :requests, :in => :request_ids, :class_name => 'Request' + many :posts, :in => :post_ids, :class_name => 'Post' belongs_to :user, :class_name => 'User' diff --git a/app/models/user.rb b/app/models/user.rb index 7f353e5ca..0090e59d6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -162,7 +162,8 @@ class User person.profile = object person.save elsif object.verify_creator_signature == true - Rails.logger.debug("Saving object with success: #{object.save}") + Rails.logger.debug("Saving object: #{object}") + object.save object.socket_to_uid( id) if object.respond_to? :socket_to_uid end end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 07de46d02..3e4344a64 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -12,6 +12,29 @@ describe Diaspora::Parser do @person = Factory.create(:person_with_private_key, :email => "bill@gates.com") @user2 = Factory.create(:user) end + + + it "should associate the post with a group" do + @user.activate_friend(@person, @group) + + status_message = Factory.build(:status_message, :message => "hey!", :person => @person) + @user.receive status_message.to_diaspora_xml + + + # mongomapper doesn't support joins, meaning we can't do a query + # on user.groups. + # should this code below be a function of a user? + # something like self.find_group_for(friend_id) ? + groups = @user.groups + groups.shift while not groups[0].person_ids.include?(@person.id) + group = groups[0] + #### + + @group.posts.count.should == 1 + end + + + describe 'with encryption' do before do unstub_mocha_stubs @@ -38,7 +61,6 @@ describe Diaspora::Parser do " @user.receive xml Post.count.should == 0 - end end From d0c02859e679dd4d58c5a557ac3e56ecf3c407f4 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 16 Aug 2010 10:00:04 -0700 Subject: [PATCH 156/198] DG IZ got one more log statement in the user person retraction --- app/models/user.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 7f353e5ca..28f99db7b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -144,7 +144,10 @@ class User if object.is_a? Retraction if object.type == 'Person' && object.signature_valid? + + Rails.logger.info( "the person id is #{object.post_id} the friend found is #{friends.first(object.post_id)}") unfriended_by friends.first(object.post_id) + else object.perform self.id end From e84b25b3f51d0dccc40c07b1a64a971b6c19943d Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 10:31:39 -0700 Subject: [PATCH 157/198] Log the xml again --- app/models/user.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/user.rb b/app/models/user.rb index 7bb292491..9277e1e30 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -139,6 +139,7 @@ class User ###### Receiving ####### def receive xml + Rails.logger.info("Received xml is #{xml}") object = Diaspora::Parser.from_xml(xml) Rails.logger.debug("Receiving object:\n#{object.inspect}") From ad2d8f8b461e8c918f8917de32cee9196c47eda1 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 10:37:07 -0700 Subject: [PATCH 158/198] Specify id field in the query whose result is passed to unfriended_by --- 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 9277e1e30..b2122efa4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -147,7 +147,7 @@ class User if object.type == 'Person' && object.signature_valid? Rails.logger.info( "the person id is #{object.post_id} the friend found is #{friends.first(object.post_id)}") - unfriended_by friends.first(object.post_id) + unfriended_by friends.first(:id => object.post_id) else object.perform self.id From 0e67ef8d7e3ab243595ebcdc7f62be7d5f02e2fe Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 10:38:36 -0700 Subject: [PATCH 159/198] Inspect the friend before calling unfriended by --- app/models/user.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index b2122efa4..306458485 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -139,14 +139,13 @@ class User ###### Receiving ####### def receive xml - Rails.logger.info("Received xml is #{xml}") object = Diaspora::Parser.from_xml(xml) Rails.logger.debug("Receiving object:\n#{object.inspect}") if object.is_a? Retraction if object.type == 'Person' && object.signature_valid? - Rails.logger.info( "the person id is #{object.post_id} the friend found is #{friends.first(object.post_id)}") + Rails.logger.info( "the person id is #{object.post_id} the friend found is #{friends.first(:id => object.post_id).inspect}") unfriended_by friends.first(:id => object.post_id) else From 26abc68236503e48c7edd63dd85f9a58ea5b4ebd Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 10:50:38 -0700 Subject: [PATCH 160/198] Use group_by_id or friend_by_id, no querying on friends or groups --- app/models/user.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 306458485..1a3504120 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -45,7 +45,7 @@ class User self.pending_requests << request self.save - group = self.groups.first(:id => group_id) + group = self.group_by_id(group_id) group.requests << request group.save @@ -60,7 +60,7 @@ class User request = Request.where(:id => friend_request_id).first n = pending_requests.delete(request) - activate_friend(request.person, groups.first(:id => group_id)) + activate_friend(request.person, group_by_id(group_id)) request.reverse self @@ -82,7 +82,7 @@ class User def receive_friend_request(friend_request) Rails.logger.info("receiving friend request #{friend_request.to_json}") if request_from_me?(friend_request) - group = self.groups.first(:id => friend_request.group_id) + group = self.group_by_id(friend_request.group_id) activate_friend(friend_request.person, group) Rails.logger.info("#{self.real_name}'s friend request has been accepted") @@ -145,8 +145,8 @@ class User if object.is_a? Retraction if object.type == 'Person' && object.signature_valid? - Rails.logger.info( "the person id is #{object.post_id} the friend found is #{friends.first(:id => object.post_id).inspect}") - unfriended_by friends.first(:id => object.post_id) + Rails.logger.info( "the person id is #{object.post_id} the friend found is #{friend_by_id(object.post_id).inspect}") + unfriended_by friend_by_id(object.post_id) else object.perform self.id @@ -189,10 +189,13 @@ class User self.password_confirmation = self.password end - def self.owner - User.first + def friend_by_id( id ) + friends.detect{|x| x.id == id } + end + + def group_by_id( id ) + groups.detect{|x| x.id == id } end - protected def assign_key From 3efa36587aebb8089bb320afffcafc17f5d05b13 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 11:01:58 -0700 Subject: [PATCH 161/198] Took out a bunch of user.owner references --- app/controllers/publics_controller.rb | 1 - app/helpers/application_helper.rb | 10 +++++----- app/models/blog.rb | 4 ++-- app/models/bookmark.rb | 4 ++-- app/models/status_message.rb | 4 ++-- spec/models/post_spec.rb | 11 ----------- 6 files changed, 11 insertions(+), 23 deletions(-) diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index e6506c55e..2b942541f 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -11,7 +11,6 @@ class PublicsController < ApplicationController end def host_meta - @user = User.owner render 'host_meta', :layout => false, :content_type => 'application/xrd+xml' end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d6913a9e5..7f6a7bae2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -32,7 +32,11 @@ module ApplicationHelper end def owner_image_tag - person_image_tag(User.owner) + person_image_tag(current_user) + end + + def owner_image_link + person_image_link(current_user) end def person_image_tag(person) @@ -46,10 +50,6 @@ module ApplicationHelper link_to person_image_tag(person), object_path(person) end - def owner_image_link - person_image_link(User.owner) - end - def new_request(request_count) "new_requests" if request_count > 0 end diff --git a/app/models/blog.rb b/app/models/blog.rb index 0df0dd558..3859cfa1e 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb @@ -15,8 +15,8 @@ class Blog < Post http://activitystrea.ms/schema/1.0/post #{self.title} #{self.body} - - #{User.owner.url}blogs/#{self.id} + + #{person.url}blogs/#{self.id} #{self.created_at.xmlschema} #{self.updated_at.xmlschema} diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb index de1eb9258..677bfa126 100644 --- a/app/models/bookmark.rb +++ b/app/models/bookmark.rb @@ -17,9 +17,9 @@ class Bookmark < Post http://activitystrea.ms/schema/1.0/post #{self.title} - + - #{User.owner.url}bookmarks/#{self.id} + #{person.url}bookmarks/#{self.id} #{self.created_at.xmlschema} #{self.updated_at.xmlschema} diff --git a/app/models/status_message.rb b/app/models/status_message.rb index bf56410be..3fb9aa39d 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -13,8 +13,8 @@ class StatusMessage < Post http://activitystrea.ms/schema/1.0/post #{self.message} - - #{User.owner.url}status_messages/#{self.id} + + #{person.url}status_messages/#{self.id} #{self.created_at.xmlschema} #{self.updated_at.xmlschema} diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index f013e1583..a20ffb504 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -6,17 +6,6 @@ describe Post do @user.person.save end - describe 'defaults' do - before do - WebSocket.stub!(:update_clients) - @post = Factory.create(:post, :person => nil) - end - - it "should associate the owner if none is present" do - @post.person.should == User.owner - end - end - describe "newest" do before do @person_one = Factory.create(:person, :email => "some@dudes.com") From eb793ea129003f1984b23733888f3b7f722b76c3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 11:07:18 -0700 Subject: [PATCH 162/198] Took out a couple more references to User.owner --- app/models/photo.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/photo.rb b/app/models/photo.rb index c06ceb62c..d93a1189a 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -37,7 +37,7 @@ class Photo < Post end def remote_photo - @remote_photo ||= User.owner.url.chop + image.url + @remote_photo ||= self.person.url.chop + image.url end def remote_photo= remote_path @@ -47,10 +47,10 @@ class Photo < Post end def ensure_user_picture - user = User.owner - if user.profile.image_url == image.url(:thumb_medium) + users = Person.all('profile.image_url' => image.url(:thumb_medium) ) + users.each{ |user| user.profile.update_attributes!(:image_url => nil) - end + } end def thumb_hash From 99fb383dc06ed78f39a77eb16ecc875ff1573acf Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 11:13:00 -0700 Subject: [PATCH 163/198] BSONify ids in by_id methods --- app/models/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 1a3504120..f22290e18 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -190,11 +190,11 @@ class User end def friend_by_id( id ) - friends.detect{|x| x.id == id } + friends.detect{|x| x.id == id || x.id == BSON::ObjectID(id) } end def group_by_id( id ) - groups.detect{|x| x.id == id } + groups.detect{|x| x.id == id || x.id == BSON::ObjectID(id) } end protected From 6ae4c31e050c2e67767b11ff4c668862a6e0d1f1 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 11:18:52 -0700 Subject: [PATCH 164/198] Person show should be scoped through user --- app/controllers/people_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 5d0fc35fe..686a81b88 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -6,7 +6,7 @@ class PeopleController < ApplicationController end def show - @person= Person.where(:id => params[:id]).first + @person= current_user.friend_by_id(params[:id]) @person_profile = @person.profile @person_posts = Post.where(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC' From 4c731bf81871b778f2b7ba666f22013fc9eddbd6 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 11:29:14 -0700 Subject: [PATCH 165/198] special-casing local webfinger --- app/controllers/publics_controller.rb | 2 +- app/helpers/requests_helper.rb | 13 ++++++++++--- app/models/person.rb | 6 +++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index 2b942541f..91edf995d 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -15,7 +15,7 @@ class PublicsController < ApplicationController end def webfinger - @person = Person.first(:email => params[:q].gsub('acct:', '')) + @person = Person.by_webfinger(params[:q]) unless @person.nil? || @person.owner.nil? render 'webfinger', :layout => false, :content_type => 'application/xrd+xml' end diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb index 99f73be66..478d9853b 100644 --- a/app/helpers/requests_helper.rb +++ b/app/helpers/requests_helper.rb @@ -26,9 +26,16 @@ module RequestsHelper end def relationship_flow(identifier) - f = Redfinger.finger(identifier) - action = subscription_mode(f) - url = subscription_url(action, f) + puts request.host + if identifier.include?(request.host) + person = Person.by_webfinger identifier + action = :friend + url = person.owner.receive_url + else + f = Redfinger.finger(identifier) + action = subscription_mode(f) + url = subscription_url(action, f) + end { action => url } end diff --git a/app/models/person.rb b/app/models/person.rb index cf4899a1e..50a3cc410 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -75,7 +75,7 @@ class Person false end - def send_comment c + def send_comment( c ) if self.owner.nil? if c.post.person.owner.nil? #puts "The commenter is not here, and neither is the poster" @@ -112,6 +112,10 @@ class Person "#{self.url}receive/users/#{self.id}/" end + def self.by_webfinger( identifier ) + Person.first(:email => identifier.gsub('acct:', '')) + end + protected def clean_url self.url ||= "http://localhost:3000/" if self.class == User From 0ee03afe1da70c3622e13f5435d0385122c29c4e Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 16 Aug 2010 11:39:33 -0700 Subject: [PATCH 167/198] DG IZ selector box on request page --- app/controllers/requests_controller.rb | 5 ----- app/views/requests/_request.html.haml | 14 +++++++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 4caff37f4..5865aacaf 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -43,9 +43,4 @@ class RequestsController < ApplicationController end end - - - private - - end diff --git a/app/views/requests/_request.html.haml b/app/views/requests/_request.html.haml index 03ab427f3..b44a27adb 100644 --- a/app/views/requests/_request.html.haml +++ b/app/views/requests/_request.html.haml @@ -3,6 +3,14 @@ %span.from = link_to "#{request.person.real_name}", '#' - %ul.request_buttons - %li= link_to 'Accept', request_path(request, :accept => true), :method => :delete - %li= link_to 'Ignore', request_path(request), :confirm => 'Are you sure?', :method => :delete + .request_buttons + = form_for request do |r| + = r.hidden_field(:accept, :accept, true) + %select{ :id => "request_group_id", :name => "request[group_id]"} + - for group in current_user.groups + %option{:value => group.id}= group.name + = r.submit_tag "Accept" + + = form_for request do |r| + = r.hidden_field(:accept, :accept, false) + = r.submit_tag "Ignore" From f4d6a04f4f40661f3b5da793ceb58d24dc56c998 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 11:46:36 -0700 Subject: [PATCH 171/198] Get objects by bson id --- app/models/user.rb | 12 ++++++++++-- db/seeds/tom.rb | 8 -------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index f22290e18..647fe3172 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -190,12 +190,13 @@ class User end def friend_by_id( id ) - friends.detect{|x| x.id == id || x.id == BSON::ObjectID(id) } + friends.detect{|x| x.id == ensure_bson id } end def group_by_id( id ) - groups.detect{|x| x.id == id || x.id == BSON::ObjectID(id) } + groups.detect{|x| x.id == ensure_bson id } end + protected def assign_key @@ -210,4 +211,11 @@ class User OpenSSL::PKey::RSA::generate 1024 end + def ensure_bson id + if id.class == String + BSON::ObjectID(id) + else + id + end + end end diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index f171eb0f9..6f3e84582 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -1,11 +1,3 @@ -#This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) -# Mayor.create(:name => 'Daley', :city => citie - require 'config/environment' # Create seed user From a8b402636a29d3584dc4ff92de5daecd3a768a23 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 11:47:23 -0700 Subject: [PATCH 172/198] Shorten ensure_bson --- app/models/user.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 647fe3172..28e750789 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -212,10 +212,6 @@ class User end def ensure_bson id - if id.class == String - BSON::ObjectID(id) - else - id - end + id.class == String ? BSON::ObjectID(id) : id end end From 00a9bd820b499f13521a593b50b59f16dcbfb1d6 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 11:50:43 -0700 Subject: [PATCH 173/198] Parser confused :( --- app/models/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 28e750789..b086535b2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -190,11 +190,11 @@ class User end def friend_by_id( id ) - friends.detect{|x| x.id == ensure_bson id } + friends.detect{|x| x.id == ensure_bson( id ) } end def group_by_id( id ) - groups.detect{|x| x.id == ensure_bson id } + groups.detect{|x| x.id == ensure_bson( id ) } end protected From b37b8303d3ec43042355329334f325a7eab25071 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 11:55:32 -0700 Subject: [PATCH 174/198] Check for friending yourself in requests helper --- app/helpers/requests_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb index 478d9853b..16a50a886 100644 --- a/app/helpers/requests_helper.rb +++ b/app/helpers/requests_helper.rb @@ -29,7 +29,7 @@ module RequestsHelper puts request.host if identifier.include?(request.host) person = Person.by_webfinger identifier - action = :friend + action = (person == current_user.person ? :none : :friend) url = person.owner.receive_url else f = Redfinger.finger(identifier) From 2bc9d0156dddfb7088467bde97b44b6351a75b5b Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 16 Aug 2010 11:59:13 -0700 Subject: [PATCH 175/198] 2 arguments in the hidden field --- app/views/requests/_request.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/requests/_request.html.haml b/app/views/requests/_request.html.haml index b44a27adb..f5b280a5a 100644 --- a/app/views/requests/_request.html.haml +++ b/app/views/requests/_request.html.haml @@ -5,12 +5,12 @@ .request_buttons = form_for request do |r| - = r.hidden_field(:accept, :accept, true) + = r.hidden_field(:accept, true) %select{ :id => "request_group_id", :name => "request[group_id]"} - for group in current_user.groups %option{:value => group.id}= group.name = r.submit_tag "Accept" = form_for request do |r| - = r.hidden_field(:accept, :accept, false) + = r.hidden_field(:accept,false) = r.submit_tag "Ignore" From 4f22222b300c242c4f344d0400b42b0153057d54 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 12:10:23 -0700 Subject: [PATCH 176/198] Splitting accept_friend_request into two methods --- app/controllers/requests_controller.rb | 2 +- app/models/user.rb | 10 ++++++++-- db/seeds/tom.rb | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 4caff37f4..705e781b6 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -8,7 +8,7 @@ class RequestsController < ApplicationController def destroy if params[:accept] - @friend = current_user.accept_friend_request( params[:id], current_user.groups.first.id) + @friend = current_user.accept_and_respond( params[:id], current_user.groups.first.id) flash[:notice] = "you are now friends" redirect_to root_url diff --git a/app/models/user.rb b/app/models/user.rb index b086535b2..1de2d3e76 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -63,11 +63,17 @@ class User activate_friend(request.person, group_by_id(group_id)) request.reverse self - + request + end + + def dispatch_friend_acceptance request request.push_to_url(request.callback_url) - request.destroy end + + def accept_and_respond(friend_request_id, group_id) + dispatch_friend_acceptance(accept_friend_request(friend_request_id, group_id)) + end def ignore_friend_request(friend_request_id) request = Request.first(:id => friend_request_id) diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 6f3e84582..d3aa7289b 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -22,4 +22,5 @@ user2.person.save # friending users group = user.group(:name => "other dudes") request = user.send_friend_request_to(user2.receive_url, group.id) -user2.accept_friend_request request.id, user2.group(:name => "presidents").id +reversed_request = user2.accept_friend_request( request.id, user2.group(:name => "presidents").id ) +user.receive reversed_request.to_diaspora_xml From d7a9c3c0874f45a8329381dbc99e688b2e72e198 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 12:18:36 -0700 Subject: [PATCH 177/198] Take out another couple friends.first and replace with friend_by_id --- app/controllers/application_controller.rb | 2 +- app/controllers/people_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 89c637b13..c3b74a861 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -20,7 +20,7 @@ class ApplicationController < ActionController::Base @groups = current_user.groups @friends = current_user.friends @latest_status_message = StatusMessage.newest_for(current_user.person) - @group = params[:group] ? current_user.groups.first(:id => params[:group]) : current_user.groups.first + @group = params[:group] ? current_user.group_by_id(params[:group]) : current_user.groups.first end end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 686a81b88..16cb235b8 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -15,7 +15,7 @@ class PeopleController < ApplicationController end def destroy - current_user.unfriend(current_user.friends.first(params[:id])) + current_user.unfriend(current_user.friend_by_id(params[:id])) flash[:notice] = "unfriended person." redirect_to people_url end From fb8d3b3e85171a8b3f3d56448d15693d51f097d9 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 12:26:15 -0700 Subject: [PATCH 178/198] Check for local person before destroying accepted request --- app/models/user.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 1de2d3e76..7279360b8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -66,10 +66,10 @@ class User request end - def dispatch_friend_acceptance request + def dispatch_friend_acceptance(request) request.push_to_url(request.callback_url) - request.destroy - end + request.destroy unless request.callback_url.include? user.url + end def accept_and_respond(friend_request_id, group_id) dispatch_friend_acceptance(accept_friend_request(friend_request_id, group_id)) From 1f0ca49ce508742ca53a08f3396fdf541135b96a Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 12:29:26 -0700 Subject: [PATCH 179/198] url, not user.url --- 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 7279360b8..d224cef44 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -68,7 +68,7 @@ class User def dispatch_friend_acceptance(request) request.push_to_url(request.callback_url) - request.destroy unless request.callback_url.include? user.url + request.destroy unless request.callback_url.include? url end def accept_and_respond(friend_request_id, group_id) From e2d5bf909f6da38ffa16c9cb7d89232d5928cc55 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 12:45:31 -0700 Subject: [PATCH 180/198] Call right method in dev_utilities, clear junk out of comments helper --- app/controllers/dev_utilities_controller.rb | 2 +- app/helpers/comments_helper.rb | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index 0295e4114..a9711164e 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -39,7 +39,7 @@ def warzombie def zombiefriendaccept render :nothing => true Request.all.each{|r| - current_user.accept_friend_request(r.id, current_user.groups.first.id) + current_user.accept_and_respond(r.id, current_user.groups.first.id) } end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index a94d176ad..b1e4df9cd 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -1,9 +1,3 @@ module CommentsHelper - def target - - end - - def text - params[:comment][:text] - end + end From 598c646b07dfefdf4971d3b0137a2b1ad2e83fae Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 12:56:02 -0700 Subject: [PATCH 181/198] Hack to get comments working for now --- app/models/person.rb | 29 ++++++++++++++--------------- app/models/user.rb | 1 + 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 50a3cc410..827d4945d 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -77,22 +77,21 @@ class Person def send_comment( c ) if self.owner.nil? - if c.post.person.owner.nil? - #puts "The commenter is not here, and neither is the poster" - elsif c.post.person.owner - #puts "The commenter is not here, and the poster is" - c.push_downstream - end - else - if owns? c.post - #puts "The commenter is here, and is the poster" - c.push_downstream - else - #puts "The commenter is here, and is not the poster" - c.push_upstream - end + if c.post.person.owner.nil? + #puts "The commenter is not here, and neither is the poster" + elsif c.post.person.owner + #puts "The commenter is not here, and the poster is" + c.push_downstream end - + else + if owns? c.post + #puts "The commenter is here, and is the poster" + c.push_downstream + else + #puts "The commenter is here, and is not the poster" + c.push_upstream + end + end end ##profile def update_profile(params) diff --git a/app/models/user.rb b/app/models/user.rb index d224cef44..e35ec88cb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -174,6 +174,7 @@ class User Rails.logger.debug("Saving object: #{object}") object.save object.socket_to_uid( id) if object.respond_to? :socket_to_uid + object.person.send_comment object if object.is_a? Comment end end From f8e2e6bf2dd2f1f3d421ae0067b7a5ee2ecc4bab Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 13:49:48 -0700 Subject: [PATCH 182/198] Infinite loops are the best --- app/models/person.rb | 6 +++++- app/models/user.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 827d4945d..fd601076f 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -76,7 +76,7 @@ class Person end def send_comment( c ) - if self.owner.nil? + if self.remote? if c.post.person.owner.nil? #puts "The commenter is not here, and neither is the poster" elsif c.post.person.owner @@ -114,6 +114,10 @@ class Person def self.by_webfinger( identifier ) Person.first(:email => identifier.gsub('acct:', '')) end + + def remote? + owner.nil? + end protected def clean_url diff --git a/app/models/user.rb b/app/models/user.rb index e35ec88cb..fcd45a268 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -174,7 +174,7 @@ class User Rails.logger.debug("Saving object: #{object}") object.save object.socket_to_uid( id) if object.respond_to? :socket_to_uid - object.person.send_comment object if object.is_a? Comment + object.person.send_comment object if object.is_a? Comment && owns? object end end From 91b0a1e8f9b3cc0e809b85de92560f552dc4246b Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 13:51:49 -0700 Subject: [PATCH 183/198] PAAAARSER --- 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 fcd45a268..88c77f929 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -174,7 +174,7 @@ class User Rails.logger.debug("Saving object: #{object}") object.save object.socket_to_uid( id) if object.respond_to? :socket_to_uid - object.person.send_comment object if object.is_a? Comment && owns? object + object.person.send_comment object if (object.is_a? Comment && self.owns?( object)) end end From 1f40ea23b62ea04ed11fe83964c5d8ba8f70ecc8 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 13:58:05 -0700 Subject: [PATCH 184/198] logging is awesome --- app/models/comment.rb | 2 ++ app/models/person.rb | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 0323b0d6a..3b574f28f 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -22,10 +22,12 @@ class Comment validates_presence_of :text def push_upstream + Rails.logger.info("GOIN UPSTREAM") push_to([post.person]) end def push_downstream + Rails.logger.info("SWIMMIN DOWNSTREAM") push_to(post.people_with_permissions) end diff --git a/app/models/person.rb b/app/models/person.rb index fd601076f..01947bcd6 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -78,17 +78,17 @@ class Person def send_comment( c ) if self.remote? if c.post.person.owner.nil? - #puts "The commenter is not here, and neither is the poster" + Rails.logger.info "The commenter is not here, and neither is the poster" elsif c.post.person.owner - #puts "The commenter is not here, and the poster is" + Rails.logger.info "The commenter is not here, and the poster is" c.push_downstream end else if owns? c.post - #puts "The commenter is here, and is the poster" + Rails.logger.info "The commenter is here, and is the poster" c.push_downstream else - #puts "The commenter is here, and is not the poster" + Rails.logger.info "The commenter is here, and is not the poster" c.push_upstream end end From deeb4832c184d2616e4c2ebdc1a2351d29fd43db Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 14:02:26 -0700 Subject: [PATCH 185/198] Error: insufficient parenthases --- 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 88c77f929..d59d10a82 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -174,7 +174,7 @@ class User Rails.logger.debug("Saving object: #{object}") object.save object.socket_to_uid( id) if object.respond_to? :socket_to_uid - object.person.send_comment object if (object.is_a? Comment && self.owns?( object)) + object.person.send_comment object if (object.is_a?(Comment) && self.owns?( object)) end end From b463958f0d9bc17317af3c0c1d8922d5b440249d Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 14:06:52 -0700 Subject: [PATCH 186/198] Check ownership on the comment's post --- 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 d59d10a82..ede993334 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -174,7 +174,7 @@ class User Rails.logger.debug("Saving object: #{object}") object.save object.socket_to_uid( id) if object.respond_to? :socket_to_uid - object.person.send_comment object if (object.is_a?(Comment) && self.owns?( object)) + object.person.send_comment object if (object.is_a?(Comment) && self.owns?( object.post)) end end From 71aaa9240c5470a7413487495f7d9d548e2b6a84 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 14:18:08 -0700 Subject: [PATCH 187/198] only socket if the object isn't yours --- 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 ede993334..aa4526edd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -173,7 +173,7 @@ class User elsif object.verify_creator_signature == true Rails.logger.debug("Saving object: #{object}") object.save - object.socket_to_uid( id) if object.respond_to? :socket_to_uid + object.socket_to_uid( id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object)) object.person.send_comment object if (object.is_a?(Comment) && self.owns?( object.post)) end end From e4af2ccb1fa4ce82087b4cb7dfb401b3cc7e6800 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 14:22:14 -0700 Subject: [PATCH 188/198] Rename send_comment to dispatch_comment, simplify it --- app/models/person.rb | 23 ++++++----------------- app/models/user.rb | 2 +- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 01947bcd6..7e0c2d3bb 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -66,7 +66,7 @@ class Person raise "must comment on something!" unless options[:on] c = Comment.new(:person_id => self.id, :text => text, :post => options[:on]) if c.save - send_comment c + dispatch_comment c c.socket_to_uid owner.id if owner_id true else @@ -75,22 +75,11 @@ class Person false end - def send_comment( c ) - if self.remote? - if c.post.person.owner.nil? - Rails.logger.info "The commenter is not here, and neither is the poster" - elsif c.post.person.owner - Rails.logger.info "The commenter is not here, and the poster is" - c.push_downstream - end - else - if owns? c.post - Rails.logger.info "The commenter is here, and is the poster" - c.push_downstream - else - Rails.logger.info "The commenter is here, and is not the poster" - c.push_upstream - end + def dispatch_comment( c ) + if owns? c.post + push_downstream + elsif owns? c + c.push_upstream end end ##profile diff --git a/app/models/user.rb b/app/models/user.rb index aa4526edd..ac8a98d76 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -174,7 +174,7 @@ class User Rails.logger.debug("Saving object: #{object}") object.save object.socket_to_uid( id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object)) - object.person.send_comment object if (object.is_a?(Comment) && self.owns?( object.post)) + object.person.dispatch_comment object if (object.is_a?(Comment) end end From fa2e621b0feeb838cb83fd1e23fbf1b3dc901ec8 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 14:24:30 -0700 Subject: [PATCH 189/198] Syntax error --- 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 ac8a98d76..d20c48bdb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -174,7 +174,7 @@ class User Rails.logger.debug("Saving object: #{object}") object.save object.socket_to_uid( id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object)) - object.person.dispatch_comment object if (object.is_a?(Comment) + object.person.dispatch_comment object if object.is_a?(Comment) end end From b1c29083df936787233cda5359aafd7fb13dc467 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 16 Aug 2010 14:34:16 -0700 Subject: [PATCH 190/198] changed the link data-method --- app/views/requests/_request.html.haml | 25 +++++++++++++++---------- app/views/requests/index.html.haml | 1 - 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/views/requests/_request.html.haml b/app/views/requests/_request.html.haml index f5b280a5a..ebc21cbe0 100644 --- a/app/views/requests/_request.html.haml +++ b/app/views/requests/_request.html.haml @@ -1,16 +1,21 @@ +:javascript + $(document).ready(function(){ + $(".group_selector").change( function() { + var id = $(this).children(":selected").val(); + $(this).parent().children(".accept").html( "Accept"); + }); + }); + + %li.message{:id => request.id} %span.from = link_to "#{request.person.real_name}", '#' - .request_buttons - = form_for request do |r| - = r.hidden_field(:accept, true) - %select{ :id => "request_group_id", :name => "request[group_id]"} - - for group in current_user.groups - %option{:value => group.id}= group.name - = r.submit_tag "Accept" + %ul.request_buttons + %select{ :class => "group_selector" } + - for group in current_user.groups + %option{:value => group.id}= group.name + %li.accept= button_to 'Accept', request_path(request, :accept => true), :method => :delete + %li.ignore= button_to 'Ignore', request_path(request), :confirm => 'Are you sure?', :method => :delete - = form_for request do |r| - = r.hidden_field(:accept,false) - = r.submit_tag "Ignore" diff --git a/app/views/requests/index.html.haml b/app/views/requests/index.html.haml index cc33576cd..81b84f6ab 100644 --- a/app/views/requests/index.html.haml +++ b/app/views/requests/index.html.haml @@ -6,7 +6,6 @@ = render "form", :request => @request %h3= "currently #{@request_count} requests" - %ul#stream - for request in @remote_requests = render "request", :request => request From 97e5468cea672b3cd125d51de45b3c9c40c8b4a7 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 16 Aug 2010 14:46:15 -0700 Subject: [PATCH 191/198] adding the user to the correct group --- app/controllers/requests_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 4945436c3..756087d31 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -8,7 +8,7 @@ class RequestsController < ApplicationController def destroy if params[:accept] - @friend = current_user.accept_and_respond( params[:id], current_user.groups.first.id) + @friend = current_user.accept_and_respond( params[:id], current_user.group_by_id(params[:group_id])) flash[:notice] = "you are now friends" redirect_to root_url From 373321beefdb3fcc60f7f8bd366eb0b17425450a Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 16 Aug 2010 14:52:59 -0700 Subject: [PATCH 192/198] DG IZ made the selector box going to the right thing by passing only the id --- app/controllers/requests_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 756087d31..fd6cfc74f 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -8,7 +8,7 @@ class RequestsController < ApplicationController def destroy if params[:accept] - @friend = current_user.accept_and_respond( params[:id], current_user.group_by_id(params[:group_id])) + @friend = current_user.accept_and_respond( params[:id], params[:group_id]) flash[:notice] = "you are now friends" redirect_to root_url From 92aa72447fa62da792bf403c234a1f726d0dca52 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 16 Aug 2010 14:57:22 -0700 Subject: [PATCH 193/198] DG IZ fixed the css in selector --- app/views/requests/_request.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/requests/_request.html.haml b/app/views/requests/_request.html.haml index ebc21cbe0..6c8bb7307 100644 --- a/app/views/requests/_request.html.haml +++ b/app/views/requests/_request.html.haml @@ -13,7 +13,7 @@ = link_to "#{request.person.real_name}", '#' %ul.request_buttons - %select{ :class => "group_selector" } + %select{ :class => "group_selector", :style=>"display:inline;"} - for group in current_user.groups %option{:value => group.id}= group.name %li.accept= button_to 'Accept', request_path(request, :accept => true), :method => :delete From 4a36df29e518c53486e871e67c04cf162662cf65 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 16 Aug 2010 14:59:23 -0700 Subject: [PATCH 194/198] DG IZ now the links are of button style --- app/views/requests/_request.html.haml | 6 +++--- app/views/requests/index.html.haml | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/views/requests/_request.html.haml b/app/views/requests/_request.html.haml index 6c8bb7307..e29b45bc5 100644 --- a/app/views/requests/_request.html.haml +++ b/app/views/requests/_request.html.haml @@ -2,7 +2,7 @@ $(document).ready(function(){ $(".group_selector").change( function() { var id = $(this).children(":selected").val(); - $(this).parent().children(".accept").html( "Accept"); + $(this).parent().children(".accept").html( "Accept"); }); }); @@ -16,6 +16,6 @@ %select{ :class => "group_selector", :style=>"display:inline;"} - for group in current_user.groups %option{:value => group.id}= group.name - %li.accept= button_to 'Accept', request_path(request, :accept => true), :method => :delete - %li.ignore= button_to 'Ignore', request_path(request), :confirm => 'Are you sure?', :method => :delete + %li.accept= link_to 'Accept', request_path(request, :accept => true), :method => :delete, :class => "button" + %li.ignore= link_to 'Ignore', request_path(request), :confirm => 'Are you sure?', :method => :delete, :class => "button" diff --git a/app/views/requests/index.html.haml b/app/views/requests/index.html.haml index 81b84f6ab..6ba3067c5 100644 --- a/app/views/requests/index.html.haml +++ b/app/views/requests/index.html.haml @@ -3,8 +3,6 @@ = link_to "⇧ home", root_path Requests -= render "form", :request => @request - %h3= "currently #{@request_count} requests" %ul#stream - for request in @remote_requests From b0537e2f340540d316411d3d740eca08c18fea31 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 15:04:09 -0700 Subject: [PATCH 195/198] Comments pushing in the right directions --- app/models/person.rb | 9 ++++++++- app/models/user.rb | 2 +- db/seeds/tom.rb | 13 +++++++------ lib/diaspora/websocket.rb | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 7e0c2d3bb..9a0723233 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -66,7 +66,14 @@ class Person raise "must comment on something!" unless options[:on] c = Comment.new(:person_id => self.id, :text => text, :post => options[:on]) if c.save + begin dispatch_comment c + rescue Exception => e + puts e.inspect + raise e + end + + c.socket_to_uid owner.id if owner_id true else @@ -77,7 +84,7 @@ class Person def dispatch_comment( c ) if owns? c.post - push_downstream + c.push_downstream elsif owns? c c.push_upstream end diff --git a/app/models/user.rb b/app/models/user.rb index d20c48bdb..16a58862e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -174,7 +174,7 @@ class User Rails.logger.debug("Saving object: #{object}") object.save object.socket_to_uid( id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object)) - object.person.dispatch_comment object if object.is_a?(Comment) + dispatch_comment object if object.is_a?(Comment) && !owns?(object) end end diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index d3aa7289b..c8b1d41a6 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -1,23 +1,24 @@ require 'config/environment' +remote_url = "http://tom.joindiaspora.com/" # Create seed user -user = User.create( :email => "tom@tom.joindiaspora.com", +user = User.create!( :email => "tom@tom.joindiaspora.com", :password => "evankorth", :person => Person.new( :email => "tom@tom.joindiaspora.com", - :url => "http://tom.joindiaspora.com/", + :url => remote_url, :profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" )) ) -user.person.save +user.person.save! -user2 = User.create( :email => "korth@tom.joindiaspora.com", +user2 = User.create!( :email => "korth@tom.joindiaspora.com", :password => "evankorth", :person => Person.new( :email => "korth@tom.joindiaspora.com", - :url => "http://tom.joindiaspora.com/", + :url => remote_url, :profile => Profile.new( :first_name => "Evan", :last_name => "Korth"))) -user2.person.save +user2.person.save! # friending users group = user.group(:name => "other dudes") diff --git a/lib/diaspora/websocket.rb b/lib/diaspora/websocket.rb index fcdcc9744..bfbc69c26 100644 --- a/lib/diaspora/websocket.rb +++ b/lib/diaspora/websocket.rb @@ -21,7 +21,7 @@ module Diaspora end def self.unsubscribe(uid,sid) - Rails.logger.debug "Unsubscribing socket #{sid} from #{User.first(:id => uid).email}" + Rails.logger.debug "Unsubscribing socket #{sid} from #{uid}" @channels[uid][0].unsubscribe(sid) if @channels[uid] @channels[uid][1] -= 1 if @channels[uid][1] <= 0 From 33ed838b79d0f6356d300e89f0e6e01c35005206 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 16 Aug 2010 15:08:05 -0700 Subject: [PATCH 196/198] DG IZ added an error message on request delete --- app/controllers/requests_controller.rb | 12 ++++++++---- app/views/requests/_request.html.haml | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index fd6cfc74f..22f133e1d 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -8,10 +8,14 @@ class RequestsController < ApplicationController def destroy if params[:accept] - @friend = current_user.accept_and_respond( params[:id], params[:group_id]) - - flash[:notice] = "you are now friends" - redirect_to root_url + + if params[:group_id] + @friend = current_user.accept_and_respond( params[:id], params[:group_id]) + + flash[:notice] = "you are now friends" + redirect_to root_url + else + flash[:error] = "please select a group!" else current_user.ignore_friend_request params[:id] flash[:notice] = "ignored friend request" diff --git a/app/views/requests/_request.html.haml b/app/views/requests/_request.html.haml index e29b45bc5..3cd2c398f 100644 --- a/app/views/requests/_request.html.haml +++ b/app/views/requests/_request.html.haml @@ -14,6 +14,8 @@ %ul.request_buttons %select{ :class => "group_selector", :style=>"display:inline;"} + %option Add to group + %option - for group in current_user.groups %option{:value => group.id}= group.name %li.accept= link_to 'Accept', request_path(request, :accept => true), :method => :delete, :class => "button" From 6bb8c52dc491dca0b714982484c66ae87580270c Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 15:16:29 -0700 Subject: [PATCH 197/198] Syntax error in requests --- app/controllers/requests_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 22f133e1d..147672057 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -16,6 +16,7 @@ class RequestsController < ApplicationController redirect_to root_url else flash[:error] = "please select a group!" + end else current_user.ignore_friend_request params[:id] flash[:notice] = "ignored friend request" From 16a4cbc4e22f603506879a064b3c7bbbeee5119e Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 16 Aug 2010 15:21:45 -0700 Subject: [PATCH 198/198] DG IZ redirect to requests on error --- app/controllers/requests_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 147672057..f5c73660f 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -16,6 +16,7 @@ class RequestsController < ApplicationController redirect_to root_url else flash[:error] = "please select a group!" + redirect_to requests_url end else current_user.ignore_friend_request params[:id]