Make requesting ajaxy, refactor _person request partials, add route for ajaxy webfingering, people now socket to search and _manage_aspect_contacts
This commit is contained in:
parent
f3a301d314
commit
c0414b8184
11 changed files with 69 additions and 39 deletions
|
|
@ -18,33 +18,13 @@ class PeopleController < ApplicationController
|
|||
|
||||
#only do it if it is an email address
|
||||
if params[:q].try(:match, Devise.email_regexp)
|
||||
find_remote_user(params[:q])
|
||||
webfinger(params[:q])
|
||||
end
|
||||
|
||||
respond_with @people
|
||||
end
|
||||
|
||||
def find_remote_user(account)
|
||||
|
||||
finger = EMWebfinger.new(account)
|
||||
finger.on_person do |response|
|
||||
begin
|
||||
puts response.inspect
|
||||
if response.class == Person
|
||||
|
||||
response.socket_to_uid(current_user.id, :aspects => @aspects)
|
||||
else
|
||||
require File.join(Rails.root,'lib/diaspora/websocket')
|
||||
puts Diaspora::WebSocket
|
||||
Diaspora::WebSocket.queue_to_user(current_user.id, {:class => 'person', :query => account, :response => response})
|
||||
end
|
||||
rescue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
@person = Person.find(params[:id].to_id)
|
||||
@post_type = :all
|
||||
@aspect = :none
|
||||
|
|
@ -62,7 +42,6 @@ class PeopleController < ApplicationController
|
|||
@posts = current_user.visible_posts(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
|
||||
respond_with @person, :locals => {:post_type => :all}
|
||||
|
||||
|
||||
else
|
||||
flash[:error] = I18n.t 'people.show.does_not_exist'
|
||||
redirect_to people_path
|
||||
|
|
@ -111,4 +90,30 @@ class PeopleController < ApplicationController
|
|||
redirect_to edit_person_path
|
||||
end
|
||||
end
|
||||
|
||||
def retrieve_remote
|
||||
if params[:diaspora_handle]
|
||||
webfinger(params[:diaspora_handle], :single_aspect_form => true)
|
||||
render :nothing => true
|
||||
else
|
||||
render :nothing => true, :status => 422
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def webfinger(account, opts = {})
|
||||
finger = EMWebfinger.new(account)
|
||||
finger.on_person do |response|
|
||||
begin
|
||||
if response.class == Person
|
||||
response.socket_to_uid(current_user.id, opts)
|
||||
else
|
||||
require File.join(Rails.root,'lib/diaspora/websocket')
|
||||
Diaspora::WebSocket.queue_to_user(current_user.id, {:class => 'person', :query => account, :response => response})
|
||||
end
|
||||
rescue RuntimeError => e
|
||||
puts e.message
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,6 +4,14 @@
|
|||
|
||||
module PeopleHelper
|
||||
|
||||
def request_partial single_aspect_form
|
||||
if single_aspect_form
|
||||
'requests/new_request_with_aspect_to_person'
|
||||
else
|
||||
'requests/new_request_to_person'
|
||||
end
|
||||
end
|
||||
|
||||
def search_or_index
|
||||
if params[:q]
|
||||
I18n.t 'people.helper.results_for',:params => params[:q]
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ module SocketsHelper
|
|||
if object.is_a? Post
|
||||
v = render_to_string(:partial => 'shared/stream_element', :locals => {:post => object, :current_user => user})
|
||||
elsif object.is_a? Person
|
||||
v = render_to_string(:partial => type_partial(object), :locals => {:person => object, :current_user => user}) unless object.is_a? Retraction
|
||||
v = render_to_string(:partial => type_partial(object), :locals => {:single_aspect_form => opts[:single_aspect_form], :person => object, :aspects => user.aspects, :current_user => user})
|
||||
else
|
||||
v = render_to_string(:partial => type_partial(object), :locals => {:post => object, :current_user => user}) unless object.is_a? Retraction
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
- elsif current_user.pending_requests.find_by_person_id(person.id)
|
||||
= link_to =t('.pending_request'), aspects_manage_path
|
||||
- else
|
||||
= render :partial => 'requests/new_request_to_person', :locals => {:aspects => aspects, :person => person}
|
||||
- single_aspect_form ||= nil
|
||||
= render(:partial => request_partial(single_aspect_form), :locals => {:aspects => aspects, :destination_handle => person.diaspora_handle})
|
||||
|
||||
.info
|
||||
= person.diaspora_handle
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
.description
|
||||
= t('.request_people')
|
||||
|
||||
= render :partial =>'requests/new_request_to_person', :locals => {:aspects => @aspects, :person => @person}
|
||||
= render :partial =>'requests/new_request_to_person', :locals => {:aspects => @aspects, :destination_handle => @person.diaspora_handle}
|
||||
|
||||
- else
|
||||
%h3
|
||||
|
|
|
|||
|
|
@ -7,21 +7,20 @@
|
|||
%h4
|
||||
Manage contacts within
|
||||
%i= aspect.name
|
||||
|
||||
.span-6.append-1.last
|
||||
%h3 Existing contacts
|
||||
= render 'shared/contact_list', :aspect => aspect, :contacts => @contacts, :manage => defined?(manage)
|
||||
|
||||
.span-7.last
|
||||
%h3 Add a new contact
|
||||
= form_tag(requests_path, :id => "new_request_to_#{aspect.id}") do
|
||||
= form_tag(person_by_handle_path, :id => "new_request_to_#{aspect.id}", :remote => true) do
|
||||
=t('.enter_a_diaspora_username')
|
||||
%br
|
||||
%i= t '.your_diaspora_username_is', :diaspora_handle => current_user.diaspora_handle
|
||||
|
||||
%p
|
||||
= label_tag :destination_handle, t('.contact_username'), :for => "request_d_handle_to_#{aspect.id}"
|
||||
= text_field_tag :destination_handle,'', :id => "request_d_handle_to_#{aspect.id}"
|
||||
= label_tag :diaspora_handle, t('.contact_username'), :for => "request_d_handle_to_#{aspect.id}"
|
||||
= text_field_tag :diaspora_handle,'', :id => "request_d_handle_to_#{aspect.id}"
|
||||
= hidden_field_tag :aspect_id, aspect.id
|
||||
|
||||
- if defined?(getting_started)
|
||||
|
|
@ -30,4 +29,6 @@
|
|||
= hidden_field_tag :manage, true
|
||||
|
||||
= submit_tag t('.create_request')
|
||||
%br
|
||||
%ul#request_result{:aspect_id => aspect.id}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
= form_tag(requests_path) do
|
||||
= select_tag(:aspect_id, options_from_collection_for_select(aspects, "id", "name"))
|
||||
= hidden_field_tag :destination_handle, person.diaspora_handle
|
||||
= submit_tag t('people.person.add_contact')
|
||||
= form_for(Request.new, :remote => true ) do |request|
|
||||
= request.select(:into, options_from_collection_for_select(aspects, "id", "name"))
|
||||
= request.hidden_field :to, :value => destination_handle
|
||||
= request.submit t('people.person.add_contact'), :disable_with => t('requests.create.sending')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
-# 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 Request.new, :remote => true do |request|
|
||||
= request.hidden_field :into, :value => "changeme"
|
||||
= request.hidden_field :to, :value => destination_handle
|
||||
= request.submit '+', :class => 'add', :disable_with => "Sending..."
|
||||
|
|
@ -303,6 +303,8 @@ en:
|
|||
error: "Please select an aspect!"
|
||||
ignore: "Ignored contact request."
|
||||
create:
|
||||
sending: "Sending..."
|
||||
sent: "You've asked to share with %{name}. They should see it next time they log in to Diaspora."
|
||||
tried: "we tried our best to send a message to %{account}"
|
||||
services:
|
||||
index:
|
||||
|
|
|
|||
|
|
@ -3,18 +3,18 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
Diaspora::Application.routes.draw do
|
||||
resources :people
|
||||
resources :status_messages, :only => [:create, :destroy, :show]
|
||||
resources :comments, :except => [:index]
|
||||
resources :requests, :except => [:edit, :update]
|
||||
resources :photos, :except => [:index]
|
||||
resources :services
|
||||
|
||||
resources :people
|
||||
resources :people do
|
||||
resources :status_messages
|
||||
resources :photos
|
||||
end
|
||||
|
||||
match '/people/by_handle' => 'people#retrieve_remote', :as => 'person_by_handle'
|
||||
|
||||
match '/auth/:provider/callback' => 'services#create'
|
||||
|
||||
|
|
|
|||
|
|
@ -511,7 +511,6 @@ input.comment_submit
|
|||
:margin
|
||||
:right -10px
|
||||
|
||||
|
||||
ul.comments
|
||||
:margin 0
|
||||
:top 1em
|
||||
|
|
@ -909,9 +908,6 @@ h1.big_text
|
|||
> li
|
||||
:padding 0
|
||||
:display inline
|
||||
:margin 0
|
||||
:left -1px
|
||||
|
||||
a
|
||||
:-webkit-border-radius 4px 4px 0 0
|
||||
:-moz-border-radius 4px 4px 0 0
|
||||
|
|
@ -1548,6 +1544,15 @@ h3 span.current_gs_step
|
|||
:color #eee
|
||||
:text-shadow none
|
||||
|
||||
ul#request_result
|
||||
:list-style none
|
||||
:padding 0
|
||||
:margin 0
|
||||
li
|
||||
:margin
|
||||
:bottom 25px
|
||||
input.add
|
||||
:color green
|
||||
|
||||
.contact_list
|
||||
:height 300px
|
||||
|
|
|
|||
Loading…
Reference in a new issue