diff --git a/Gemfile b/Gemfile index 70a944119..4e8b65d55 100644 --- a/Gemfile +++ b/Gemfile @@ -60,7 +60,7 @@ group :test do gem 'rspec-rails', '>= 2.0.0' gem 'mocha' gem 'database_cleaner', '0.5.2' - gem 'webmock' + gem 'webmock', :require => false gem 'jasmine', :path => 'vendor/gems/jasmine', :require => false gem 'mongrel', :require => false if RUBY_VERSION.include? "1.8" end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3e32d4c27..2ab2838c2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -35,7 +35,6 @@ class ApplicationController < ActionController::Base end def set_locale - I18n.default_locale = DEFAULT_LANGUAGE if current_user I18n.locale = current_user.language else diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 6887e4bee..9f2942f6c 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -18,13 +18,13 @@ class AspectsController < ApplicationController end def create - @aspect = current_user.aspect(params[:aspect]) + @aspect = current_user.aspects.create(params[:aspect]) if @aspect.valid? flash[:notice] = I18n.t('aspects.create.success') respond_with @aspect else flash[:error] = I18n.t('aspects.create.failure') - redirect_to aspects_manage_path + redirect_to :back end end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 89ed4bc9a..ea56ed81b 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -56,7 +56,7 @@ class PeopleController < ApplicationController end # upload and set new profile photo - if params[:person][:profile][:image] + if params[:person][:profile][:image].present? raw_image = params[:person][:profile].delete(:image) params[:profile_image_hash] = { :user_file => raw_image, :to => "all" } diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index a5c018af2..92bda1a36 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -13,9 +13,7 @@ class StatusMessagesController < ApplicationController public_flag.to_s.match(/(true)/) ? public_flag = true : public_flag = false params[:status_message][:public] = public_flag - data = clean_hash params[:status_message] - message = params[:status_message][:message] - status_message = current_user.post(:status_message, data) + status_message = current_user.post(:status_message, params[:status_message]) render :nothing => true end @@ -29,13 +27,4 @@ class StatusMessagesController < ApplicationController @status_message = current_user.find_visible_post_by_id params[:id] respond_with @status_message end - - private - def clean_hash(params) - return { - :message => params[:message], - :to => params[:to], - :public => params[:public] - } - end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 36f31c6b8..b5e11f86a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -79,6 +79,11 @@ class UsersController < ApplicationController @step = ((params[:step].to_i>0)&&(params[:step].to_i<5)) ? params[:step].to_i : 1 @step ||= 1 + + if @step == 4 + @user.getting_started = false + @user.save + end render "users/getting_started" end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9cb502908..0060f0156 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -34,7 +34,7 @@ module ApplicationHelper end def how_long_ago(obj) - "#{time_ago_in_words(obj.created_at)} ago" + "#{time_ago_in_words(obj.created_at)} #{t('ago')}" end def person_url(person) diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb index 86bef13fa..eba28dd5f 100644 --- a/app/helpers/sockets_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -21,12 +21,9 @@ module SocketsHelper action_hash.merge! opts if object.is_a? Photo 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 - if object.person.owner_id == uid + if object.person && object.person.owner_id == uid action_hash[:mine?] = true end diff --git a/app/models/aspect.rb b/app/models/aspect.rb index 5758f49c4..1e3382250 100644 --- a/app/models/aspect.rb +++ b/app/models/aspect.rb @@ -29,11 +29,6 @@ class Aspect name end - def posts_by_person_id( id ) - id = id.to_id - posts.detect{|x| x.person.id == id } - end - def person_objects person_ids = people.map{|x| x.person_id} Person.all(:id.in => person_ids) diff --git a/app/models/person.rb b/app/models/person.rb index 63da72145..53f9b3afe 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -23,6 +23,7 @@ class Person one :profile, :class_name => 'Profile' validates_associated :profile + delegate :first_name, :last_name, :to => :profile before_save :downcase_diaspora_handle def downcase_diaspora_handle diff --git a/app/models/photo.rb b/app/models/photo.rb index d60bd3645..bce9d469d 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -29,9 +29,9 @@ class Photo < Post validates_with PhotoAlbumValidator - before_destroy :ensure_user_picture + attr_accessible :caption - attr_protected :person + before_destroy :ensure_user_picture def self.instantiate(params = {}) image_file = params.delete(:user_file) diff --git a/app/models/post.rb b/app/models/post.rb index 5b49dacd5..298d25b5f 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -32,11 +32,12 @@ class Post before_destroy :propogate_retraction after_destroy :destroy_comments + attr_accessible :user_refs def self.instantiate params new_post = self.new params.to_hash new_post.person = params[:person] new_post.public = params[:public] - new_post.save + new_post.diaspora_handle = new_post.person.diaspora_handle new_post end diff --git a/app/models/profile.rb b/app/models/profile.rb index 8848cd823..d69c64e12 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -8,13 +8,13 @@ class Profile include Diaspora::Webhooks include ROXML - xml_reader :person_id xml_reader :first_name xml_reader :last_name xml_reader :image_url xml_reader :birthday xml_reader :gender xml_reader :bio + xml_accessor :diaspora_handle key :first_name, String key :last_name, String @@ -22,19 +22,23 @@ class Profile key :birthday, Date key :gender, String key :bio, String + key :diaspora_handle, String after_validation :strip_names + validates_length_of :first_name, :maximum => 32 + validates_length_of :last_name, :maximum => 32 before_save :strip_names - def person_id - self._parent_document.id - end - def person self._parent_document end + def diaspora_handle + #get the parent diaspora handle, unless we want to access a profile without a person + (self._parent_document) ? self.person.diaspora_handle : self[:diaspora_handle] + end + protected def strip_names diff --git a/app/models/request.rb b/app/models/request.rb index 2226a7b45..cba28cdef 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -9,18 +9,18 @@ class Request include Diaspora::Webhooks include ROXML - xml_accessor :_id - xml_accessor :person, :as => Person - xml_accessor :destination_url - xml_accessor :callback_url - xml_accessor :exported_key, :cdata => true + xml_reader :_id + xml_reader :diaspora_handle + xml_reader :destination_url + xml_reader :callback_url - key :person_id, ObjectId - key :aspect_id, ObjectId + key :aspect_id, ObjectId key :destination_url, String key :callback_url, String key :exported_key, String + key :diaspora_handle, String + belongs_to :person validates_presence_of :destination_url, :callback_url @@ -30,15 +30,13 @@ class Request person = options[:from] self.new(:destination_url => options[:to], :callback_url => person.receive_url, - :person => person, - :exported_key => person.exported_key, - :aspect_id => options[:into]) + :diaspora_handle => person.diaspora_handle, + :aspect_id => options[:into]) end def reverse_for accepting_user - self.person = accepting_user.person - self.exported_key = accepting_user.exported_key - self.destination_url = self.callback_url + self.diaspora_handle = accepting_user.diaspora_handle + self.destination_url = self.callback_url self.save end diff --git a/app/models/retraction.rb b/app/models/retraction.rb index 10b055a38..9f1db49e0 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -7,12 +7,13 @@ class Retraction include Diaspora::Webhooks xml_accessor :post_id - xml_accessor :person_id + xml_accessor :diaspora_handle xml_accessor :type attr_accessor :post_id - attr_accessor :person_id + attr_accessor :diaspora_handle attr_accessor :type + attr_accessor :person def self.for(object) retraction = self.new @@ -23,12 +24,16 @@ class Retraction retraction.post_id = object.id retraction.type = object.class.to_s end - retraction.person_id = person_id_from(object) + retraction.diaspora_handle = object.diaspora_handle retraction end def perform receiving_user_id Rails.logger.debug "Performing retraction for #{post_id}" + unless Post.first(:diaspora_handle => person.diaspora_handle, :id => post_id) + raise "#{person.inspect} is trying to retract a post they do not own" + end + begin Rails.logger.debug("Retracting #{self.type} id: #{self.post_id}") target = self.type.constantize.first(:id => self.post_id) @@ -38,13 +43,4 @@ class Retraction Rails.logger.info("Retraction for unknown type recieved.") end end - - def self.person_id_from(object) - object.is_a?(Person) ? object.id : object.person.id - end - - def person - Person.find_by_id(self.person_id) - end - end diff --git a/app/models/status_message.rb b/app/models/status_message.rb index 093316659..d67bba6fb 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -11,6 +11,8 @@ class StatusMessage < Post key :message, String validates_presence_of :message + attr_accessible :message + def to_activity <<-XML @@ -24,9 +26,5 @@ class StatusMessage < Post XML end - - def latest_hash - { :text => message} - end end diff --git a/app/models/user.rb b/app/models/user.rb index 9a077bd40..bb465e78a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -40,8 +40,11 @@ class User validates_presence_of :username validates_uniqueness_of :username, :case_sensitive => false validates_format_of :username, :with => /\A[A-Za-z0-9_.]+\z/ - validates_presence_of :person, :unless => proc {|user| user.invitation_token.present?} + validates_length_of :username, :maximum => 32 + validates_inclusion_of :language, :in => AVAILABLE_LANGUAGE_CODES + + validates_presence_of :person, :unless => proc {|user| user.invitation_token.present?} validates_associated :person one :person, :class_name => 'Person', :foreign_key => :owner_id @@ -85,13 +88,6 @@ class User end ######### Aspects ###################### - def aspect(opts = {}) - aspect = Aspect.new(opts) - aspect.user = self - aspect.save - aspect - end - def drop_aspect(aspect) if aspect.people.size == 0 aspect.destroy @@ -149,6 +145,7 @@ class User aspect_ids = validate_aspect_permissions(aspect_ids) post = build_post(class_name, options) + post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid) push_to_aspects(post, aspect_ids) @@ -205,9 +202,11 @@ class User model_class = class_name.to_s.camelize.constantize post = model_class.instantiate(options) - post.save - self.raw_visible_posts << post - self.save + if post.save + raise 'MongoMapper failed to catch a failed save' unless post.id + self.raw_visible_posts << post + self.save + end post end @@ -417,8 +416,8 @@ class User end def seed_aspects - aspect(:name => "Family") - aspect(:name => "Work") + self.aspects.create(:name => "Family") + self.aspects.create(:name => "Work") end def diaspora_handle diff --git a/app/views/albums/edit.html.haml b/app/views/albums/edit.html.haml index ccc5854fd..81da980e0 100644 --- a/app/views/albums/edit.html.haml +++ b/app/views/albums/edit.html.haml @@ -16,10 +16,10 @@ .photo_edit_block= image_tag photo.url(:thumb_medium) .submit_block - = link_to t('.cancel'), root_path + = link_to t('cancel'), root_path or = album.submit t('.update_album') .button.delete - = link_to t('.delete_album'), @album, :confirm => t('.are_you_sure'), :method => :delete + = link_to t('.delete_album'), @album, :confirm => t('are_you_sure'), :method => :delete diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index f997d91af..267b43bc1 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -42,5 +42,5 @@ .album_id{:id => @album_id, :style => "display:hidden;"} -unless current_user.person.id == @person.id - %h4= "#{t('.by')} #{@person.real_name}" + %h4= "#{t('by')} #{@person.real_name}" diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml index 54612d7e4..9dcff29ba 100644 --- a/app/views/comments/_comment.html.haml +++ b/app/views/comments/_comment.html.haml @@ -9,4 +9,4 @@ = link_to post.person.real_name, post.person = post.text %div.time - = "#{time_ago_in_words(post.updated_at)} #{t('.ago')}" + = "#{time_ago_in_words(post.updated_at)} #{t('ago')}" diff --git a/app/views/comments/_new_comment.html.haml b/app/views/comments/_new_comment.html.haml index bb8719ee7..b7c1fbbf4 100644 --- a/app/views/comments/_new_comment.html.haml +++ b/app/views/comments/_new_comment.html.haml @@ -4,7 +4,7 @@ = form_for Comment.new, :remote => true do |comment| %p - = label_tag "comment_text_on_#{post.id}", "Comment" + = label_tag "comment_text_on_#{post.id}", t('.comment') = comment.text_area :text, :rows => 1, :id => "comment_text_on_#{post.id}", :class => "comment_box" = comment.hidden_field :post_id, :value => post.id diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 15c29ec4f..595fba52d 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -5,13 +5,13 @@ = form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| #user %p.username - = f.label :username , t('.username') + = f.label :username , t('username') = f.text_field :username %p.user_network ="@#{APP_CONFIG[:terse_pod_url]}" %p - = f.label :password , t('.password') + = f.label :password , t('password') = f.password_field :password /%p /- if devise_mapping.rememberable? diff --git a/app/views/invitations/_new.haml b/app/views/invitations/_new.haml index 77b07faa2..b63184327 100644 --- a/app/views/invitations/_new.haml +++ b/app/views/invitations/_new.haml @@ -1,20 +1,23 @@ .span-12.last .modal_title_bar - %h4 Invite someone to join Diaspora! + %h4 + = t('.invite_someone_to_join') - %i if they accept, they will be added to the aspect you invited them + %i + = t('.if_they_accept_info') = form_for User.new, :url => invitation_path(User) do |invite| %p - = invite.label :email + = invite.label :email , t('email') = invite.text_field :email - To + = t('.to') - unless @aspect.is_a? Aspect = invite.select(:aspects, @aspects_dropdown_array) - else = invite.select(:aspects, @aspects_dropdown_array, :selected => @aspect.id) - Message: + = t('.message') + = invite.text_area :invite_messages, :value => "" - %p= invite.submit "Send an invitation" + %p= invite.submit t('.send_an_invitation') diff --git a/app/views/invitations/new.html.haml b/app/views/invitations/new.html.haml index 598b16a3d..b22e1f0c2 100644 --- a/app/views/invitations/new.html.haml +++ b/app/views/invitations/new.html.haml @@ -1,8 +1,9 @@ -%h2 Send invitation +%h2 + = t('.send_invitation') = form_for User.new, :url => invitation_path(User) do |f| = devise_error_messages! %p - = f.label :email + = f.label :email , t('email') = f.text_field :email - %p= f.submit "Send an invitation" + %p= f.submit t('.send_an_invitation') /= link_to "Home", after_sign_in_path_for(resource_name) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index c8c0448cc..70f610ebc 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -44,7 +44,7 @@ %header .container{:style => "position:relative;"} #diaspora_text{:href => root_path} - = link_to "DIASPORA*", (current_user ? root_path : new_user_session_path) + = link_to "DIASPORA", (current_user ? root_path : new_user_session_path) %span.sub_text PREVIEW diff --git a/app/views/people/edit.html.haml b/app/views/people/edit.html.haml index f9aaab68c..d3b8b135d 100644 --- a/app/views/people/edit.html.haml +++ b/app/views/people/edit.html.haml @@ -5,18 +5,18 @@ #section_header %h2 - = t('.settings') + = t('settings') %ul#settings_nav - %li=link_to t('.profile'), edit_person_path(current_user.person) - %li=link_to t('.account'), edit_user_path(current_user) - %li=link_to t('.services'), services_path + %li=link_to t('profile'), edit_person_path(current_user.person) + %li=link_to t('account'), edit_user_path(current_user) + %li=link_to t('services'), services_path .span-19.prepend-5.last = form_for @person, :html => { :multipart => true } do |person| %h3 = t('.your_profile') .description - This info will be available to whomever you connect with on Diaspora. + =t('.info_available_to') = person.error_messages @@ -45,6 +45,6 @@ = render 'people/profile_photo_upload', :form => profile .submit_block - = link_to t('.cancel'), edit_user_path(current_user) - = t('.or') + = link_to t('cancel'), edit_user_path(current_user) + = t('or') = person.submit t('.update_profile') diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index 022955032..fd8bedee1 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -28,11 +28,11 @@ %li= link_to aspect.name, aspect - if @person != current_user.person && @contact - = link_to t('.remove_friend'), @person, :confirm => t('.are_you_sure'), :method => :delete, :class => "button" + = link_to t('.remove_friend'), @person, :confirm => t('are_you_sure'), :method => :delete, :class => "button" - if @person == current_user.person %b - = link_to "Edit my profile", edit_person_path(@person) + = link_to t('.edit_my_profile'), edit_person_path(@person) %br %br diff --git a/app/views/photos/_photo.haml b/app/views/photos/_photo.haml index 9e878b510..a122614aa 100644 --- a/app/views/photos/_photo.haml +++ b/app/views/photos/_photo.haml @@ -20,7 +20,7 @@ - if current_user.owns?(post) .right - = link_to t('.delete'), photo_path(post), :confirm => t('.are_you_sure'), :method => :delete, :remote => true, :class => "delete" + = link_to t('delete'), photo_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete" - if !post.album_id.nil? =t('.posted_a_new_photo_to') diff --git a/app/views/photos/edit.html.haml b/app/views/photos/edit.html.haml index 08e6dae0a..dcdebab1c 100644 --- a/app/views/photos/edit.html.haml +++ b/app/views/photos/edit.html.haml @@ -19,5 +19,5 @@ = link_to "⇧ #{@album.name}", album_path(@album) -if current_user.owns? @album .button.right - = link_to t('.delete_photo'), @photo, :confirm => t('.are_you_sure'), :method => :delete + = link_to t('.delete_photo'), @photo, :confirm => t('are_you_sure'), :method => :delete diff --git a/app/views/registrations/edit.html.haml b/app/views/registrations/edit.html.haml index 5da950379..9cadd779f 100644 --- a/app/views/registrations/edit.html.haml +++ b/app/views/registrations/edit.html.haml @@ -24,5 +24,5 @@ = f.submit t('.update') %h3 t('.cancel_my_account') %p - Unhappy? #{link_to t('.cancel_my_account'), registration_path(resource_name), :confirm => t('.are_you_sure'), :method => :delete}. + Unhappy? #{link_to t('.cancel_my_account'), registration_path(resource_name), :confirm => t('are_you_sure'), :method => :delete}. = link_to t('.back'), :back diff --git a/app/views/registrations/new.html.haml b/app/views/registrations/new.html.haml index 8dae3824a..41423e55e 100644 --- a/app/views/registrations/new.html.haml +++ b/app/views/registrations/new.html.haml @@ -5,16 +5,16 @@ = image_tag "http://needcoffee.cachefly.net/needcoffee/uploads/2009/02/predator-arnold-schwarzenegger.jpg" = form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %p - = f.label :username , t('.username') + = f.label :username , t('username') = f.text_field :username %p - = f.label :email , t('.email') + = f.label :email , t('email') = f.text_field :email %p - = f.label :password , t('.password') + = f.label :password , t('password') = f.password_field :password %p - = f.label :password_confirmation , t('.password_confirmation') + = f.label :password_confirmation , t('password_confirmation') = f.password_field :password_confirmation = f.submit t('.sign_up') diff --git a/app/views/services/index.html.haml b/app/views/services/index.html.haml index bf1546172..5d5a3b772 100644 --- a/app/views/services/index.html.haml +++ b/app/views/services/index.html.haml @@ -4,15 +4,15 @@ #section_header %h2 - = t('.settings') + = t('settings') %ul#settings_nav - %li=link_to t('.profile'), edit_person_path(current_user.person) - %li=link_to t('.account'), edit_user_path(current_user) - %li=link_to t('.services'), services_path + %li=link_to t('profile'), edit_person_path(current_user.person) + %li=link_to t('account'), edit_user_path(current_user) + %li=link_to t('services'), services_path .span-19.prepend-5.last %h2 - = t('.services') + = t('services') %ul - for service in @services diff --git a/app/views/shared/_invitations.haml b/app/views/shared/_invitations.haml index 40476eae7..8ef2ba877 100644 --- a/app/views/shared/_invitations.haml +++ b/app/views/shared/_invitations.haml @@ -1,6 +1,7 @@ -%h4 Invites -= link_to "Invite a friend", "#invite_user_pane", :class => "invite_user_button", :title => "Invite a friend" -= "(#{invites} left)" +%h4 + = t('.invites') += link_to t('.invite_a_friend'), "#invite_user_pane", :class => "invite_user_button", :title => "Invite a friend" += t('.invitations_left', :count => invites) %br .yo{ :style => "display:none;"} #invite_user_pane diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 6499b01f3..94f7737d7 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -26,7 +26,7 @@ = form_for StatusMessage.new, :remote => true do |status| = status.error_messages %p - = status.label :message, "Post a message to #{aspect}" + = status.label :message, t('.post_a_message_to', :aspect => aspect) = status.text_area :message, :rows => 2, :value => params[:prefill] = status.hidden_field :to, :value => (aspect == :all ? aspect : aspect.id) @@ -35,7 +35,7 @@ - if aspect == :all .public_toggle = status.check_box( :public, {}, true, false ) - make public + = t('.make_public') = link_to '(?)', "#question_mark_pane", :class => 'question_mark' .fancybox_content @@ -48,7 +48,7 @@ = status.submit t('.share'), :title => "Share with #{aspect}" #publisher_photo_upload - or + = t('or') = render 'photos/new_photo', :aspect_id => (aspect == :all ? aspect : aspect.id), :album_id => nil diff --git a/app/views/shared/_reshare.haml b/app/views/shared/_reshare.haml index 44c8f00dd..a479dddef 100644 --- a/app/views/shared/_reshare.haml +++ b/app/views/shared/_reshare.haml @@ -5,7 +5,7 @@ - unless current_user.aspects.size == current_user.aspects_with_post(post.id).size .reshare_pane %span.reshare_button - = link_to "Reshare", "#" + = link_to t('.reshare'), "#" %ul.reshare_box - for aspect in current_user.aspects @@ -14,4 +14,4 @@ - else .reshare_pane %span.reshare_button - = link_to "Reshare", "#", :class => "inactive" + = link_to t('.reshare'), "#", :class => "inactive" diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index 7e065b475..f78f4d405 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -21,7 +21,7 @@ - if current_user.owns?(post) .right = render "shared/reshare", :post => post, :current_user => current_user - = link_to t('.delete'), status_message_path(post), :confirm => t('.are_you_sure'), :method => :delete, :remote => true, :class => "delete" + = link_to t('delete'), status_message_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete" = make_links(post.message) diff --git a/app/views/status_messages/show.html.haml b/app/views/status_messages/show.html.haml index 0672ca1e8..8ab8d3a35 100644 --- a/app/views/status_messages/show.html.haml +++ b/app/views/status_messages/show.html.haml @@ -13,7 +13,7 @@ - if current_user.owns? @status_message %p - = link_to t('.destroy'), @status_message, :confirm => t('.are_you_sure'), :method => :delete + = link_to t('.destroy'), @status_message, :confirm => t('are_you_sure'), :method => :delete .span-9.last #stream.show diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 23fae0742..634729a83 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -14,15 +14,15 @@ #section_header %h2 - = t('.settings') + = t('settings') %ul#settings_nav - %li=link_to t('.profile'), edit_person_path(current_user.person) - %li=link_to t('.account'), edit_user_path(current_user) - %li=link_to t('.services'), services_path + %li=link_to t('profile'), edit_person_path(current_user.person) + %li=link_to t('account'), edit_user_path(current_user) + %li=link_to t('services'), services_path .span-19.prepend-5.last %h2 - = t('.account') + = t('account') = link_to t('.invite_friends'), new_user_invitation_path(current_user) @@ -39,12 +39,12 @@ = f.label :password, t('.new_password') = f.password_field :password %p - = f.label :password_confirmation, t('.password_confirmation') + = f.label :password_confirmation, t('password_confirmation') = f.password_field :password_confirmation .submit_block - = link_to t('.cancel'), edit_user_path(current_user) - or + = link_to t('cancel'), edit_user_path(current_user) + = t('or') = f.submit t('.change_password') %h3 @@ -70,5 +70,5 @@ %h3 = t('.close_account') = link_to t('.close_account'), current_user, - :confirm => t('.are_you_sure'), :method => :delete, + :confirm => t('are_you_sure'), :method => :delete, :class => "button" diff --git a/app/views/users/getting_started.html.haml b/app/views/users/getting_started.html.haml index 5edb3e67a..c90a3fadd 100644 --- a/app/views/users/getting_started.html.haml +++ b/app/views/users/getting_started.html.haml @@ -30,7 +30,7 @@ %h1{:style => "text-align:right;"} = "Welcome to Diaspora!" .description - Do the stuff below to further complete some things. + =t('.signup_steps') %h3{:style => "text-align:right;"} = link_to "Edit your profile", getting_started_path(:step => 1) diff --git a/app/views/users/getting_started/_step_2.html.haml b/app/views/users/getting_started/_step_2.html.haml index bed14bd33..eb944cd62 100644 --- a/app/views/users/getting_started/_step_2.html.haml +++ b/app/views/users/getting_started/_step_2.html.haml @@ -10,7 +10,7 @@ %h4 Aspect name - - form_for Aspect.new, :remote => true, :format => :json do |aspect| + = form_for Aspect.new, :remote => true, :format => :json do |aspect| = aspect.text_field :name, :style => "display:inline;" = aspect.submit "Add" diff --git a/app/views/users/getting_started/_step_4.html.haml b/app/views/users/getting_started/_step_4.html.haml index b5ca7b274..fed321aea 100644 --- a/app/views/users/getting_started/_step_4.html.haml +++ b/app/views/users/getting_started/_step_4.html.haml @@ -3,14 +3,6 @@ -# the COPYRIGHT file. -- if current_user.getting_started == true - :javascript - $.ajax({ - type: "PUT", - url: "/users/#{current_user.id}", - data: {"user":{"getting_started":'false'}} - }) - %h1 = "You're all set up, #{current_user.person.profile.first_name}!" .description diff --git a/chef/cookbooks/centos/recipes/bootstrap.rb b/chef/cookbooks/centos/recipes/bootstrap.rb index bf7b5da36..b3bc9a522 100644 --- a/chef/cookbooks/centos/recipes/bootstrap.rb +++ b/chef/cookbooks/centos/recipes/bootstrap.rb @@ -6,4 +6,20 @@ execute "nokogiri deps" do end execute "eventmachine deps" do command "yum install -y gcc-c++" -end \ No newline at end of file +end + +def harden_ruby(ruby_string) + Dir.glob("/usr/local/rvm/wrappers/#{ruby_string}/*").each do |file| + link "/usr/local/bin/#{file.split('/').last}" do + to file + end + end + Dir.glob("/usr/local/rvm/gems/#{ruby_string}/bin/*").each do |file| + link "/usr/local/bin/#{file.split('/').last}" do + to file + end + end + +end + +harden_ruby("ruby-1.8.7-p302") \ No newline at end of file diff --git a/config/initializers/_load_app_config.rb b/config/initializers/_load_app_config.rb index 723e38525..b66b0c8f9 100644 --- a/config/initializers/_load_app_config.rb +++ b/config/initializers/_load_app_config.rb @@ -23,4 +23,4 @@ end APP_CONFIG[:terse_pod_url] = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '') APP_CONFIG[:terse_pod_url].chop! if APP_CONFIG[:terse_pod_url][-1, 1] == '/' -puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" if APP_CONFIG[:terse_pod_url] == "example.org" && Rails.env != :test +puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" if APP_CONFIG[:terse_pod_url] == "example.org" && Rails.env != "test" diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb index 08d3923b0..5d4a53a61 100644 --- a/config/initializers/locale.rb +++ b/config/initializers/locale.rb @@ -4,4 +4,8 @@ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] -I18n.default_locale = :en +I18n.default_locale = DEFAULT_LANGUAGE +I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) +AVAILABLE_LANGUAGE_CODES.each do |c| + I18n.fallbacks[c.to_sym] = [c.to_sym, DEFAULT_LANGUAGE.to_sym, :en] +end \ No newline at end of file diff --git a/config/locales/devise/devise.fr.yml b/config/locales/devise/devise.fr.yml index d549c2931..ce99a0b6a 100644 --- a/config/locales/devise/devise.fr.yml +++ b/config/locales/devise/devise.fr.yml @@ -15,6 +15,11 @@ fr: timeout: 'Votre session a expiré, veuillez vous connecter de nouveau afin de continuer.' inactive: 'Votre compte n’a pas encore été activé.' sessions: + new: + login: 'Se connecter' + username: "Nom d'utilisateur" + password: 'Mot de passe' + sign_in: 'Connexion' signed_in: 'Connecté avec succès.' signed_out: 'Déconnecté avec succès.' passwords: @@ -43,4 +48,9 @@ fr: subject: 'Instructions de déverrouillage' invitation: subject: 'Un ami souhaite que vous rejoigniez Diaspora !' + shared: + links: + sign_in: 'Connexion' + sign_up: 'Inscription' + forgot_your_password: 'Mot de passe oublié ?' diff --git a/config/locales/devise/devise.sv.yml b/config/locales/devise/devise.sv.yml index 0366d0c49..419d90deb 100644 --- a/config/locales/devise/devise.sv.yml +++ b/config/locales/devise/devise.sv.yml @@ -8,6 +8,7 @@ sv: errors: messages: not_found: "kan ej hitta" + already_confirmed: "är redan bekräftad" not_locked: "var ej låst" devise: @@ -15,11 +16,16 @@ sv: unauthenticated: 'Du måste logga in innan du kan fortsätta.' unconfirmed: 'Du måste verifiera ditt konto innan du kan fortsätta.' locked: 'Ditt konto är låst.' - invalid: 'Felaktig användare eller lösenord.' + invalid: 'Felaktigt användarnamn eller lösenord.' invalid_token: 'Ogiltig identifiering.' timeout: 'Din session är avslutad, var vänlig logga in igen.' inactive: 'Ditt konto är inte aktiverat.' sessions: + new: + login: 'Logga in' + username: 'Användarnamn' + password: 'Lösenord' + sign_in: 'Logga in' signed_in: 'Inloggning ok.' signed_out: 'Utloggning ok.' passwords: @@ -40,6 +46,16 @@ sv: invitation_token_invalid: 'Denna inbjudan är ej giltig!' updated: 'Ditt lösenord är nu inställt och du är inloggad.' mailer: - confirmation_instructions: 'Instruktioner för att verifiera ditt konto.' - reset_password_instructions: 'Instruktioner för att återställa ditt lösenord.' - unlock_instructions: 'Instruktioner för att låsa upp ditt konto.' + confirmation_instructions: + subject: 'Instruktioner för att verifiera ditt konto.' + reset_password_instructions: + subject: 'Instruktioner för att återställa ditt lösenord.' + unlock_instructions: + subject: 'Instruktioner för att låsa upp ditt konto.' + invitation: + subject: 'En vän vill att du ska gå med i Diaspora!' + shared: + links: + sign_in: 'Logga in' + sign_up: 'Registrera dig' + forgot_your_password: 'Glömt ditt lösenord?' diff --git a/config/locales/diaspora/ar.yml b/config/locales/diaspora/ar.yml index 87522287a..6e9d7700e 100644 --- a/config/locales/diaspora/ar.yml +++ b/config/locales/diaspora/ar.yml @@ -5,18 +5,18 @@ # Sample localization file for Arabic. ar: - hello: "مرحبا العالم" + hello: "مرحبا" application: helper: - unknown_person: "غير معروف شخص" + unknown_person: "شخص غير معروف" new_requests: "طلبات جديدة" dashboards: helper: - home: "منزل" + home: "الرئيسية" error_messages: helper: - invalid_fields: "الحقول غير صالحة" - correct_the_following_errors_and_try_again: ".تصحيح الأخطاء التالية وحاول مرة أخرى" + invalid_fields: "مدخلات غير صحيحة" + correct_the_following_errors_and_try_again: ".صحح الأخطاء التالية وحاول مرة أخرى" people: helper: results_for: "%{params} نتائج " @@ -34,39 +34,39 @@ ar: all_aspects: "جميع الجوانب" manage_aspects: "إدارة الجوانب" publisher: - share: "تقاسم" + share: "مشاركة" aspect_friends: add_friends: "أضف أصدقاء" albums: album: you: "أنت" new_album: - create: "خلق" - add_a_new_album: "إضافة ألبوم جديد" + create: "جديد" + add_a_new_album: "أضف ألبوم جديد" show: edit_album: "تعديل الألبوم" albums: "البومات" updated: "تحديث" by: "بواسطة" edit: - editing: "التحرير" - updated: "تحديث" + editing: "تحرير" + updated: "محدث" are_you_sure: "هل أنت متأكد؟" delete_album: "حذف ألبوم" cancel: "إلغاء" index: - home: "منزل" + home: "الرئيسية" new_album: "ألبوم جديد" create: - success: ".ألبوما %{name} لقد قمت دعا" + success: " .%{name} لقد قمت بإنشاء ألبوم بإسم" update: - success: ".تحرير بنجاح %{name} الألبوم" + success: ".بنجاح %{name} تم تحرير ألبوم" failure: ".%{name} فشلت في تحرير ألبوم" destroy: - success: ".حذفها %{name} الألبوم" + success: ".%{name} تم حذف ألبوم" helper: - friends_albums: "أصدقاء البومات" - your_albums: "البومات الخاص" + friends_albums: "ألبومات الأصدقاء" + your_albums: "البوماتك" aspects: index: photos: "صور" @@ -81,23 +81,23 @@ ar: ignore_remove: "تجاهل/إزالة" new_aspect: add_a_new_aspect: "أضف جانبا جديدا" - create: "خلق" + create: "جديد" create: - success: ".الذي يمكن أن نرى الجانب الجديد الخاص بك Diaspora انقر على علامة الجمع على الجانب الأيسر لنقو" + success: ".من الذي يمكنه مشاهدة مظهرك الجديد Diaspora انقر على علامة الزائد على الجانب الأيسر لتقول ل" failure: ".فشل إنشاء الجانب" destroy: - success: ".%{name} وقد نجحت في إزالة" + success: ".بنجاح %{name} تم إزالة" update: - success: ".تحرير بنجاح ,%{name} ,وقد الجانب الخاص بك" + success: ".بنجاح %{name} تم تعديل" move_friends: failure: ".%{real_name} فشل تحرير آسبكت لصدي" success: ".جوانب الموضوع بنجاح" move_friend: failure: "%{inspect} لم تنجح" - success: ".أنت الآن عرض صديقك جانبا مختلفا من جوانب نفسك" + success: ".تم إضافة صديقك بنجاح" helper: - remove: "نزع" - aspect_not_empty: "الجانب يست فارغ" + remove: "حذف" + aspect_not_empty: "الجانب ليس فارغ" users: edit: editing_profile: "تحرير الملف الشخصي" @@ -110,82 +110,82 @@ ar: picture: "صورة" editing_profile: "تحرير الملف الشخصي" albums: "البومات" - you_dont_have_any_photos: "ليس لديك أي صوا! نتقل إلى" - page_to_upload_some: ".الصفحة لتحميل بعض" + you_dont_have_any_photos: "ليس لديك أي صور! انتقل إلى" + page_to_upload_some: ".صفحة تحميل بعض" comments: comment: ago: "منذ" new_comment: - comment: "كيف" + comment: "تعليق" photos: show: prev: "السابق" - full_size: "الحجم الكام" + full_size: "الحجم اﻷصلي" next: "القادم" - edit_photo: "تحرير الصو" - delete_photo: "حذف الصو" + edit_photo: "تحرير الصورة" + delete_photo: "حذف الصورة" are_you_sure: "هل أنت متأكد؟" comments: "تعليقات" edit: - editing: "تصحيح" - are_you_sure: "هل أنت متأك؟" - delete_photo: "حذف الصو" + editing: "تحرير" + are_you_sure: "هل أنت متأكد؟" + delete_photo: "حذف الصورة" photo: - show_comments: "sعرض التعليقا" - posted_a_new_photo_to: "أرسلت صورة جديدة ل" + show_comments: "عرض التعليقات" + posted_a_new_photo_to: "أضفت صورة جديدة ل" new: - new_photo: "جديد الصو" - back_to_list: "عودة إلى قائم" - post_it: "!بعد ذلك" + new_photo: "صورة جديدة" + back_to_list: "عودة إلى القائمة" + post_it: "!ألصقها" create: - runtime_error: "?فشل تحميل الصور. هل أنت متأكد من أن يتم ربط حزام الأمان" - integrity_error: "?فشل تحميل الصور. هل أنت متأكد من أن صورة" - type_error: "?فشل تحميل الصور. هل أنت متأكد من وأضيف صورة" + runtime_error: "فشل تحميل الصور. هل ربطت حزام الأمان؟" + integrity_error: "فشل تحميل الصور. هل ملفك صورة؟" + type_error: "فشل تحميل الصور. هل أنت متأكد أنك أضفت صورة؟" update: - notice: ".الصورة تحديثها بنجاح" - error: ".فشل لتحرير الصو" + notice: "تم تحديث الصورة بنجاح" + error: "فشل تحرير الصورة." destroy: - notice: ".الصور المحذوفة" + notice: "تم حذف الصورة" registrations: new: - sign_up: "قم بالتسجي" + sign_up: "التسجيل" create: - success: "!Diaspora لقد انضممت" + success: "!Diaspora سجل في" status_messages: new_status_message: - tell_me_something_good: "قل لي شيئا جيد" - oh_yeah: "!نعم" + tell_me_something_good: "قل لي شيئا جيداً" + oh_yeah: "!يا سلااام" status_message: - show_comments: "عرض التعليقا" + show_comments: "عرض التعليقات" delete: "حذف" are_you_sure: "هل أنت متأكد؟" show: - status_message: "رسالة الحالة" + status_message: "الحالة" comments: "تعليقات" are_you_sure: "هل أنت متأكد؟" - destroy: "هدم" - view_all: "عرض الك" + destroy: "إزالة" + view_all: "عرض الكل" message: "رسالة" owner: "مالك" helper: - no_message_to_display: ".أي رسالة لعرضه" + no_message_to_display: "لا يوجد رسالة لعرضها" people: person: - add_friend: "أضف صدي" - pending_request: "في انتظار طلب" + add_friend: "أضف صديق" + pending_request: "طلبات معلقة" index: - add_friend: "أضف صدي" - real_name: "اسمه الحقيقي" + add_friend: "أضف صديق" + real_name: "الاسم الحقيقي" diaspora_handle: "اسمك المستعار diaspora" - thats_you: "!هذا لك" - friend_request_pending: "طلب صديق معلقة" - you_have_a_friend_request_from_this_person: "لديك صديق طلب من هذا الشخص" + thats_you: "!هذا أنت" + friend_request_pending: "طلبات صداقة معلقة" + you_have_a_friend_request_from_this_person: "لديك طلب صداقة من هذا الشخص" new: new_person: "شخص جديد" - back_to_list: "عودة إلى قائمة" + back_to_list: "عودة إلى القائمة" show: - last_seen: "%{how_long_ago} :المشاهدة الأخيرة" - friends_since: "%{how_long_ago} :أصدقاء منذ" + last_seen: "%{how_long_ago} :آخر مشاهدة" + friends_since: "%{how_long_ago} :صديق منذ" save: "حفظ" are_you_sure: "هل أنت متأكد؟" remove_friend: "إزالة صديق" @@ -194,13 +194,13 @@ ar: add_a_new_friend_to: "إضافة صديق جديد إلى" enter_a_diaspora_username: ":Diaspora أدخل اسم مستخدم" your_diaspora_username_is: "%{diaspora_handle} :هو Diaspora اسم المستخدم الخاص" - friends_username: "صديق اسم المستخدم" + friends_username: "اسم مستخدم الصديق" destroy: - success: ".أنت الآن أصدقاء" - error: "!الرجاء اختيار جانبا" - ignore: ".صديق تجاهل الطلب" + success: ".أنتم الآن أصدقاء" + error: "!الرجاء اختيار جانب" + ignore: ". تجاهل طلب الصداقة" create: - error: "!مع هذا البريد الإلكتروني diaspora لم يتم العثور على بذور" - already_friends: "!%{destination_url} كنت بالفعل مع أصدقاء" - success: ".%{destination_url} وأرسل طلب صداقة إلى" - horribly_wrong: ".ذهب شيء خاطئ" + error: "!في هذا البريد الإلكتروني diaspora لم يتم العثور على بذور" + already_friends: "!من قبل %{destination_url} أنت صديق مع" + success: ".%{destination_url} تم إرسال طلب صداقة ل" + horribly_wrong: ".فيه بلوى كبيرة حصلت" diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index d61abb8a2..3a9de1b7c 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -6,6 +6,23 @@ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. en: + + settings: "Settings" + profile: "Profile" + account: "Account" + services: "Services" + cancel: "Cancel" + delete: "Delete" + or: "or" + by: "by" + ago: "ago" + username: "Username" + email: "Email" + home: "Home" + password: "Password" + password_confirmation: "Password confirmation" + are_you_sure: "Are you sure?" + activemodel: errors: models: @@ -26,9 +43,6 @@ en: helper: unknown_person: "unknown person" new_requests: "new requests" - dashboards: - helper: - home: "home" error_messages: helper: invalid_fields: "Invalid Fields" @@ -54,9 +68,19 @@ en: manage_aspects: "Manage Aspects" publisher: share: "Share" + post_a_message_to: "Post a message to %{aspect}" + make_public: "make public" aspect_friends: add_friends: "add friends" photos: "photos" + invitations: + invites: 'Invites' + invite_a_friend: 'Invite a friend' + invitations_left: '(%{count} left)' + reshare: + reshare: 'Reshare' + author_info: + view_profile: 'View profile' albums: album: you: "you" @@ -67,17 +91,13 @@ en: edit_album: "Edit Album" albums: "albums" updated: "updated" - by: "by" edit: album_name: "Album name" editing: "Editing" updated: "updated" update_album: "Update album" - are_you_sure: "Are you sure?" delete_album: "Delete Album" - cancel: "Cancel" index: - home: "home" new_album: "New Album" create: success: "You've created an album called %{name}." @@ -91,7 +111,7 @@ en: your_albums: "Your Albums" aspects: no_friends_message: - nobody: "We know you have friends, bring them to Diaspora!" + nobody: "We know you have friends — bring them to Diaspora!" nobody_in_aspect: "Your aspect '%{aspect_name}' is empty." add_friend: "Add a friend" add_friend_to: "Add someone to %{aspect_name}" @@ -129,28 +149,19 @@ en: edit: editing_profile: "Editing profile" invite_friends: "Invite friends" - are_you_sure: "Are you sure?" export_data: "Export Data" close_account: "Close Account" change_language: "Change Language" change_password: "Change Password" new_password: "New Password" - password_confirmation: "Password confirmation" - settings: "Settings" - profile: "Profile" - account: "Account" - services: "Services" - cancel: "Cancel" destroy: "Account successfully closed." getting_started: + signup_steps: "Complete your sign-up by doing these things:" 'step_1': albums: "Albums" you_dont_have_any_photos: "You don't have any photos! Go to the" page_to_upload_some: "page to upload some." - or: "or" comments: - comment: - ago: "ago" new_comment: comment: "Comment" photos: @@ -160,17 +171,13 @@ en: next: "next" edit_photo: "Edit Photo" delete_photo: "Delete Photo" - are_you_sure: "Are you sure?" comments: "comments" edit: editing: "Editing" - are_you_sure: "Are you sure?" delete_photo: "Delete Photo" photo: show_comments: "show comments" posted_a_new_photo_to: "posted a new photo to" - delete: "Delete" - are_you_sure: "Are you sure?" new: new_photo: "New Photo" back_to_list: "Back to List" @@ -190,10 +197,6 @@ en: sign_up_for_diaspora: "Sign up for Diaspora" upload_existing_account: "Upload an existing Diaspora account" upload: "Upload" - username: "Username" - email: "Email" - password: "Password" - password_confirmation: "Password confirmation" create: success: "You've joined Diaspora!" invitations: @@ -204,19 +207,22 @@ en: already_friends: 'You are already friends with this person' invitation_token_invalid: 'The invitation token provided is not valid!' updated: 'Your password was set successfully. You are now signed in.' - + new: + invite_someone_to_join: 'Invite someone to join Diaspora!' + if_they_accept_info: 'if they accept, they will be added to the aspect you invited them' + to: 'To' + message: 'Message:' + send_an_invitation: 'Send an invitation' + send_invitation: 'Send invitation' status_messages: new_status_message: tell_me_something_good: "tell me something good" oh_yeah: "oh yeah!" status_message: show_comments: "show comments" - delete: "Delete" - are_you_sure: "Are you sure?" show: status_message: "Status Message" comments: "comments" - are_you_sure: "Are you sure?" destroy: "Destroy" view_all: "View All" message: "Message" @@ -241,12 +247,12 @@ en: last_seen: "last seen: %{how_long_ago}" friends_since: "friends since: %{how_long_ago}" save: "save" - are_you_sure: "Are you sure?" remove_friend: "remove friend" no_posts: "no posts to display!" add_friend: "add friend" + edit_my_profile: "Edit my profile" edit: - settings: "Settings" + info_available_to: "This info will be available to whomever you connect with on Diaspora." your_profile: "Your profile" your_name: "Your name" first_name: "First name" @@ -256,12 +262,7 @@ en: your_bio: "Your bio" fill_me_out: "Fill me out" your_photo: "Your photo" - profile: "Profile" - account: "Account" - services: "Services" - cancel: "Cancel" update_profile: "Update Profile" - home: "Home" diaspora_username: "DIASPORA USERNAME" info: "Info" picture: "Picture" @@ -269,7 +270,6 @@ en: albums: "Albums" you_dont_have_any_photos: "You don't have any photos! Go to the" page_to_upload_some: "page to upload some." - or: "or" requests: new_request: add_a_new_friend_to: "Add a new friend to" @@ -289,9 +289,3 @@ en: already_friends: "You are already friends with %{destination_url}!" success: "A friend request was sent to %{destination_url}." horribly_wrong: "Something went horribly wrong." - services: - index: - settings: "Settings" - profile: "Profile" - account: "Account" - services: "Services" diff --git a/config/locales/diaspora/fr.yml b/config/locales/diaspora/fr.yml index 2cf05237a..76673ae02 100644 --- a/config/locales/diaspora/fr.yml +++ b/config/locales/diaspora/fr.yml @@ -11,6 +11,8 @@ fr: models: user: attributes: + person: + invalid: "est invalide" username: taken: "est déjà pris" email: @@ -37,7 +39,10 @@ fr: people_on_pod_are_aware_of: " personnes agissant comme des automates sont au courant" layouts: application: + view_profile: "voir le profil" edit_profile: "éditer le profil" + account_settings: "options du compte" + search: "Rechercher" logout: "déconnexion" shared: aspect_nav: @@ -64,8 +69,10 @@ fr: updated: "mis à jour" by: "par" edit: + album_name: "Nom de l'album" editing: "Édition" updated: "mis à jour" + update_album: "Mettre à jour l'album" are_you_sure: "Êtes-vous sûr(e) ?" delete_album: "Supprimer l’album" cancel: "Annuler" @@ -100,6 +107,7 @@ fr: ignore_remove: "Ignorer/Supprimer" new_aspect: add_a_new_aspect: "Ajouter un nouvel aspect" + name: "Nom" create: "Créer" create: success: "Cliquez sur le symbole plus situé sur le côté gauche afin que Diaspora détermine qui peut voir votre nouvel aspect." @@ -120,19 +128,26 @@ fr: users: edit: editing_profile: "Édition du profil" - profile: + invite_friends: "Inviter des amis" + are_you_sure: "Êtes-vous sûr(e) ?" + export_data: "Exporter des données" + close_account: "Clôre le compte" + change_language: "Changer la langue" + change_password: "Changer le mot de passe" + new_password: "Noveau mot de passe" + password_confirmation: "Confirmation du mot de passe" + settings: "Options" + profile: "Profil" + account: "Compte" + services: "Services" cancel: "Annuler" - update_profile: "Mettre à jour le profil" - home: "Accueil" - diaspora_username: "NOM D’UTILISATEUR DIASPORA" - info: "Informations" - picture: "Image" - editing_profile: "Édition du profil" - albums: "Albums" - you_dont_have_any_photos: "Vous n’avez aucune photo ! Rendez-vous sur la page" - page_to_upload_some: "afin d’en transférer quelques-unes." - or: "ou" destroy: "Compte clôturé avec succès." + getting_started: + 'step_1': + albums: "Albums" + you_dont_have_any_photos: "Vous n'avez aucune photos ! Rendez-vous sur la page" + page_to_upload_some: "afin d'en transférer quelques une." + or: "ou" comments: comment: ago: "il y a" @@ -172,6 +187,13 @@ fr: registrations: new: sign_up: "Inscription" + sign_up_for_diaspora: "Inscription à Diaspora" + upload_existing_account: "Télécharger un compte Diaspora existant" + upload: "Télécharger" + username: "Nom d'utilisateur" + email: "Courriel" + password: "Mot de passe" + password_confirmation: "Confirmation du mot de passe" create: success: "Vous avez rejoint Diaspora !" invitations: @@ -222,12 +244,39 @@ fr: are_you_sure: "Êtes-vous sûr(e) ?" remove_friend: "supprimer de mes amis" no_posts: "aucun message à afficher !" + add_friend: "ajouter un ami" + edit: + settings: "Options" + your_profile: "Votre profil" + your_name: "Votre nom" + first_name: "Votre prénom" + last_name: "Votre nom de famille" + your_gender: "Votre sexe" + your_birthday: "Votre anniversaire" + your_bio: "Votre bio" + fill_me_out: "Remplissez-moi" + your_photo: "Votre photo" + profile: "Profil" + account: "Compte" + services: "Services" + cancel: "Annuler" + update_profile: "Mettre à jour le profil" + home: "Accueil" + diaspora_username: "NOM D'UTILISATEUR DIASPORA" + info: "Info" + picture: "Image" + editing_profile: "Edition du profil" + albums: "Albums" + you_dont_have_any_photos: "Vous n'aver aucune photo ! Rendez-vous sur la page" + page_to_upload_some: "afin d'en transférer quelques une." + or: "ou" requests: new_request: add_a_new_friend_to: "Ajouter un nouvel ami à" enter_a_diaspora_username: "Saisissez un nom d’utilisateur Diaspora :" your_diaspora_username_is: "Votre nom d’utilisateur Diaspora est : %{diaspora_handle}" friends_username: "Nom d’utilisateur de l’ami" + create_request: "Créer une requête" destroy: success: "Vous êtes à présent amis." error: "Veuillez sélectionner un aspect !" @@ -240,3 +289,184 @@ fr: already_friends: "Vous êtes déjà ami avec %{destination_url}!" success: "Une requête d’ami a été envoyée à %{destination_url}." horribly_wrong: "Quelque chose d’horrible s’est produit." + services: + index: + settings: "Options" + profile: "Profil" + account: "Compte" + services: "Services" + +# From http://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/fr.yml + date: + formats: + default: "%d/%m/%Y" + short: "%e %b" + long: "%e %B %Y" + day_names: [lundi, mardi, mercredi, jeudi, vendredi, samedi, dimanche] + abbr_day_names: [lun, mar, mer, jeu, ven, sam, dim] + month_names: [~, janvier, février, mars, avril, mai, juin, juillet, août, septembre, octobre, novembre, décembre] + abbr_month_names: [~, jan., fév., mar., avr., mai, juin, juil., août, sept., oct., nov., déc.] + order: [ :day, :month, :year ] + + time: + formats: + default: "%d %B %Y %H:%M:%S" + short: "%d %b %H:%M" + long: "%A %d %B %Y %H:%M" + am: 'am' + pm: 'pm' + + datetime: + distance_in_words: + half_a_minute: "une demi-minute" + less_than_x_seconds: + zero: "moins d'une seconde" + one: "moins d'une seconde" + other: "moins de %{count} secondes" + x_seconds: + one: "1 seconde" + other: "%{count} secondes" + less_than_x_minutes: + zero: "moins d'une minute" + one: "moins d'une minute" + other: "moins de %{count} minutes" + x_minutes: + one: "1 minute" + other: "%{count} minutes" + about_x_hours: + one: "environ une heure" + other: "environ %{count} heures" + x_days: + one: "1 jour" + other: "%{count} jours" + about_x_months: + one: "environ un mois" + other: "environ %{count} mois" + x_months: + one: "1 mois" + other: "%{count} mois" + about_x_years: + one: "environ un an" + other: "environ %{count} ans" + over_x_years: + one: "plus d'un an" + other: "plus de %{count} ans" + almost_x_years: + one: "presqu'un an" + other: "presque %{count} ans" + prompts: + year: "Année" + month: "Mois" + day: "Jour" + hour: "Heure" + minute: "Minute" + second: "Seconde" + + number: + format: + separator: "," + delimiter: " " + precision: 3 + significant: false + strip_insignificant_zeros: false + currency: + format: + format: "%n %u" + unit: "€" + separator: "," + delimiter: " " + precision: 2 + significant: false + strip_insignificant_zeros: false + percentage: + format: + delimiter: "" + precision: + format: + delimiter: "" + human: + format: + delimiter: "" + precision: 2 + significant: true + strip_insignificant_zeros: true + storage_units: + format: "%n %u" + units: + byte: + one: "Octet" + other: "Octets" + kb: "ko" + mb: "Mo" + gb: "Go" + tb: "To" + decimal_units: + format: "%n %u" + units: + unit: "" + thousand: "Millier" + million: "Million" + billion: "Milliard" + trillion: "Mille milliard" + quadrillion: "Million de milliard" + + support: + array: + words_connector: ", " + two_words_connector: " et " + last_word_connector: " et " + select: + prompt: "Veuillez sélectionner" + + helpers: + select: + prompt: "Veuillez sélectionner" + submit: + create: "Créer un %{model}" + update: "Modifier ce %{model}" + submit: "Enregistrer ce %{model}" + + errors: + template: &errors_template + header: + one: "Impossible d'enregistrer ce %{model} : 1 erreur" + other: "Impossible d'enregistrer ce %{model} : %{count} erreurs" + body: "Veuillez vérifier les champs suivants : " + + attributes: + created_at: "Créé le" + updated_at: "Modifié le" + + errors: + format: "Le %{attribute} %{message}" + messages: &errors_messages + inclusion: "n'est pas inclus(e) dans la liste" + exclusion: "n'est pas disponible" + invalid: "n'est pas valide" + confirmation: "ne concorde pas avec la confirmation" + accepted: "doit être accepté(e)" + empty: "doit être rempli(e)" + blank: "doit être rempli(e)" + too_long: "est trop long (pas plus de %{count} caractères)" + too_short: "est trop court (au moins %{count} caractères)" + wrong_length: "ne fait pas la bonne longueur (doit comporter %{count} caractères)" + not_a_number: "n'est pas un nombre" + not_an_integer: "doit être un nombre entier" + greater_than: "doit être supérieur à %{count}" + greater_than_or_equal_to: "doit être supérieur ou égal à %{count}" + equal_to: "doit être égal à %{count}" + less_than: "doit être inférieur à %{count}" + less_than_or_equal_to: "doit être inférieur ou égal à %{count}" + odd: "doit être impair" + even: "doit être pair" + + activerecord: + errors: + messages: + taken: "n'est pas disponible" + record_invalid: "La validation a échoué : %{errors}" + <<: *errors_messages + template: + <<: *errors_template + full_messages: + format: "%{attribute} %{message}" diff --git a/config/locales/diaspora/sv.yml b/config/locales/diaspora/sv.yml index 968a3cafa..587bc4350 100644 --- a/config/locales/diaspora/sv.yml +++ b/config/locales/diaspora/sv.yml @@ -27,6 +27,8 @@ sv: models: user: attributes: + person: + invalid: "är ogiltigt" username: taken: "är redan taget" email: @@ -35,7 +37,6 @@ sv: attributes: diaspora_handle: taken: "är redan taget" - hello: "Hej världen!" application: helper: @@ -54,7 +55,10 @@ sv: people_on_pod_are_aware_of: " personer på denna plats är medvetna om att" layouts: application: + view_profile: "visa profil" edit_profile: "ändra profil" + account_settings: "kontoinstallningar" + search: "Sök ..." logout: "logga ut" shared: aspect_nav: @@ -81,8 +85,10 @@ sv: updated: "uppdaterad" by: "av" edit: + album_name: "Namn på fotoalbum" editing: "Ändrar" updated: "uppdaterad" + update_album: "Uppdatera fotoalbum" are_you_sure: "Är du säker?" delete_album: "Ta bort fotoalbum" cancel: "Avbryt" @@ -117,6 +123,7 @@ sv: ignore_remove: "Ignorera/Ta bort" new_aspect: add_a_new_aspect: "Lägg till ny sida" + name: "Namn" create: "Skapa" create: success: "Klicka på plustecknet till höger för att välja vilka som kan se din nya sida." @@ -137,19 +144,26 @@ sv: users: edit: editing_profile: "Ändrar profil" - profile: + invite_friends: "Bjud in en vän" + are_you_sure: "Är du säker?" + export_data: "Exportera data" + close_account: "Stäng kontot" + change_language: "Ändra språk" + change_password: "Ändra lösenord" + new_password: "Nytt lösenord" + password_confirmation: "Bekräfta lösenord" + settings: "Inställningar" + profile: "Profil" + account: "Konto" + services: "Tjänster" cancel: "Avbryt" - update_profile: "Uppdatera Profil" - home: "Hem" - diaspora_username: "Diaspora-användarnamn:" - info: "Info" - picture: "Profilbild" - editing_profile: "Ändrar profil" - albums: "Album" - you_dont_have_any_photos: "Du har inga foton! Gå till" - page_to_upload_some: "sidan för att ladda upp några." - or: "eller" destroy: "Ditt konto är nu stängt." + getting_started: + 'step_1': + albums: "Fotoalbum" + you_dont_have_any_photos: "Du har inga foton! Gå till" + page_to_upload_some: "sidan för att ladda upp några." + or: "eller" comments: comment: ago: "sedan" @@ -189,6 +203,13 @@ sv: registrations: new: sign_up: "Registrera dig" + sign_up_for_diaspora: "Gå med i Diaspora" + upload_existing_account: "Ladda upp ett befintligt Diaspora-konto" + upload: "Ladda upp" + username: "Användarnamn" + email: "E-post address" + password: "Lösenord" + password_confirmation: "Bekräfta lösenord" create: success: "Du har nu gått med i Diaspora!" invitations: @@ -232,10 +253,6 @@ sv: new: new_person: "Ny person" back_to_list: "Tillbaka till listan" - edit: - cancel: "Avbryt" - or: "eller" - update_profile: "Uppdatera profil" show: last_seen: "senast sedd: %{how_long_ago}" friends_since: "vänner sedan: %{how_long_ago}" @@ -243,12 +260,39 @@ sv: are_you_sure: "Är du säker?" remove_friend: "ta bort vän" no_posts: "ingenting att visa!" + add_friend: "lägg till en vän" + edit: + settings: "Inställningar" + your_profile: "Din profil" + your_name: "Ditt namn" + first_name: "Förnamn" + last_name: "Efternamn" + your_gender: "Ditt kön" + your_birthday: "Din födelsedag" + your_bio: "Din biografi" + fill_me_out: "Fyll i mig" + your_photo: "Ditt foto" + profile: "Profil" + account: "Konto" + services: "Tjänster" + cancel: "Avbryt" + update_profile: "Uppdatera profil" + home: "Hem" + diaspora_username: "Användarnamn:" + info: "Info" + picture: "Foto" + editing_profile: "Ändrar profil" + albums: "Fotoalbum" + you_dont_have_any_photos: "Du har inga foton! Gå till" + page_to_upload_some: "sidan för att ladda upp några." + or: "eller" requests: new_request: add_a_new_friend_to: "Lägg till en vän till" enter_a_diaspora_username: "Ange ett användarnamn:" your_diaspora_username_is: "Din Diaspora-adress är: %{diaspora_handle}" friends_username: "Vännens Diaspora-adress" + create_request: "Skapa förfrågan" destroy: success: "Ni är nu vänner." error: "Var god välj en aspekt!" @@ -261,6 +305,12 @@ sv: already_friends: "Du är redan vän med %{destination_url}!" success: "En vänförfrågan har skickats till %{destination_url}." horribly_wrong: "Nu gick något rejält fel här." + services: + index: + settings: "Inställningar" + profile: "Profil" + account: "Konto" + services: "Tjänster" # The following is from the rails-i18n project at http://github.com/svenfuchs/rails-i18n diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index e51c82344..b27d1c674 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -32,7 +32,7 @@ def create user.save user.person.save! - user.aspect(:name => "Presidents") + user.aspects.create(:name => "Presidents") end def set_app_config username diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index 8fc7c499b..ac0cc8cf0 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -46,8 +46,8 @@ user2.save user2.person.save! user2.seed_aspects # friending users -aspect = user.aspect(:name => "other dudes") -aspect2 = user2.aspect(:name => "presidents") +aspect = user.aspects.create(:name => "other dudes") +aspect2 = user2.aspects.create(:name => "presidents") friend_users(user, aspect, user2, aspect2) -user.aspect(:name => "Presidents") +user.aspects.create(:name => "Presidents") diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 28f043728..6290da594 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -42,8 +42,8 @@ user2.save! user2.seed_aspects user2.person.save! # friending users -aspect = user.aspect(:name => "other dudes") -aspect2 = user2.aspect(:name => "presidents") +aspect = user.aspects.create(:name => "other dudes") +aspect2 = user2.aspects.create(:name => "presidents") friend_users(user, aspect, user2, aspect2) -user.aspect(:name => "Presidents") +user.aspects.create(:name => "Presidents") diff --git a/features/logs_in_and_out.feature b/features/logs_in_and_out.feature new file mode 100644 index 000000000..35777b2b9 --- /dev/null +++ b/features/logs_in_and_out.feature @@ -0,0 +1,16 @@ +Feature: user authentication + + Scenario: user logs in + Given a user with username "ohai" and password "secret" + When I go to the new user session page + And I fill in "Username" with "ohai" + And I fill in "Password" with "secret" + And I press "Sign in" + Then I should be on the home page + + @javascript + Scenario: user logs out + Given I am signed in + And I click on my name in the header + And I follow "logout" + Then I should be on the new user session page \ No newline at end of file diff --git a/features/manages_aspects.feature b/features/manages_aspects.feature new file mode 100644 index 000000000..74f6744f4 --- /dev/null +++ b/features/manages_aspects.feature @@ -0,0 +1,14 @@ +@aspects @javascript +Feature: User manages aspects + In order to share with a limited group + As a User + I want to create new aspects + + Scenario: creating an aspect + Given I am signed in + When I follow "Manage" in the header + And I follow "Add a new aspect" + And I fill in "Name" with "Dorm Mates" in the modal window + And I press "Create" in the modal window + Then I should see "Dorm Mates" in the header + And I should see "Your aspect 'Dorm Mates' is empty." diff --git a/features/signs_up.feature b/features/signs_up.feature new file mode 100644 index 000000000..80e32934f --- /dev/null +++ b/features/signs_up.feature @@ -0,0 +1,40 @@ +@javascript +Feature: new user registration + + Background: + When I go to the new user registration page + And I fill in "Username" with "ohai" + And I fill in "Email" with "ohai@example.com" + And I fill in "user_password" with "secret" + And I fill in "Password confirmation" with "secret" + And I press "Sign up" + Then I should be on the getting started page + And I should see "Welcome to Diaspora!" + + Scenario: new user goes through the setup wizard + When I fill in "person_profile_first_name" with "O" + And I fill in "person_profile_last_name" with "Hai" + And I press "Save and continue" + Then I should see "Profile updated" + And I should see "Your aspects" + +# Not working with selenium - it thinks the aspect name field is hidden +# When I fill in "Aspect name" with "cheez friends" +# And I press "Add" +# And show me the page +# Then I should see "cheez friends" + When I follow "Save and continue" + Then I should see "Your services" + + When I follow "Save and continue" + Then I should see "You're all set up, O!" + + When I follow "Continue on to your everyone page, an overview of all of your aspects." + Then I should be on the home page + And I should see "bring them to Diaspora!" + + Scenario: new user skips the setup wizard + When I follow "skip getting started" + And I wait for the home page to load + Then I should be on the home page + And I should see "bring them to Diaspora!" diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index d213cbf4d..c98150d3d 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -20,4 +20,8 @@ Then /^I should see "([^\"]*)" in the main content area$/ do |stuff| within("#stream") do Then "I should see #{stuff}" end +end + +When /^I wait for the home page to load$/ do + wait_until { current_path == root_path } end \ No newline at end of file diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb new file mode 100644 index 000000000..e952730d2 --- /dev/null +++ b/features/step_definitions/user_steps.rb @@ -0,0 +1,8 @@ +Given /^a user with username "([^\"]*)" and password "([^\"]*)"$/ do |username, password| + Factory(:user, :username => username, :password => password, + :password_confirmation => password, :getting_started => false) +end + +When /^I click on my name$/ do + click_link("#{@me.first_name} #{@me.last_name}") +end \ No newline at end of file diff --git a/features/support/env.rb b/features/support/env.rb index 2fb86c4dc..f196e1776 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -22,8 +22,6 @@ require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links wi # steps to use the XPath syntax. Capybara.default_selector = :css -WebMock.disable_net_connect!(:allow_localhost => true) - # If you set this to false, any error raised from within your app will bubble # up to your step definition and out to cucumber unless you catch it somewhere # on the way. You can make Rails rescue errors and render error pages on a diff --git a/features/support/paths.rb b/features/support/paths.rb index 3d3f64724..9a08357a0 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -1,6 +1,8 @@ module NavigationHelpers def path_to(page_name) case page_name + when /^the home page$/ + root_path when /^its ([\w ]+) page$/ send("#{$1.gsub(/\W+/, '_')}_path", @it) when /^the ([\w ]+) page$/ diff --git a/features/user_creates_an_aspect.feature b/features/user_creates_an_aspect.feature deleted file mode 100644 index d611d412f..000000000 --- a/features/user_creates_an_aspect.feature +++ /dev/null @@ -1,21 +0,0 @@ -@aspects @javascript -Feature: User creates an aspect - In order to share with a limited group - As a User - I want to create a new aspect - - Background: - Given I am signed in - And I follow "Manage" in the header - And I follow "Add a new aspect" - - Scenario: success - Given I fill in "Name" with "Dorm Mates" in the modal window - When I press "Create" in the modal window - Then I should see "Dorm Mates" in the header - And I should see "Your aspect 'Dorm Mates' is empty." - - Scenario: I omit the name - Given I fill in "Name" with "" in the modal window - When I press "Create" in the modal window - Then I should see "Aspect creation failed." diff --git a/lib/collect_user_photos.rb b/lib/collect_user_photos.rb index 4b0fedea2..d95aa386a 100644 --- a/lib/collect_user_photos.rb +++ b/lib/collect_user_photos.rb @@ -17,12 +17,12 @@ module PhotoMover current_photo_location = "#{Rails.root}/public/uploads/images/#{photo.image_filename}" new_photo_location = "#{album_dir}/#{photo.image_filename}" - `cp #{current_photo_location} #{new_photo_location}` + FileUtils::cp current_photo_location new_photo_location end end - `tar cf #{user.id}.tar #{user.id}` - `rm -r #{user.id}` + system("tar", "cf #{user.id}.tar #{user.id}") + FileUtils::rm_r user.id, :secure => true, :force => true "#{Rails.root}/#{temp_dir}.tar" end diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index 2d002a2c9..acdd27afd 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -4,22 +4,7 @@ module Diaspora module Parser - 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 self.parse_or_find_person_from_xml(xml) - doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks } - person_xml = doc.xpath("//person").to_s - person_id = doc.xpath("//person/_id").text.to_s - person = Person.first(:_id => person_id) - person ? person : Person.from_xml( person_xml) - end - def self.from_xml(xml) - doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks } return unless body = doc.xpath("/XML/post").children.first diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index db3a30c4d..472926346 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -140,7 +140,7 @@ module Diaspora end def requests_for_me - pending_requests.select{|req| req.person != self.person } + pending_requests.select{|req| req.destination_url == self.person.receive_url} end end end diff --git a/lib/diaspora/user/receiving.rb b/lib/diaspora/user/receiving.rb index 25ccad7fb..6a8324842 100644 --- a/lib/diaspora/user/receiving.rb +++ b/lib/diaspora/user/receiving.rb @@ -18,73 +18,53 @@ module Diaspora def receive xml, salmon_author object = Diaspora::Parser.from_xml(xml) Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}") - Rails.logger.debug("From: #{object.person.inspect}") if object.person + Rails.logger.debug("From: #{object.diaspora_handle}") + + if object.is_a?(Comment) + xml_author = (owns?(object.post))? object.diaspora_handle : object.post.person.diaspora_handle + else + xml_author = object.diaspora_handle + end - if object.is_a?(Comment) || object.is_a?(Post) + if (salmon_author.diaspora_handle != xml_author) + raise "Malicious Post, #{salmon_author.real_name} with id #{salmon_author.id} is sending a #{object.class} as #{xml_author} " + end + + if object.is_a?(Comment) || object.is_a?(Post)|| object.is_a?(Request) || object.is_a?(Retraction) || object.is_a?(Profile) e = EMWebfinger.new(object.diaspora_handle) e.on_person { |person| if person.class == Person - sender_in_xml = sender(object, xml, person) - if (salmon_author != sender_in_xml) - raise "Malicious Post, #{salmon_author.real_name} with id #{salmon_author.id} is sending a #{object.class} as #{sender_in_xml.real_name} with id #{sender_in_xml.id} " + object.person = person if object.respond_to? :person= + + if object.is_a? Request + return receive_request object, person end raise "Not friends with that person" unless self.contact_for(salmon_author) if object.is_a?(Comment) receive_comment object, xml + elsif object.is_a?(Retraction) + receive_retraction object, xml + elsif object.is_a?(Profile) + receive_profile object, person else receive_post object, xml end - end } - else - sender_in_xml = sender(object, xml) - - if (salmon_author != sender_in_xml) - raise "Malicious Post, #{salmon_author.real_name} with id #{salmon_author.id} is sending a #{object.class} as #{sender_in_xml.real_name} with id #{sender_in_xml.id} " - end - - if object.is_a? Request - return receive_request object, sender_in_xml - end - raise "Not friends with that person" unless self.contact_for(salmon_author) - - if object.is_a? Retraction - receive_retraction object, xml - elsif object.is_a? Profile - receive_profile object, xml - else - receive_post object, xml - end + raise "you messed up" end end - def sender(object, xml, webfingered_person = nil) - if object.is_a? Retraction - sender = object.person - elsif object.is_a? Request - sender = object.person - elsif object.is_a? Profile - sender = Diaspora::Parser.owner_id_from_xml xml - - else - object.person = webfingered_person - if object.is_a?(Comment) - sender = (owns?(object.post))? object.person : object.post.person - else - sender = object.person - end - end - sender - end - def receive_retraction retraction, xml if retraction.type == 'Person' + unless retraction.person.id.to_s == retraction.post_id.to_s + raise "#{retraction.diaspora_handle} trying to unfriend #{retraction.post_id} from #{self.id}" + end Rails.logger.info( "the person id is #{retraction.post_id} the friend found is #{visible_person_by_id(retraction.post_id).inspect}") unfriended_by visible_person_by_id(retraction.post_id) else @@ -97,18 +77,16 @@ module Diaspora end def receive_request request, person - person.serialized_public_key ||= request.exported_key request.person = person - request.person.save - old_request = Request.first(:id => request.id) + request.person.save! + old_request = Request.find(request.id) Rails.logger.info("I got a reqest_id #{request.id} with old request #{old_request.inspect}") request.aspect_id = old_request.aspect_id if old_request request.save receive_friend_request(request) end - def receive_profile profile, xml - person = Diaspora::Parser.owner_id_from_xml xml + def receive_profile profile, person person.profile = profile person.save end diff --git a/pkg/.gitignore b/pkg/.gitignore new file mode 100644 index 000000000..470b7660b --- /dev/null +++ b/pkg/.gitignore @@ -0,0 +1,2 @@ +dist +*.log diff --git a/pkg/README.md b/pkg/README.md new file mode 100644 index 000000000..aa99e0ad7 --- /dev/null +++ b/pkg/README.md @@ -0,0 +1,15 @@ +## Diaspora install and packaging tools + +This directory contains stuff to install and run diaspora. + +- ubuntu-setup.bash: script which installs all of Diasporas + dependencies and starts the server. + +- bootstrap-fedora-diaspora.sh. does the same for Fedora. + +- source: stuff to package Diaspora into traditional tarballs + which can be installed. + +- ubuntu: Scripts and tools to install generic tarballs on Ubuntu + +- fedora: Scripts and tools to create fedora RPMS:s from tarballs diff --git a/pkg/bootstrap-fedora-diaspora.sh b/pkg/bootstrap-fedora-diaspora.sh index 84352f12d..7c0d267d0 100755 --- a/pkg/bootstrap-fedora-diaspora.sh +++ b/pkg/bootstrap-fedora-diaspora.sh @@ -1,48 +1,127 @@ #!/bin/bash +# +# Install diaspora, its dependencies and start. +# +# Usage: pkg/bootstrap-fedora-diaspora.sh [external hostname] +# +# Synopsis, install: +# $ git clone git@github.com:diaspora/diaspora.git +# $ cd diaspora +# $ sudo pkg/bootstrap-fedora-diaspora.sh +# +# New start: +# $ sudo su - diaspora +# $ cd diaspora +# $ script/server +# +# Unless already existing, the diaspora user is created. +# The directory the scripts is invoked from is copied to +# diasporas's home dir, populated and configured and finally +# acts as a base for running diaspora servers. +# +# Script is designed not to make any changes in invoking +# caller's environment. +# +# Must run as root -export DIASPORADIR=`pwd` +GIT_REPO='git@github.com:leamas/diaspora.git' +DIASPORA_HOSTNAME=${1:-'mumin.dnsalias.net'} -echo "####" -echo "Installing build deps ..." -echo "####" -sleep 3 -su -c "yum install git bison svn autoconf sqlite-devel gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel ImageMagick git rubygems libxslt libxslt-devel libxml2 libxml2-devel openssl-devel" +test $UID = "0" || { + echo "You need to be root to do this, giving up" + exit 2 +} -echo "####" -echo "Installing RVM ..." -echo "####" -sleep 3 +[[ -d config && -d script ]] || { + echo Error: "this is not a diaspora base directory" + exit 3 +} +yum install -y git bison sqlite-devel gcc-c++ patch \ + readline-devel zlib-devel libyaml-devel libffi-devel \ + ImageMagick libxslt-devel libxml2-devel \ + openssl-devel mongodb-server wget \ + make autoconf automake -mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone --depth 1 git://github.com/wayneeseguin/rvm.git && cd rvm && ./install +getent group diaspora >/dev/null || groupadd diaspora +getent passwd diaspora >/dev/null || { + useradd -g diaspora -s /bin/bash -m diaspora + echo "Created user diaspora" +} -echo "####" -echo "Installing RVM into bashrc and sourcing bash ..." -echo "####" -sleep 3 +home=$( getent passwd diaspora | cut -d: -f6) +[ -e $home/diaspora ] && { + echo "Moving existing $home/diaspora out of the way" + mv $home/diaspora $home/diaspora.$$ +} +mkdir $home/diaspora +cp -ar * $home/diaspora +chown -R diaspora $home/diaspora -if [[ `grep -l "rvm/scripts/rvm" $HOME/.bashrc | wc -l` -eq 0 ]]; then - echo 'if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi' >> $HOME/.bashrc +service mongod start + +su - diaspora << EOF +#set -x + +cd diaspora + +[ -e "\$HOME/.rvm/scripts/rvm" ] || { + echo '#### Installing rvm ####' + wget http://rvm.beginrescueend.com/releases/rvm-install-head + bash < rvm-install-head && rm rvm-install-head + if [[ -s "\$HOME/.rvm/scripts/rvm" ]]; then + . "\$HOME/.rvm/scripts/rvm" + else + echo "Error: rvm installation failed"; + exit 1; + fi + touch \$HOME/.bashrc + grep -q "rvm/scripts/rvm" \$HOME/.bashrc || { + echo '[[ -s "\$HOME/.rvm/scripts/rvm" ]] && \ + source "\$HOME/.rvm/scripts/rvm"' \ + >> \$HOME/.bashrc + } +} + +source \$HOME/.bashrc + +ruby=\$(which ruby) || ruby="" + +if [[ -z "\$ruby" || ("\${ruby:0:4}" == "/usr") ]]; then + echo '#### Installing ruby (will take forever) ... ####' + rvm install ruby-1.8.7-p302 + rvm --default ruby-1.8.7 + + echo "#### Installing bundler ... ####" + gem install bundler fi -source $HOME/.bashrc -echo "####" -echo "Installing ruby (will take forever) ..." -echo "####" -sleep 3 +bundle install -rvm install ruby-1.8.7-p302 -rvm --default ruby-1.8.7 +#Configure diaspora +cp config/app_config.yml.example config/app_config.yml +source pkg/source/funcs.sh +init_appconfig config/app_config.yml "$DIASPORA_HOSTNAME" -echo "####" -echo "Installing bundler ..." -echo "####" -sleep 3 -gem install bundler +echo "Setting up DB..." +if bundle exec rake db:seed:dev ; then + cat <<- EOM + DB ready. Login -> tom and password -> evankorth. + More details ./diaspora/db/seeds/tom.rb. and ./diaspora/db/seeds/dev.rb. + EOM +else + cat <<- EOM + Database config failed. You might want to remove all db files with + 'rm -rf /var/lib/mongodb/*' and/or reset the config file by + 'cp config/app_config.yml.example config/app_config.yml' before + making a new try. Also, make sure the mongodb server is running + e. g., by running 'service mongodb status'. + EOM +fi + +echo "Starting server" +script/server + +EOF -echo "####" -echo "Installing deps with bundle ..." -echo "####" -sleep 3 -pushd $DIASPORADIR && bundle install && popd diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md index 38801dc42..e926f5a4d 100644 --- a/pkg/fedora/README.md +++ b/pkg/fedora/README.md @@ -1,13 +1,12 @@ ## Diaspora RPM tools -Creates diaspora source tarballs and RPM packages +Create RPM packages An alternative to the capistrano system, providing classic, binary RPM -packages for deployment on Fedora 13 and OS-independent source tarballs -aimed for packaging purposes. +packages for deployment on Fedora. -#### Fedora RPM synopsis +#### Synopsis Prerequisites: @@ -18,16 +17,20 @@ Prerequisites: - A personal environment to build RPM:s, also described in [RPM installation Fedora](http://github.com/diaspora/diaspora/wiki/Rpm-installation-on-fedora) -Install g++ (unnecessary?): +Install g++ and gcc: % yum install gcc-c++ -Create source tarballs like dist/diaspora-0.0-1010041233_fade4231.tar.gz -and dist/diaspora-bundle-0.0-1010041233_fade4231.tar.gz: - % ./make-dist.sh source - % ./make-dist.sh bundle +Bootstrap the distribution from git: + % sudo apt-get install git-core + % git clone git://github.com/diaspora/diaspora.git + % cd diaspora/pkg/ubuntu -Setup links to tarballs from RPM source directory and create spec files: - % ./make-dist.sh prepare +Create and install the diaspora bundle and application in +diaspora/pkg/source according to +[source README](http://github.com/diaspora/diaspora/tree/master/pkg/source/) + +Setup links from tarballs to RPM source directory and create spec files: + % ./prepare-rpm.sh Build rpms: rpmbuild -ba dist/diaspora.spec @@ -51,75 +54,21 @@ apache/passenger setup. After configuration, start with: /sbin/service diaspora-wsd start /sbin/service httpd restart -#### Generic source synopsis - -Generate source tarball: - % ./make-dist.sh source - Using repo: http://github.com/diaspora/diaspora.git - Commit id: 1010092232_b313272 - Source: dist/diaspora-0.0-1010092232_b313272.tar.gz - Required bundle: 1010081636_d1a4ee0 - % - -The source tarball could be used as-is, by unpacking add making a -*bundle install*. An alternative is to generate a canned bundle like: - % ./make-dist.sh bundle - [ lot's of output...] - Bundle: dist/diaspora-bundle-0.0-1010081636_d1a4ee0.tar.gz - % - -This file can be installed anywhere. To use it, add a symlink from vendor/bundle -to the bundle's bundle directory. Reasonable defaults are to install -diaspora in /usr/share/diaspora and bundle in /usr/lib/diaspora-bundle. With these, -the link is - % rm -rf /usr/share/diaspora/master/vendor/bundle - % ln -sf /usr/lib/diaspora-bundle/vendor/bundle \ - > /usr/share/diaspora/master/vendor - % - -The directories tmp, log, and public/uploads needs to be writable. If using -apache passenger, read the docs on uid used and file ownership. - -Note that the bundle version required is printed each time a new source -is generated. +prepare-rpm.sh prepare creates links also for all files listed in SOURCES. +Typically, this is secondary sources. *make-dist.sh source* #### Notes -The source tarball is as retrieved from diaspora with following differences: +prepare-rpm.sh prepare creates links also for all files listed in SOURCES. +Typically, this is secondary sources. - - The .git directories are removed (freeing more than 50% of the size). - - A new file /master/config/gitversion is created. - - The file public/source.tar.gz is generated. - - The file .bundle/config is patched. Remove before doing - *bundle install* - -The bundle is basically the output from 'bundle package'. The git-based -gems are also added into vendor/git. - -./make-dist.sh bundle|source occasionally fails on bad Gemfile.lock. The -root cause is a bad Gemfile in the git repo. Possible fixes includes -using a older version known to work: - % ./make-dist.sh -c c818885b6 bundle - % ./make-dist.sh -c c818885b6 source - -or forcing a complete update of Gemfile.lock using 'bundle update' (a -potentially problematic operation): - % ./make-dist.sh -f bundle - -*make-dist prepare* creates links also for all files listed in SOURCES. -Typically, this is secondary sources. *make-dist.sh sources* -applies all patches named *.patch in this directory after checking out -source from git. - -The spec-files in dist/ are patched by *./make-dist.sh prepare* to reference -correct versions of diaspora and diaspora-bundle. The diaspora-bundle -is only updated if Gemfile is updated, upgrading diaspora doesn't -always require a new diaspora-bundle. Editing spec files should be done -in this directory, changes in dist/ are lost when doing *./make-dist prepare*. +The spec-files in dist/ are patched by *./prepare-rpm.sh to reference +correct versions of diaspora and diaspora-bundle. Editing spec files should be +done in this directory, changes in dist/ are lost when doing *./prepare-rpm.sh *. The topmost comment's version is patched to reflect the complete version -of current specfile by *make-dist source*. Write the comment in this -directory, copy-paste previous version nr. It will be updated. +of current specfile . Write the comment in this directory, copy-paste +previous version nr. It will be updated. This has been confirmed to start up and provide basic functionality both using the thin webserver and apache passenger, on 32/64 bit systems and in the @@ -128,17 +77,6 @@ at [ftp://mumin.dnsalias.net/pub/leamas/diaspora/builds](ftp://mumin.dnsalias.ne #### Implementation -'make-dist.sh source' script checks out latest version of diaspora into the - dist/diaspora directory. This content is, after some patches, the diaspora package. - -'make-dir.sh bundle' makes a *bundle package* in the diaspora dir. -The resulting bundle is stored in vendor/bundle. This is, after some more -patches, the content of diaspora-bundle tarball. Target systems makes a -*bundle install --local* to use it. - -Here is also support for running the diaspora websocket service as a system -service through /sbin/service and some install scripts. - Diaspora files are stored in /usr/share/diaspora, and owned by root. The bundle, containing some C extensions, is architecture-dependent and lives in /usr/lib[64]/diaspora. Log files are in /var/log/diaspora. Symlinks in @@ -154,6 +92,9 @@ diaspora app. This is more or less as mandated by LSB and Fedora packaging rule #### Discussion +The 1.8.7 rebuild is a pain. However, in Fedora 14 1.8.7 is the default +ruby version. + For better or worse, this installation differs from the procedure outlined in the original README.md: diff --git a/pkg/fedora/prepare-rpm.sh b/pkg/fedora/prepare-rpm.sh new file mode 100755 index 000000000..908c1844a --- /dev/null +++ b/pkg/fedora/prepare-rpm.sh @@ -0,0 +1,169 @@ +#!/bin/bash + +# Create RPM spec files matching diaspora tarballs +# +# Usage: See function usage() at bottom. +# +GIT_REPO='http://github.com/diaspora/diaspora.git' +VERSION='0.0' +RELEASE='1' + +. ../source/funcs.sh + + +function fix_alphatag() +# Patch version on top comment first id line: +# Usage: fix_alphatag +# Patches:\ +# * Fri Sep 24 2010 name surname 1.20100925_faf23207 +{ + local dist=$(rpm --eval %dist) + awk -v dist="$dist" -v version="$2" -v commit="$3" -v release="$4" \ + ' BEGIN { done = 0 } + /^[*]/ { if (done) + print + else + { + s = sprintf( "-%s.%s%s\n", release, commit, dist) + gsub( "-[0-9][.][^ ]*$", s) + done = 1 + # add new gsub for version... + print + } + next + } + { print }' < $1 > $1.tmp && mv -f $1.tmp $1 +} + + +function fix_bundle_deps +# usage: fix_bundle_deps +# Patches: Requires: diaspora-bundle = 0.0-20101021-aefsf323148 +{ + awk -v vers="$2-$3" \ + ' /Requires:/ { if ($2 == "diaspora-bundle") + printf( "%s %s = %s\n", $1,$2,vers) + else + print + next + } + { print}' \ + < $1 > $1.tmp && mv -f $1.tmp $1 +} + + +function patch() +# Patch spec-files with current version-release +# Usage: patch +{ + sed -e "/^%define/s|HEAD|$2|" \ + -e '/^Version:/s|.*|Version: '$1'|' \ + dist/diaspora.spec + fix_alphatag dist/diaspora.spec $1 $2 $3 + local bundle_id=$(git_id dist/diaspora/Gemfile) + local dist_tag=$(rpm --eval %dist) + fix_bundle_deps dist/diaspora.spec $1 "$RELEASE.${bundle_id}$dist_tag" + sed -e "/^%define/s|HEAD|$bundle_id|" \ + -e '/^Version:/s|.*|Version: '$1'|' \ + < diaspora-bundle.spec > dist/diaspora-bundle.spec + + cp dist/diaspora.spec dist/diaspora/diaspora.spec +} + + +function prepare_rpm() +# Usage: prepare_rpm < commit> +{ + local dest=$(rpm --eval %_sourcedir) + test -z "$dest" && { + echo "Can't find RPM source directory, giving up." + exit 2 + } + + local commit=$( checkout $1) + echo "Release: $RELEASE.$commit" + echo "Rpm source dir: $dest" + + patch $VERSION $commit $RELEASE + + local src="dist/diaspora-$VERSION-$commit.tar.gz" + test -e $src || + cat <<- EOF + Warning: $src does not exist + (last version not built?) + EOF + ln -sf $PWD/$src $dest + + local bundle_commit=$( git_id dist/diaspora/Gemfile) + local bundle="dist/diaspora-bundle-$VERSION-$bundle_commit.tar.gz" + test -e $bundle || + cat <<- EOF + Warning: $bundle does not exist + (last version not built?) + EOF + ln -sf $PWD/$bundle $dest + + local file + for file in $( grep -v '^#' SOURCES); do + if [ -e "$file" ]; then + ln -sf $PWD/$file $dest/$file + else + echo "Warning: $file (listed in SOURCES) does not exist" + fi + done + + ( cd $dest; find . -type l -not -readable -exec rm {} \;) + echo "Source specfile: dist/diaspora.spec" + echo "Bundle specfile: dist/diaspora-bundle.spec" +} + + +function usage() +{ + cat <<- EOF + + Usage: prepare-rpm [options] + + Options: + + -h Print this message. + -r release For prepare, mark with release nr, defaults to 1. + -u uri Git repository URI, defaults to + $GIT_REPO. + + Symlink bundle and source tarballs to rpm source dir, create + patched rpm spec files. + + All results are stored in dist/ + + EOF +} + + +commit='HEAD' +BUNDLE_FIX='no' +while getopts ":r:u:h" opt +do + case $opt in + r) RELEASE="$OPTARG:" + ;; + h) usage + exit 0 + ;; + u) GIT_REPO="$OPTARG" + ;; + *) usage + exit 2 + ;; + esac +done +shift $(($OPTIND - 1)) + +typeset -r GIT_REPO RELEASE BUNDLE_FIX +export LANG=C + +test $# -gt 0 && { + usage; + exit 2; +} +prepare_rpm diff --git a/pkg/source/README.md b/pkg/source/README.md new file mode 100644 index 000000000..789da6ec8 --- /dev/null +++ b/pkg/source/README.md @@ -0,0 +1,74 @@ +## Diaspora source tarball generation + +Creates diaspora source tarballs. + +#### Generic source synopsis + +Generate source tarball: + % ./make-dist.sh source + Using repo: http://github.com/diaspora/diaspora.git + Commit id: 1010092232_b313272 + Source: dist/diaspora-0.0-1010092232_b313272.tar.gz + Required bundle: 1010081636_d1a4ee0 + % + +The source tarball could be used as-is, by unpacking add making a +*bundle install*. An alternative is to generate a canned bundle like: + % ./make-dist.sh bundle + [ lot's of output...] + Bundle: dist/diaspora-bundle-0.0-1010081636_d1a4ee0.tar.gz + % + +This file can be installed anywhere. To use it, add a symlinks from app +to the bundle'. Reasonable defaults are to install diaspora in +/usr/share/diaspora and bundle in /usr/lib/diaspora-bundle. With these, +the link setups is + % cd /usr/share/diaspora/master + % rm -rf vendor + % ln -sf /usr/lib/diaspora-bundle/vendor vendor + % ln -sf /usr/lib/diaspora-bundle/Gemfile . + % ln -sf /usr/lib/diaspora-bundle/Gemfile.lock . + + +The directories tmp, log, and public/uploads needs to be writable. If using +apache passenger, read the docs on uid used and file ownership. + +Note that the bundle version required is printed each time a new source +is generated. + +#### Notes + +The source tarball is as retrieved from diaspora with following differences: + + - The .git directories are removed (freeing more than 50% of the size). + - A new file /master/config/gitversion is created. + - The file public/source.tar.gz is generated. + - The file .bundle/config is patched. Remove before doing + *bundle install* + +The bundle is basically the output from 'bundle package'. The git-based +gems are also added into git-gems. Bundle also houses the two files +Gemfile and Gemfile.lock + +*make-dist.sh source* applies all patches named *.patch in this directory +after checking out source from git. + +./make-dist.sh bundle|source occasionally fails on bad Gemfile.lock. The +root cause is a bad Gemfile in the git repo. Possible fixes includes +using a older version known to work: + % ./make-dist.sh -c c818885b6 bundle + % ./make-dist.sh -c c818885b6 source + +or forcing a complete update of Gemfile.lock using 'bundle update' (a +potentially problematic operation): + % ./make-dist.sh -f bundle + +#### Implementation + +'make-dist.sh source' script checks out latest version of diaspora into the + dist/diaspora directory. This content is, after some patches, the diaspora package. + +'make-dir.sh bundle' makes a *bundle package* in the diaspora dir. +The resulting bundle is stored in vendor/bundle. This is, after some more +patches, the content of diaspora-bundle tarball. Target systems makes a +*bundle install --local* to use it. diff --git a/pkg/fedora/add-bundle.diff b/pkg/source/add-bundle.diff similarity index 100% rename from pkg/fedora/add-bundle.diff rename to pkg/source/add-bundle.diff diff --git a/pkg/fedora/dist/.gitkeep b/pkg/source/dist/.gitkeep similarity index 100% rename from pkg/fedora/dist/.gitkeep rename to pkg/source/dist/.gitkeep diff --git a/pkg/source/funcs.sh b/pkg/source/funcs.sh new file mode 100644 index 000000000..e47af236d --- /dev/null +++ b/pkg/source/funcs.sh @@ -0,0 +1,108 @@ +# +# Common stuff for pkg scripts +# + +function git_id +# +# Echo package-friendly source id. +# +# Usage: git_id [-n] [file or directory] +# +{ + local nl="\n" + local file_or_dir="$PWD" + test "$1" = '-n' && { nl=""; shift; } + test -n "$1" && file_or_dir="$1" + if [ -d $file_or_dir ]; then + local file="" + local dir=$file_or_dir + else + local file=$(basename $file_or_dir) + local dir=$(dirname $file_or_dir) + fi + + ( + cd $dir + git log -1 --abbrev-commit --date=iso $file | + awk -v nl="$nl" \ + ' BEGIN { commit = ""; d[1] = "" } + /^commit/ { if ( commit == "") commit = $2 } + /^Date:/ { if (d[1] == "") { + split( $2, d, "-") + split( $3, t, ":") + } + } + END { printf( "%s%s%s%s%s_%s%s", + substr( d[1],3), d[2], d[3], + t[1], t[2], + commit, nl) + }' + ) +} + +function checkout() +# Checkout last version of diaspora unless it's already there. +# Uses global GIT_REPO to determine repo url +# Usage: checkout [commit id, defaults to HEAD] +# Returns: commit for current branch's HEAD. +{ + mkdir dist &>/dev/null || : + ( + local last_repo='' + cd dist + + test -e '.last-repo' && + last_repo=$( cat '.last-repo') + test "$last_repo" != $GIT_REPO && + rm -rf diaspora + test -d diaspora || { + git clone --quiet $GIT_REPO; + ( + cd diaspora; + git checkout Gemfile Gemfile.lock + git remote add upstream \ + git://github.com/diaspora/diaspora.git + for p in ../../*.patch; do + git apply --whitespace=fix $p > /dev/null + done &> /dev/null || : + ) + } + echo -n "$GIT_REPO" > '.last-repo' + + cd diaspora; + git fetch --quiet upstream + git merge --quiet upstream/master + [ -n "$1" ] && git reset --hard --quiet $1 + git_id -n + ) +} + +function init_appconfig +# Edit pod_url in hostname +# Silently uses argumetn if present, else run dialog. +# Usage: init_appconfig [hostname] +{ + config=$1 + arg_hostname="$2" + hostname=$( awk '/pod_url:/ { print $2; exit }' <$config ) + + if [ -n "$arg_hostname" ]; then + sed -i "/pod_url:/s|$hostname|$arg_hostname|g" $config && \ + echo "config/app_config.yml updated." + return 0 + else + while : ; do + echo "Current hostname is \"$hostname\"" + echo -n "Enter new hostname [$hostname] :" + read new_hostname garbage + echo -n "Use \"$new_hostname\" as pod_url (Yes/No) [Yes]? :" + read yesno garbage + [ "${yesno:0:1}" = 'y' -o "${yesno:0:1}" = 'Y' -o -z "$yesno" ] && { + sed -i "/pod_url:/s|$hostname|$new_hostname|g" $config && + echo "config/app_config.yml updated." + break + } + done + fi +} + diff --git a/pkg/fedora/make-dist.sh b/pkg/source/make-dist.sh similarity index 50% rename from pkg/fedora/make-dist.sh rename to pkg/source/make-dist.sh index 5d6d1cdba..e96e62ef6 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/source/make-dist.sh @@ -1,180 +1,13 @@ #!/bin/bash -# Create a diaspora distribution +# Create diaspora distribution tarballs. # # Usage: See function usage() at bottom. # GIT_REPO='http://github.com/diaspora/diaspora.git' VERSION='0.0' -RELEASE='1' - -function git_id -# -# Echo package-friendly source id. -# -# Usage: git_id [-n] [file or directory] -# -{ - local nl="\n" - local file_or_dir="$PWD" - test "$1" = '-n' && { nl=""; shift; } - test -n "$1" && file_or_dir="$1" - if [ -d $file_or_dir ]; then - local file="" - local dir=$file_or_dir - else - local file=$(basename $file_or_dir) - local dir=$(dirname $file_or_dir) - fi - - ( - cd $dir - git log -1 --abbrev-commit --date=iso $file | - awk -v nl="$nl" \ - ' BEGIN { commit = ""; d[1] = "" } - /^commit/ { if ( commit == "") commit = $2 } - /^Date:/ { if (d[1] == "") { - split( $2, d, "-") - split( $3, t, ":") - } - } - END { printf( "%s%s%s%s%s_%s%s", - substr( d[1],3), d[2], d[3], - t[1], t[2], - commit, nl) - }' - ) -} - - -function fix_alphatag() -# Patch version on top comment first id line: -# Usage: fix_alphatag -# Patches:\ -# * Fri Sep 24 2010 name surname 1.20100925_faf23207 -{ - local dist=$(rpm --eval %dist) - awk -v dist="$dist" -v version="$2" -v commit="$3" -v release="$4" \ - ' BEGIN { done = 0 } - /^[*]/ { if (done) - print - else - { - s = sprintf( "-%s.%s%s\n", release, commit, dist) - gsub( "-[0-9][.][^ ]*$", s) - done = 1 - # add new gsub for version... - print - } - next - } - { print }' < $1 > $1.tmp && mv -f $1.tmp $1 -} - - -function fix_bundle_deps -# usage: fix_bundle_deps -# Patches: Requires: diaspora-bundle = 0.0-20101021-aefsf323148 -{ - awk -v vers="$2-$3" \ - ' /Requires:/ { if ($2 == "diaspora-bundle") - printf( "%s %s = %s\n", $1,$2,vers) - else - print - next - } - { print}' \ - < $1 > $1.tmp && mv -f $1.tmp $1 -} - - -function patch() -# Patch spec-files with current version-release -# Usage: patch -{ - sed -e "/^%define/s|HEAD|$2|" \ - -e '/^Version:/s|.*|Version: '$1'|' \ - dist/diaspora.spec - fix_alphatag dist/diaspora.spec $1 $2 $3 - local bundle_id=$(git_id dist/diaspora/Gemfile) - local dist_tag=$(rpm --eval %dist) - fix_bundle_deps dist/diaspora.spec $1 "$RELEASE.${bundle_id}$dist_tag" - sed -e "/^%define/s|HEAD|$bundle_id|" \ - -e '/^Version:/s|.*|Version: '$1'|' \ - < diaspora-bundle.spec > dist/diaspora-bundle.spec - - cp dist/diaspora.spec dist/diaspora/diaspora.spec -} - - -function checkout() -# Checkout last version of diaspora unless it's already there. -# Usage: checkout [commit id, defaults to HEAD] -# Returns: commit for current branch's HEAD. -{ - mkdir dist &>/dev/null || : - ( - local last_repo='' - cd dist - - test -e '.last-repo' && - last_repo=$( cat '.last-repo') - test "$last_repo" != $GIT_REPO && - rm -rf diaspora - test -d diaspora || { - git clone --quiet $GIT_REPO; - ( - cd diaspora; - git remote add upstream \ - git://github.com/diaspora/diaspora.git - for p in ../../*.patch; do - git apply --whitespace=fix $p > /dev/null - done &> /dev/null || : - ) - } - echo -n "$GIT_REPO" > '.last-repo' - - cd diaspora; - git fetch --quiet upstream - git merge --quiet upstream/master - [ -n "$1" ] && git reset --hard --quiet $1 - git_id -n - ) -} - - -function make_src -# Create a distribution tarball -# Usage: make src -{ - echo "Using repo: $GIT_REPO" - - commit=$(checkout ${1:-'HEAD'}) - echo "Commit id: $commit" - - RELEASE_DIR="diaspora-$VERSION-$commit" - rm -rf dist/${RELEASE_DIR} - mkdir dist/${RELEASE_DIR} - cd dist - mkdir ${RELEASE_DIR}/master - cp -ar diaspora/* diaspora/.git* ${RELEASE_DIR}/master - ( - cd ${RELEASE_DIR}/master - rm -rf vendor/bundle/* vendor/git/* vendor/cache/* gem-tmp - git show --name-only > config/gitversion - tar czf public/source.tar.gz \ - --exclude='source.tar.gz' -X .gitignore * - find $PWD -name .git\* | xargs rm -rf - rm -rf .bundle - /usr/bin/patch -p1 -s <../../../add-bundle.diff - ) - tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && \ - rm -rf ${RELEASE_DIR} - cd .. - echo "Source: dist/${RELEASE_DIR}.tar.gz" - echo "Required bundle: $(git_id dist/diaspora/Gemfile)" -} +. ./funcs.sh function build_git_gems() # Usage: build_git_gems @@ -213,6 +46,38 @@ function build_git_gems() # rm -rf gem-tmp } +function make_src +# Create a distribution tarball +# Usage: make src +{ + echo "Using repo: $GIT_REPO" + + commit=$(checkout ${1:-'HEAD'}) + echo "Commit id: $commit" + + RELEASE_DIR="diaspora-$VERSION-$commit" + rm -rf dist/${RELEASE_DIR} + mkdir dist/${RELEASE_DIR} + cd dist + mkdir ${RELEASE_DIR}/master + cp -ar diaspora/* diaspora/.git* ${RELEASE_DIR}/master + ( + cd ${RELEASE_DIR}/master + rm -rf vendor/bundle/* vendor/git/* vendor/cache/* gem-tmp + git show --name-only > config/gitversion + tar czf public/source.tar.gz \ + --exclude='source.tar.gz' -X .gitignore * + find $PWD -name .git\* | xargs rm -rf + rm -rf .bundle + /usr/bin/patch -p1 -s <../../../add-bundle.diff + ) + tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && \ + rm -rf ${RELEASE_DIR} + cd .. + echo "Source: dist/${RELEASE_DIR}.tar.gz" + echo "Required bundle: $(git_id dist/diaspora/Gemfile)" +} + function make_docs() { local gems=$1 @@ -238,6 +103,7 @@ function make_docs() } + function make_bundle() # Create the bundle tarball # Usage: make_bundle [ commit, defaults to HEAD] @@ -280,6 +146,7 @@ function make_bundle() mv vendor/cache ../$bundle_name/vendor mv vendor/gems ../$bundle_name/vendor mv git-repos ../$bundle_name + git checkout Gemfile cd .. tar czf $bundle_name.tar.gz $bundle_name mv $bundle_name/vendor/cache diaspora/vendor/cache @@ -289,65 +156,16 @@ function make_bundle() echo "Bundle: dist/$bundle_name.tar.gz" } - -function prepare_rpm() -# Usage: prepare_rpm < commit> -{ - local dest=$(rpm --eval %_sourcedir) - test -z "$dest" && { - echo "Can't find RPM source directory, giving up." - exit 2 - } - - local commit=$( checkout $1) - echo "Release: $RELEASE.$commit" - echo "Rpm source dir: $dest" - - patch $VERSION $commit $RELEASE - - local src="dist/diaspora-$VERSION-$commit.tar.gz" - test -e $src || - cat <<- EOF - Warning: $src does not exist - (last version not built?) - EOF - ln -sf $PWD/$src $dest - - local bundle_commit=$( git_id dist/diaspora/Gemfile) - local bundle="dist/diaspora-bundle-$VERSION-$bundle_commit.tar.gz" - test -e $bundle || - cat <<- EOF - Warning: $bundle does not exist - (last version not built?) - EOF - ln -sf $PWD/$bundle $dest - - local file - for file in $( grep -v '^#' SOURCES); do - if [ -e "$file" ]; then - ln -sf $PWD/$file $dest/$file - else - echo "Warning: $file (listed in SOURCES) does not exist" - fi - done - - ( cd $dest; find . -type l -not -readable -exec rm {} \;) - echo "Source specfile: dist/diaspora.spec" - echo "Bundle specfile: dist/diaspora-bundle.spec" -} - - function usage() { cat <<- EOF - Usage: make-dist [options] + Usage: make-dist [options] Options: -h Print this message. -c commit Use a given commit, defaults to last checked in. - -r release For prepare, mark with release nr, defaults to 1. -u uri Git repository URI, defaults to $GIT_REPO. -f For bundle, fix dependencies by running 'bundle update' @@ -355,8 +173,6 @@ function usage() source Build a diaspora application tarball. bundle Build a bundler(1) bundle for diaspora. - prepare Symlink bundle and source tarballs to rpm source dir, - create patched rpm spec files. All results are stored in dist/ @@ -366,15 +182,13 @@ function usage() commit='HEAD' BUNDLE_FIX='no' -while getopts ":r:c:u:fh" opt +while getopts ":c:u:fh" opt do case $opt in u) GIT_REPO="$OPTARG" ;; c) commit="${OPTARG:0:7}" ;; - r) RELEASE="$OPTARG:" - ;; f) BUNDLE_FIX='yes' ;; h) usage @@ -387,7 +201,7 @@ do done shift $(($OPTIND - 1)) -typeset -r GIT_REPO RELEASE BUNDLE_FIX +typeset -r GIT_REPO BUNDLE_FIX export LANG=C test $# -gt 1 -o $# -eq 0 && { @@ -401,8 +215,6 @@ case $1 in ;; 'source') make_src $commit ;; - 'prepare') prepare_rpm $commit $release - ;; *) usage exit 1 ;; diff --git a/pkg/ubuntu/README.md b/pkg/ubuntu/README.md index 44e83c79b..99735621a 100644 --- a/pkg/ubuntu/README.md +++ b/pkg/ubuntu/README.md @@ -5,23 +5,20 @@ work as a first step towards packaging, but should be usable as is. ### Synopsis - Bootstrap the distribution from git: % sudo apt-get install git-core % git clone git://github.com/diaspora/diaspora.git % cd diaspora/pkg/ubuntu +Create and install the diaspora bundle and application in +diaspora/pkg/source according to +[source README](http://github.com/diaspora/diaspora/tree/master/pkg/source/) + Install the dependencies (a good time for a coffe break): % sudo ./diaspora-install-deps -Create and install the diaspora bundle and application: - % ./make-dist.sh bundle - % sudo ./diaspora-bundle-install dist/diaspora-bundle-*.tar.gz - - % ./make-dist.sh source - % sudo ./diaspora-install dist/diaspora-0.0*.tar.gz - -Initiate and start the server; +Install, initiate and start the server; + % sudo ./diaspora-install % sudo ./diaspora-setup % sudo su - diaspora % cd /usr/share/diaspora/master diff --git a/pkg/ubuntu/add-bundle.diff b/pkg/ubuntu/add-bundle.diff deleted file mode 100644 index 24c0f6035..000000000 --- a/pkg/ubuntu/add-bundle.diff +++ /dev/null @@ -1,11 +0,0 @@ -diff --git a/.bundle/config b/.bundle/config -new file mode 100644 -index 0000000..1c3e2ce ---- /dev/null -+++ b/.bundle/config -@@ -0,0 +1,5 @@ -+--- -+BUNDLE_FROZEN: "1" -+BUNDLE_DISABLE_SHARED_GEMS: "1" -+BUNDLE_WITHOUT: test:rdoc -+BUNDLE_PATH: vendor/bundle diff --git a/pkg/ubuntu/diaspora-install b/pkg/ubuntu/diaspora-install index 4679c9f2b..7090e775b 100755 --- a/pkg/ubuntu/diaspora-install +++ b/pkg/ubuntu/diaspora-install @@ -43,12 +43,20 @@ mkdir -p /var/lib/diaspora/tmp mkdir -p /var/run/diaspora mkdir -p /etc/diaspora +bundle='/usr/lib/diaspora-bundle' +[ "$(arch | tr -d '\n')" = 'x86_64' ] && \ + bundle='/usr/lib64/diaspora-bundle' + ln -sf /var/log/diaspora ./master/log cp master/config/app_config.yml.example /etc/diaspora/app_config.yml ln -sf /etc/diaspora/app_config.yml master/config/app_config.yml ln -sf /var/lib/diaspora/uploads master/public/ ln -sf /var/lib/diaspora/tmp master -ln -sf /usr/lib/diaspora-bundle/vendor/bundle master/vendor +rm -rf master/vendor +ln -sf $bundle/vendor master/vendor + +ln -sf $bundle/Gemfile master/Gemfile +ln -sf $bundle/Gemfile.lock master/Gemfile.lock rm -rf /usr/share/doc/diaspora mkdir -p /usr/share/doc/diaspora diff --git a/pkg/ubuntu/dist b/pkg/ubuntu/dist new file mode 120000 index 000000000..2fb4d8549 --- /dev/null +++ b/pkg/ubuntu/dist @@ -0,0 +1 @@ +../source/dist/ \ No newline at end of file diff --git a/pkg/ubuntu/dist/.gitkeep b/pkg/ubuntu/dist/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pkg/ubuntu/make-dist.sh b/pkg/ubuntu/make-dist.sh deleted file mode 120000 index f6ba9c6a2..000000000 --- a/pkg/ubuntu/make-dist.sh +++ /dev/null @@ -1 +0,0 @@ -../fedora/make-dist.sh \ No newline at end of file diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index e4a581d57..c4e05d7d0 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -24,8 +24,8 @@ $(function() { $("ul .person").draggable({ revert: true, start: function(event,ui){ - $(this).children("img").animate({'height':80, 'width':80, 'opacity':0.8},200); - $(this).children("img").tipsy("hide"); + $(this).children("img").animate({'height':80, 'width':80, 'opacity':0.8},200) + .tipsy("hide"); $(".draggable_info").fadeIn(100); }, drag: function(event,ui){ @@ -67,7 +67,7 @@ $(function() { }}); } - $(this).closest("ul").append(person); + dropzone.closest("ul").append(person); } }); @@ -96,8 +96,6 @@ $(function() { } } }); - - }); @@ -107,7 +105,6 @@ $(".delete").live("click", function() { var person = $(this).closest("li.person"); if (person.hasClass('request')){ - if( confirm("Ignore request?") ){ var request_id = person.attr("data-guid"); @@ -121,7 +118,6 @@ $(".delete").live("click", function() { } } else { - if( confirm("Remove this person from all aspects?") ){ var person_id = $(this).closest("li.person").attr('data-guid'); diff --git a/public/javascripts/image_picker.js b/public/javascripts/image_picker.js index 2692ffee9..eacf7822d 100644 --- a/public/javascripts/image_picker.js +++ b/public/javascripts/image_picker.js @@ -2,16 +2,15 @@ * licensed under the Affero General Public License version 3 or later. See * the COPYRIGHT file. */ - - -$(document).ready( function() { +$(document).ready(function() { $('div#image_picker div.small_photo').click( function() { - $('#image_url_field').val($(this).attr('id')); + var $this = $(this); + document.getElementById("image_url_field").value = this.id; - $('div#image_picker div.small_photo').removeClass('selected'); - $("div#image_picker div.small_photo input[type='checkbox']").attr("checked", false); + $('div#image_picker div.small_photo.selected').removeClass('selected') + .children("input[type='checkbox']").attr("checked", false); - $(this).addClass('selected'); - $(this).children("input[type='checkbox']").attr("checked", true); + $this.addClass('selected') + .children("input[type='checkbox']").attr("checked", true); }); }); diff --git a/public/javascripts/photo.js b/public/javascripts/photo.js index 2991903d7..ff20a1735 100644 --- a/public/javascripts/photo.js +++ b/public/javascripts/photo.js @@ -20,6 +20,8 @@ $(document).keydown(function(e){ }); $(document).ready(function(){ + var $edit_photo = $(".edit_photo"); + //add a clas to verify if a textarea has focus $("textarea").live('focus',function(){ $(this).addClass("hasfocus"); @@ -34,13 +36,13 @@ $(document).ready(function(){ }); //Add a description with ajax request - $("#photo_submit").click(function(evenet){ + $("#photo_submit").click(function(event){ event.preventDefault(); - var method = $(".edit_photo").attr("method"); - var url = $(".edit_photo").attr("action"); - var data = $(".edit_photo").serialize(); + var method = $edit_photo.attr("method"); + var url = $edit_photo.attr("action"); + var data = $edit_photo.serialize(); $(".description").text($("#photo_caption").val()); - $(".edit_photo").toggle(); + $edit_photo.toggle(); $.ajax({ type: method, diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js index ae6ae7d91..ede3fa652 100644 --- a/public/javascripts/stream.js +++ b/public/javascripts/stream.js @@ -5,7 +5,7 @@ $(document).ready(function(){ - + var $stream = $("#stream"); // expand all comments on page load $("#stream:not('.show')").find('.comments').each(function(index) { var comments = $(this); @@ -16,17 +16,17 @@ $(document).ready(function(){ }); // comment toggle action - $("#stream:not('.show')").delegate("a.show_post_comments", "click", function(evt) { + $stream.not(".show").delegate("a.show_post_comments", "click", function(evt) { evt.preventDefault(); expandComments($(this)); }); // comment submit action - $("#stream").delegate("a.comment_submit", "click", function(evt){ + $stream.delegate("a.comment_submit", "click", function(evt){ $(this).closest("form").children(".comment_box").attr("rows", 1); }); - $("#stream").delegate("textarea.comment_box", "focus", function(evt){ + $stream.delegate("textarea.comment_box", "focus", function(evt){ var commentBox = $(this); commentBox.attr("rows", 2) .closest("form").find(".comment_submit").fadeIn(200); @@ -41,11 +41,14 @@ $(document).ready(function(){ }); // reshare button action - $("#stream").delegate(".reshare_button", "click", function(evt){ + $stream.delegate(".reshare_button", "click", function(evt){ evt.preventDefault(); - var button = $(this); - button.closest(".reshare_pane").children(".reshare_box").show(); - button.addClass("active"); + button = $(this) + box = button.siblings(".reshare_box"); + if(box.length > 0){ + button.toggleClass("active"); + box.toggle(); + } }); });//end document ready diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 8cbc5786c..aa20805ba 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -5,10 +5,9 @@ $(document).ready(function(){ - - $('#debug_info').click(function() { - $('#debug_more').toggle('fast'); - }); + $('#debug_info').click(function() { + $('#debug_more').toggle('fast'); + }); $("label").inFieldLabels(); @@ -26,12 +25,12 @@ $(document).ready(function(){ }); //buttons////// - $(".add_aspect_button").fancybox({ 'titleShow' : false , 'hideOnOverlayClick' : false }); - $(".add_request_button").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false }); - $(".invite_user_button").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false }); - $(".add_photo_button").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false }); - $(".remove_person_button").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false }); - $(".question_mark").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false }); + $(".add_aspect_button," + + ".add_request_button," + + ".invite_user_button," + + ".add_photo_button," + + ".remove_person_button," + + ".question_mark").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false }); $("input[type='submit']").addClass("button"); @@ -49,13 +48,13 @@ $(document).ready(function(){ ); $("#publisher").find("textarea").keydown( function(e) { - if (e.keyCode == 13) { + if (e.keyCode === 13) { $(this).closest("form").submit(); } }); $("#stream").delegate("textarea.comment_box", "keydown", function(e){ - if (e.keyCode == 13) { + if (e.keyCode === 13) { $(this).closest("form").submit(); } }); @@ -65,17 +64,15 @@ $(document).ready(function(){ }); $('body').click( function(event){ - if(!$(event.target).closest('#user_menu').length){ + var target = $(event.target); + if(!target.closest('#user_menu').length){ $("#user_menu").removeClass("active"); }; - if(!$(event.target).closest('.reshare_box').length){ + if(!target.closest('.reshare_pane').length){ $(".reshare_button").removeClass("active"); $(".reshare_box").hide(); }; }); - - //$("#slider").easySlider({speed:400}); - $("img", "#left_pane").tipsy({live:true}); $(".add_aspect_button", "#aspect_nav").tipsy({gravity:'w'}); @@ -104,26 +101,29 @@ $.fn.clearForm = function() { var video_active_container = null; function openVideo(type, videoid, link) { - var container = document.createElement('div'); + var container = document.createElement('div'), + $container = $(container); if(type == 'youtube.com') { - container.innerHTML = 'Watch this video on Youtube
'; + $container.html('Watch this video on Youtube
'); } else { - container.innerHTML = 'Invalid videotype '+type+' (ID: '+videoid+')'; + $container.html('Invalid videotype '+type+' (ID: '+videoid+')'); } if(video_active_container != null) { video_active_container.parentNode.removeChild(video_active_container); } video_active_container = container; - $(container).hide(); + $container.hide(); link.parentNode.insertBefore(container, this.nextSibling); - $(container).slideDown('fast', function() { }); - link.onclick = function() { $(container).slideToggle('fast', function() { } ); } + $container.slideDown('fast', function() { }); + link.onclick = function() { $container.slideToggle('fast', function() { } ); } } $(".make_profile_photo").live("click", function(){ - var user_id = $(this).closest(".controls").attr('data-actor'); - person_id = $(this).closest(".controls").attr('data-actor_person'); - photo_url = $(this).closest(".controls").attr('data-image_url'); + var $this = $(this), + $controls = $this.closest(".controls"), + user_id = $controls.attr('data-actor'); + person_id = $controls.attr('data-actor_person'); + photo_url = $controls(".controls").attr('data-image_url'); $.ajax({ type: "PUT", @@ -131,7 +131,7 @@ $(".make_profile_photo").live("click", function(){ data: {"person":{"profile":{ "image_url": photo_url }}}, success: function(){ $("img[data-person_id='"+ person_id +"']").each( function() { - $(this).attr('src', photo_url); + this.src = photo_url; }); } }); diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index b271a1df7..c541f5c41 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -50,7 +50,6 @@ h3 :padding 1em - :box-shadow 0 1px 2px #333 :-moz-box-shadow 0 1px 2px #333 :-webkit-box-shadow 0 1px 2px #333 @@ -206,10 +205,16 @@ header :display inline .avatar + :-webkit-border-radius 5px + :-moz-border-radius 5px :border-radius 5px img :-webkit-box-shadow 0 1px 2px #666 + :-moz-box-shadow 0 1px 2px #666 + + :-webkit-border-radius 5px + :-moz-border-radius 5px :border-radius 5px @@ -262,7 +267,9 @@ header :position absolute :top 7px :left 0 + :-webkit-box-shadow 0 1px 2px #666 + :-moz-box-shadow 0 1px 2px #666 h2 :margin @@ -276,6 +283,8 @@ header :size 14px .avatar + :-webkit-border-radius 5px + :-moz-border-radius 5px :border-radius 5px li.message @@ -337,7 +346,11 @@ li.message &.active :background :color #333 + + :-webkit-border-radius 5px 5px 0 0 + :-moz-border-radius 5px 5px 0 0 :border-radius 5px 5px 0 0 + a :color #fff :text-shadow none @@ -540,9 +553,11 @@ ul.comments #stream, #profile, .comments img.person_picture - :border-radius 3px + :-webkit-border-radius 3px :-moz-border-radius 3px + :border-radius 3px + :display inline block :height 30px :display absolute @@ -586,10 +601,12 @@ li.message .from .right #show_photo img :max-width 100% - :-webkit-box-shadow 0 2px 4px #333 :border 10px solid #fff :bottom 80px solid #fff + :-webkit-box-shadow 0 2px 4px #333 + :-moz-box-shadow 0 2px 4px #333 + :-webkit-border-radius 3px :-moz-border-radius 3px :border-radius 3px @@ -619,9 +636,9 @@ textarea :border 1px solid #ccc :height auto - :border-radius 5px :-webkit-border-radius 5px :-moz-border-radius 5px + :border-radius 5px input[type='checkbox'] :width auto @@ -661,9 +678,10 @@ label :position absolute :margin :right 15px - :border-radius 5px + :-webkit-border-radius 5px :-moz-border-radius 5px + :border-radius 5px form :position relative @@ -715,6 +733,8 @@ label :bottom 1em img + :-moz-border-radius 3px + :-webkit-border-radius 3px :border-radius 3px input[type='checkbox'] @@ -859,6 +879,7 @@ h1.big_text a :-webkit-border-radius 5px 5px 0 0 :-moz-border-radius 5px 5px 0 0 + :border-radius 5px 5px 0 0 :text-shadow 0 1px 0 #444 :line @@ -1000,8 +1021,13 @@ h1.big_text img :height 70px :width 70px - :border-radius 5px + :-webkit-box-shadow 0 1px 2px #999 + :-moz-box-shadow 0 1px 2px #999 + + :-webkit-border-radius 5px + :-moz-border-radius 5px + :border-radius 5px &:hover .delete @@ -1041,6 +1067,7 @@ h1.big_text :border-radius 20px :-webkit-box-shadow 0 1px 3px #000 + :-moz-box-shadow 0 1px 3px #000 .x :z-index 2 @@ -1095,6 +1122,10 @@ ul#settings_nav :width 30px :height 30px +.friend_pictures.horizontal + img + :margin-right -5px + #thumbnails :line-height 14px @@ -1103,6 +1134,9 @@ ul#settings_nav :padding 0 #left_pane + h2 + :font + :weight 200 ul :margin 0 :padding 0 @@ -1132,6 +1166,9 @@ ul#settings_nav :bottom 0.7em :border 2px dashed #FAC421 + + :-webkit-border-radius 5px + :-moz-border-radius 5px :border-radius 5px .null_arrow @@ -1158,6 +1195,7 @@ h2,h3,h4 input[type="search"] :-webkit-appearance textfield + :-moz-appearance textfield header input[type="search"] @@ -1286,6 +1324,8 @@ ul.aspects :height 20px :-webkit-border-radius 10px + :-moz-border-radius 10px + :border-radius 10px :line-height 16px :text-indent 6px @@ -1299,8 +1339,14 @@ ul.aspects :padding 12px :background :color rgb(255,255,255) + :-webkit-box-shadow 0 1px 3px #333 + :-moz-box-shadow 0 1px 3px #333 + + :-webkit-border-radius 2px + :-moz-border-radius 2px :border-radius 2px + :border :bottom 1px solid #ccc :top 1px solid #fff @@ -1335,6 +1381,9 @@ ul.aspects :background :color rgb(16,127,201) :padding 8px + + :-webkit-border-radius 10px + :-moz-border-radius 10px :border-radius 10px &:hover @@ -1369,7 +1418,10 @@ ul.aspects #user_photo_uploader .avatar + :-webkit-border-radius 5px + :-moz-border-radius 5px :border-radius 5px + :height 100px :width 100px @@ -1382,13 +1434,19 @@ ul.aspects #profile_photo_upload :margin :top 5px + :min-height 100px img :position absolute :left 0 :height 100px :width 100px + + :-webkit-border-radius 5px + :-moz-border-radius 5px :border-radius 5px + :-webkit-box-shadow 0 1px 2px #666 + :-moz-box-shadow 0 1px 2px #666 :padding :left 120px diff --git a/spec/controllers/albums_controller_spec.rb b/spec/controllers/albums_controller_spec.rb index d1db2c3e2..21e750685 100644 --- a/spec/controllers/albums_controller_spec.rb +++ b/spec/controllers/albums_controller_spec.rb @@ -8,7 +8,7 @@ describe AlbumsController do render_views before do @user = make_user - @aspect = @user.aspect(:name => "lame-os") + @aspect = @user.aspects.create(:name => "lame-os") @album = @user.post :album, :to => @aspect.id, :name => 'things on fire' sign_in :user, @user end diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 54a914eaa..7c3c0dda9 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -9,13 +9,14 @@ describe AspectsController do before do @user = make_user - @aspect = @user.aspect(:name => "lame-os") - @aspect1 = @user.aspect(:name => "another aspect") + @aspect = @user.aspects.create(:name => "lame-os") + @aspect1 = @user.aspects.create(:name => "another aspect") @user2 = make_user - @aspect2 = @user2.aspect(:name => "party people") + @aspect2 = @user2.aspects.create(:name => "party people") friend_users(@user,@aspect, @user2, @aspect2) @contact = @user.contact_for(@user2.person) sign_in :user, @user + request.env["HTTP_REFERER"] = 'http://' + request.host end describe "#index" do @@ -44,9 +45,9 @@ describe AspectsController do post :create, "aspect" => {"name" => ""} @user.reload.aspects.count.should == 2 end - it "goes back to manage aspects" do + it "goes back to the page you came from" do post :create, "aspect" => {"name" => ""} - response.should redirect_to(aspects_manage_path) + response.should redirect_to(:back) end end end @@ -63,7 +64,7 @@ describe AspectsController do describe "#update" do before do - @aspect = @user.aspect(:name => "Bruisers") + @aspect = @user.aspects.create(:name => "Bruisers") end it "doesn't overwrite random attributes" do new_user = Factory.create :user diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 7ed3ffbff..16b0968a4 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -8,7 +8,7 @@ describe PeopleController do render_views let(:user) { Factory(:user) } - let!(:aspect) { user.aspect(:name => "lame-os") } + let!(:aspect) { user.aspects.create(:name => "lame-os") } before do sign_in :user, user @@ -37,32 +37,18 @@ describe PeopleController do it "doesn't overwrite the profile photo when an empty string is passed in" do user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg" user.person.profile.save - - params = {"profile"=> - {"image_url" => "", - "last_name" => user.person.profile.last_name, - "first_name" => user.person.profile.first_name}} + + params = { "profile" => + { "image" => "", + "last_name" => user.person.profile.last_name, + "first_name" => user.person.profile.first_name }} image_url = user.person.profile.image_url - put("update", :id => user.person.id, "person" => params) + put :update, "id" => user.person.id.to_s, "person" => params user.person.reload user.person.profile.image_url.should == image_url end - - it "doesn't prepend (https?://) if already present in image_url" do - params = {:profile=> - {:image_url => "https://google.com/image.png", - :last_name => user.person.profile.last_name, - :first_name => user.person.profile.first_name}} - - put("update", :id => user.person.id, "person" => params) - - user.person.reload - user.person.profile.image_url.should == params[:profile][:image_url] - end - end end - end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index f435ca568..00c838642 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -8,7 +8,7 @@ describe PhotosController do render_views before do @user = make_user - @aspect = @user.aspect(:name => "lame-os") + @aspect = @user.aspects.create(:name => "lame-os") @album = @user.post :album, :to => @aspect.id, :name => 'things on fire' @fixture_filename = 'button.png' @fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', @fixture_filename) diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index b89e5fbc3..136eff689 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -9,9 +9,9 @@ describe PublicsController do render_views let!(:user) { make_user } let!(:user2) { make_user } - let!(:aspect1) { user.aspect(:name => "foo") } - let!(:aspect2) { user2.aspect(:name => "far") } - let!(:aspect2) { user2.aspect(:name => 'disciples') } + let!(:aspect1) { user.aspects.create(:name => "foo") } + let!(:aspect2) { user2.aspects.create(:name => "far") } + let!(:aspect2) { user2.aspects.create(:name => 'disciples') } let!(:req) { user2.send_friend_request_to(user.person, aspect2) } let!(:xml) { user2.salmon(req).xml_for(user.person) } let(:person){Factory(:person)} diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index 8b276dfc8..636d6e2b9 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -10,7 +10,7 @@ describe RequestsController do @user = make_user sign_in :user, @user - @user.aspect(:name => "lame-os") + @user.aspects.create(:name => "lame-os") end it "should not error out when requesting to be friends with yourself" do diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index 71c7317b4..9ffa6f622 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe ServicesController do render_views let(:user) { make_user } - let!(:aspect) { user.aspect(:name => "lame-os") } + let!(:aspect) { user.aspects.create(:name => "lame-os") } let!(:service1) {a = Factory(:service); user.services << a; a} let!(:service2) {a = Factory(:service); user.services << a; a} diff --git a/spec/controllers/sockets_controller_spec.rb b/spec/controllers/sockets_controller_spec.rb index 0b7e6ab1a..011f29453 100644 --- a/spec/controllers/sockets_controller_spec.rb +++ b/spec/controllers/sockets_controller_spec.rb @@ -24,7 +24,7 @@ describe SocketsController do describe 'actionhash' do before do - @aspect = @user.aspect :name => "losers" + @aspect = @user.aspects.create(:name => "losers") @message = @user.post :status_message, :message => "post through user for victory", :to => @aspect.id @fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png' end diff --git a/spec/controllers/status_message_controller_spec.rb b/spec/controllers/status_message_controller_spec.rb index 8b96e49cb..059fe5fb4 100644 --- a/spec/controllers/status_message_controller_spec.rb +++ b/spec/controllers/status_message_controller_spec.rb @@ -8,7 +8,7 @@ describe StatusMessagesController do render_views let!(:user) { make_user } - let!(:aspect) { user.aspect(:name => "lame-os") } + let!(:aspect) { user.aspects.create(:name => "lame-os") } before do sign_in :user, user @@ -16,7 +16,12 @@ describe StatusMessagesController do end describe '#create' do - let(:status_message_hash) {{"status_message"=>{"public"=>"true", "message"=>"facebook, is that you?", "to" =>"#{aspect.id}"}}} + let(:status_message_hash) { + {:status_message =>{ + :public =>"true", + :message =>"facebook, is that you?", + :to =>"#{aspect.id}"}} + } context "posting out to facebook" do let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s } @@ -27,10 +32,22 @@ describe StatusMessagesController do end it 'should not post to facebook when public is not set' do - status_message_hash['status_message']['public'] = 'false' + status_message_hash[:status_message][:public] = 'false' user.should_not_receive(:post_to_facebook) post :create, status_message_hash end + it "doesn't overwrite person_id" do + new_user = make_user + status_message_hash[:status_message][:person_id] = new_user.person.id + post :create, status_message_hash + StatusMessage.find_by_message(status_message_hash[:status_message][:message]).person_id.should == user.person.id + end + it "doesn't overwrite id" do + old_status_message = user.post(:status_message, :message => "hello", :to => aspect.id) + status_message_hash[:status_message][:id] = old_status_message.id + lambda {post :create, status_message_hash}.should raise_error /failed save/ + old_status_message.reload.message.should == 'hello' + end end context "posting to twitter" do @@ -42,7 +59,7 @@ describe StatusMessagesController do end it 'should not post to twitter when public in not set' do - status_message_hash['status_message']['public'] = 'false' + status_message_hash[:status_message][:public] = 'false' user.should_not_receive(:post_to_twitter) post :create, status_message_hash end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index b48115f08..13699c59b 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe UsersController do let(:user) { make_user } - let!(:aspect) { user.aspect(:name => "lame-os") } + let!(:aspect) { user.aspects.create(:name => "lame-os") } let!(:old_password) { user.encrypted_password } let!(:old_language) { user.language } diff --git a/spec/helper_methods.rb b/spec/helper_methods.rb index e60b39535..4dc1ca8f2 100644 --- a/spec/helper_methods.rb +++ b/spec/helper_methods.rb @@ -28,9 +28,12 @@ module HelperMethods def friend_users(user1, aspect1, user2, aspect2) request = user1.send_friend_request_to(user2.person, aspect1) - user2.receive_friend_request(request) + + user2.receive request.to_diaspora_xml, user1.person + reversed_request = user2.accept_friend_request( request.id, aspect2.id) user1.reload + user1.receive reversed_request.to_diaspora_xml, user2.person user1.reload aspect1.reload diff --git a/spec/lib/diaspora/exporter_spec.rb b/spec/lib/diaspora/exporter_spec.rb index 6e9e6e1f9..85ee28a6c 100644 --- a/spec/lib/diaspora/exporter_spec.rb +++ b/spec/lib/diaspora/exporter_spec.rb @@ -11,10 +11,10 @@ describe Diaspora::Exporter do let!(:user2) { make_user } let!(:user3) { make_user } - let!(:aspect) { user1.aspect(:name => "Old Work") } - let(:aspect1) { user1.aspect(:name => "Work") } - let(:aspect2) { user2.aspect(:name => "Family") } - let(:aspect3) { user3.aspect(:name => "Pivots") } + let!(:aspect) { user1.aspects.create(:name => "Old Work") } + let(:aspect1) { user1.aspects.create(:name => "Work") } + let(:aspect2) { user2.aspects.create(:name => "Family") } + let(:aspect3) { user3.aspects.create(:name => "Pivots") } let!(:status_message1) { user1.post(:status_message, :message => "One", :public => true, :to => aspect1.id) } let!(:status_message2) { user1.post(:status_message, :message => "Two", :public => true, :to => aspect1.id) } diff --git a/spec/lib/diaspora/importer_spec.rb b/spec/lib/diaspora/importer_spec.rb index 2d37205c7..f855f8bd0 100644 --- a/spec/lib/diaspora/importer_spec.rb +++ b/spec/lib/diaspora/importer_spec.rb @@ -20,18 +20,18 @@ describe Diaspora::Importer do @person2 = Factory(:person) # User1 has four aspects(1-4), each following user has one aspect - @aspect1 = @user1.aspect(:name => "Dudes") - @aspect2 = @user1.aspect(:name => "Girls") - @aspect3 = @user1.aspect(:name => "Bros") - @aspect4 = @user1.aspect(:name => "People") - @aspect5 = @user2.aspect(:name => "Abe Lincolns") - @aspect6 = @user3.aspect(:name => "Cats") - @aspect7 = @user4.aspect(:name => "Dogs") - @aspect8 = @user5.aspect(:name => "Hamsters") - @aspect9 = @user5.aspect(:name => "Gophers") + @aspect1 = @user1.aspects.create(:name => "Dudes") + @aspect2 = @user1.aspects.create(:name => "Girls") + @aspect3 = @user1.aspects.create(:name => "Bros") + @aspect4 = @user1.aspects.create(:name => "People") + @aspect5 = @user2.aspects.create(:name => "Abe Lincolns") + @aspect6 = @user3.aspects.create(:name => "Cats") + @aspect7 = @user4.aspects.create(:name => "Dogs") + @aspect8 = @user5.aspects.create(:name => "Hamsters") + @aspect9 = @user5.aspects.create(:name => "Gophers") - @aspect10 = @user1.aspect(:name => "Work") - @aspect11 = @user1.aspect(:name => "Family") + @aspect10 = @user1.aspects.create(:name => "Work") + @aspect11 = @user1.aspects.create(:name => "Family") # User1 posts one status messages to aspects (1-4), two other users post message to one aspect @status_message1 = @user1.post(:status_message, :message => "One", :public => false, :to => @aspect1.id) diff --git a/spec/lib/diaspora/ostatus_builder.rb b/spec/lib/diaspora/ostatus_builder.rb index 6c75348cb..c155ef351 100644 --- a/spec/lib/diaspora/ostatus_builder.rb +++ b/spec/lib/diaspora/ostatus_builder.rb @@ -9,7 +9,7 @@ require File.join(Rails.root, 'lib/diaspora/ostatus_builder') describe Diaspora::OstatusBuilder do let!(:user) { make_user } - let(:aspect) { user.aspect(:name => "Public People") } + let(:aspect) { user.aspects.create(:name => "Public People") } let!(:status_message1) { user.post(:status_message, :message => "One", :public => true, :to => aspect.id) } let!(:status_message2) { user.post(:status_message, :message => "Two", :public => true, :to => aspect.id) } let!(:status_message3) { user.post(:status_message, :message => "Three", :public => false, :to => aspect.id) } diff --git a/spec/lib/diaspora/parser_spec.rb b/spec/lib/diaspora/parser_spec.rb index 4be621c23..6ad1da099 100644 --- a/spec/lib/diaspora/parser_spec.rb +++ b/spec/lib/diaspora/parser_spec.rb @@ -6,9 +6,9 @@ require 'spec_helper' describe Diaspora::Parser do let(:user) { make_user } - let(:aspect) { user.aspect(:name => 'spies') } + let(:aspect) { user.aspects.create(:name => 'spies') } let(:user2) { make_user } - let(:aspect2) { user2.aspect(:name => "pandas") } + let(:aspect2) { user2.aspects.create(:name => "pandas") } let(:user3) { make_user } let(:person) { user3.person } @@ -27,7 +27,7 @@ describe Diaspora::Parser do it 'should accept retractions' do friend_users(user, aspect, user2, aspect2) - message = Factory.create(:status_message, :person => user2.person) + message = user2.post(:status_message, :message => "cats", :to => aspect2.id) retraction = Retraction.for(message) xml = retraction.to_diaspora_xml @@ -35,6 +35,8 @@ describe Diaspora::Parser do end context "friending" do + + let(:good_request) { FakeHttpRequest.new(:success)} before do deliverable = Object.new deliverable.stub!(:deliver) @@ -42,30 +44,17 @@ describe Diaspora::Parser do end it "should create a new person upon getting a person request" do - request = Request.instantiate(:to =>"http://www.google.com/", :from => person) + new_person = Factory.build(:person) - xml = request.to_diaspora_xml - - user3.destroy - person.destroy - user - lambda { user.receive xml, person }.should change(Person, :count).by(1) - end - - it "should not create a new person if the person is already here" do - request = Request.instantiate(:to =>"http://www.google.com/", :from => user2.person) - original_person_id = user2.person.id + Person.should_receive(:by_account_identifier).and_return(new_person) + request = Request.instantiate(:to =>"http://www.google.com/", :from => new_person) xml = request.to_diaspora_xml user - lambda { user.receive xml, user2.person }.should_not change(Person, :count) - user2.reload - user2.person.reload - user2.serialized_private_key.include?("PRIVATE").should be true - - url = "http://" + request.callback_url.split("/")[2] + "/" - Person.where(:url => url).first.id.should == original_person_id + lambda { user.receive xml, new_person }.should change(Person, :count).by(1) end + + end it "should activate the Person if I initiated a request to that url" do @@ -73,13 +62,12 @@ describe Diaspora::Parser do user.reload request.reverse_for user3 - xml = request.to_diaspora_xml + xml = user3.salmon(request).xml_for(user.person) - user3.person.destroy - user3.destroy + user3.delete - user.receive xml, user3.person - new_person = Person.first(:url => user3.person.url) + user.receive_salmon(xml) + new_person = Person.find_by_url(user3.person.url) new_person.nil?.should be false user.reload diff --git a/spec/lib/encryptor_spec.rb b/spec/lib/encryptor_spec.rb index c277eb576..eba23e6e5 100644 --- a/spec/lib/encryptor_spec.rb +++ b/spec/lib/encryptor_spec.rb @@ -7,39 +7,7 @@ require 'spec_helper' describe 'user encryption' do before do @user = make_user - @aspect = @user.aspect(:name => 'dudes') - end - - describe 'key exchange on friending' do - - it 'should receive and marshal a public key from a request' do - remote_user = Factory.build(:user) - remote_user.encryption_key.nil?.should== false - - deliverable = Object.new - deliverable.stub!(:deliver) - Notifier.stub!(:new_request).and_return(deliverable) - Person.should_receive(:by_account_identifier).and_return(remote_user.person) - remote_user.should_receive(:push_to_people).and_return(true) - #should move this to friend request, but i found it here - id = remote_user.person.id - original_key = remote_user.exported_key - - request = remote_user.send_friend_request_to( - @user.person, remote_user.aspect(:name => "temp")) - - xml = remote_user.salmon(request).xml_for(@user) - - remote_user.person.delete - remote_user.delete - - person_count = Person.all.count - @user.receive_salmon xml - - Person.all.count.should == person_count + 1 - new_person = Person.first(:id => id) - new_person.exported_key.should == original_key - end + @aspect = @user.aspects.create(:name => 'dudes') end describe 'encryption' do diff --git a/spec/lib/salmon_salmon_spec.rb b/spec/lib/salmon_salmon_spec.rb index fbf64673d..72c71d3ee 100644 --- a/spec/lib/salmon_salmon_spec.rb +++ b/spec/lib/salmon_salmon_spec.rb @@ -8,7 +8,7 @@ describe Salmon do let(:user){make_user} let(:user2) {make_user} let(:user3) {make_user} - let(:post){ user.post :status_message, :message => "hi", :to => user.aspect(:name => "sdg").id } + let(:post){ user.post :status_message, :message => "hi", :to => user.aspects.create(:name => "sdg").id } let!(:created_salmon) {Salmon::SalmonSlap.create(user, post.to_diaspora_xml)} diff --git a/spec/lib/verify_spec.rb b/spec/lib/verify_spec.rb index 515cd11af..9dca1cb78 100644 --- a/spec/lib/verify_spec.rb +++ b/spec/lib/verify_spec.rb @@ -11,9 +11,9 @@ describe Diaspora::Importer do let!(:user2) { make_user } let!(:user3) { make_user } - let(:aspect1) { user1.aspect(:name => "Work") } - let(:aspect2) { user2.aspect(:name => "Family") } - let(:aspect3) { user3.aspect(:name => "Pivots") } + let(:aspect1) { user1.aspects.create(:name => "Work") } + let(:aspect2) { user2.aspects.create(:name => "Family") } + let(:aspect3) { user3.aspects.create(:name => "Pivots") } let!(:status_message1) { user1.post(:status_message, :message => "One", :public => true, :to => aspect1.id) } let!(:status_message2) { user1.post(:status_message, :message => "Two", :public => true, :to => aspect1.id) } diff --git a/spec/lib/websocket_spec.rb b/spec/lib/websocket_spec.rb index 92ecd1035..e3917008a 100644 --- a/spec/lib/websocket_spec.rb +++ b/spec/lib/websocket_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe Diaspora::WebSocket do before do @user = make_user - @aspect = @user.aspect(:name => "losers") + @aspect = @user.aspects.create(:name => "losers") @post = @user.build_post(:status_message, :message => "hey", :to => @aspect.id) end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 2fd26c4cc..c50dd6932 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' describe Notifier do let!(:user) {make_user} - let!(:aspect) {user.aspect(:name => "science")} + let!(:aspect) {user.aspects.create(:name => "science")} let!(:person) {Factory.create :person} let!(:request_mail) {Notifier.new_request(user, person)} let!(:request_accepted_mail) {Notifier.request_accepted(user, person, aspect)} diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index a8e4e4429..d4d9a20cd 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -37,15 +37,19 @@ describe 'making sure the spec runner works' do it 'does not save a built user' do Factory.build(:user).persisted?.should be_false end + + it 'does not save a built person' do + Factory.build(:person).persisted?.should be_false + end end end describe '#friend_users' do before do @user1 = make_user - @aspect1 = @user1.aspect(:name => "losers") + @aspect1 = @user1.aspects.create(:name => "losers") @user2 = make_user - @aspect2 = @user2.aspect(:name => "bruisers") + @aspect2 = @user2.aspects.create(:name => "bruisers") friend_users(@user1, @aspect1, @user2, @aspect2) end diff --git a/spec/models/album_spec.rb b/spec/models/album_spec.rb index b9cde5710..d8226c2dc 100644 --- a/spec/models/album_spec.rb +++ b/spec/models/album_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe Album do let(:user) { make_user } let(:person) { user.person } - let(:aspect) { user.aspect(:name => "Foo") } + let(:aspect) { user.aspects.create(:name => "Foo") } let(:album) { user.post(:album, :name => "test collection", :to => aspect.id) } it 'is valid' do diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb index 4c7eb2a87..682a06c8b 100644 --- a/spec/models/aspect_spec.rb +++ b/spec/models/aspect_spec.rb @@ -10,27 +10,27 @@ describe Aspect do let(:user2) { make_user } let(:friend_2) { Factory.create(:person) } - let(:aspect) {user.aspect(:name => 'losers')} - let(:aspect2) {user2.aspect(:name => 'failures')} - let(:aspect1) {user.aspect(:name => 'cats')} + let(:aspect) {user.aspects.create(:name => 'losers')} + let(:aspect2) {user2.aspects.create(:name => 'failures')} + let(:aspect1) {user.aspects.create(:name => 'cats')} let(:not_friend) { Factory(:person, :diaspora_handle => "not@person.com")} let(:user3) {make_user} - let(:aspect3) {user3.aspect(:name => "lala")} + let(:aspect3) {user3.aspects.create(:name => "lala")} describe 'creation' do - let!(:aspect){user.aspect(:name => 'losers')} + let!(:aspect){user.aspects.create(:name => 'losers')} it 'should have a name' do aspect.name.should == "losers" end it 'should not allow duplicate names' do lambda { - invalid_aspect = user.aspect(:name => "losers ") + invalid_aspect = user.aspects.create(:name => "losers ") }.should_not change(Aspect, :count) end it 'should not be creatable with people' do - aspect = user.aspect(:name => 'losers', :people => [friend, friend_2]) + aspect = user.aspects.create(:name => 'losers', :people => [friend, friend_2]) aspect.people.size.should == 0 end @@ -55,12 +55,12 @@ describe Aspect do aspect end it 'has a unique name for one user' do - aspect2 = user.aspect(:name => aspect.name) + aspect2 = user.aspects.create(:name => aspect.name) aspect2.valid?.should be_false end it 'has no uniqueness between users' do - aspect2 = user2.aspect(:name => aspect.name) + aspect2 = user2.aspects.create(:name => aspect.name) aspect2.valid?.should be_true end end @@ -82,7 +82,7 @@ describe Aspect do end describe '#aspects_with_person' do - let!(:aspect_without_friend) {user.aspect(:name => "Another aspect")} + let!(:aspect_without_friend) {user.aspects.create(:name => "Another aspect")} it 'should return the aspects with given friend' do user.reload aspects = user.aspects_with_person(friend) @@ -105,7 +105,7 @@ describe Aspect do describe 'posting' do it 'should add post to aspect via post method' do - aspect = user.aspect(:name => 'losers', :people => [friend]) + aspect = user.aspects.create(:name => 'losers', :people => [friend]) status_message = user.post( :status_message, :message => "hey", :to => aspect.id ) @@ -114,8 +114,8 @@ describe Aspect do end it 'should add post to aspect via receive method' do - aspect = user.aspect(:name => 'losers') - aspect2 = user2.aspect(:name => 'winners') + aspect = user.aspects.create(:name => 'losers') + aspect2 = user2.aspects.create(:name => 'winners') friend_users(user, aspect, user2, aspect2) message = user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id) @@ -128,8 +128,8 @@ describe Aspect do end it 'should retract the post from the aspects as well' do - aspect = user.aspect(:name => 'losers') - aspect2 = user2.aspect(:name => 'winners') + aspect = user.aspects.create(:name => 'losers') + aspect2 = user2.aspects.create(:name => 'winners') friend_users(user, aspect, user2, aspect2) message = user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 19f7fdd5e..290a87958 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -6,10 +6,10 @@ require 'spec_helper' describe Comment do let(:user) {make_user} - let(:aspect) {user.aspect(:name => "Doofuses")} + let(:aspect) {user.aspects.create(:name => "Doofuses")} let(:user2) {make_user} - let(:aspect2) {user2.aspect(:name => "Lame-faces")} + let(:aspect2) {user2.aspects.create(:name => "Lame-faces")} it 'validates that the handle belongs to the person' do user_status = user.post(:status_message, :message => "hello", :to => aspect.id) @@ -115,7 +115,7 @@ describe Comment do describe 'serialization' do it 'should serialize the handle and not the sender' do commenter = make_user - commenter_aspect = commenter.aspect :name => "bruisers" + commenter_aspect = commenter.aspects.create(:name => "bruisers") friend_users(user, aspect, commenter, commenter_aspect) post = user.post :status_message, :message => "hello", :to => aspect.id comment = commenter.comment "Fool!", :on => post diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index df871cba3..498588fa8 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -9,11 +9,24 @@ describe Person do @user = make_user @user2 = make_user @person = Factory.create(:person) - @aspect = @user.aspect(:name => "Dudes") - @aspect2 = @user2.aspect(:name => "Abscence of Babes") + @aspect = @user.aspects.create(:name => "Dudes") + @aspect2 = @user2.aspects.create(:name => "Abscence of Babes") end - describe "vaild url" do + describe "delegating" do + it "delegates first_name to the profile" do + @person.first_name.should == @person.profile.first_name + @person.profile.update_attributes(:first_name => "Jane") + @person.reload.first_name.should == "Jane" + end + it "delegates last_name to the profile" do + @person.last_name.should == @person.profile.last_name + @person.profile.update_attributes(:last_name => "Heathers") + @person.reload.last_name.should == "Heathers" + end + end + + describe "vaild url" do it 'should allow for https urls' do person = Factory.create(:person, :url => "https://example.com") person.valid?.should == true diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 86adb1c89..f5d07fc55 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe Photo do before do @user = make_user - @aspect = @user.aspect(:name => "losers") + @aspect = @user.aspects.create(:name => "losers") @album = @user.post :album, :name => "foo", :to => @aspect.id @fixture_filename = 'button.png' @@ -112,7 +112,7 @@ describe Photo do #security hax user2 = Factory.create(:user) - aspect2 = user2.aspect(:name => "foobars") + aspect2 = user2.aspects.create(:name => "foobars") friend_users(@user, @aspect, user2, aspect2) @photo.person = user2.person diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 02e70a836..587751b0c 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe Post do before do @user = make_user - @aspect = @user.aspect(:name => "winners") + @aspect = @user.aspects.create(:name => "winners") end describe 'deletion' do diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index fed124726..9e54cf6c7 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -12,6 +12,16 @@ describe Profile do profile.should be_valid profile.first_name.should == "Shelly" end + + it "can be 32 characters long" do + profile = Factory.build(:profile, :first_name => "Hexagoooooooooooooooooooooooooon") + profile.should be_valid + end + + it "cannot be 33 characters" do + profile = Factory.build(:profile, :first_name => "Hexagooooooooooooooooooooooooooon") + profile.should_not be_valid + end end describe "of last_name" do it "strips leading and trailing whitespace" do @@ -19,6 +29,27 @@ describe Profile do profile.should be_valid profile.last_name.should == "Ohba" end + + it "can be 32 characters long" do + profile = Factory.build(:profile, :last_name => "Hexagoooooooooooooooooooooooooon") + profile.should be_valid + end + + it "cannot be 33 characters" do + profile = Factory.build(:profile, :last_name => "Hexagooooooooooooooooooooooooooon") + profile.should_not be_valid + end + end + end + + describe 'serialization' do + let(:person) {Factory.create(:person)} + + it 'should include persons diaspora handle' do + xml = person.profile.to_diaspora_xml + + xml.should include person.diaspora_handle + xml.should_not include person.id.to_s end end end diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index a40ef1863..daab156b7 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -8,7 +8,7 @@ describe Request do let(:user) { make_user } let(:user2) { make_user} let(:person) {Factory :person} - let(:aspect) { user.aspect(:name => "dudes") } + let(:aspect) { user.aspects.create(:name => "dudes") } let(:request){ user.send_friend_request_to user2.person, aspect } it 'should require a destination and callback url' do @@ -19,17 +19,6 @@ describe Request do person_request.valid?.should be true end - it 'should generate xml for the User as a Person' do - - request = user.send_friend_request_to person, aspect - xml = request.to_xml.to_s - - xml.should include user.person.diaspora_handle - xml.should include user.person.url - xml.should include user.profile.first_name - xml.should include user.profile.last_name - xml.should include user.exported_key - end it 'should strip the destination url' do person_request = Request.new @@ -68,4 +57,28 @@ describe Request do end end + describe 'serialization' do + it 'should not generate xml for the User as a Person' do + request = user.send_friend_request_to person, aspect + xml = request.to_xml.to_s + + xml.should_not include user.person.profile.first_name + end + + it 'should serialize the handle and not the sender' do + request = user.send_friend_request_to person, aspect + xml = request.to_xml.to_s + + xml.should include user.person.diaspora_handle + end + + it 'should not serialize the exported key' do + request = user.send_friend_request_to person, aspect + xml = request.to_xml.to_s + + xml.should_not include user.person.exported_key + end + + end + end diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index cc34647f6..b5dcc1523 100644 --- a/spec/models/retraction_spec.rb +++ b/spec/models/retraction_spec.rb @@ -8,7 +8,7 @@ describe Retraction do let(:user) { make_user } let(:person) { Factory(:person) } - let(:aspect) { user.aspect(:name => "Bruisers") } + let(:aspect) { user.aspects.create(:name => "Bruisers") } let!(:activation) { user.activate_friend(person, aspect) } let!(:post) { user.post :status_message, :message => "Destroy!", :to => aspect.id } diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 06f346e69..8297640fe 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe StatusMessage do before do @user = make_user - @aspect = @user.aspect(:name => "losers") + @aspect = @user.aspects.create(:name => "losers") end it "should have a message" do diff --git a/spec/models/user/attack_vectors_spec.rb b/spec/models/user/attack_vectors_spec.rb index 0f7ecee5a..8ee200dce 100644 --- a/spec/models/user/attack_vectors_spec.rb +++ b/spec/models/user/attack_vectors_spec.rb @@ -7,15 +7,15 @@ require 'spec_helper' describe "attack vectors" do let(:user) { make_user } - let(:aspect) { user.aspect(:name => 'heroes') } + let(:aspect) { user.aspects.create(:name => 'heroes') } let(:bad_user) { make_user} let(:user2) { make_user } - let(:aspect2) { user2.aspect(:name => 'losers') } + let(:aspect2) { user2.aspects.create(:name => 'losers') } let(:user3) { make_user } - let(:aspect3) { user3.aspect(:name => 'heroes') } + let(:aspect3) { user3.aspects.create(:name => 'heroes') } before do friend_users(user, aspect, user2, aspect2) @@ -80,20 +80,60 @@ describe "attack vectors" do user2.profile.first_name.should == first_name end - it 'can send retractions on post you do not own' do - pending + it 'should not receive retractions on post you do not own' do original_message = user2.post :status_message, :message => 'store this!', :to => aspect2.id user.receive_salmon(user2.salmon(original_message).xml_for(user.person)) user.raw_visible_posts.count.should be 1 ret = Retraction.new ret.post_id = original_message.id - ret.person_id = user3.person.id + ret.diaspora_handle = user3.person.diaspora_handle ret.type = original_message.class.to_s - user.receive_salmon(user3.salmon(ret).xml_for(user.person)) + proc{ user.receive_salmon(user3.salmon(ret).xml_for(user.person)) }.should raise_error /is trying to retract a post they do not own/ StatusMessage.count.should be 1 user.reload.raw_visible_posts.count.should be 1 end + + it 'should not receive retractions where the retractor and the salmon author do not match' do + original_message = user2.post :status_message, :message => 'store this!', :to => aspect2.id + user.receive_salmon(user2.salmon(original_message).xml_for(user.person)) + user.raw_visible_posts.count.should be 1 + + ret = Retraction.new + ret.post_id = original_message.id + ret.diaspora_handle = user2.person.diaspora_handle + ret.type = original_message.class.to_s + + proc{ user.receive_salmon(user3.salmon(ret).xml_for(user.person)) }.should raise_error /Malicious Post/ + StatusMessage.count.should be 1 + user.reload.raw_visible_posts.count.should be 1 + end + + it 'it should not allow you to send retractions for other people' do + ret = Retraction.new + ret.post_id = user2.person.id + ret.diaspora_handle = user3.person.diaspora_handle + ret.type = user2.person.class.to_s + + proc{ + user.receive_salmon(user3.salmon(ret).xml_for(user.person)) + }.should raise_error /#{user3.diaspora_handle} trying to unfriend #{user2.person.id} from #{user.id}/ + + user.reload.friends.count.should == 2 + end + + it 'it should not allow you to send retractions with xml and salmon handle mismatch' do + ret = Retraction.new + ret.post_id = user2.person.id + ret.diaspora_handle = user2.person.diaspora_handle + ret.type = user2.person.class.to_s + + proc{ + user.receive_salmon(user3.salmon(ret).xml_for(user.person)) + }.should raise_error /Malicious Post/ + + user.reload.friends.count.should == 2 + end end end diff --git a/spec/models/user/invite_spec.rb b/spec/models/user/invite_spec.rb index 202f5f395..b7c68d52d 100644 --- a/spec/models/user/invite_spec.rb +++ b/spec/models/user/invite_spec.rb @@ -6,11 +6,11 @@ require 'spec_helper' describe User do let(:inviter) {make_user} - let(:aspect) {inviter.aspect(:name => "awesome")} + let(:aspect) {inviter.aspects.create(:name => "awesome")} let(:another_user) {make_user} - let(:wrong_aspect) {another_user.aspect(:name => "super")} + let(:wrong_aspect) {another_user.aspects.create(:name => "super")} let(:inviter_with_3_invites) {Factory.create :user, :invites => 3} - let(:aspect2) {inviter_with_3_invites.aspect(:name => "Jersey Girls")} + let(:aspect2) {inviter_with_3_invites.aspects.create(:name => "Jersey Girls")} before do @@ -122,7 +122,7 @@ describe User do u.pending_requests u.pending_requests.count.should == 1 request = u.pending_requests.first - aspect2 = u.aspect(:name => "dudes") + aspect2 = u.aspects.create(:name => "dudes") u.reload inviter inviter.receive_salmon(u.salmon(u.accept_friend_request(request.id, aspect2.id)).xml_for(inviter.person)) diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 24408e4c7..734c187fc 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -9,9 +9,9 @@ describe User do let!(:user) { make_user } let!(:user2) { make_user } - let!(:aspect) { user.aspect(:name => 'heroes') } - let!(:aspect1) { user.aspect(:name => 'other') } - let!(:aspect2) { user2.aspect(:name => 'losers') } + let!(:aspect) { user.aspects.create(:name => 'heroes') } + let!(:aspect1) { user.aspects.create(:name => 'other') } + let!(:aspect2) { user2.aspects.create(:name => 'losers') } let!(:service1) { s = Factory(:service, :provider => 'twitter'); user.services << s; s } let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s } @@ -81,9 +81,9 @@ describe User do context 'dispatching' do let!(:user3) { make_user } - let!(:aspect3) { user3.aspect(:name => 'heroes') } + let!(:aspect3) { user3.aspects.create(:name => 'heroes') } let!(:user4) { make_user } - let!(:aspect4) { user4.aspect(:name => 'heroes') } + let!(:aspect4) { user4.aspects.create(:name => 'heroes') } let!(:post) { user.build_post :status_message, :message => "hey" } diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb index c21f88c4d..e3cb645c1 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -39,8 +39,8 @@ describe User do context 'with two users' do let!(:user) {make_user} - let!(:first_aspect) {user.aspect(:name => 'bruisers')} - let!(:second_aspect) {user.aspect(:name => 'losers')} + let!(:first_aspect) {user.aspects.create(:name => 'bruisers')} + let!(:second_aspect) {user.aspects.create(:name => 'losers')} it "queries by aspect" do friend_users(user, first_aspect, user2, user2.aspects.first) @@ -59,8 +59,8 @@ describe User do context 'with two users' do let!(:user) {make_user} - let!(:first_aspect) {user.aspect(:name => 'bruisers')} - let!(:second_aspect) {user.aspect(:name => 'losers')} + let!(:first_aspect) {user.aspects.create(:name => 'bruisers')} + let!(:second_aspect) {user.aspects.create(:name => 'losers')} let!(:user4) { Factory.create(:user_with_aspect)} before do @@ -103,8 +103,8 @@ describe User do describe '#albums_by_aspect' do - let!(:first_aspect) {user2.aspect(:name => 'bruisers')} - let!(:second_aspect) {user2.aspect(:name => 'losers')} + let!(:first_aspect) {user2.aspects.create(:name => 'bruisers')} + let!(:second_aspect) {user2.aspects.create(:name => 'losers')} before do user2.post :album, :name => "Georges", :to => first_aspect.id user2.post :album, :name => "Borges", :to => first_aspect.id diff --git a/spec/models/user/receive_spec.rb b/spec/models/user/receive_spec.rb index 6e959c508..86f0246a3 100644 --- a/spec/models/user/receive_spec.rb +++ b/spec/models/user/receive_spec.rb @@ -7,13 +7,13 @@ require 'spec_helper' describe User do let(:user) { make_user } - let(:aspect) { user.aspect(:name => 'heroes') } + let(:aspect) { user.aspects.create(:name => 'heroes') } let(:user2) { make_user } - let(:aspect2) { user2.aspect(:name => 'losers') } + let(:aspect2) { user2.aspects.create(:name => 'losers') } let(:user3) { make_user } - let(:aspect3) { user3.aspect(:name => 'heroes') } + let(:aspect3) { user3.aspects.create(:name => 'heroes') } before do friend_users(user, aspect, user2, aspect2) diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index 5ec769da8..a1232b80b 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -7,8 +7,8 @@ require 'spec_helper' describe Diaspora::UserModules::Friending do let(:user) { make_user } - let(:aspect) { user.aspect(:name => 'heroes') } - let(:aspect1) { user.aspect(:name => 'other') } + let(:aspect) { user.aspects.create(:name => 'heroes') } + let(:aspect1) { user.aspects.create(:name => 'other') } let(:friend) { Factory.create(:person) } let(:person_one) { Factory.create :person } @@ -16,7 +16,7 @@ describe Diaspora::UserModules::Friending do let(:person_three) { Factory.create :person } let(:user2) { make_user } - let(:aspect2) { user2.aspect(:name => "aspect two") } + let(:aspect2) { user2.aspects.create(:name => "aspect two") } before do deliverable = Object.new @@ -233,23 +233,22 @@ describe Diaspora::UserModules::Friending do end it "keeps the right counts of friends" do - user.receive_friend_request @request + user.receive @request.to_diaspora_xml, person_one - person_two.destroy - user.reload.pending_requests.size.should be 1 + user.reload.pending_requests.size.should == 1 user.friends.size.should be 0 - user.receive_friend_request @request_two - user.reload.pending_requests.size.should be 2 + user.receive @request_two.to_diaspora_xml, person_two + user.reload.pending_requests.size.should == 2 user.friends.size.should be 0 user.accept_friend_request @request.id, aspect.id - user.reload.pending_requests.size.should be 1 + user.reload.pending_requests.size.should == 1 user.friends.size.should be 1 user.contact_for(person_one).should_not be_nil user.ignore_friend_request @request_two.id - user.reload.pending_requests.size.should be 0 + user.reload.pending_requests.size.should == 0 user.friends.size.should be 1 user.contact_for(person_two).should be_nil end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a1b89a1d3..077224674 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -6,9 +6,9 @@ require 'spec_helper' describe User do let(:user) { make_user } - let(:aspect) { user.aspect(:name => 'heroes') } + let(:aspect) { user.aspects.create(:name => 'heroes') } let(:user2) { make_user } - let(:aspect2) { user2.aspect(:name => 'stuff') } + let(:aspect2) { user2.aspects.create(:name => 'stuff') } it 'should have a key' do user.encryption_key.should_not be nil @@ -106,6 +106,16 @@ describe User do user = Factory.build(:user, :username => "kittens;") user.should_not be_valid end + + it "can be 32 characters long" do + user = Factory.build(:user, :username => "hexagoooooooooooooooooooooooooon") + user.should be_valid + end + + it "cannot be 33 characters" do + user = Factory.build(:user, :username => "hexagooooooooooooooooooooooooooon") + user.should_not be_valid + end end describe "of email" do diff --git a/vendor/plugins/.gitkeep b/vendor/plugins/.gitkeep deleted file mode 100644 index e69de29bb..000000000