Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 0523a3a6f2c30a305de8f4746b34edc9caf0d6ba Mon Sep 17 00:00:00 2001
- From: svmk <svmk-tmsk@yandex.ru>
- Date: Sat, 16 Apr 2011 19:48:02 +0700
- Subject: [PATCH] Added DAC of conversation.
- In database ConversationVisibility added three variables: owner, editor, deleted.
- The owner can manage the members of the conversations.
- The editor can send messages.
- If the deleted flag is set, the user does not have a conversation.
- This code has been tested on a Opera Browser. Html code uses css3.
- ---
- app/controllers/conversations_controller.rb | 172 ++++++++++++++++++-
- app/controllers/messages_controller.rb | 6 +
- app/helpers/application_helper.rb | 11 ++
- app/views/conversations/_access_denied.haml | 15 ++
- app/views/conversations/_show.haml | 60 ++++++-
- app/views/conversations/access_denied.haml | 5 +
- app/views/conversations/create_contact.haml | 1 +
- app/views/conversations/delete_contact.haml | 1 +
- app/views/conversations/index.haml | 16 +-
- app/views/conversations/new_contact.haml | 177 ++++++++++++++++++++
- app/views/conversations/show.haml | 2 +-
- config/locales/diaspora/en.yml | 1 +
- config/locales/diaspora/ru.yml | 1 +
- config/routes.rb | 8 +-
- ...6095653_add_owner_to_conversation_visibility.rb | 19 ++
- db/schema.rb | 5 +-
- public/images/user/add_button.png | Bin 0 -> 242 bytes
- public/images/user/add_contact.png | Bin 0 -> 234 bytes
- public/stylesheets/sass/application.sass | 145 ++++++++++++++++-
- 19 files changed, 621 insertions(+), 24 deletions(-)
- create mode 100644 app/views/conversations/_access_denied.haml
- create mode 100644 app/views/conversations/access_denied.haml
- create mode 100644 app/views/conversations/create_contact.haml
- create mode 100644 app/views/conversations/delete_contact.haml
- create mode 100644 app/views/conversations/new_contact.haml
- create mode 100644 db/migrate/20110326095653_add_owner_to_conversation_visibility.rb
- create mode 100644 public/images/user/add_button.png
- create mode 100644 public/images/user/add_contact.png
- diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb
- index 2a4008d..633dde1 100644
- --- a/app/controllers/conversations_controller.rb
- +++ b/app/controllers/conversations_controller.rb
- @@ -1,4 +1,4 @@
- -class ConversationsController < ApplicationController
- + class ConversationsController < ApplicationController
- before_filter :authenticate_user!
- respond_to :html, :json
- @@ -19,20 +19,41 @@ class ConversationsController < ApplicationController
- @conversation = Conversation.joins(:conversation_visibilities).where(
- :conversation_visibilities => {:person_id => current_user.person.id, :conversation_id => params[:conversation_id]}).first
- + @conversation_vis = ConversationVisibility.where(:conversation_id => params[:conversation_id]).order('owner DESC, editor DESC, deleted ASC')
- + @allow_access = true
- + if not @conversation_vis.any?{|i| i.person_id == current_user.person.id and not i.deleted} then
- + # Access denied
- + @allow_access = false
- + end
- + if params[:conversation_id] then
- + @owner = @conversation_vis.any?{|i| i.person_id == current_user.person.id and i.owner and not i.deleted}
- + @url_new_contact = url_for(:controller=>'conversations',:action=>'new_contact',:conversation_id=>params[:conversation_id])
- + end
- end
- def create
- - person_ids = Contact.where(:id => params[:contact_ids].split(',')).map! do |contact|
- + contact_ids = []
- + if params[:contact_ids] then
- + contact_ids = params[:contact_ids].split(',')
- + end
- + if contact_ids.length == 0 then
- + flash[:notice] = t('.desteny_field_error')
- + redirect_to conversations_path
- + return
- + end
- + person_ids = Contact.where(:id => contact_ids).map! do |contact|
- contact.person_id
- end
- params[:conversation][:participant_ids] = person_ids | [current_user.person.id]
- params[:conversation][:author] = current_user.person
- - if @conversation = Conversation.create(params[:conversation])
- + @conversation = Conversation.create(params[:conversation])
- + if @conversation then
- + @conversation.participants.update_all({:owner => false, :editor=> true, :deleted=> false})
- + @conversation.participants.update_all({:owner => true, :editor=> true, :deleted=> false},{:id => current_user.person.id})
- Postzord::Dispatch.new(current_user, @conversation).post
- -
- - flash[:notice] = "Message sent"
- + flash[:notice] = t('.message_sent')
- if params[:profile]
- redirect_to person_path(params[:profile])
- else
- @@ -42,8 +63,16 @@ class ConversationsController < ApplicationController
- end
- def show
- + @conversation_vis = ConversationVisibility.where(:conversation_id => params[:id]).order('owner DESC, editor DESC, deleted ASC')
- + if not @conversation_vis.any?{|i| i.person_id == current_user.person.id and not i.deleted} then
- + # Access denied
- + render :access_denied,:layout=>false
- + return
- + end
- + @owner = @conversation_vis.any?{|i| i.person_id == current_user.person.id and i.owner and not i.deleted}
- + @url_new_contact = url_for(:controller=>'conversations',:action=>'new_contact',:conversation_id=>params[:id])
- @conversation = Conversation.joins(:conversation_visibilities).where(:id => params[:id],
- - :conversation_visibilities => {:person_id => current_user.person.id}).first
- + :conversation_visibilities => {:person_id => current_user.person.id}).first
- if @visibility = ConversationVisibility.where(:conversation_id => params[:id], :person_id => current_user.person.id).first
- @visibility.unread = 0
- @@ -53,7 +82,7 @@ class ConversationsController < ApplicationController
- if @conversation
- render :layout => false
- else
- - redirect_to conversations_path
- + # render error message! don't redirect!
- end
- end
- @@ -63,4 +92,133 @@ class ConversationsController < ApplicationController
- render :layout => false
- end
- + def new_contact
- + @aspect = :manage
- + @contacts = current_user.contacts.includes(:person => :profile)
- + @conversation_id = params[:conversation_id]
- + @active_contacts = ConversationVisibility.where(:conversation_id => @conversation_id).order('owner DESC, editor DESC, deleted ASC')
- + #@active_contacts = ConversationVisibility.order('owner DESC, editor DESC, deleted ASC') + ConversationVisibility.order('owner DESC, editor DESC, deleted ASC') # TODO!
- + render :layout => false
- + end
- +
- + def prepare_info(item)
- + str = ''
- + if item then
- + if (item.owner) then
- + str = str + 'O';
- + end
- + if (item.editor) then
- + str = str + 'E';
- + end
- + if (not item.deleted) then
- + str = str + 'R';
- + end
- + end
- + return str
- + end
- +
- + def is_owner
- + item = ConversationVisibility.where(:conversation_id => params[:conversation_id],:person_id => current_user.person.id).first
- + return (item.owner and not item.deleted)
- + end
- +
- + def create_contact
- + if is_owner then
- + @conversation = Conversation.find(params[:conversation_id])
- + if @conversation then
- + if not @conversation.participant_ids.any?{|rec| rec == params[:person_id].to_i} then
- + @conversation.participant_ids = @conversation.participant_ids + [params[:person_id]]
- + else
- + item = ConversationVisibility.where(:conversation_id => params[:conversation_id],:person_id => params[:person_id]).first
- + if item then
- + item.deleted = false
- + item.save
- + end
- + end
- + @participant = Person.find(params[:person_id])
- + end
- + end
- + render :text => prepare_info(item),:layout => false
- + end
- +
- + def delete_contact
- + if is_owner then
- + @conversation = Conversation.find(params[:conversation_id])
- + if @conversation then
- + count = ConversationVisibility.where(:conversation_id => params[:conversation_id],:deleted=>false).count(:all)
- + item = ConversationVisibility.where(:conversation_id => params[:conversation_id],:person_id => params[:person_id]).first
- + if item and count > 1 then
- + item.deleted = true
- + item.owner = false
- + item.editor = false
- + item.save
- + end
- + end
- + end
- + render :text => prepare_info(item),:layout => false
- + end
- +
- + def afford_to_own
- + if is_owner then
- + conversation = Conversation.find(params[:conversation_id])
- + if conversation then
- + item = ConversationVisibility.where(:conversation_id => params[:conversation_id],:person_id => params[:person_id]).first
- + if item then
- + item.owner = true
- + item.editor = true
- + item.deleted = false
- + item.save
- + else
- + ConversationVisibility.create(:conversation_id => params[:conversation_id],:person_id => params[:person_id],:owner => true, :editor=>true, :deleted => false, :unread=>true)
- + end
- + end
- + end
- + render :text=>prepare_info(item),:layout=>false
- + end
- +
- + def prohibit_owning
- + if is_owner then
- + conversation = Conversation.find(params[:conversation_id])
- + if conversation then
- + count_owner = ConversationVisibility.where(:conversation_id => params[:conversation_id],:owner=>true).count(:all)
- + item = ConversationVisibility.where(:conversation_id => params[:conversation_id],:person_id => params[:person_id]).first
- + if item and count_owner > 1 then
- + item.owner = false
- + item.save
- + end
- + end
- + end
- + render :text=>prepare_info(item),:layout=>false
- + end
- +
- + def allow_edit
- + if is_owner then
- + conversation = Conversation.find(params[:conversation_id])
- + if conversation then
- + item = ConversationVisibility.where(:conversation_id => params[:conversation_id],:person_id => params[:person_id]).first
- + if item then
- + item.editor = true
- + item.deleted = false
- + item.save
- + else
- + ConversationVisibility.create(:conversation_id => params[:conversation_id],:person_id => params[:person_id],:owner => false, :editor=>true, :deleted => false, :unread=>true)
- + end
- + end
- + end
- + render :text=>prepare_info(item),:layout=>false
- + end
- +
- + def prohibit_edit
- + if is_owner then
- + conversation = Conversation.find(params[:conversation_id])
- + if conversation then
- + item = ConversationVisibility.where(:conversation_id => params[:conversation_id],:person_id => params[:person_id]).first
- + if item then
- + item.editor = false
- + item.save
- + end
- + end
- + end
- + render :text=>prepare_info(item),:layout=>false
- + end
- end
- diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
- index 2dac50d..82f5a6e 100644
- --- a/app/controllers/messages_controller.rb
- +++ b/app/controllers/messages_controller.rb
- @@ -14,6 +14,8 @@ class MessagesController < ApplicationController
- :conversation_visibilities => {:person_id => current_user.person.id}).first
- if cnv
- + cur_user = ConversationVisibility.where(:conversation_id => params[:conversation_id],:person_id => current_user.person.id).first
- + if cur_user.editor and not cur_user.deleted then
- message = Message.new(:conversation_id => cnv.id, :text => params[:message][:text], :author => current_user.person)
- if message.save
- @@ -25,6 +27,10 @@ class MessagesController < ApplicationController
- render :nothing => true, :status => 406
- end
- else
- + flash[:error] = t('.sending_prohibited')
- + redirect_to conversations_path(:conversation_id => cnv.id)
- + end
- + else
- render :nothing => true, :status => 406
- end
- end
- diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
- index 4c2a780..c7e5ffc 100644
- --- a/app/helpers/application_helper.rb
- +++ b/app/helpers/application_helper.rb
- @@ -158,6 +158,17 @@ module ApplicationHelper
- end
- end
- + def person_image_link_with_class(person, opts = {},class_name = '')
- + return "" if person.nil? || person.profile.nil?
- + if opts[:to] == :photos
- + link_to person_image_tag(person, opts[:size]), person_photos_path(person)
- + else
- + "<a href='/people/#{person.id}' class='#{class_name}'>
- + #{person_image_tag(person)}
- +</a>".html_safe
- + end
- + end
- +
- def post_yield_tag(post)
- (':' + post.id.to_s).to_sym
- end
- diff --git a/app/views/conversations/_access_denied.haml b/app/views/conversations/_access_denied.haml
- new file mode 100644
- index 0000000..4856062
- --- /dev/null
- +++ b/app/views/conversations/_access_denied.haml
- @@ -0,0 +1,15 @@
- +.span-16.last
- + .conversation_participants
- + .span-9
- + %h3
- + = t('.no_conversation_selected')
- + .conversation_controls
- + .span-6.avatars.last
- +
- +%br
- +%br
- +%br
- +%br
- +%br
- +.span-16.last
- + .stream
- \ No newline at end of file
- diff --git a/app/views/conversations/_show.haml b/app/views/conversations/_show.haml
- index 0d7e7c1..77f738b 100644
- --- a/app/views/conversations/_show.haml
- +++ b/app/views/conversations/_show.haml
- @@ -1,8 +1,52 @@
- -# Copyright (c) 2010, Diaspora Inc. This file is
- -# licensed under the Affero General Public License version 3 or later. See
- -# the COPYRIGHT file.
- -
- -
- +:javascript
- + function add_contact_hide_keyup(ev)
- + {
- + if (ev.keyCode == 27){ // Escape key
- + $('#add_avatar_container').animate({ opacity: "hide" },200);
- + $(document).unbind('click');
- + $(document).unbind('keyup');
- + }
- + if (ev.keyCode == 13){ // Enter key
- + $('.contact_list_new ul li:not(.hiding):first .right.add_delete_button span a:not(.hiding)').click()
- + }
- + }
- + function add_contact_hide(ev)
- + {
- + el = $('#add_avatar_container');
- + pos = $('#add_avatar_container').offset();
- + shadow_size = 12;
- + if (!(ev.pageX >= pos.left &&
- + ev.pageX <= (pos.left + el[0].clientWidth) &&
- + ev.pageY >= (pos.top - shadow_size) &&
- + ev.pageY <= (pos.top + el[0].clientHeight + shadow_size)))
- + {
- + $('#add_avatar_container').animate({ opacity: "hide" },200);
- + $(document).unbind('click');
- + $(document).unbind('keyup');
- + }
- + }
- + $(document).ready(function(){
- + $('a#add_avatar img').click(function(){
- + $('#add_avatar_container').load('#{@url_new_contact}',function(){
- + pos = $('a#add_avatar').position();
- + width = 330;
- + height = 350;
- + this.style.width = width + 'px';
- + this.style.position = 'absolute';
- + this.style.left = (pos.left - width + 25) + 'px';
- + this.style.top = (pos.top + 34) + 'px';
- + this.style.opacity = 0;
- + this.style.display = 'block';
- + $(this).animate({opacity: 1},150);
- + $(document).bind('click',add_contact_hide);
- + $(document).bind('keyup',add_contact_hide_keyup);
- + $('#contact_search').focus();
- + });
- + });
- + });
- .span-16.last
- .conversation_participants
- .span-9
- @@ -14,8 +58,16 @@
- = 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)
- + - if owner then
- + %div#add_avatar_container
- + %a.no_highlight#add_avatar
- + %img{:alt=>t('.add_contact'),:src=>'/images/user/add_contact.png',:title=>t('.add_contact')}
- + - for participant in @conversation_vis
- + - class_name = 'no_highlight'
- + - if participant.owner then class_name = 'owner_highlight'
- + - if participant.editor then class_name = 'editor_highlight'
- + - if participant.deleted then class_name = class_name + ' avatar_hiding'
- + = person_image_link_with_class(participant.person,{},class_name)
- %br
- %br
- diff --git a/app/views/conversations/access_denied.haml b/app/views/conversations/access_denied.haml
- new file mode 100644
- index 0000000..69f91a4
- --- /dev/null
- +++ b/app/views/conversations/access_denied.haml
- @@ -0,0 +1,5 @@
- +-# Copyright (c) 2010, Diaspora Inc. This file is
- +-# licensed under the Affero General Public License version 3 or later. See
- +-# the COPYRIGHT file.
- +
- += render 'access_denied'
- \ No newline at end of file
- diff --git a/app/views/conversations/create_contact.haml b/app/views/conversations/create_contact.haml
- new file mode 100644
- index 0000000..253b9b7
- --- /dev/null
- +++ b/app/views/conversations/create_contact.haml
- @@ -0,0 +1 @@
- += person_image_link(@participant)
- \ No newline at end of file
- diff --git a/app/views/conversations/delete_contact.haml b/app/views/conversations/delete_contact.haml
- new file mode 100644
- index 0000000..45b18c4
- --- /dev/null
- +++ b/app/views/conversations/delete_contact.haml
- @@ -0,0 +1 @@
- += 'REMOVED'
- \ No newline at end of file
- diff --git a/app/views/conversations/index.haml b/app/views/conversations/index.haml
- index 1285cdd..027b867 100644
- --- a/app/views/conversations/index.haml
- +++ b/app/views/conversations/index.haml
- @@ -34,10 +34,14 @@
- = t('.no_messages')
- #conversation_show.span-16.prepend-8.last
- - - if @conversation
- - = render 'conversations/show', :conversation => @conversation
- + - if @conversation and @allow_access then
- + = render 'conversations/show', :conversation => @conversation,:url_new_contact => @url_new_contact,:conversation_vis => @conversation_vis,:owner=>@owner
- - else
- - #no_conversation_text
- - = t('.no_conversation_selected')
- - #no_conversation_controls
- - = link_to t('.create_a_new_message'), new_conversation_path, :rel => 'facebox'
- + - if not @allow_access then
- + = render 'conversations/access_denied',:layout=>false
- + - else
- + #no_conversation_text
- + = t('.no_conversation_selected')
- + #no_conversation_controls
- + = link_to t('.create_a_new_message'), new_conversation_path, :rel => 'facebox'
- +
- diff --git a/app/views/conversations/new_contact.haml b/app/views/conversations/new_contact.haml
- new file mode 100644
- index 0000000..f792eb1
- --- /dev/null
- +++ b/app/views/conversations/new_contact.haml
- @@ -0,0 +1,177 @@
- +-# Copyright (c) 2010, Diaspora Inc. This file is
- +-# licensed under the Affero General Public License version 3 or later. See
- +-# the COPYRIGHT file.
- +-#
- +:javascript
- + $(document).ready(function(){
- + $('#contact_search').change(function(){
- + $('.contact_list_new ul li').each(function(indx,val){
- + text_serach = $('#contact_search')[0].value.replace(' ','').toLowerCase();
- + content = $(val).find('h4.name a')[0].textContent.replace(' ','').toLowerCase();
- + if ((content.search(text_serach) >= 0))
- + {
- + $(val).removeClass('hiding');
- + }
- + else
- + {
- + $(val).addClass('hiding');
- + }
- + });
- + });
- + });
- + function change_contact(people_id,url_path,people_url,it,class_name)
- + {
- + g = $.ajax({url:url_path,async:false,cache:false});
- + if (g.status == 200)
- + {
- + if (g.responseText.indexOf('O') != -1)
- + {
- + $(it).parent().parent().parent().find('.right.owner_button span a').addClass('hiding');
- + $(it).parent().parent().parent().find('.right.owner_button span a.remove_owner').removeClass('hiding');
- + }
- + else
- + {
- + $(it).parent().parent().parent().find('.right.owner_button span a').addClass('hiding');
- + $(it).parent().parent().parent().find('.right.owner_button span a.add_owner').removeClass('hiding');
- + }
- +
- + if (g.responseText.indexOf('E') != -1)
- + {
- + $(it).parent().parent().parent().find('.right.edit_button span a').addClass('hiding');
- + $(it).parent().parent().parent().find('.right.edit_button span a.remove_editor').removeClass('hiding');
- + }
- + else
- + {
- + $(it).parent().parent().parent().find('.right.edit_button span a').addClass('hiding');
- + $(it).parent().parent().parent().find('.right.edit_button span a.add_editor').removeClass('hiding');
- + }
- +
- + if (g.responseText.indexOf('R') != -1)
- + {
- + al_have = false;
- + $('div.span-6.avatars.last a').each(function(indx,itm){
- + if ($(itm).find('img').data('person_id') == people_id)
- + {
- + al_have = true;
- + if ($(itm).hasClass('avatar_hiding'))
- + {
- + $(itm).animate({opacity:1.0},500);
- + $(itm).removeClass('avatar_hiding');
- + }
- + }
- + });
- + if (!al_have)
- + {
- + $('div.span-6.avatars.last').append(g.responseText);
- + }
- + $(it).parent().parent().parent().find('.right.add_delete_button span a').addClass('hiding');
- + $(it).parent().parent().parent().find('.right.add_delete_button span a.remove').removeClass('hiding');
- + }
- + else
- + {
- + $(it).parent().parent().parent().find('.right.add_delete_button span a').addClass('hiding');
- + $(it).parent().parent().parent().find('.right.add_delete_button span a.add').removeClass('hiding');
- + $('div.span-6.avatars.last a').each(function(indx,itm){
- + if ($(itm).find('img').data('person_id') == people_id)
- + {
- + $(itm).animate({opacity:0.5},500);
- + $(itm).addClass('avatar_hiding');
- + }
- + });
- + }
- + if (class_name == 'remove_owner')
- + {
- + $(it).parent().parent().parent().find('.right.edit_button span a').addClass('hiding');
- + $(it).parent().parent().parent().find('.right.edit_button span a.remove_editor').removeClass('hiding');
- + $(it).parent().parent().parent().find('.right.add_delete_button span a').addClass('hiding');
- + $(it).parent().parent().parent().find('.right.add_delete_button span a.remove').removeClass('hiding');
- + }
- + if (class_name == 'remove_editor')
- + {
- + $(it).parent().parent().parent().find('.right.add_delete_button span a').addClass('hiding');
- + $(it).parent().parent().parent().find('.right.add_delete_button span a.remove').removeClass('hiding');
- + }
- + $('div.span-6.avatars.last a').each(function(indx,itm){
- + if ($(itm).find('img').data('person_id') == people_id)
- + {
- + $(itm).removeClass('no_highlight');
- + $(itm).removeClass('editor_highlight');
- + $(itm).removeClass('owner_highlight');
- + if (g.responseText.indexOf('O')!=-1)
- + {
- + $(itm).addClass('owner_highlight');
- + }
- + else
- + {
- + if (g.responseText.indexOf('E')!=-1)
- + {
- + $(itm).addClass('editor_highlight');
- + }
- + else
- + {
- + if (g.responseText.indexOf('R')!=-1)
- + {
- + $(itm).addClass('no_highlight');
- + }
- + }
- + }
- + }
- + });
- + };
- + }
- +.contact_list_new
- + = search_field_tag :contact_search, "", :class => 'contact_list_search', :results => 5, :placeholder => t('shared.contact_list.all_contacts')
- + %ul
- + - active_records = @active_contacts.map{|rec| rec.person.id}
- + - for contact in @active_contacts
- + %li{:data=>{:contact_id=>contact.person_id}}
- + = person_image_tag contact.person
- + %h4.name
- + = link_to contact.person.name, contact.person
- + .description
- + = contact.person.diaspora_handle
- + .right.owner_button
- + %span
- + %a{:title=>t('.add_owner'),:class => 'button add_owner' + ((not contact.owner) ? '': ' hiding'),:data_id=>contact.person_id.to_s,:onclick => 'change_contact(' + contact.person_id.to_s + ',"' + url_for(:action => 'afford_to_own',:conversation_id => params[:conversation_id],:person_id => contact.person_id) + '","' + url_for(:controller=>'people',:id => contact.person_id) + '",this,"remove_owner");'}
- + = image_tag('icons/monotone_plus_add_round.png')
- + %a{:title=>t('.remove_owner'),:class => 'button remove_owner' + (contact.owner ? '': ' hiding'),:data_id=>contact.person_id.to_s,:onclick => 'change_contact(' + contact.person_id.to_s + ',"' + url_for(:action => 'prohibit_owning',:conversation_id => params[:conversation_id],:person_id => contact.person_id) + '","' + url_for(:controller=>'people',:id => contact.person_id) + '",this,"add_owner");'}
- + = image_tag('icons/monotone_check_yes.png')
- + .right.edit_button
- + %span
- + %a{:title=>t('.add_editor'),:class => 'button add_editor' + ((not contact.editor) ? '' : ' hiding'),:data_id=>contact.person_id.to_s,:onclick => 'change_contact(' + contact.person_id.to_s + ',"' + url_for(:action => 'allow_edit',:conversation_id => params[:conversation_id],:person_id => contact.person_id) + '","' + url_for(:controller=>'people',:id => contact.person_id) + '",this,"remove_editor");'}
- + = image_tag('icons/monotone_plus_add_round.png')
- + %a{:title=>t('.remove_editor'),:class => 'button remove_editor' + (contact.editor ? '' : ' hiding'),:data_id=>contact.person_id.to_s,:onclick => 'change_contact(' + contact.person_id.to_s + ',"' + url_for(:action => 'prohibit_edit',:conversation_id => params[:conversation_id],:person_id => contact.person_id) + '","' + url_for(:controller=>'people',:id => contact.person_id) + '",this,"add_editor");'}
- + = image_tag('icons/monotone_check_yes.png')
- + .right.add_delete_button
- + %span
- + %a{:title=>t('.add_contact'),:onclick => 'change_contact(' + contact.person_id.to_s + ',"' + url_for(:action => 'create_contact',:conversation_id => params[:conversation_id],:person_id => contact.person_id) + '","' + url_for(:controller=>'people',:id => contact.person_id) + '",this,"remove");',:class => 'button add' + (contact.deleted ? '' : ' hiding'),:data_id=>contact.person_id.to_s}
- + = image_tag('icons/monotone_plus_add_round.png')
- + %a{:title=>t('.remove_contact'),:onclick => 'change_contact(' + contact.person_id.to_s + ',"' + url_for(:action => 'delete_contact',:conversation_id => params[:conversation_id],:person_id => contact.person_id) + '","' + url_for(:controller=>'people',:id => contact.person_id) + '",this,"add");',:class => 'button remove' + ((not contact.deleted) ? '' : ' hiding'),:data_id=>contact.person_id.to_s}
- + = image_tag('icons/monotone_check_yes.png')
- + - for contact in @contacts
- + - if not active_records.any?{|rec| rec == contact.person.id} then
- + %li{:data=>{:contact_id=>contact.person_id}}
- + = person_image_tag contact.person
- + %h4.name
- + = link_to contact.person.name, contact.person
- + .description
- + = contact.person.diaspora_handle
- + .right.owner_button
- + %span
- + %a{:title=>t('.add_owner'),:class => 'button add_owner',:data_id=>contact.person_id.to_s,:onclick => 'change_contact(' + contact.person_id.to_s + ',"' + url_for(:action => 'afford_to_own',:conversation_id => params[:conversation_id],:person_id => contact.person_id) + '","' + url_for(:controller=>'people',:id => contact.person_id) + '",this,"remove_owner");'}
- + = image_tag('icons/monotone_plus_add_round.png')
- + %a{:title=>t('.remove_owner'),:class => 'button remove_owner hiding',:data_id=>contact.person_id.to_s,:onclick => 'change_contact(' + contact.person_id.to_s + ',"' + url_for(:action => 'prohibit_owning',:conversation_id => params[:conversation_id],:person_id => contact.person_id) + '","' + url_for(:controller=>'people',:id => contact.person_id) + '",this,"add_owner");'}
- + = image_tag('icons/monotone_check_yes.png')
- + .right.edit_button
- + %span
- + %a{:title=>t('.add_editor'),:class => 'button add_editor',:data_id=>contact.person_id.to_s,:onclick => 'change_contact(' + contact.person_id.to_s + ',"' + url_for(:action => 'allow_edit',:conversation_id => params[:conversation_id],:person_id => contact.person_id) + '","' + url_for(:controller=>'people',:id => contact.person_id) + '",this,"remove_editor");'}
- + = image_tag('icons/monotone_plus_add_round.png')
- + %a{:title=>t('.remove_editor'),:class => 'button remove_editor hiding',:data_id=>contact.person_id.to_s,:onclick => 'change_contact(' + contact.person_id.to_s + ',"' + url_for(:action => 'prohibit_edit',:conversation_id => params[:conversation_id],:person_id => contact.person_id) + '","' + url_for(:controller=>'people',:id => contact.person_id) + '",this,"add_editor");'}
- + = image_tag('icons/monotone_check_yes.png')
- + .right.add_delete_button
- + %span
- + %a{:title=>t('.add_contact'),:onclick => 'change_contact(' + contact.person_id.to_s + ',"' + url_for(:action => 'create_contact',:conversation_id => params[:conversation_id],:person_id => contact.person_id) + '","' + url_for(:controller=>'people',:id => contact.person_id) + '",this,"remove");',:class => 'button add',:data_id=>contact.person_id.to_s}
- + = image_tag('icons/monotone_plus_add_round.png')
- + %a{:title=>t('.remove_contact'),:onclick => 'change_contact(' + contact.person_id.to_s + ',"' + url_for(:action => 'delete_contact',:conversation_id => params[:conversation_id],:person_id => contact.person_id) + '","' + url_for(:controller=>'people',:id => contact.person_id) + '",this,"add");',:class => 'button remove hiding',:data_id=>contact.person_id.to_s}
- + = image_tag('icons/monotone_check_yes.png')
- +
- \ No newline at end of file
- diff --git a/app/views/conversations/show.haml b/app/views/conversations/show.haml
- index b5d871d..77174d2 100644
- --- a/app/views/conversations/show.haml
- +++ b/app/views/conversations/show.haml
- @@ -2,4 +2,4 @@
- -# licensed under the Affero General Public License version 3 or later. See
- -# the COPYRIGHT file.
- -= render 'show', :conversation => @conversation
- += render 'show', :conversation => @conversation,:url_new_contact => @url_new_contact,:conversation_vis => @conversation_vis,:owner => @owner
- diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml
- index 4dc2743..63a67d9 100644
- --- a/config/locales/diaspora/en.yml
- +++ b/config/locales/diaspora/en.yml
- @@ -188,6 +188,7 @@ en:
- show:
- reply: "reply"
- delete: "delete and block conversation"
- + add_contact: "Add contact"
- new:
- to: "to"
- subject: "subject"
- diff --git a/config/locales/diaspora/ru.yml b/config/locales/diaspora/ru.yml
- index 0bdb584..92452af 100644
- --- a/config/locales/diaspora/ru.yml
- +++ b/config/locales/diaspora/ru.yml
- @@ -165,6 +165,7 @@ ru:
- show:
- delete: "delete and block conversation"
- reply: "reply"
- + add_contact: "Добавить контакт"
- date:
- formats:
- birthday: "%B %d"
- diff --git a/config/routes.rb b/config/routes.rb
- index ad70d3e..84d2b5e 100644
- --- a/config/routes.rb
- +++ b/config/routes.rb
- @@ -25,7 +25,13 @@ Diaspora::Application.routes.draw do
- resources :contacts
- resources :aspect_memberships, :only => [:destroy, :create]
- -
- + match 'conversations/:conversation_id/afford_to_own/:person_id', :to => 'conversations#afford_to_own'
- + match 'conversations/:conversation_id/prohibit_owning/:person_id', :to => 'conversations#prohibit_owning'
- + match 'conversations/:conversation_id/allow_edit/:person_id', :to => 'conversations#allow_edit'
- + match 'conversations/:conversation_id/prohibit_edit/:person_id', :to => 'conversations#prohibit_edit'
- + match 'conversations/:conversation_id/delete_contact/:person_id', :to => 'conversations#delete_contact'
- + match 'conversations/:conversation_id/create_contact/:person_id', :to => 'conversations#create_contact'
- + match 'conversations/:conversation_id/new_contact', :to => 'conversations#new_contact'
- resources :conversations do
- resources :messages, :only => [:create, :show]
- resource :conversation_visibility, :only => [:destroy], :path => '/visibility/'
- diff --git a/db/migrate/20110326095653_add_owner_to_conversation_visibility.rb b/db/migrate/20110326095653_add_owner_to_conversation_visibility.rb
- new file mode 100644
- index 0000000..b97c06e
- --- /dev/null
- +++ b/db/migrate/20110326095653_add_owner_to_conversation_visibility.rb
- @@ -0,0 +1,19 @@
- +class AddOwnerToConversationVisibility < ActiveRecord::Migration
- + def self.up
- + add_column :conversation_visibilities, :owner, :boolean
- + add_column :conversation_visibilities, :editor, :boolean
- + add_column :conversation_visibilities, :deleted, :boolean
- + ConversationVisibility.find(:all).each do |p|
- + p.owner = true
- + p.editor = false
- + p.deleted = false
- + p.save
- + end
- + end
- +
- + def self.down
- + remove_column :conversation_visibilities, :owner
- + remove_column :conversation_visibilities, :editor
- + remove_column :conversation_visibilities, :deleted
- + end
- +end
- diff --git a/db/schema.rb b/db/schema.rb
- index a55b15a..8317501 100644
- --- a/db/schema.rb
- +++ b/db/schema.rb
- @@ -10,7 +10,7 @@
- #
- # It's strongly recommended to check this file into your version control system.
- -ActiveRecord::Schema.define(:version => 20110319005509) do
- +ActiveRecord::Schema.define(:version => 20110326095653) do
- create_table "aspect_memberships", :force => true do |t|
- t.integer "aspect_id", :null => false
- @@ -76,6 +76,9 @@ ActiveRecord::Schema.define(:version => 20110319005509) do
- t.integer "unread", :default => 0, :null => false
- t.datetime "created_at"
- t.datetime "updated_at"
- + t.boolean "owner"
- + t.boolean "deleted"
- + t.boolean "editor"
- end
- add_index "conversation_visibilities", ["conversation_id", "person_id"], :name => "index_conversation_visibilities_on_conversation_id_and_person_id", :unique => true
- diff --git a/public/images/user/add_button.png b/public/images/user/add_button.png
- new file mode 100644
- index 0000000000000000000000000000000000000000..a8ebad327e8ef81cae8c5e5e286446520e5e2ae3
- GIT binary patch
- literal 242
- zcmeAS@N?(olHy`uVBq!ia0vp^Qb26P!3HFqww|5}q!^2X+?^QKos)S9<gg`qySp&_
- z2f+n<mrn+Ya29w(7Bet#3xhBt!>l<HKtc8rPhVH|+stAdDqJ%!=H3SiNtU=qlsM<-
- z=BDPAFgO>bCYGe8D3oWGWGJ|M`UZqI@`(c#`FgrIhD02GdwnDC0R<igN9&|%DRT_8
- zUK{YvR1kD^X?zzQz3b4_&vMT@SY<bA2yn14{f(FznRU_rxv8ExQ=@}|Kt{gC-f0Rz
- cnX31Ur+2b@r=0(N8E7zrr>mdKI;Vst0AA)u+W-In
- literal 0
- HcmV?d00001
- diff --git a/public/images/user/add_contact.png b/public/images/user/add_contact.png
- new file mode 100644
- index 0000000000000000000000000000000000000000..27125ee0c7b8f5199767024d614bc0f34164bafc
- GIT binary patch
- literal 234
- zcmeAS@N?(olHy`uVBq!ia0vp^{6H+n!3HEh$GDULDaPU;cPEB*=VV?2Ih+L^k;M!Q
- z+`=Ht$S`Y;1W=H@#M9T6{Wh~0hoL49^RJyiA;}Wgh!W@g+}zZ>5(ej@)Wnk16ovB4
- zk_-iRPv3y>Mm}+%qHs?a#}JFt$u(bJU9D#`Viaa(O$hmX;=-9GZ>9Wft2wqOtDhy5
- zeyeA@^qE~*CtUIOM1h7@M&X^?g5IRN<+L8GZ~M>lGuoI<VU>iW1pA5ei+@&z7#lG#
- Y#0$vj$4>U}1zN%2>FVdQ&MBb@0GifDvH$=8
- literal 0
- HcmV?d00001
- diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass
- index 9e801f8..b3b2b50 100644
- --- a/public/stylesheets/sass/application.sass
- +++ b/public/stylesheets/sass/application.sass
- @@ -53,6 +53,15 @@ form
- :width 50px
- :height 50px
- +#add_avatar_container
- + :border 2px solid rgba(0,0,0,0.3)
- + :-moz-box-shadow 0 0 8px black
- + :-webkit-box-shadow 0 0 8px black
- + :box-shadow 0 0 8px black
- + :border-radius 3px
- + :opacity 0.0
- + :display none
- +
- #content
- :background
- :color #fff
- @@ -1811,6 +1820,94 @@ ul#request_result
- :bottom 25px
- input.add
- :color green
- +.contact_list_new
- + :height 450px
- + :max-height 450px
- +
- + :overflow-y hidden
- + :overflow-x hidden
- +
- + :border 2px solid #eee
- +
- + :background
- + :color rgb(252,252,252)
- +
- + .name
- + :position absolute
- + :left 70px
- + :top 10px
- +
- + .avatar
- + :position absolute
- + :left 6px
- + :height 50px
- + :width 50px
- +
- + :-webkit-box-shadow 0 1px #fff
- + :-moz-box-shadow 0 1px #fff
- + :box-shadow 0 1px #fff
- +
- + :-webkit-border-radius 0 0 5px 5px
- + :-moz-border-radius 0 0 5px 5px
- + :border-radius 0 0 5px 5px
- +
- + input.contact_list_search
- + :width 97.5%
- + :margin
- + :top 0
- +
- + ul
- + :margin-top 1px
- + :margin-left 0px
- + :margin-right 0px
- + :padding 0
- + :overflow-y auto
- + :height 423px
- +
- + > li.hiding
- + :display none
- +
- + > li
- + :position relative
- + :height 50px
- + :padding 4px
- + :border
- + :bottom 1px solid #eee
- +
- + &:last-child
- + :border
- + :bottom none
- +
- + &:hover
- + :background
- + :color rgb(245,245,245)
- + .hiding
- + :display none
- + .right
- + :right 8px
- + :top 12px
- + .overflow
- + :overflow-y scroll
- + .owner_button
- + :margin-right 70px
- + .edit_button
- + :margin-right 35px
- + a.button
- + :padding
- + :right 4px
- + :left 4px
- + &.added
- + :background -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(92,199,86)), color-stop(1, rgb(158,255,153)))
- + :background -moz-linear-gradient(top, rgb(158,255,153), rgb(92,199,86))
- +
- + &.added.remove
- + :background -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(199,86,86)), color-stop(1, rgb(255,153,153)))
- + :background -moz-linear-gradient(top, rgb(255,153,153), rgb(199,86,86))
- +
- + &:active
- + :background -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(130,55,55)), color-stop(1, rgb(199,119,119)))
- + :background -moz-linear-gradient(top, rgb(199,119,119), rgb(130,55,55))
- +
- .contact_list,
- .aspect_list
- @@ -1845,7 +1942,7 @@ ul#request_result
- :border-radius 0 0 5px 5px
- input.contact_list_search
- - :width 100%
- + :width 97.5%
- :margin
- :top 0
- @@ -1853,6 +1950,9 @@ ul#request_result
- :margin 0
- :padding 0
- + > li.hiding
- + :display none
- +
- > li
- :position relative
- :height 50px
- @@ -1867,11 +1967,17 @@ ul#request_result
- &:hover
- :background
- :color rgb(245,245,245)
- -
- + .hiding
- + :display none
- .right
- :right 8px
- :top 12px
- -
- + .overflow
- + :overflow-y scroll
- + .owner_button
- + :margin-right 70px
- + .edit_button
- + :margin-right 35px
- a.button
- :padding
- :right 4px
- @@ -2629,7 +2735,6 @@ ul.show_comments
- a
- :margin
- :right 10px
- -
- :margin
- :bottom 10px
- @@ -2647,6 +2752,28 @@ ul.show_comments
- :margin
- :top 9px
- +
- +.avatars.last
- + a.owner_highlight
- + img
- + :-moz-box-shadow 0 0 3px #006700
- + :-webkit-box-shadow 0 0 3px #006700
- + :box-shadow 0 0 3px #006700
- + a.editor_highlight
- + img
- + :-moz-box-shadow 0 0 3px #A87DFF
- + :-webkit-box-shadow 0 0 3px #A87DFF
- + :box-shadow 0 0 3px #A87DFF
- + a.no_highlight
- + img
- + :-moz-box-shadow 0 0 3px gray
- + :-webkit-box-shadow 0 0 3px gray
- + :box-shadow 0 0 3px gray
- + a.avatar_hiding
- + img
- + :opacity 0.5
- +
- +
- .stream_element.new_message
- :border
- :top 1px solid #999
- @@ -2767,6 +2894,16 @@ ul.show_comments
- :font
- :size 12px
- +#acces_denied
- + :text
- + :align center
- + :font
- + :size 20px
- + :weight bold
- + :color black
- + :margin
- + :top 200px
- +
- .text-right
- :text
- :align right
- --
- 1.7.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement