private message inbox wip

This commit is contained in:
danielgrippi 2011-03-03 17:32:26 -08:00
parent 2522ab7ee4
commit 5f55dfa1bc
13 changed files with 300 additions and 90 deletions

View file

@ -119,14 +119,14 @@ GEM
erubis erubis
extlib extlib
highline highline
json (>= 1.4.4, <= 1.4.6) json (<= 1.4.6, >= 1.4.4)
mixlib-authentication (>= 1.1.0) mixlib-authentication (>= 1.1.0)
mixlib-cli (>= 1.1.0) mixlib-cli (>= 1.1.0)
mixlib-config (>= 1.1.2) mixlib-config (>= 1.1.2)
mixlib-log (>= 1.2.0) mixlib-log (>= 1.2.0)
moneta moneta
ohai (>= 0.5.7) ohai (>= 0.5.7)
rest-client (>= 1.0.4, < 1.7.0) rest-client (< 1.7.0, >= 1.0.4)
uuidtools uuidtools
childprocess (0.1.7) childprocess (0.1.7)
ffi (~> 0.6.3) ffi (~> 0.6.3)
@ -163,7 +163,7 @@ GEM
faraday (0.5.4) faraday (0.5.4)
addressable (~> 2.2.2) addressable (~> 2.2.2)
multipart-post (~> 1.1.0) multipart-post (~> 1.1.0)
rack (>= 1.1.0, < 2) rack (< 2, >= 1.1.0)
faraday_middleware (0.3.2) faraday_middleware (0.3.2)
faraday (~> 0.5.4) faraday (~> 0.5.4)
fastercsv (1.5.4) fastercsv (1.5.4)
@ -271,7 +271,7 @@ GEM
multi_json (~> 0.0.4) multi_json (~> 0.0.4)
ohai (0.5.8) ohai (0.5.8)
extlib extlib
json (>= 1.4.4, <= 1.4.6) json (<= 1.4.6, >= 1.4.4)
mixlib-cli mixlib-cli
mixlib-config mixlib-config
mixlib-log mixlib-log
@ -353,7 +353,7 @@ GEM
simple_oauth (0.1.4) simple_oauth (0.1.4)
sinatra (1.1.3) sinatra (1.1.3)
rack (~> 1.1) rack (~> 1.1)
tilt (>= 1.2.2, < 2.0) tilt (< 2.0, >= 1.2.2)
subexec (0.0.4) subexec (0.0.4)
systemu (1.2.0) systemu (1.2.0)
term-ansicolor (1.0.5) term-ansicolor (1.0.5)

View file

@ -5,7 +5,9 @@ class ConversationsController < ApplicationController
def index def index
@conversations = Conversation.joins(:conversation_visibilities).where( @conversations = Conversation.joins(:conversation_visibilities).where(
:conversation_visibilities => {:person_id => current_user.person.id}).all :conversation_visibilities => {:person_id => current_user.person.id}).paginate(
:page => params[:page], :per_page => 7, :order => 'updated_at DESC')
@conversation = Conversation.joins(:conversation_visibilities).where( @conversation = Conversation.joins(:conversation_visibilities).where(
:conversation_visibilities => {:person_id => current_user.person.id, :conversation_id => params[:conversation_id]}).first :conversation_visibilities => {:person_id => current_user.person.id, :conversation_id => params[:conversation_id]}).first
end end
@ -34,4 +36,8 @@ class ConversationsController < ApplicationController
end end
end end
def new
render :layout => false
end
end end

View file

@ -14,7 +14,7 @@ class ProfilesController < ApplicationController
# upload and set new profile photo # upload and set new profile photo
params[:profile] ||= {} params[:profile] ||= {}
params[:profile][:searchable] ||= false params[:profile][:searchable] ||= false
params[:profile][:photo] = Photo.where(:person_id => current_user.person.id, params[:profile][:photo] = Photo.where(:author_id => current_user.person.id,
:id => params[:photo_id]).first if params[:photo_id] :id => params[:photo_id]).first if params[:photo_id]
if current_user.update_profile params[:profile] if current_user.update_profile params[:profile]

View file

@ -13,11 +13,10 @@ module ApplicationHelper
def page_title text=nil def page_title text=nil
title = "" title = ""
if text.blank? if text.blank?
title = "#{current_user.name} | " if current_user title = "#{current_user.name}" if current_user
else else
title = "#{text} | " title = "#{text}"
end end
title += "DIASPORA*"
end end
def aspects_with_post aspects, post def aspects_with_post aspects, post

View file

@ -11,7 +11,7 @@ class Message < ActiveRecord::Base
xml_reader :conversation_guid xml_reader :conversation_guid
belongs_to :author, :class_name => 'Person' belongs_to :author, :class_name => 'Person'
belongs_to :conversation belongs_to :conversation, :touch => true
after_create do after_create do
#sign comment as commenter #sign comment as commenter

View file

@ -2,18 +2,23 @@
-# licensed under the Affero General Public License version 3 or later. See -# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file. -# the COPYRIGHT file.
.stream_element.conversation{:data=>{:guid=>conversation.id}, :class => ('selected' if conversation.id == conversation.id)} .stream_element.conversation{:data=>{:guid=>conversation.id}}
- if conversation.author.owner_id == current_user.id = person_image_tag(conversation.messages.last.author)
.right.hidden.controls
/= link_to image_tag('deletelabel.png'), status_message_path(conversation), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete", :title => t('delete')
.from
= person_link(conversation.author, :class => 'author')
.subject .subject
= conversation.subject .message_count
= conversation.messages.size
= conversation.subject[0..30]
.last_author
.timestamp
= time_ago_in_words conversation.updated_at
= conversation.author.name
- if conversation.participants.size > 2
%span.participant_count
= "(+#{conversation.participants.size - 1})"
.message .message
= "#{conversation.messages.first.text[0..60]}..." = "#{conversation.messages.last.text[0..45]}..."
.info
/%span.timeago= link_to(how_long_ago(conversation), status_message_path(conversation))

View file

@ -2,15 +2,24 @@
-# licensed under the Affero General Public License version 3 or later. See -# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file. -# the COPYRIGHT file.
.conversation_participants .conversation_participants.span-16.last
.span-10
%h3 %h3
= conversation.subject = conversation.subject
.right
= link_to t('delete'), conversation_conversation_visibility_path(conversation), :method => 'delete', :confirm => t('are_you_sure') .conversation_controls
= link_to (image_tag('reply.png', :height => 14, :width => 14) + ' ' + 'reply'), '#', :id => 'reply_to_conversation'
= link_to (image_tag('deletelabel.png') + ' ' + t('delete').downcase), conversation_conversation_visibility_path(conversation), :method => 'delete', :confirm => t('are_you_sure')
.span-6.avatars.last
- for participant in conversation.participants - for participant in conversation.participants
= person_image_link(participant) = person_image_link(participant)
.stream %br
%br
%br
.span-16.last
.stream
= render :partial => 'messages/message', :collection => conversation.messages = render :partial => 'messages/message', :collection => conversation.messages
.stream_element.new_message .stream_element.new_message

View file

@ -2,40 +2,39 @@
-# licensed under the Affero General Public License version 3 or later. See -# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file. -# the COPYRIGHT file.
:javascript
$(document).ready(function(){
$('.conversation', '.stream').click(function(){
var conversationSummary = $(this),
conversationGuid = conversationSummary.attr('data-guid');
$.get("conversations/"+conversationGuid, function(data){
$('.conversation', '.stream').removeClass('selected'); - content_for :head do
conversationSummary.addClass('selected'); = include_javascripts :inbox
$('#conversation_show').html(data);
});
});
});
.span-24.last{:style => 'position:relative;'} - content_for :page_title do
Message Inbox
:css
footer{ display:none;}
.span-5.append-3
%h3.fixit{:style => 'width:300px;'}
.right .right
= link_to 'New Message', new_conversation_path, :class => 'button' = link_to 'New Message', new_conversation_path, :class => 'button', :rel => 'facebox'
= link_to 'Inbox', conversations_path, :class => 'button' Inbox
= link_to 'Sent', conversations_path, :class => 'button'
%br %br
%br %br
%br %br
.span-7 #conversation_inbox
- if @conversations.count > 0 - if @conversations.count > 0
.stream.conversations .stream.conversations
= render :partial => 'conversations/conversation', :collection => @conversations = render :partial => 'conversations/conversation', :collection => @conversations
= will_paginate @conversations
- else - else
%i %i
You have no messages You have no messages
#conversation_show.span-17.last #conversation_show.span-16.last
- if @conversation - if @conversation
= render 'conversations/show', :conversation => @conversation = render 'conversations/show', :conversation => @conversation
- else - else
%i #no_conversation_text
no conversation selected no conversation selected
#no_conversation_controls
= link_to 'create a new message', new_conversation_path, :rel => 'facebox'

View file

@ -17,7 +17,7 @@
= person_link(post.author, :class => 'author') = person_link(post.author, :class => 'author')
%time.timeago{:datetime => post.created_at} %time.timeago{:datetime => post.created_at}
= link_to(how_long_ago(post), status_message_path(post)) = link_to(how_long_ago(post), status_message_path(post))
%p
= render 'status_messages/status_message', :post => post, :photos => post.photos = render 'status_messages/status_message', :post => post, :photos => post.photos
.info .info

View file

@ -56,6 +56,8 @@ javascripts:
- public/javascripts/contact-list.js - public/javascripts/contact-list.js
photos: photos:
- public/javascripts/photo-show.js - public/javascripts/photo-show.js
inbox:
- public/javascripts/inbox.js
stylesheets: stylesheets:
default: default:

BIN
public/images/reply.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1,79 @@
/* Copyright (c) 2010, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
$(document).ready(function(){
var bindIt = function(element){
var conversationSummary = element,
conversationGuid = conversationSummary.attr('data-guid');
$.get("conversations/"+conversationGuid, function(data){
$('.conversation', '.stream').removeClass('selected');
conversationSummary.addClass('selected');
$('#conversation_show').html(data);
});
if (typeof(history.pushState) == 'function') {
history.pushState(null, document.title, '?conversation_id='+conversationGuid);
}
}
$('.conversation', '.stream').bind('mousedown', function(){
bindIt($(this));
});
resize();
$(window).resize(function(){
resize();
});
$('#conversation_inbox .stream').infinitescroll({
navSelector : ".pagination",
// selector for the paged navigation (it will be hidden)
nextSelector : ".pagination a.next_page",
// selector for the NEXT link (to page 2)
itemSelector : "#conversation_inbox .conversation",
// selector for all items you'll retrieve
localMode: true,
debug: false,
donetext: "no more.",
loadingText: "",
loadingImg: '/images/ajax-loader.gif'
}, function(){
$('.conversation', '.stream').bind('mousedown', function(){
bindIt($(this));
});
});
// kill scroll binding
$(window).unbind('.infscr');
// hook up the manual click guy.
$('a.next_page').click(function(){
$(document).trigger('retrieve.infscr');
return false;
});
// remove the paginator when we're done.
$(document).ajaxError(function(e,xhr,opt){
if (xhr.status == 404) $('a.next_page').remove();
});
$('#reply_to_conversation').live('click', function(evt) {
evt.preventDefault();
$('html, body').animate({scrollTop:$(window).height()}, 'medium', function(){
$('#message_text').focus();
});
});
});
var resize = function(){
var inboxSidebar = $('#conversation_inbox');
inboxSidebarOffset = inboxSidebar.offset().top,
windowHeight = $(window).height();
inboxSidebar.css('height', windowHeight - inboxSidebarOffset);
};

View file

@ -9,7 +9,7 @@ $background: rgb(252,252,252)
body body
:padding 2em :padding 2em
:margin 0 :margin 0
:top 60px :top 50px
:background-color $background :background-color $background
a a
:color #107FC9 :color #107FC9
@ -127,8 +127,8 @@ header
:color #111 :color #111
:color rgba(15,15,15,0.90) :color rgba(15,15,15,0.90)
:background -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(30,30,30,0.85)), to(rgba(20,20,20,1))) :background -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(20,20,20,0.85)), to(rgba(20,20,20,1)))
:background -moz-linear-gradient(top, rgba(30,30,30,0.85), rgba(20,20,20,0.98)) :background -moz-linear-gradient(top, rgba(20,20,20,0.85), rgba(20,20,20,0.98))
:-webkit-box-shadow 0 1px 3px #111 :-webkit-box-shadow 0 1px 3px #111
:-moz-box-shadow 0 1px 2px #111 :-moz-box-shadow 0 1px 2px #111
@ -254,8 +254,6 @@ header
:top 1px solid #fff :top 1px solid #fff
&:hover &:hover
:border
:bottom 1px solid #ddd
.right .right
:display inline :display inline
@ -2486,30 +2484,63 @@ ul.show_comments
.stream_element .stream_element
.subject .subject
:font :font
:size 13px :size 14px
:weight bold :weight bold
:color #444
:overflow hidden
:white-space nowrap
.last_author
:font
:size 12px
:weight bold
:color #777
.message .message
:font :font
:size 12px :size 12px
.participants
.avatar
:float none
:height 24px
:width 24px
:margin
:top 3px
.conversation_participants .conversation_participants
:z-index 3
:background
:color $background
:position fixed
:margin
:bottom 10px
:-webkit-box-shadow 0 3px 3px -3px #333
:-moz-box-shadow 0 3px 3px -3px #333
h3
:margin 0
:top 6px
:bottom 0px
.avatar .avatar
:height 30px :height 30px
:width 30px :width 30px
:background :line
:color #eee :height 0
.conversation_controls
a
:margin
:right 10px
:margin
:bottom 10px
:border :border
:bottom 1px solid #999 :bottom 1px solid #666
:padding 1em :padding 5px
:left 10px
:top 90px
:margin
:top -100px
.avatars
:text
:align right
.stream_element.new_message .stream_element.new_message
:border :border
@ -2526,12 +2557,92 @@ ul.show_comments
:right -11px :right -11px
.stream_element.conversation .stream_element.conversation
:padding 10px :padding 5px
.stream.conversations .message_count
:border :right 6px
:right 1px solid #ccc :background
:color #999
:color #eee
:position absolute
:padding 0 5px
:font
:size 12px
:weight normal
:-webkit-border-radius 3px
.participant_count
:font
:weight normal
.timestamp
:position absolute
:right 6px
:font
:weight normal
:color $blue
.avatar
:display inline
:width 35px
:height 35px
:margin
:right 5px
.message
:padding
:left 40px
&:hover:not(.selected)
:background
:color #f0f0f0
&:hover
:cursor pointer
.conversation.selected .conversation.selected
:background :background
:color $blue
.subject
:color #fff
.last_author
:color #fff
.message
:color #eee
.timestamp
:color #eee
:border
:bottom 1px solid darken($blue, 10%)
:top 1px solid darken($blue, 10%)
#conversation_inbox
:position fixed
:height 100%
:overflow-y auto
:overflow-x none
:background
:color #f8f8f8
:width 300px
:border
:right 2px solid #999
:left 2px solid #eee
.fixit
:position fixed
#no_conversation_text
:font
:size 20px
:weight bold
:color #ccc :color #ccc
:text
:align center
:margin
:top 100px
#no_conversation_controls
:text
:align center
:font
:size 12px