diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 42abc665c..e581613f3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -10,16 +10,6 @@ class ApplicationController < ActionController::Base before_filter :count_requests before_filter :set_invites - layout :layout_by_resource - - def layout_by_resource - if devise_controller? - "session_wall" - else - "application" - end - end - def set_friends_and_status if current_user if params[:aspect] == nil || params[:aspect] == 'all' diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 549ee6096..6887e4bee 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -11,6 +11,10 @@ class AspectsController < ApplicationController def index @posts = current_user.visible_posts(:by_members_of => :all).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' @aspect = :all + + if current_user.getting_started == true + redirect_to getting_started_path + end end def create @@ -43,7 +47,6 @@ class AspectsController < ApplicationController def show @aspect = current_user.aspect_by_id params[:id] - @friends_not_in_aspect = current_user.friends_not_in_aspect(@aspect) unless @aspect render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404 else @@ -86,7 +89,11 @@ class AspectsController < ApplicationController flash[:error] = I18n.t 'aspects.add_to_aspect.failure' end - redirect_to aspect_path(params[:aspect_id]) + if params[:manage] + redirect_to aspects_manage_path + else + redirect_to aspect_path(params[:aspect_id]) + end end def remove_from_aspect diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 498ca8157..f76f1c6e6 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -41,6 +41,12 @@ class PeopleController < ApplicationController end def update + # convert date selector into proper timestamp + birthday = params[:date] + if birthday + params[:person][:profile][:birthday] ||= Date.parse("#{birthday[:year]}-#{birthday[:month]}-#{birthday[:day]}") + end + prep_image_url(params[:person]) if current_user.update_profile params[:person][:profile] @@ -49,7 +55,11 @@ class PeopleController < ApplicationController flash[:error] = "Failed to update profile" end - redirect_to edit_person_path + if params[:getting_started] + redirect_to getting_started_path(:step => params[:getting_started].to_i+1) + else + redirect_to edit_person_path + end end private diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 4a10821aa..ffc845c93 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -44,7 +44,12 @@ class RequestsController < ApplicationController else raise e end - respond_with :location => aspect + + if params[:getting_started] + redirect_to getting_started_path(:step=>params[:getting_started]) + else + respond_with :location => aspect + end return end @@ -61,16 +66,29 @@ class RequestsController < ApplicationController else raise e end - respond_with :location => aspect + + if params[:getting_started] + redirect_to getting_started_path(:step=>params[:getting_started]) + else + respond_with :location => aspect + end return end if @request flash[:notice] = I18n.t 'requests.create.success',:destination_url => @request.destination_url - respond_with :location => aspect + if params[:getting_started] + redirect_to getting_started_path(:step=>params[:getting_started]) + else + respond_with :location => aspect + end else flash[:error] = I18n.t 'requests.create.horribly_wrong' - respond_with :location => aspect + if params[:getting_started] + redirect_to getting_started_path(:step=>params[:getting_started]) + else + respond_with :location => aspect + end end end diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 7c5da42a7..d5fd50c83 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -31,7 +31,6 @@ class ServicesController < ApplicationController :uid => auth['uid']) end - flash[:notice] = "Authentication successful." redirect_to services_url end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c5121784a..79d33940a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -20,18 +20,26 @@ class UsersController < ApplicationController def update @user = current_user - params[:user].delete(:password) if params[:user][:password].blank? - params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank? - if params[:user][:password] && params[:user][:password_confirmation] - if @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation]) - flash[:notice] = "Password Changed" - else - flash[:error] = "Password Change Failed" + if params[:user][:getting_started] + boolean = params[:user][:getting_started] == "true" + @user.update_attributes( :getting_started => boolean ) + redirect_to root_path + + else + params[:user].delete(:password) if params[:user][:password].blank? + params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank? + + if params[:user][:password] && params[:user][:password_confirmation] + if @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation]) + flash[:notice] = "Password Changed" + else + flash[:error] = "Password Change Failed" + end end - end - redirect_to edit_user_path(@user) + redirect_to edit_user_path(@user) + end end def destroy @@ -55,6 +63,19 @@ class UsersController < ApplicationController end end + def getting_started + @aspect = :getting_started + @user = current_user + @person = @user.person + @profile = @user.profile + @photos = @user.visible_posts(:person_id => current_user.person.id, :_type => 'Photo').paginate :page => params[:page], :order => 'created_at DESC' + @services = @user.services + + @step = ((params[:step].to_i>0)&&(params[:step].to_i<5)) ? params[:step].to_i : 1 + @step ||= 1 + render "users/getting_started" + end + def export exporter = Diaspora::Exporter.new(Diaspora::Exporters::XML) send_data exporter.execute(current_user), :filename => "#{current_user.username}_diaspora_data.xml", :type => :xml diff --git a/app/models/comment.rb b/app/models/comment.rb index 540b44f2e..e6686efce 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -2,6 +2,14 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. +class HandleValidator < ActiveModel::Validator + def validate(document) + unless document.diaspora_handle == document.person.diaspora_handle + document.errors[:base] << "Diaspora handle and person handle must match" + end + end +end + class Comment include MongoMapper::Document include ROXML @@ -10,18 +18,21 @@ class Comment include Diaspora::Socketable xml_accessor :text - xml_accessor :person, :as => Person + xml_reader :diaspora_handle xml_accessor :post_id xml_accessor :_id key :text, String key :post_id, ObjectId key :person_id, ObjectId + key :diaspora_handle, String belongs_to :post, :class_name => "Post" belongs_to :person, :class_name => "Person" - validates_presence_of :text + validates_presence_of :text, :diaspora_handle + validates_with HandleValidator + timestamps! diff --git a/app/models/person.rb b/app/models/person.rb index 58e637557..c79a62955 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -60,7 +60,11 @@ class Person end def real_name - "#{profile.first_name.to_s} #{profile.last_name.to_s}" + if profile.first_name.nil? || profile.first_name.empty? + self.diaspora_handle + else + "#{profile.first_name.to_s} #{profile.last_name.to_s}" + end end def owns?(post) diff --git a/app/models/profile.rb b/app/models/profile.rb index baab495d7..8848cd823 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -9,15 +9,20 @@ class Profile include ROXML xml_reader :person_id - xml_accessor :first_name - xml_accessor :last_name - xml_accessor :image_url + xml_reader :first_name + xml_reader :last_name + xml_reader :image_url + xml_reader :birthday + xml_reader :gender + xml_reader :bio key :first_name, String key :last_name, String key :image_url, String + key :birthday, Date + key :gender, String + key :bio, String - validates_presence_of :first_name, :last_name after_validation :strip_names before_save :strip_names diff --git a/app/models/user.rb b/app/models/user.rb index 82d103034..071abfcb0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -40,6 +40,8 @@ class User key :invite_messages, Hash + key :getting_started, Boolean, :default => true + before_validation :strip_username, :on => :create validates_presence_of :username validates_uniqueness_of :username, :case_sensitive => false @@ -87,10 +89,6 @@ class User self.person.send(method, *args) end - def real_name - "#{person.profile.first_name.to_s} #{person.profile.last_name.to_s}" - end - ######### Aspects ###################### def aspect(opts = {}) aspect = Aspect.new(opts) @@ -275,7 +273,7 @@ class User def build_comment(text, options = {}) raise "must comment on something!" unless options[:on] - comment = Comment.new(:person_id => self.person.id, :text => text, :post => options[:on]) + comment = Comment.new(:person_id => self.person.id, :diaspora_handle => self.person.diaspora_handle, :text => text, :post => options[:on]) comment.creator_signature = comment.sign_with_key(encryption_key) if comment.save comment @@ -409,12 +407,15 @@ class User ###Helpers############ def self.build(opts = {}) + opts[:person] ||= {} + opts[:person][:profile] ||= Profile.new opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}" opts[:person][:url] = APP_CONFIG[:pod_url] opts[:serialized_private_key] = generate_key opts[:person][:serialized_public_key] = opts[:serialized_private_key].public_key + u = User.new(opts) u end diff --git a/app/views/aspects/manage.html.haml b/app/views/aspects/manage.html.haml index a49030d34..77ca7750d 100644 --- a/app/views/aspects/manage.html.haml +++ b/app/views/aspects/manage.html.haml @@ -22,6 +22,10 @@ - else - for request in @remote_requests %li.person.request{:data=>{:guid=>request.id, :person_id=>request.person.id}} + .delete + .x + X + .circle = person_image_tag(request.person) %h3 Remove from Aspect @@ -63,6 +67,6 @@ .fancybox_content %div{:id => "add_request_pane_#{aspect.id}"} - = render "requests/new_request", :aspect => aspect + = render "requests/new_request", :aspect => aspect, :manage => true diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml index 1d877b70e..d9431bbb8 100644 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -1,9 +1,12 @@ -%h2 Forgot your password? -= form_for(resource, :as => resource_name, :url => password_path(resource_name)) do |f| - = devise_error_messages! - %p - = f.label :email - = f.text_field :email - %p - = f.submit "Send me reset password instructions" -= render :partial => "devise/shared/links" +.span-12.prepend-6.last + .floating + %h3 + Forgot your password? + = form_for(resource, :as => resource_name, :url => password_path(resource_name)) do |f| + = devise_error_messages! + %p + = f.label :email + = f.text_field :email + %p + = f.submit "Send me reset password instructions" + = render :partial => "devise/shared/links" diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 5803415b4..852a8afd5 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,26 +1,33 @@ -%h1 - This is a technology preview, do not provide any private information. -%h3 - your account may be deleted until we move into a more stable development period. -%h3 - USE AT YOUR OWN RISK!! -= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| - #user - %p.username - = f.label :username - = f.text_field :username - %p.user_network - ="@#{APP_CONFIG[:terse_pod_url]}" +.span-10.append-1.last + .floating + %h3 Login + = form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| + #user + %p.username + = f.label :username + = f.text_field :username + %p.user_network + ="@#{APP_CONFIG[:terse_pod_url]}" + %p + = f.label :password + = f.password_field :password + /%p + /- if devise_mapping.rememberable? + / = f.check_box :remember_me + / = f.label :remember_me + = f.submit "Sign in" + %p - = f.label :password - = f.password_field :password - /%p - /- if devise_mapping.rememberable? - / = f.check_box :remember_me - / = f.label :remember_me - = f.submit "Sign in" - = link_to "Have a problem? Find an answer here", 'http://diaspora.shapado.com/' - %p -= render :partial => "devise/shared/links" + = render :partial => "devise/shared/links" + %p + = link_to "Have a problem? Find an answer here", 'http://diaspora.shapado.com/' + +.span-13.last + %h1 + This is a technology preview, do not provide any private information. + %h3 + your account may be deleted until we move into a more stable development period. + %h3 + USE AT YOUR OWN RISK!! diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7f6cf94cf..c7deeda8e 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -31,7 +31,8 @@ = javascript_include_tag 'view', 'image_picker', 'stream' - = render 'js/websocket_js' + - if current_user + = render 'js/websocket_js' = csrf_meta_tag = yield(:head) @@ -43,24 +44,25 @@ %header .container{:style => "position:relative;"} #diaspora_text{:href => root_path} - = link_to "DIASPORA*", root_path + = link_to "DIASPORA*", (current_user ? root_path : new_user_session_path) %span.sub_text PREVIEW - #global_search - = form_tag(people_path, :method => 'get') do - = text_field_tag 'q', nil, :placeholder => "Search", :type => 'search', :results => 5 + - if current_user + #global_search + = form_tag(people_path, :method => 'get') do + = text_field_tag 'q', nil, :placeholder => "Search", :type => 'search', :results => 5 - %ul#user_menu - .avatar - = owner_image_tag - = link_to current_user.real_name, '#' - %li= link_to "view profile", current_user.person - %li= link_to "edit profile", edit_person_path(current_user.person) - %li= link_to "account settings", edit_user_path(current_user) - %li= link_to t('.logout.'), destroy_user_session_path + %ul#user_menu + .avatar + = owner_image_tag + = link_to current_user.real_name, '#' + %li= link_to "view profile", current_user.person + %li= link_to "edit profile", edit_person_path(current_user.person) + %li= link_to "account settings", edit_user_path(current_user) + %li= link_to t('.logout.'), destroy_user_session_path - = render "shared/aspect_nav" + = render "shared/aspect_nav" .container .span-24.last @@ -68,3 +70,4 @@ .span-24.last = render "posts/debug" + diff --git a/app/views/layouts/session_wall.html.haml b/app/views/layouts/session_wall.html.haml deleted file mode 100644 index bc15063d6..000000000 --- a/app/views/layouts/session_wall.html.haml +++ /dev/null @@ -1,53 +0,0 @@ --# Copyright (c) 2010, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3 or later. See --# the COPYRIGHT file. - -!!! -%html - %head - %title - DIASPORA | login - %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/ - %meta{"http-equiv"=> "X-UA-Compatible", :content =>"chrome=1" } - - = stylesheet_link_tag "sessions" - /= javascript_include_tag"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" - = javascript_include_tag 'jquery142' - = javascript_include_tag 'jquery.infieldlabel' - - :javascript - $(document).ready(function(){ - $("#user_username").focus(); - $("label").inFieldLabels(); - }); - - = csrf_meta_tag - = yield(:head) - - %body - - :plain - - - - flash.each do |name, msg| - = content_tag :div, msg, :id => "flash_#{name}" - %div#huge_text - DIASPORA* - = yield - - /= link_to "signup", "/signup" diff --git a/app/views/people/edit.html.haml b/app/views/people/edit.html.haml index 8db35bb3e..29e10d757 100644 --- a/app/views/people/edit.html.haml +++ b/app/views/people/edit.html.haml @@ -12,56 +12,58 @@ %li=link_to 'Services', services_path .span-19.prepend-5.last - %h2 Profile = form_for @person do |person| + %h3 + Your Profile + .description + This info will be available to whomever you connect with on Diaspora. + = person.error_messages - = person.fields_for :profile do |p| + = person.fields_for :profile do |profile| + %h4 + Your name + = profile.text_field :first_name, :value => @profile.first_name, :placeholder => "First name" + = profile.text_field :last_name, :value => @profile.last_name, :placeholder => "Last name" - %h3="#{t('.picture')}" - %div#image_picker - = p.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field' + %h4 + Your gender + %br + = select_tag 'person[profile][gender]', options_for_select(["","Female","Male"], @person.profile.gender) - - unless @photos.nil? || @photos.empty? - - for photo in @photos - - if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium)) - %div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'} - = check_box_tag 'checked_photo', true, true - = link_to image_tag(photo.url(:thumb_medium)), "#" - - else - %div.small_photo{:id => photo.url(:thumb_medium)} - = check_box_tag 'checked_photo' - = link_to image_tag(photo.url(:thumb_medium)), "#" + %h4 + Your birthday + %br + = select_date @person.profile.birthday, :order => [:month, :day, :year], :start_year => 1930, :end_year => 2000 - - else - =t('.you_dont_have_any_photos') - = link_to t('.albums'), albums_path(:aspect => 'all') - =t('.page_to_upload_some') + %h4 + Your bio + = profile.text_area :bio, :value => @profile.bio, :rows => 5, :placeholder => "Fill me out" - =will_paginate @photos + %h4 + Your photo + %div#image_picker + = profile.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field' - %br + - unless @photos.nil? || @photos.empty? + - for photo in @photos + - if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium)) + %div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'} + = check_box_tag 'checked_photo', true, true + = link_to image_tag(photo.url(:thumb_medium)), "#" + - else + %div.small_photo{:id => photo.url(:thumb_medium)} + = check_box_tag 'checked_photo' + = link_to image_tag(photo.url(:thumb_medium)), "#" - %h3="#{t('.info')}" + - else + =t('.you_dont_have_any_photos') + = link_to t('.albums'), albums_path(:aspect => 'all') + =t('.page_to_upload_some') - %p - %b - ="#{t('.diaspora_username')}:" - = @person.diaspora_handle - - %p - = p.label :first_name - = p.text_field :first_name, :value => @profile.first_name - %p - = p.label :last_name - = p.text_field :last_name, :value => @profile.last_name + =will_paginate @photos .submit_block = link_to t('.cancel'), edit_user_path(current_user) = t('.or') = person.submit t('.update_profile') - - #content_bottom - .back - = link_to "⇧ #{t('.home')}", root_path - diff --git a/app/views/registrations/new.html.haml b/app/views/registrations/new.html.haml index cea31ff78..ea0be2b75 100644 --- a/app/views/registrations/new.html.haml +++ b/app/views/registrations/new.html.haml @@ -1,50 +1,42 @@ -= 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 - = f.text_field :username - %p - = f.label :email - = f.text_field :email - %p - = f.label :password - = f.password_field :password - %p - = f.label :password_confirmation - = f.password_field :password_confirmation - - = f.fields_for :person do |p| - = p.fields_for :profile do |pr| +.span-12.prepend-6.last + .floating + %h3 + Sign up for Diaspora + = 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 - = pr.label :first_name - = pr.text_field :first_name + = f.label :username + = f.text_field :username %p - = pr.label :last_name - = pr.text_field :last_name - = f.submit t('.sign_up') -= render :partial => "devise/shared/links" + = f.label :email + = f.text_field :email + %p + = f.label :password + = f.password_field :password + %p + = f.label :password_confirmation + = f.password_field :password_confirmation + + = f.submit t('.sign_up') -%br -%br + .floating + %h3 + Upload an existing Diaspora account -%h2 or, upload yourself + = form_tag '/users/import', :multipart => true do + %p + = label_tag 'user[email]' + = text_field_tag 'user[email]' + %p + = label_tag 'user[password]' + = password_field_tag 'user[password]' + %p + = label_tag 'user[password_confirmation]' + = password_field_tag 'user[password_confirmation]' -= form_tag '/users/import', :multipart => true do - - %p - = label_tag 'user[email]' - = text_field_tag 'user[email]' - %p - = label_tag 'user[password]' - = password_field_tag 'user[password]' - %p - = label_tag 'user[password_confirmation]' - = password_field_tag 'user[password_confirmation]' - - %label Select File - = file_field 'upload', 'file' - = submit_tag "Upload" + %label Select File + = file_field 'upload', 'file' + = submit_tag "Upload" diff --git a/app/views/requests/_new_request.haml b/app/views/requests/_new_request.haml index c67bc61b9..0ec66d163 100644 --- a/app/views/requests/_new_request.haml +++ b/app/views/requests/_new_request.haml @@ -8,12 +8,7 @@ =t('.add_a_new_friend_to') %i= aspect.name - - if @friends_not_in_aspect - = render('shared/add_friend_dropdown', :aspect => @aspect, :friends => @friends_not_in_aspect) - - - - + = render 'shared/add_friend_dropdown', :aspect => aspect, :friends => current_user.friends_not_in_aspect(aspect), :manage => defined?(manage) = form_for Request.new do |fr_request| = fr_request.error_messages @@ -26,5 +21,11 @@ = fr_request.label :destination_url, t(".friends_username") = fr_request.text_field :destination_url = fr_request.hidden_field :aspect_id, :value => aspect.id + + - if defined?(getting_started) + = hidden_field_tag :getting_started, getting_started + - if defined?(manage) + = hidden_field_tag :manage, true + = fr_request.submit diff --git a/app/views/services/index.html.haml b/app/views/services/index.html.haml index 8d00f8eb3..ee298eb34 100644 --- a/app/views/services/index.html.haml +++ b/app/views/services/index.html.haml @@ -14,7 +14,7 @@ %h2 Services - %ul#stream + %ul - for service in @services %h3 %b= service.provider diff --git a/app/views/shared/_add_friend_dropdown.html.haml b/app/views/shared/_add_friend_dropdown.html.haml index ee39fc6ad..062f534b8 100644 --- a/app/views/shared/_add_friend_dropdown.html.haml +++ b/app/views/shared/_add_friend_dropdown.html.haml @@ -2,4 +2,6 @@ = form_tag '/aspects/add_to_aspect', :id => 'add_to_aspect' do = select_tag :friend_id, options_from_collection_for_select(friends, "id", "real_name"), :include_blank => true = hidden_field_tag :aspect_id, aspect.id + - if defined?(manage) && manage + = hidden_field_tag :manage, true = submit_tag "add to #{aspect.name}" diff --git a/app/views/shared/_aspect_friends.haml b/app/views/shared/_aspect_friends.haml index f4b2f06f7..c7137b025 100644 --- a/app/views/shared/_aspect_friends.haml +++ b/app/views/shared/_aspect_friends.haml @@ -16,7 +16,7 @@ = person_image_link(friend) -unless (@aspect == :all) - = link_to (image_tag('add_friend_button.png', :title => "add to #{@aspect}")), "#add_request_pane", :id => 'add_request_button' + = link_to (image_tag('add_friend_button.png', :title => "add to #{@aspect}")), "#add_request_pane", :class => 'add_request_button' .fancybox_content #add_request_pane diff --git a/app/views/users/getting_started.html.haml b/app/views/users/getting_started.html.haml new file mode 100644 index 000000000..5edb3e67a --- /dev/null +++ b/app/views/users/getting_started.html.haml @@ -0,0 +1,51 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + + +- content_for :head do + :javascript + $("#new_aspect").live("ajax:success", function(data,stat,xhr){ + window.location.reload(); + }); + + $(".aspects li").find(".delete").live("click", function(){ + var aspectElement = $(this).parent("li"); + aspectElement.fadeOut(300, function(){aspectElement.remove();}); + }); + + - if current_user.getting_started == true + :javascript + $("#getting_started_skip").live("click", function(evt){ + evt.preventDefault(); + $.ajax({ + type: "PUT", + url: "/users/#{current_user.id}", + data: {"user":{"getting_started":'false'}}, + success: function() { window.location = "#{root_path}"} + }) + }); + +.span-8.append-1.last + %h1{:style => "text-align:right;"} + = "Welcome to Diaspora!" + .description + Do the stuff below to further complete some things. + + %h3{:style => "text-align:right;"} + = link_to "Edit your profile", getting_started_path(:step => 1) + %br + = link_to "Define your aspects", getting_started_path(:step => 2) + %br + = link_to "Connect your services", getting_started_path(:step => 3) + %br + +.span-15.last + .floating{:style=>"min-height:500px;"} + = render "users/getting_started/step_#{@step}", :current_user => current_user + + - if @step > 1 + = link_to "Back", getting_started_path(:step => @step-1), :class => "button", :id => "previous_step" + +.bottom_notification + = link_to "skip getting started →", '#', :id => "getting_started_skip" diff --git a/app/views/users/getting_started/_step_1.html.haml b/app/views/users/getting_started/_step_1.html.haml new file mode 100644 index 000000000..7778a39f8 --- /dev/null +++ b/app/views/users/getting_started/_step_1.html.haml @@ -0,0 +1,61 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + + += form_for @person do |person| + %h3 + Your Profile + .description + This info will be available to whomever you connect with on Diaspora. + + = person.error_messages + + = person.fields_for :profile do |profile| + %h4 + Your name + = profile.text_field :first_name, :value => @profile.first_name, :placeholder => "First name" + = profile.text_field :last_name, :value => @profile.last_name, :placeholder => "Last name" + + %h4 + Your gender + %br + = select_tag 'person[profile][gender]', options_for_select(["","Female","Male"], @person.profile.gender) + + %h4 + Your birthday + %br + = select_date @person.profile.birthday, :order => [:month, :day, :year], :start_year => 1930, :end_year => 2000 + + %h4 + Your bio + = profile.text_area :bio, :value => @profile.bio, :rows => 5, :placeholder => "Fill me out" + + %h4 + Your photo + %div#image_picker + = profile.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field' + + - unless @photos.nil? || @photos.empty? + - for photo in @photos + - if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium)) + %div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'} + = check_box_tag 'checked_photo', true, true + = link_to image_tag(photo.url(:thumb_medium)), "#" + - else + %div.small_photo{:id => photo.url(:thumb_medium)} + = check_box_tag 'checked_photo' + = link_to image_tag(photo.url(:thumb_medium)), "#" + + - else + =t('.you_dont_have_any_photos') + = link_to t('.albums'), albums_path(:aspect => 'all') + =t('.page_to_upload_some') + + =will_paginate @photos + + = hidden_field_tag :getting_started, @step + + .submit_block + = person.submit "Save and continue →" + diff --git a/app/views/users/getting_started/_step_2.html.haml b/app/views/users/getting_started/_step_2.html.haml new file mode 100644 index 000000000..bed14bd33 --- /dev/null +++ b/app/views/users/getting_started/_step_2.html.haml @@ -0,0 +1,38 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + + +%h3 + Your aspects + .description + Diaspora aspects are mappings of your real-life aspects. You can manage these later by clicking the manage tab on the top right. Your aspects are unique to you, and not visible by others. + +%h4 + Aspect name + - form_for Aspect.new, :remote => true, :format => :json do |aspect| + = aspect.text_field :name, :style => "display:inline;" + = aspect.submit "Add" + +%ul.aspects + - for aspect in @aspects + %li{:style=>"position:relative;"} + = aspect + .friend_pictures.horizontal + - for friend in aspect.person_objects + = person_image_link(friend) + + = link_to (image_tag('add_friend_button.png', :title => "add to #{aspect}")), "#add_request_pane", :class => 'add_request_button' + + .fancybox_content + #add_request_pane + = render "requests/new_request", :aspect => aspect, :getting_started => 2 + + = link_to "x", aspect_path(aspect), :confirm => "are you sure?", :method => :delete, :remote => true, :class => "delete right" + +%br +%br + +.submit_block + = link_to "Save and continue →", getting_started_path(:step => 3), :class => "button" + diff --git a/app/views/users/getting_started/_step_3.html.haml b/app/views/users/getting_started/_step_3.html.haml new file mode 100644 index 000000000..18789da19 --- /dev/null +++ b/app/views/users/getting_started/_step_3.html.haml @@ -0,0 +1,23 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + + +%h3 + Your services + .description + Connect your existing social networks to your Diaspora account. You will be able to post publically through your Everyone tab when you select "public." +%ul#stream + - for service in @services + %h3 + %b= service.provider + logged in as + %b= service.nickname + = link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete + +%h4= link_to "Connect to twitter", "/auth/twitter" if SERVICES['twitter']['consumer_key']!= "" +%h4= link_to "Connect to facebook", "/auth/facebook" if SERVICES['facebook']['app_id'] !="" + +.submit_block + = link_to "Save and continue →", getting_started_path(:step => 4), :class => "button" + diff --git a/app/views/users/getting_started/_step_4.html.haml b/app/views/users/getting_started/_step_4.html.haml new file mode 100644 index 000000000..b5ca7b274 --- /dev/null +++ b/app/views/users/getting_started/_step_4.html.haml @@ -0,0 +1,44 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# 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 + You're now ready to start sharing with + %ul.inline_aspect_listing + - for aspect in @aspects + %li= aspect + +%br +%br + +%h3 + = link_to "Continue on to your everyone page, an overview of all of your aspects.", root_path + +%br +%br +%br + +%p + You can change your profile any time by clicking + %b edit profile + in your user menu (top right). +%p + You can connect/disconnect your services any time by clicking + %b edit account + in your user menu (top right). +%p + You can manage your aspects any time by clicking the + %b manage + tab. Your contacts can also be added while on a particular aspect page, as well. + diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 33c3d62bd..7071d13d4 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -121,6 +121,12 @@ en: edit: editing_profile: "Editing profile" destroy: "Account successfully closed." + getting_started: + '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" diff --git a/config/routes.rb b/config/routes.rb index e46a65b0a..c72ed855f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,11 +17,12 @@ Diaspora::Application.routes.draw do :password => "devise/passwords", :invitations => "invitations"} # added public route to user - match 'public/:username', :to => 'users#public' - match 'users/export', :to => 'users#export' - match 'users/import', :to => 'users#import' - match 'users/export_photos', :to => 'users#export_photos' - resources :users, :except => [:create, :new, :show] + match 'public/:username', :to => 'users#public' + match 'getting_started', :to => 'users#getting_started', :as => 'getting_started' + match 'users/export', :to => 'users#export' + match 'users/import', :to => 'users#import' + match 'users/export_photos', :to => 'users#export_photos' + resources :users, :except => [:create, :new, :show] match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend' match 'aspects/add_to_aspect',:to => 'aspects#add_to_aspect', :as => 'add_to_aspect' diff --git a/lib/diaspora/user/receiving.rb b/lib/diaspora/user/receiving.rb index bcf8897f1..19732552f 100644 --- a/lib/diaspora/user/receiving.rb +++ b/lib/diaspora/user/receiving.rb @@ -44,6 +44,7 @@ module Diaspora elsif object.is_a? Profile sender = Diaspora::Parser.owner_id_from_xml xml elsif object.is_a?(Comment) + object.person = Person.by_webfinger(object.diaspora_handle) sender = (owns?(object.post))? object.person : object.post.person else sender = object.person @@ -82,14 +83,13 @@ module Diaspora end def receive_comment comment, xml - comment.person = Diaspora::Parser.parse_or_find_person_from_xml( xml ).save if comment.person.nil? raise "In receive for #{self.real_name}, signature was not valid on: #{comment.inspect}" unless comment.post.person == self.person || comment.verify_post_creator_signature self.visible_people = self.visible_people | [comment.person] self.save Rails.logger.debug("The person parsed from comment xml is #{comment.person.inspect}") unless comment.person.nil? comment.person.save Rails.logger.debug("From: #{comment.person.inspect}") if comment.person - comment.save + comment.save! unless owns?(comment) dispatch_comment comment end diff --git a/public/404.html b/public/404.html index 13597a69a..02624c38a 100644 --- a/public/404.html +++ b/public/404.html @@ -18,9 +18,7 @@
-You should try going outside.
-
+