private message inbox wip
This commit is contained in:
parent
2522ab7ee4
commit
5f55dfa1bc
13 changed files with 300 additions and 90 deletions
10
Gemfile.lock
10
Gemfile.lock
|
|
@ -119,14 +119,14 @@ GEM
|
|||
erubis
|
||||
extlib
|
||||
highline
|
||||
json (>= 1.4.4, <= 1.4.6)
|
||||
json (<= 1.4.6, >= 1.4.4)
|
||||
mixlib-authentication (>= 1.1.0)
|
||||
mixlib-cli (>= 1.1.0)
|
||||
mixlib-config (>= 1.1.2)
|
||||
mixlib-log (>= 1.2.0)
|
||||
moneta
|
||||
ohai (>= 0.5.7)
|
||||
rest-client (>= 1.0.4, < 1.7.0)
|
||||
rest-client (< 1.7.0, >= 1.0.4)
|
||||
uuidtools
|
||||
childprocess (0.1.7)
|
||||
ffi (~> 0.6.3)
|
||||
|
|
@ -163,7 +163,7 @@ GEM
|
|||
faraday (0.5.4)
|
||||
addressable (~> 2.2.2)
|
||||
multipart-post (~> 1.1.0)
|
||||
rack (>= 1.1.0, < 2)
|
||||
rack (< 2, >= 1.1.0)
|
||||
faraday_middleware (0.3.2)
|
||||
faraday (~> 0.5.4)
|
||||
fastercsv (1.5.4)
|
||||
|
|
@ -271,7 +271,7 @@ GEM
|
|||
multi_json (~> 0.0.4)
|
||||
ohai (0.5.8)
|
||||
extlib
|
||||
json (>= 1.4.4, <= 1.4.6)
|
||||
json (<= 1.4.6, >= 1.4.4)
|
||||
mixlib-cli
|
||||
mixlib-config
|
||||
mixlib-log
|
||||
|
|
@ -353,7 +353,7 @@ GEM
|
|||
simple_oauth (0.1.4)
|
||||
sinatra (1.1.3)
|
||||
rack (~> 1.1)
|
||||
tilt (>= 1.2.2, < 2.0)
|
||||
tilt (< 2.0, >= 1.2.2)
|
||||
subexec (0.0.4)
|
||||
systemu (1.2.0)
|
||||
term-ansicolor (1.0.5)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ class ConversationsController < ApplicationController
|
|||
|
||||
def index
|
||||
@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_visibilities => {:person_id => current_user.person.id, :conversation_id => params[:conversation_id]}).first
|
||||
end
|
||||
|
|
@ -34,4 +36,8 @@ class ConversationsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def new
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class ProfilesController < ApplicationController
|
|||
# upload and set new profile photo
|
||||
params[:profile] ||= {}
|
||||
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]
|
||||
|
||||
if current_user.update_profile params[:profile]
|
||||
|
|
|
|||
|
|
@ -13,11 +13,10 @@ module ApplicationHelper
|
|||
def page_title text=nil
|
||||
title = ""
|
||||
if text.blank?
|
||||
title = "#{current_user.name} | " if current_user
|
||||
title = "#{current_user.name}" if current_user
|
||||
else
|
||||
title = "#{text} | "
|
||||
title = "#{text}"
|
||||
end
|
||||
title += "DIASPORA*"
|
||||
end
|
||||
|
||||
def aspects_with_post aspects, post
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class Message < ActiveRecord::Base
|
|||
xml_reader :conversation_guid
|
||||
|
||||
belongs_to :author, :class_name => 'Person'
|
||||
belongs_to :conversation
|
||||
belongs_to :conversation, :touch => true
|
||||
|
||||
after_create do
|
||||
#sign comment as commenter
|
||||
|
|
|
|||
|
|
@ -2,18 +2,23 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
.stream_element.conversation{:data=>{:guid=>conversation.id}, :class => ('selected' if conversation.id == conversation.id)}
|
||||
- if conversation.author.owner_id == current_user.id
|
||||
.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')
|
||||
.stream_element.conversation{:data=>{:guid=>conversation.id}}
|
||||
= person_image_tag(conversation.messages.last.author)
|
||||
|
||||
.from
|
||||
= person_link(conversation.author, :class => 'author')
|
||||
.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
|
||||
= "#{conversation.messages.first.text[0..60]}..."
|
||||
|
||||
.info
|
||||
/%span.timeago= link_to(how_long_ago(conversation), status_message_path(conversation))
|
||||
= "#{conversation.messages.last.text[0..45]}..."
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,23 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
.conversation_participants
|
||||
.conversation_participants.span-16.last
|
||||
.span-10
|
||||
%h3
|
||||
= 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
|
||||
= person_image_link(participant)
|
||||
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
.span-16.last
|
||||
.stream
|
||||
= render :partial => 'messages/message', :collection => conversation.messages
|
||||
|
||||
|
|
|
|||
|
|
@ -2,40 +2,39 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# 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');
|
||||
conversationSummary.addClass('selected');
|
||||
$('#conversation_show').html(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
- content_for :head do
|
||||
= include_javascripts :inbox
|
||||
|
||||
.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
|
||||
= link_to 'New Message', new_conversation_path, :class => 'button'
|
||||
= link_to 'Inbox', conversations_path, :class => 'button'
|
||||
= link_to 'Sent', conversations_path, :class => 'button'
|
||||
= link_to 'New Message', new_conversation_path, :class => 'button', :rel => 'facebox'
|
||||
Inbox
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
.span-7
|
||||
#conversation_inbox
|
||||
- if @conversations.count > 0
|
||||
.stream.conversations
|
||||
= render :partial => 'conversations/conversation', :collection => @conversations
|
||||
= will_paginate @conversations
|
||||
- else
|
||||
%i
|
||||
You have no messages
|
||||
|
||||
#conversation_show.span-17.last
|
||||
#conversation_show.span-16.last
|
||||
- if @conversation
|
||||
= render 'conversations/show', :conversation => @conversation
|
||||
- else
|
||||
%i
|
||||
#no_conversation_text
|
||||
no conversation selected
|
||||
#no_conversation_controls
|
||||
= link_to 'create a new message', new_conversation_path, :rel => 'facebox'
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
= person_link(post.author, :class => 'author')
|
||||
%time.timeago{:datetime => post.created_at}
|
||||
= link_to(how_long_ago(post), status_message_path(post))
|
||||
|
||||
%p
|
||||
= render 'status_messages/status_message', :post => post, :photos => post.photos
|
||||
|
||||
.info
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ javascripts:
|
|||
- public/javascripts/contact-list.js
|
||||
photos:
|
||||
- public/javascripts/photo-show.js
|
||||
inbox:
|
||||
- public/javascripts/inbox.js
|
||||
|
||||
stylesheets:
|
||||
default:
|
||||
|
|
|
|||
BIN
public/images/reply.png
Normal file
BIN
public/images/reply.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
79
public/javascripts/inbox.js
Normal file
79
public/javascripts/inbox.js
Normal 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);
|
||||
};
|
||||
|
|
@ -9,7 +9,7 @@ $background: rgb(252,252,252)
|
|||
body
|
||||
:padding 2em
|
||||
:margin 0
|
||||
:top 60px
|
||||
:top 50px
|
||||
:background-color $background
|
||||
a
|
||||
:color #107FC9
|
||||
|
|
@ -127,8 +127,8 @@ header
|
|||
:color #111
|
||||
: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 -moz-linear-gradient(top, rgba(30,30,30,0.85), rgba(20,20,20,0.98))
|
||||
: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(20,20,20,0.85), rgba(20,20,20,0.98))
|
||||
|
||||
:-webkit-box-shadow 0 1px 3px #111
|
||||
:-moz-box-shadow 0 1px 2px #111
|
||||
|
|
@ -254,8 +254,6 @@ header
|
|||
:top 1px solid #fff
|
||||
|
||||
&:hover
|
||||
:border
|
||||
:bottom 1px solid #ddd
|
||||
.right
|
||||
:display inline
|
||||
|
||||
|
|
@ -2486,30 +2484,63 @@ ul.show_comments
|
|||
.stream_element
|
||||
.subject
|
||||
:font
|
||||
:size 13px
|
||||
:size 14px
|
||||
:weight bold
|
||||
:color #444
|
||||
:overflow hidden
|
||||
:white-space nowrap
|
||||
|
||||
.last_author
|
||||
:font
|
||||
:size 12px
|
||||
:weight bold
|
||||
:color #777
|
||||
|
||||
.message
|
||||
:font
|
||||
:size 12px
|
||||
|
||||
.participants
|
||||
.avatar
|
||||
:float none
|
||||
:height 24px
|
||||
:width 24px
|
||||
:margin
|
||||
:top 3px
|
||||
|
||||
.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
|
||||
:height 30px
|
||||
:width 30px
|
||||
|
||||
:background
|
||||
:color #eee
|
||||
:line
|
||||
:height 0
|
||||
|
||||
.conversation_controls
|
||||
a
|
||||
:margin
|
||||
:right 10px
|
||||
|
||||
:margin
|
||||
:bottom 10px
|
||||
|
||||
:border
|
||||
:bottom 1px solid #999
|
||||
:padding 1em
|
||||
:bottom 1px solid #666
|
||||
:padding 5px
|
||||
:left 10px
|
||||
:top 90px
|
||||
:margin
|
||||
:top -100px
|
||||
|
||||
.avatars
|
||||
:text
|
||||
:align right
|
||||
|
||||
.stream_element.new_message
|
||||
:border
|
||||
|
|
@ -2526,12 +2557,92 @@ ul.show_comments
|
|||
:right -11px
|
||||
|
||||
.stream_element.conversation
|
||||
:padding 10px
|
||||
:padding 5px
|
||||
|
||||
.stream.conversations
|
||||
:border
|
||||
:right 1px solid #ccc
|
||||
.message_count
|
||||
:right 6px
|
||||
: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
|
||||
: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
|
||||
:text
|
||||
:align center
|
||||
:margin
|
||||
:top 100px
|
||||
|
||||
#no_conversation_controls
|
||||
:text
|
||||
:align center
|
||||
:font
|
||||
:size 12px
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue