diff --git a/Gemfile.lock b/Gemfile.lock index 72ba7dba1b6d1c4b2f25b7b58e156f03656ebcbf..4c40485691f79a70f8b6cb755ac4dbf24856157a 100644 --- a/Gemfile.lock +++ b/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) diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index b49333446ee75f8ac527759f3caa96e11a6d1e01..dfe07c023ce644d17568271783c86fac20aa3b96 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -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 diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 54c892a9a65f34883b0fca9fa68666ff44f9fcf9..79267c8cc2ebb5fe2e55c9fafe5cc77ca6aaebe6 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -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] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 96e01fffbabfecddaccfd666bf4b53cb92f5b8b1..e3927d2373104c1c53825fba6386a23f930ea871 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/models/message.rb b/app/models/message.rb index 5f95f30d96e740519f5b5195ec08fb9cfbf6aa80..6a2f1adf456dc4d2a735c98490312b44f199faf7 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -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 diff --git a/app/views/conversations/_conversation.haml b/app/views/conversations/_conversation.haml index 2c78682d76a09dddebddeaa206e168ed74b57225..5e1c450f86ae5efe1dbba4908c103bd027f7860e 100644 --- a/app/views/conversations/_conversation.haml +++ b/app/views/conversations/_conversation.haml @@ -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 - = "#{conversation.messages.first.text[0..60]}..." + .message_count + = conversation.messages.size + + = conversation.subject[0..30] - .info - /%span.timeago= link_to(how_long_ago(conversation), status_message_path(conversation)) + .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.last.text[0..45]}..." diff --git a/app/views/conversations/_show.haml b/app/views/conversations/_show.haml index aa7f72bfc1293f9e97a4225bdc10b484a084fa6b..b9566615fecc915aeee97a81d8e1f76fdb251cca 100644 --- a/app/views/conversations/_show.haml +++ b/app/views/conversations/_show.haml @@ -2,23 +2,32 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -.conversation_participants - %h3 - = conversation.subject - .right - = link_to t('delete'), conversation_conversation_visibility_path(conversation), :method => 'delete', :confirm => t('are_you_sure') - - for participant in conversation.participants - = person_image_link(participant) +.conversation_participants.span-16.last + .span-10 + %h3 + = conversation.subject + + .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') -.stream - = render :partial => 'messages/message', :collection => conversation.messages + .span-6.avatars.last + - for participant in conversation.participants + = person_image_link(participant) - .stream_element.new_message - = owner_image_tag +%br +%br +%br +.span-16.last + .stream + = render :partial => 'messages/message', :collection => conversation.messages - .content - = form_for [conversation, Message.new] do |message| - = message.text_area :text, :rows => 5 - .right - = message.submit 'Reply' - = link_to 'Cancel', '#' + .stream_element.new_message + = owner_image_tag + + .content + = form_for [conversation, Message.new] do |message| + = message.text_area :text, :rows => 5 + .right + = message.submit 'Reply' + = link_to 'Cancel', '#' diff --git a/app/views/conversations/index.haml b/app/views/conversations/index.haml index eeb17e6fb9c826ef84bb53719d9126d6bc81cd2a..21c51f330511898b5cbd819137f9c92acf61a823 100644 --- a/app/views/conversations/index.haml +++ b/app/views/conversations/index.haml @@ -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;'} - .right - = link_to 'New Message', new_conversation_path, :class => 'button' - = link_to 'Inbox', conversations_path, :class => 'button' - = link_to 'Sent', conversations_path, :class => 'button' +- 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', :rel => 'facebox' + Inbox %br %br %br -.span-7 - - if @conversations.count > 0 - .stream.conversations - = render :partial => 'conversations/conversation', :collection => @conversations - - else - %i - You have no messages + #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' diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 5779f1f1ed44c9de52d78628f247c6f96eb0c401..ec529a2e08da11ee3293027873ea77303f3952a0 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -17,8 +17,8 @@ = person_link(post.author, :class => 'author') %time.timeago{:datetime => post.created_at} = link_to(how_long_ago(post), status_message_path(post)) - - = render 'status_messages/status_message', :post => post, :photos => post.photos + %p + = render 'status_messages/status_message', :post => post, :photos => post.photos .info - if post.public? diff --git a/config/assets.yml b/config/assets.yml index f398ee1d0869349c5ac5271d180361cce2eedf0e..e70e461b4ccb786a5282c771279b7d98f92e1cf5 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -56,6 +56,8 @@ javascripts: - public/javascripts/contact-list.js photos: - public/javascripts/photo-show.js + inbox: + - public/javascripts/inbox.js stylesheets: default: diff --git a/public/images/reply.png b/public/images/reply.png new file mode 100644 index 0000000000000000000000000000000000000000..2356dc7791f28e2dae9bb96e62f9d60c7ca3906f Binary files /dev/null and b/public/images/reply.png differ diff --git a/public/javascripts/inbox.js b/public/javascripts/inbox.js new file mode 100644 index 0000000000000000000000000000000000000000..ad8478f2155bbcfff4687d4a74219cf596437cb0 --- /dev/null +++ b/public/javascripts/inbox.js @@ -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); +}; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index f09b8f529095ce5d07e7b7b44ebd64c9ef924ad4..8c3f721bc3d2b3a214a629ed7fc7b478392d08b3 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -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 - .message + :color #444 + :overflow hidden + :white-space nowrap + + .last_author :font :size 12px + :weight bold + :color #777 - .participants - .avatar - :float none - :height 24px - :width 24px - :margin - :top 3px + .message + :font + :size 12px .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 #ccc + :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 +