social_stream 0.12.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/base/app/views/groups/index.html.erb +1 -1
  2. data/base/app/views/users/index.html.erb +1 -1
  3. data/base/app/views/users/show.xml.builder +13 -26
  4. data/base/config/routes.rb +2 -1
  5. data/base/lib/social_stream/base/version.rb +1 -1
  6. data/documents/app/assets/javascripts/documents.js.erb +11 -0
  7. data/documents/app/assets/stylesheets/show.css.scss +30 -1
  8. data/documents/app/controllers/audios_controller.rb +1 -1
  9. data/documents/app/controllers/documents_controller.rb +48 -7
  10. data/documents/app/controllers/pictures_controller.rb +1 -1
  11. data/documents/app/controllers/videos_controller.rb +1 -1
  12. data/documents/app/models/document.rb +4 -1
  13. data/documents/app/views/audios/index.html.erb +1 -1
  14. data/documents/app/views/audios/show.html.erb +1 -1
  15. data/documents/app/views/{common_documents → common}/_document_info.html.erb +4 -3
  16. data/documents/app/views/common/_edit_form.html.erb +49 -0
  17. data/documents/app/views/{common_documents → common}/_index.html.erb +0 -0
  18. data/documents/app/views/{common_documents → common}/_show.html.erb +1 -1
  19. data/documents/app/views/documents/index.html.erb +1 -1
  20. data/documents/app/views/documents/show.html.erb +1 -1
  21. data/documents/app/views/pictures/index.html.erb +1 -1
  22. data/documents/app/views/pictures/show.html.erb +1 -1
  23. data/documents/app/views/videos/index.html.erb +1 -1
  24. data/documents/app/views/videos/show.html.erb +1 -1
  25. data/documents/config/locales/en.yml +3 -1
  26. data/documents/config/locales/es.yml +3 -1
  27. data/documents/lib/social_stream/documents/version.rb +1 -1
  28. data/documents/lib/social_stream/toolbar_config/documents.rb +14 -9
  29. data/documents/social_stream-documents.gemspec +1 -1
  30. data/events/Rakefile +3 -13
  31. data/events/lib/social_stream/events/version.rb +1 -1
  32. data/events/lib/social_stream/toolbar_config/events.rb +0 -6
  33. data/events/social_stream-events.gemspec +1 -1
  34. data/lib/social_stream/version.rb +1 -1
  35. data/presence/ejabberd/ejabberd_scripts/emanagement +237 -62
  36. data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
  37. data/presence/lib/social_stream/presence/models/buddy_manager.rb +33 -0
  38. data/presence/lib/social_stream/presence/version.rb +1 -1
  39. data/presence/lib/social_stream/presence/xmpp_server_order.rb +42 -13
  40. data/social_stream.gemspec +3 -3
  41. metadata +17 -17
  42. data/documents/app/controllers/common_documents_controller.rb +0 -45
@@ -39,7 +39,7 @@
39
39
  <div class="row">
40
40
  <div class="center">
41
41
  <% for g in Group.distinct_initials %>
42
- <%= link_to g.initial,{:letter => g.initial,:page => 1},:class => "user_letter_link" %>
42
+ <%= link_to g.initial.capitalize,{:letter => g.initial,:page => 1},:class => "user_letter_link" %>
43
43
  <% end %>
44
44
  </div>
45
45
  </div>
@@ -25,7 +25,7 @@
25
25
  <div class="center">
26
26
  <%= link_to t('user.all_n', :count => User.count), users_path %> -
27
27
  <% for u in User.distinct_initials %>
28
- <%= link_to u.initial,{:letter => u.initial,:page => 1},:class => "user_letter_link" %>
28
+ <%= link_to u.initial.capitalize,{:letter => u.initial,:page => 1},:class => "user_letter_link" %>
29
29
  <% end %>
30
30
  </div>
31
31
  </div>
@@ -1,28 +1,15 @@
1
1
  xml.instruct!
2
- xml.user do
3
- xml.uid @user.id
4
- xml.name @user.name
5
- xml.slug @user.slug
6
- xml.email @user.email
7
- xml.userSince @user.created_at
8
- xml.birthday @user.profile.birthday
9
- xml.organization @user.profile.organization
10
- xml.city @user.profile.city
11
- xml.country @user.profile.country
12
- xml.website @user.profile.website
13
- xml.ties do
14
- @user.actors(:subject_type => 'user', :direction => :senders).each do |u|
15
- xml.contact do
16
- xml.uid u.id
17
- xml.slug u.slug
18
- end
19
- end
20
-
21
- @user.actors(:subject_type => 'group', :direction => :senders).each do |g|
22
- xml.group do
23
- xml.gid g.id
24
- xml.slug g.slug
25
- end
26
- end
27
- end
2
+ xml.user do
3
+ xml.uid @user.id
4
+ xml.name @user.name
5
+ xml.slug @user.slug
6
+ if user_signed_in?
7
+ xml.email @user.email
8
+ end
9
+ xml.userSince @user.created_at
10
+ xml.birthday @user.profile.birthday
11
+ xml.organization @user.profile.organization
12
+ xml.city @user.profile.city
13
+ xml.country @user.profile.country
14
+ xml.website @user.profile.website
28
15
  end
@@ -82,8 +82,9 @@ Rails.application.routes.draw do
82
82
  match 'api/user/:id' => 'api#users', :as => :api_user
83
83
  match 'api/me' => 'api#users', :as => :api_me
84
84
  match 'api/me/home/' => 'api#activity_atom_feed', :format => 'atom', :as => :api_my_home
85
+ match 'api/user/:id/public' => 'api#activity_atom_feed', :format => 'atom', :as => :api_user_activities
86
+
85
87
  match 'api/me/contacts' => 'contacts#index', :format => 'json', :as => :api_contacts
86
88
  match 'api/subjects/:s/contacts' => 'contacts#index', :format => 'json', :as => :api_subject_contacts
87
- match 'api/user/:id/public' => 'api#activity_atom_feed', :format => 'atom', :as => :api_user_activities
88
89
  ##/API##
89
90
  end
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Base
3
- VERSION = "0.9.23".freeze
3
+ VERSION = "0.9.24".freeze
4
4
  end
5
5
  end
@@ -48,3 +48,14 @@ showAllDocumentComments = function(id){
48
48
  //and hide the hide_show_comments
49
49
  $("#"+id).children(".hide_show_comments").hide();
50
50
  };
51
+
52
+ toggleDocumentEdit = function(){
53
+ if($("#document_edit").css("display")=="none"){
54
+ $("#document_edit").show("slow");
55
+ $("#document_edit_action").addClass("selected");
56
+
57
+ }else{
58
+ $("#document_edit").hide("slow");
59
+ $("#document_edit_action").removeClass("selected");
60
+ }
61
+ }
@@ -45,13 +45,42 @@
45
45
  margin-left: 30px;
46
46
  }
47
47
  #document_info #actions .action{
48
- margin-right: 10px;
48
+ margin-right: 10px;
49
+ padding: 5px;
50
+ }
51
+ #document_info #actions .action.selected{
52
+ border: thin solid $separation-color;
53
+ background: $secondary-color;
49
54
  }
50
55
  #document_info #actions .action img{
51
56
  width: 16px;
52
57
  height: 16px;
53
58
  }
54
59
 
60
+ #document_edit {
61
+ margin: 5px 5px 0px 5px;
62
+ border: thin solid $separation-color;
63
+ background: $secondary-color;
64
+
65
+ }
66
+ #document_edit textarea{
67
+ resize: none;
68
+ height: 75px;
69
+ }
70
+ #document_edit .form_row {
71
+ padding: 5px 10px;
72
+ }
73
+ #document_edit .form_label {
74
+ width: 100px;
75
+ }
76
+ #document_edit .form_field {
77
+ width: 415px;
78
+ padding: 0;
79
+ }
80
+ #document_edit .form_tag {
81
+ width: 100%;
82
+ }
83
+
55
84
  #document_comments {
56
85
  margin-top: 20px;
57
86
  padding-top: 10px;
@@ -1,2 +1,2 @@
1
- class AudiosController < CommonDocumentsController
1
+ class AudiosController < DocumentsController
2
2
  end
@@ -1,19 +1,44 @@
1
- class DocumentsController < CommonDocumentsController
1
+ class DocumentsController < InheritedResources::Base
2
2
  respond_to :html, :js
3
-
4
- SEND_FILE_METHOD = :default
5
3
 
4
+ belongs_to_subjects :optional => true
5
+
6
+ before_filter :profile_subject!, :only => :index
7
+
8
+ load_and_authorize_resource :except => :index
9
+
10
+ SEND_FILE_METHOD = :default
6
11
  def create
7
12
  super do |format|
8
13
  format.all {redirect_to request.referer || home_path}
9
14
  end
10
15
  end
11
-
16
+
17
+ def update
18
+ update! do |success, failure|
19
+ failure.html { render :action => :show }
20
+ success.html { render :action => :show }
21
+ end
22
+ end
23
+
24
+ def show
25
+ respond_to do |format|
26
+ format.html {render :action => :show}
27
+ format.all {
28
+ path = resource.file.path(params[:style] || params[:format])
29
+
30
+ send_file path,
31
+ :filename => resource.file_file_name,
32
+ :disposition => "inline"
33
+ }
34
+ end
35
+ end
36
+
12
37
  #TODO: we have to add the mimetype as in videos_controller
13
38
  def download
14
39
  path = @document.file.path(params[:style])
15
40
 
16
- head(:bad_request) and return unless File.exist?(path)
41
+ head(:bad_request) and return unless File.exist?(path)
17
42
 
18
43
  send_file_options = {
19
44
  :filename => @document.file_file_name,
@@ -22,13 +47,29 @@ class DocumentsController < CommonDocumentsController
22
47
 
23
48
  # Ask Victor about the rationale of this:
24
49
  case SEND_FILE_METHOD
25
- when :apache then send_file_options[:x_sendfile] = true
26
- when :nginx then head(:x_accel_redirect => path.gsub(Rails.root, ''))
50
+ when :apache then send_file_options[:x_sendfile] = true
51
+ when :nginx then head(:x_accel_redirect => path.gsub(Rails.root, ''))
27
52
  end
28
53
 
29
54
  send_file(path, send_file_options)
30
55
  end
31
56
 
57
+ def destroy
58
+ @post_activity = resource.post_activity
59
+
60
+ destroy!
61
+ end
62
+
63
+ private
64
+
65
+ def collection
66
+ @activities = profile_subject.wall(:profile,
67
+ :for => current_subject,
68
+ :object_type => Array(self.class.index_object_type)).
69
+ page(params[:page]).
70
+ per(params[:per])
71
+ end
72
+
32
73
  class << self
33
74
  def index_object_type
34
75
  [ :Audio, :Video, :Picture, :Document ]
@@ -1,2 +1,2 @@
1
- class PicturesController < CommonDocumentsController
1
+ class PicturesController < DocumentsController
2
2
  end
@@ -1,2 +1,2 @@
1
- class VideosController < CommonDocumentsController
1
+ class VideosController < DocumentsController
2
2
  end
@@ -8,8 +8,11 @@ class Document < ActiveRecord::Base
8
8
  :path => ':rails_root/documents/:class/:id_partition/:style/:filename.:extension'
9
9
 
10
10
  validates_attachment_presence :file
11
+ validates_presence_of :title
11
12
 
12
- before_create :set_title_and_description
13
+ before_validation(:on => :create) do
14
+ set_title_and_description
15
+ end
13
16
 
14
17
  define_index do
15
18
  indexes title
@@ -1 +1 @@
1
- <%=render(:partial => 'common_documents/index') %>
1
+ <%=render(:partial => 'common/index') %>
@@ -1,2 +1,2 @@
1
- <%= render :partial => 'common_documents/show',
1
+ <%= render :partial => 'common/show',
2
2
  :locals => { :document => @audio } %>
@@ -24,11 +24,12 @@
24
24
  </div>
25
25
  <br class="clearfloat" />
26
26
  <div id="actions">
27
- <%= link_to image_tag("btn/download.png") + t('document.actions.download'), download_document_path(document), :class => :action %>
28
- <%= link_to image_tag("btn/edit.png") + t('document.actions.edit'), "javascript:toggleEdit();", :class => :action %>
27
+ <%= link_to content_tag(:span,image_tag("btn/download.png") + t('document.actions.download'), :class => :action), download_document_path(document) %>
28
+ <%= link_to content_tag(:span,image_tag("btn/edit.png") + t('document.actions.edit'), :class => :action, :id => :document_edit_action), "javascript:toggleDocumentEdit();" %>
29
29
  <% if document.post_activity.delete_object_by?(current_subject) %>
30
- <%= link_to image_tag("btn/error.png") + t('document.actions.delete'), document.post_activity.direct_object , :confirm => t('confirm_delete',
30
+ <%= link_to content_tag(:span,image_tag("btn/error.png") + t('document.actions.delete'), :class => :action), document.post_activity.direct_object , :confirm => t('confirm_delete',
31
31
  :scope => document.post_activity.direct_object.class.to_s.underscore), :method => :delete %>
32
32
  <% end %>
33
33
  </div>
34
34
  </div>
35
+ <%= render :partial => "common/edit_form", :locals => {:document => document} %>
@@ -0,0 +1,49 @@
1
+ <div class="block" id="document_edit" style="display:none;">
2
+ <%= form_for(document, :html => { :method => :put }) do |f| %>
3
+ <% if document and document.errors.any? %>
4
+ <%= javascript_tag do %>
5
+ $(document).ready(function(){
6
+ toggleDocumentEdit();
7
+ });
8
+ <% end %>
9
+ <div class="error">
10
+ <ul>
11
+ <% document.errors.full_messages.each do |msg| %>
12
+ <li>
13
+ <%= msg %>
14
+ </li>
15
+ <% end %>
16
+ </ul>
17
+ </div>
18
+ <% end %>
19
+ <div class="form_row">
20
+ <div class="form_label">
21
+ <%= f.label t('document.info.title.title') %>
22
+ </div>
23
+ <div class="form_field">
24
+ <%= f.text_field :title, :class => "form_tag" %>
25
+ </div>
26
+ </div>
27
+ <div class="form_row">
28
+ <div class="form_label">
29
+ <%= f.label t('document.info.description.title') %>
30
+ </div>
31
+ <div class="form_field">
32
+ <%= f.text_area :description, :class => "form_tag" %>
33
+ </div>
34
+ </div>
35
+ <!--
36
+ <div class="form_row">
37
+ <div class="form_label">
38
+ <%#= f.label t('document.info.file.title') %>
39
+ </div>
40
+ <div class="form_field">
41
+ <%#= f.file_field :file, :class => "form_tag" %>
42
+ </div>
43
+ </div>
44
+ -->
45
+ <div class="actions center">
46
+ <%= f.submit t('document.actions.edit'), :class => "button" %>
47
+ </div>
48
+ <% end %>
49
+ </div>
@@ -28,7 +28,7 @@
28
28
 
29
29
  <%= show_view_for document %>
30
30
 
31
- <%= render :partial => "document_info", :locals => {:document => document} %>
31
+ <%= render :partial => "common/document_info", :locals => {:document => document} %>
32
32
 
33
33
  <div id="document_comments">
34
34
  <%= render :partial => 'activities/comments', :locals => { :activity => document.post_activity } %>
@@ -1 +1 @@
1
- <%=render(:partial => 'common_documents/index') %>
1
+ <%=render(:partial => 'common/index') %>
@@ -1,2 +1,2 @@
1
- <%= render :partial => 'common_documents/show',
1
+ <%= render :partial => 'common/show',
2
2
  :locals => { :document => @document } %>
@@ -1 +1 @@
1
- <%=render(:partial => 'common_documents/index') %>
1
+ <%=render(:partial => 'common/index') %>
@@ -1,2 +1,2 @@
1
- <%= render :partial => 'common_documents/show',
1
+ <%= render :partial => 'common/show',
2
2
  :locals => { :document => @picture } %>
@@ -1 +1 @@
1
- <%=render(:partial => 'common_documents/index') %>
1
+ <%=render(:partial => 'common/index') %>
@@ -1,2 +1,2 @@
1
- <%= render :partial => 'common_documents/show',
1
+ <%= render :partial => 'common/show',
2
2
  :locals => { :document => @video } %>
@@ -21,6 +21,8 @@ en:
21
21
  updated_at: "Updated at"
22
22
  description:
23
23
  title: "Description"
24
+ file:
25
+ title: "Upload"
24
26
  title:
25
27
  title: "Title"
26
28
  mine: "My documents"
@@ -43,7 +45,7 @@ en:
43
45
  resource:
44
46
  all: "All Resources"
45
47
  confirm_delete: "Delete resource?"
46
- title: "Resources"
48
+ title: "Repository"
47
49
  mine: "My resources"
48
50
  msg: "Uploaded a resource:"
49
51
  not_mine: "Resources"
@@ -21,6 +21,8 @@ es:
21
21
  updated_at: "Última modificación"
22
22
  description:
23
23
  title: "Descripción"
24
+ file:
25
+ title: "Subir"
24
26
  title:
25
27
  title: "Título"
26
28
  mine: "Mis documentos"
@@ -43,7 +45,7 @@ es:
43
45
  resource:
44
46
  all: "Todos los recursos"
45
47
  confirm_delete: "¿Borrar recursos?"
46
- title: "Recursos"
48
+ title: "Repositorio"
47
49
  mine: "Mis recursos"
48
50
  msg: "Subió un recurso:"
49
51
  not_mine: "Recursos"
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Documents
3
- VERSION = "0.4.0".freeze
3
+ VERSION = "0.4.1".freeze
4
4
  end
5
5
  end
@@ -6,17 +6,22 @@ module SocialStream
6
6
 
7
7
  items << {
8
8
  :key => :resources,
9
- :name => image_tag("btn/btn_resource.png",:class =>"menu_icon")+t("resource.#{ subject == current_subject ? 'mine' : 'title' }"),
10
- :url => "#",
11
- :options => {:link => {:id => "resources_menu"}},
12
- :items => [
13
- {:key => :resources_documents,:name => image_tag("btn/btn_document.png")+t('document.title'),:url => polymorphic_path([subject, Document.new])},
14
- {:key => :resources_pictures,:name => image_tag("btn/btn_gallery.png")+t('picture.title'),:url => polymorphic_path([subject, Picture.new])},
15
- {:key => :resources_videos,:name => image_tag("btn/btn_video.png")+t('video.title'),:url => polymorphic_path([subject, Video.new])},
16
- {:key => :resources_audios,:name => image_tag("btn/btn_audio.png")+t('audio.title'),:url => polymorphic_path([subject, Audio.new])}
17
- ]
9
+ :name => image_tag("btn/btn_resource.png",:class =>"menu_icon")+t("resource.title"),
10
+ :url => polymorphic_path([subject, Document.new]),
11
+ :options => {:link => {:id => "resources_menu"}}
18
12
  }
19
13
  end
14
+
15
+ def home_toolbar_items
16
+ items = super
17
+
18
+ items << {
19
+ :key => :resources,
20
+ :name => image_tag("btn/btn_resource.png",:class =>"menu_icon")+t("resource.title"),
21
+ :url => polymorphic_path([current_subject, Document.new]),
22
+ :options => {:link => {:id => "resources_menu"}}
23
+ }
24
+ end
20
25
  end
21
26
  end
22
27
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.9.23')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.9.24')
16
16
  s.add_runtime_dependency('paperclip-ffmpeg', '~> 0.7.0')
17
17
  s.add_runtime_dependency('paperclip','2.3.11')
18
18
  s.add_runtime_dependency('delayed_paperclip','>= 0.7.2')
data/events/Rakefile CHANGED
@@ -1,33 +1,23 @@
1
1
  # encoding: UTF-8
2
- require 'rubygems'
3
- begin
4
- require 'bundler/setup'
5
- rescue LoadError
6
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
- end
2
+ require 'bundler/gem_tasks'
8
3
 
9
- require 'rake'
10
- require 'rake/rdoctask'
4
+ require 'rdoc/task'
11
5
 
12
6
  require 'rspec/core'
13
7
  require 'rspec/core/rake_task'
14
8
 
15
- require 'bundler'
16
-
17
9
  RSpec::Core::RakeTask.new(:spec)
18
10
 
19
11
  task :default => :spec
20
12
 
21
13
  Rake::RDocTask.new(:rdoc) do |rdoc|
22
14
  rdoc.rdoc_dir = 'rdoc'
23
- rdoc.title = 'Socialstream-events'
15
+ rdoc.title = 'Socialstream Events'
24
16
  rdoc.options << '--line-numbers' << '--inline-source'
25
17
  rdoc.rdoc_files.include('README.rdoc')
26
18
  rdoc.rdoc_files.include('lib/**/*.rb')
27
19
  end
28
20
 
29
- Bundler::GemHelper.install_tasks
30
-
31
21
  # Modify this gem's tags
32
22
  class Bundler::GemHelper
33
23
  def version_tag
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Events
3
- VERSION = "0.0.15".freeze
3
+ VERSION = "0.0.16".freeze
4
4
  end
5
5
  end
@@ -4,12 +4,6 @@ module SocialStream
4
4
  def profile_toolbar_items(subject = current_subject)
5
5
  items = super
6
6
 
7
- items.find{ |i| i[:key] == :resources }[:items].unshift({
8
- :key => :resources_events,
9
- :name => image_tag("btn/btn_event.png")+t('conference.title'),
10
- :url => polymorphic_path([subject, Event.new])
11
- })
12
-
13
7
  if SocialStream.activity_forms.include?(:event) &&
14
8
  subject.is_a?(Event) &&
15
9
  subject.agenda.present?
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.9.22')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.9.24')
16
16
  s.add_runtime_dependency('conference_manager-ruby', '~> 0.0.3')
17
17
 
18
18
  # Development Gem dependencies
@@ -1,3 +1,3 @@
1
1
  module SocialStream
2
- VERSION = "0.12.0".freeze
2
+ VERSION = "0.12.1".freeze
3
3
  end
@@ -34,36 +34,56 @@ end
34
34
  $domain = getOption("server_domain=")
35
35
 
36
36
  PARAMS_FOR_COMMANDS = {
37
- 'getRoster' => 1,
38
- 'removeBuddyFromRoster' => 2,
39
- 'addBuddyToRoster' => 5,
40
- 'removeRoster' => 1,
41
- 'getBuddysFromRoster' => 1,
42
- 'setBidireccionalBuddys' => 6,
43
- 'help' => 0,
44
- 'getUserResource' => 1,
45
- 'sendMessageToUser' => 3,
46
- 'sendPresence' => 2,
47
- 'unsetPresence' => 1,
48
- 'setPresence' => 1,
49
- 'removeAllRosters' => 0,
37
+ 'addBuddyToRoster' => 5,
38
+ 'removeBuddyFromRoster' => 2,
39
+ 'setBidireccionalBuddys' => 6,
40
+ 'unsetBidireccionalBuddys' => 4,
41
+ 'getRoster' => 1,
42
+ 'removeRoster' => 1,
43
+ 'removeAllRosters' => 0,
44
+ 'getBuddysFromRoster' => 1,
45
+ 'getAllUsersWithRoster' => 0,
46
+ 'getAllRosters' => 0,
47
+ 'printAllRosters' => 0,
48
+ 'printAllBidirecctionalBuddys' => 0,
49
+ 'checkUser' => 1,
50
+ 'checkBidirecctionalBuddys' => 2,
51
+ 'sendPresence' => 2,
52
+ 'setPresence' => 1,
53
+ 'unsetPresence' => 1,
54
+ 'sendMessageToUser' => 3,
55
+ 'getUserResource' => 1,
56
+ 'isEjabberdNodeStarted' => 0,
57
+ 'help' => 0,
50
58
  }
51
59
 
52
60
  SYNTAX_FOR_COMMANDS = {
53
- 'getRoster' => "getRoster username",
54
- 'removeBuddyFromRoster' => "removeBuddyFromRoster username buddy",
55
- 'addBuddyToRoster' => "addBuddyToRoster userSid buddySid buddyNick buddyGroup subscription_type",
56
- 'removeRoster' => "removeRoster username",
57
- 'getBuddysFromRoster' => "getBuddysFromRoster roster",
58
- 'setBidireccionalBuddys' => "setBidireccionalBuddys userASid userBSid userANick userBNick groupForA groupForB",
59
- 'getUserResource' => "getUserResource username",
60
- 'sendMessageToUser' => "sendMessageToUser from_name to_name msg",
61
- 'sendPresence' => 'sendPresence username show',
62
- 'unsetPresence' => 'unsetPresence username',
63
- 'setPresence' => 'setPresence username',
64
- 'removeAllRosters' => 'removeAllRosters'
61
+ 'addBuddyToRoster' => 'addBuddyToRoster userSid buddySid buddyNick buddyGroup subscription_type',
62
+ 'removeBuddyFromRoster' => 'removeBuddyFromRoster userSid buddySid',
63
+ 'setBidireccionalBuddys' => 'setBidireccionalBuddys userASid userBSid userANick userBNick groupForA groupForB',
64
+ 'unsetBidireccionalBuddys' => 'unsetBidireccionalBuddys userSid oldFriendSid oldFriendNick groupForOldFriend',
65
+ 'getRoster' => 'getRoster username',
66
+ 'removeRoster' => 'removeRoster username',
67
+ 'removeAllRosters' => 'removeAllRosters',
68
+ 'getBuddysFromRoster' => 'getBuddysFromRoster roster',
69
+ 'getAllUsersWithRoster' => 'getAllUsersWithRoster',
70
+ 'getAllRosters' => 'getAllRosters',
71
+ 'printAllRosters' => 'printAllRosters',
72
+ 'printAllBidirecctionalBuddys' => 'printAllBidirecctionalBuddys',
73
+ 'checkUser' => 'checkUser user',
74
+ 'checkBidirecctionalBuddys' => 'checkBidirecctionalBuddys userASid userBSid',
75
+ 'sendPresence' => 'sendPresence username show',
76
+ 'setPresence' => 'setPresence username',
77
+ 'unsetPresence' => 'unsetPresence username',
78
+ 'sendMessageToUser' => 'sendMessageToUser from_name to_name msg',
79
+ 'getUserResource' => 'getUserResource username',
80
+ 'isEjabberdNodeStarted' => 'isEjabberdNodeStarted',
81
+ 'help' => 'help',
65
82
  }
66
83
 
84
+
85
+
86
+ #Debug methods
67
87
  def log(msg)
68
88
  logWithTitle(msg,nil)
69
89
  end
@@ -78,29 +98,60 @@ def logWithTitle(msg,title)
78
98
  end
79
99
 
80
100
 
81
- def getRoster(username)
82
- command = "ejabberdctl get_roster " + username + " " + $domain
83
- %x[#{command}];
101
+
102
+ #Methods to manage rosters from Social Stream Rails App
103
+
104
+ def setBidireccionalBuddys(userASid,userBSid,userANick,userBNick,groupForA,groupForB)
105
+ addBuddyToRoster(userASid,userBSid,userBNick,groupForB,"both")
106
+ addBuddyToRoster(userBSid,userASid,userANick,groupForA,"both")
107
+ return "Done"
108
+ end
109
+
110
+ def unsetBidireccionalBuddys(userSid,oldFriendSid,oldFriendNick,groupForOldFriend)
111
+ if checkBidirecctionalBuddys(userSid,oldFriendSid)
112
+ removeBuddyFromRoster(userSid,oldFriendSid)
113
+ removeBuddyFromRoster(oldFriendSid,userSid)
114
+ addBuddyToRoster(userSid,oldFriendSid,oldFriendNick,groupForOldFriend,"to")
115
+ return "Done"
116
+ else
117
+ return userSid + " and " + oldFriendSid + " aren't bidireccional buddys"
118
+ end
84
119
  end
85
120
 
86
- def removeBuddyFromRoster(username,buddy)
87
- command = "ejabberdctl delete_rosteritem " + username + " " + $domain + " " + buddy + " " + $domain
121
+ def addBuddyToRoster(userSid,buddySid,buddyNick,buddyGroup,subscription_type)
122
+ user = userSid.split("@")[0]
123
+ buddy = buddySid.split("@")[0]
124
+ userDomain = userSid.split("@")[1]
125
+ buddyDomain = buddySid.split("@")[1]
126
+ command = "ejabberdctl add-rosteritem " + user + " " + userDomain + " " + buddy + " " + buddyDomain + " " + buddyNick + " " + buddyGroup + " " + subscription_type
88
127
  %x[#{command}];
128
+ return "Done"
89
129
  end
90
130
 
91
- def removeRoster(username)
92
- user_roster = getRoster(username);
93
- user_buddys = getBuddysFromRoster(user_roster);
94
- user_buddys.each do |buddy|
95
- removeBuddyFromRoster(username,buddy)
131
+ def removeBuddyFromRoster(userSid,buddySid)
132
+ user = userSid.split("@")[0]
133
+ buddy = buddySid.split("@")[0]
134
+ userDomain = userSid.split("@")[1]
135
+ buddyDomain = buddySid.split("@")[1]
136
+ if checkUserInRoster(buddy,getRoster(user))
137
+ command = "ejabberdctl delete_rosteritem " + user + " " + userDomain + " " + buddy + " " + buddyDomain
138
+ %x[#{command}];
139
+ return "Done"
140
+ else
141
+ return "User " + buddy + " not found in " + user + " roster."
96
142
  end
97
- return "Done"
98
143
  end
99
144
 
100
- def removeAllRosters()
101
- command = "ejabberdctl process_rosteritems delete any any any any"
102
- %x[#{command}];
103
- return "Done";
145
+
146
+ #Roster Utilities
147
+
148
+ def getRoster(username)
149
+ if checkUser(username)
150
+ command = "ejabberdctl get_roster " + username + " " + $domain
151
+ %x[#{command}];
152
+ else
153
+ return "User " + username + " not found"
154
+ end
104
155
  end
105
156
 
106
157
  def getBuddysFromRoster(roster)
@@ -112,22 +163,126 @@ def getBuddysFromRoster(roster)
112
163
  buddys
113
164
  end
114
165
 
115
- def setBidireccionalBuddys(userASid,userBSid,userANick,userBNick,groupForA,groupForB)
116
- addBuddyToRoster(userASid,userBSid,userBNick,groupForB,"both")
117
- addBuddyToRoster(userBSid,userASid,userANick,groupForA,"both")
118
- return "Done"
166
+ def removeRoster(username)
167
+ if checkUser(username)
168
+ user_sid = username + "@" + $domain
169
+ user_roster = getRoster(username);
170
+ user_buddys = getBuddysFromRoster(user_roster);
171
+ user_buddys.each do |buddy|
172
+ buddy_sid = buddy + "@" + $domain
173
+ removeBuddyFromRoster(user_sid,buddy_sid)
174
+ end
175
+ return "Done"
176
+ else
177
+ return "User " + username + " not found"
178
+ end
119
179
  end
120
180
 
121
- def addBuddyToRoster(userSid,buddySid,buddyNick,buddyGroup,subscription_type)
122
- user = userSid.split("@")[0]
123
- buddy = buddySid.split("@")[0]
124
- userDomain = userSid.split("@")[1]
125
- buddyDomain = buddySid.split("@")[1]
126
- command = "ejabberdctl add-rosteritem " + user + " " + userDomain + " " + buddy + " " + buddyDomain + " " + buddyNick + " " + buddyGroup + " " + subscription_type
127
- puts command
181
+ def removeAllRosters()
182
+ command = "ejabberdctl process_rosteritems delete any any any any"
128
183
  %x[#{command}];
184
+ return "Done";
129
185
  end
130
186
 
187
+ def getAllUsersWithRoster()
188
+ command = "ejabberdctl process_rosteritems list any any any any"
189
+ output = %x[#{command}];
190
+
191
+ i = 0
192
+ users = []
193
+
194
+ lines = output.split("\n");
195
+ items = lines[0].split(" ")[2]
196
+
197
+ #test if items string contains a correct number
198
+ if items.to_i.to_s == items
199
+ if items.to_i > 0
200
+ lines.each do |line|
201
+ if i%2==1
202
+ user = line.split(" ")[1].split("@")[0]
203
+ #puts i.to_s() + " :" + line
204
+ unless users.include?(user)
205
+ users << user
206
+ end
207
+ end
208
+ i=i+1
209
+ end
210
+ end
211
+ end
212
+
213
+ return users;
214
+ end
215
+
216
+ def getAllRosters()
217
+ rosterList = { }
218
+
219
+ users = getAllUsersWithRoster()
220
+
221
+ users.each do |user|
222
+ roster = getRoster(user)
223
+ rosterList.store(user,roster)
224
+ end
225
+ return rosterList
226
+ end
227
+
228
+ def printAllRosters()
229
+ rosterList = getAllRosters()
230
+ rosterList.keys.each do |user|
231
+ puts "\n"
232
+ puts "-------------------------------------"
233
+ puts user + " Roster"
234
+ puts "-------------------------------------"
235
+ puts rosterList[user]
236
+ puts "-------------------------------------"
237
+ puts "\n"
238
+ end
239
+ return "Done"
240
+ end
241
+
242
+ def getAllBidirecctionalBuddys()
243
+ b_buddys = []
244
+ users = getAllUsersWithRoster()
245
+ nonCheckedUsers = users
246
+ users.each do |user|
247
+ nonCheckedUsers.delete(user)
248
+ nonCheckedUsers.each do |checkUser|
249
+ if checkBidirecctionalBuddys(user + "@" + $domain,checkUser + "@" + $domain)
250
+ b_buddys << [user,checkUser]
251
+ end
252
+ end
253
+ end
254
+ return b_buddys
255
+ end
256
+
257
+ def printAllBidirecctionalBuddys()
258
+ puts "This may take a while..."
259
+ b_buddys = getAllBidirecctionalBuddys
260
+ b_buddys.each do |contact|
261
+ puts "[" + contact[0] + "," + contact[1] + "]"
262
+ end
263
+ return "Done"
264
+ end
265
+
266
+ #Check if the user have a roster
267
+ def checkUser(user)
268
+ return getAllUsersWithRoster().include?(user)
269
+ end
270
+
271
+ def checkUserInRoster(user,roster)
272
+ return getBuddysFromRoster(roster).include?(user)
273
+ end
274
+
275
+ def checkBidirecctionalBuddys(userASid,userBSid)
276
+ userA = userASid.split("@")[0]
277
+ userB = userBSid.split("@")[0]
278
+ rosterA = getRoster(userA)
279
+ rosterB = getRoster(userB)
280
+ return (checkUserInRoster(userA,rosterB) and checkUserInRoster(userB,rosterA))
281
+ end
282
+
283
+
284
+ #Manage stanzas Utilities
285
+
131
286
  def sendStanzaUserMessage(username,msg)
132
287
  resource = getUserResource(username);
133
288
  stanza = "\\<\\'message\\'\\>\\<\\'body\\'\\>\\'" + msg + "\\'\\<\\'/body\\'\\>\\<\\'/message\\'\\>"
@@ -137,17 +292,16 @@ def sendStanzaUserMessage(username,msg)
137
292
  return "Done"
138
293
  end
139
294
 
140
-
141
- def sendPresence(username,show)
142
- sendPresenceWithShow(username,username,show)
295
+ def setPresence(username)
296
+ sendPresenceStanzaWithType(username,username,"available")
143
297
  end
144
298
 
145
299
  def unsetPresence(username)
146
300
  sendPresenceStanzaWithType(username,username,"unavailable")
147
301
  end
148
302
 
149
- def setPresence(username)
150
- sendPresenceStanzaWithType(username,username,"available")
303
+ def sendPresence(username,show)
304
+ sendPresenceWithShow(username,username,show)
151
305
  end
152
306
 
153
307
  def sendPresenceWithShow(from_name,to_name,show)
@@ -198,6 +352,22 @@ def getUserResource(username)
198
352
  return username + " no have any active session"
199
353
  end
200
354
 
355
+
356
+ #More utilities
357
+
358
+ def isEjabberdNodeStarted
359
+ command = "ejabberdctl status"
360
+ output = %x[#{command}]
361
+ if firstLine = output.split("\n")[0]
362
+ return ((firstLine.split(":")[1]).strip()=="started")
363
+ end
364
+ return false
365
+ end
366
+
367
+
368
+
369
+ #Help & Support methods
370
+
201
371
  def help
202
372
  log("Command list")
203
373
  SYNTAX_FOR_COMMANDS.values.each do |command|
@@ -206,6 +376,10 @@ def help
206
376
  puts ""
207
377
  end
208
378
 
379
+
380
+
381
+ #Main thread
382
+
209
383
  log("Init Ejabberd Maintenance script")
210
384
 
211
385
  begin
@@ -235,15 +409,16 @@ begin
235
409
  end
236
410
  puts ""
237
411
  else
238
- log("Error: Params required for command " + (ARGV[0]).to_s() + ": " + (PARAMS_FOR_COMMANDS[ARGV[0]]).to_s())
239
- log("Use 'help' to get information about command syntax")
412
+ puts "Error: Params required for command " + (ARGV[0]).to_s() + ": " + (PARAMS_FOR_COMMANDS[ARGV[0]]).to_s()
413
+ puts "Syntax for command " + (ARGV[0]).to_s() + "\n" + (SYNTAX_FOR_COMMANDS[ARGV[0]]).to_s()
414
+ puts "Use 'help' to get information about command syntax"
240
415
  end
241
416
  else
242
-
243
- log("Error: Command not recognized")
244
- log("Use 'help' to get information about command syntax")
417
+ puts "Error: Command not recognized"
418
+ puts "Use 'help' to get information about command syntax"
245
419
  end
246
420
  rescue
247
- puts "Parametros incorrectos"
421
+ puts "Syntax error"
422
+ puts "Use 'help' to get information about command syntax"
248
423
  end
249
424
 
@@ -6,6 +6,7 @@ module SocialStream
6
6
 
7
7
  included do
8
8
  after_create :save_buddy
9
+ after_destroy :remove_buddy
9
10
  end
10
11
 
11
12
  module InstanceMethods
@@ -42,6 +43,38 @@ module SocialStream
42
43
 
43
44
  end
44
45
 
46
+
47
+ def remove_buddy
48
+
49
+ unless SocialStream::Presence.enable
50
+ return
51
+ end
52
+
53
+ unless self.receiver.subject_type == "User" and self.sender.subject_type == "User"
54
+ return
55
+ end
56
+
57
+ #XMPP DOMAIN
58
+ domain = SocialStream::Presence.domain
59
+ user_sid = self.sender.slug + "@" + domain
60
+ user_name = self.sender.name
61
+ buddy_sid = self.receiver.slug + "@" + domain
62
+ buddy_name = self.receiver.name
63
+
64
+ #Check if is a positive and replied tie
65
+ if self.bidirectional?
66
+ #Execute unsetRosterForBidirectionalTie(user_sid,oldfriend_sid,oldfriendNick,oldfriendGroup)
67
+ SocialStream::Presence::XmppServerOrder::unsetRosterForBidirectionalTie(user_sid,buddy_sid,buddy_name,"SocialStream")
68
+ elsif self.positive?
69
+ #Case: Possitive tie unidirectional
70
+ #Execute removeBuddyFromRoster(user_sid,buddy_sid)
71
+ SocialStream::Presence::XmppServerOrder::removeBuddyFromRoster(user_sid,buddy_sid)
72
+ else
73
+ return
74
+ end
75
+
76
+ end
77
+
45
78
  end
46
79
  end
47
80
  end
@@ -1,5 +1,5 @@
1
1
  module Socialstream
2
2
  module Presence
3
- VERSION = "0.0.12"
3
+ VERSION = "0.0.13"
4
4
  end
5
5
  end
@@ -20,13 +20,33 @@ module SocialStream
20
20
  end
21
21
  end
22
22
 
23
- def addBuddyToRoster(userSID,buddySID,buddyNick,buddyGroup,subscription_type)
23
+ def unsetRosterForBidirectionalTie(userSid,oldfriendSid,oldfriendNick,oldfriendGroup)
24
+ if SocialStream::Presence.remote_xmpp_server
25
+ puts "Not implemented unsetRosterForBidirectionalTie(user_sid,oldfriend_sid,oldfriendNick,oldfriendGroup) for remote_xmpp_server"
26
+ return
27
+ else
28
+ #SocialStream::Presence.remote_xmpp_server=false
29
+ executeEmanagementLocalCommand("unsetBidireccionalBuddys",[userSid,oldfriendSid,oldfriendNick,oldfriendGroup])
30
+ end
31
+ end
32
+
33
+ def addBuddyToRoster(userSid,buddySid,buddyNick,buddyGroup,subscription_type)
24
34
  if SocialStream::Presence.remote_xmpp_server
25
35
  puts "Not implemented addBuddyToRoster(userSID,buddySID,buddyNick,buddyGroup,subscription_type) for remote_xmpp_server"
26
36
  return
27
37
  else
28
38
  #SocialStream::Presence.remote_xmpp_server=false
29
- executeEmanagementLocalCommand("addBuddyToRoster",[userSID,buddySID,buddyNick,buddyGroup,subscription_type])
39
+ executeEmanagementLocalCommand("addBuddyToRoster",[userSid,buddySid,buddyNick,buddyGroup,subscription_type])
40
+ end
41
+ end
42
+
43
+ def removeBuddyFromRoster(userSid,buddySid)
44
+ if SocialStream::Presence.remote_xmpp_server
45
+ puts "Not implemented removeBuddyFromRoster(userSid,buddySid) for remote_xmpp_server"
46
+ return
47
+ else
48
+ #SocialStream::Presence.remote_xmpp_server=false
49
+ executeEmanagementLocalCommand("removeBuddyFromRoster",[userSid,buddySid])
30
50
  end
31
51
  end
32
52
 
@@ -50,18 +70,27 @@ module SocialStream
50
70
  else
51
71
  #SocialStream::Presence.remote_xmpp_server=false
52
72
 
53
- #Get connected users locally
54
- users = []
55
- output = %x[ejabberdctl connected-users]
56
- sessions = output.split("\n")
73
+ #Get connected users locally
74
+ output = executeEmanagementLocalCommand("isEjabberdNodeStarted",[])
75
+ nodeUp = output.split("\n")[3]
76
+
77
+ if nodeUp and nodeUp.strip() == "true"
78
+ users = []
79
+ output = %x[ejabberdctl connected-users]
80
+ sessions = output.split("\n")
57
81
 
58
- sessions.each do |session|
59
- users << session.split("@")[0]
60
- puts session.split("@")[0]
82
+ sessions.each do |session|
83
+ users << session.split("@")[0]
84
+ puts session.split("@")[0]
85
+ end
86
+
87
+ synchronize_presence_for_slugs(users)
88
+
89
+ else
90
+ reset_presence
91
+ return "Xmpp Server Down: Reset Connected Users"
61
92
  end
62
93
 
63
- synchronize_presence_for_slugs(users)
64
-
65
94
  end
66
95
  end
67
96
 
@@ -170,8 +199,8 @@ module SocialStream
170
199
  command = command + " " + param.split(" ")[0]
171
200
  end
172
201
  puts "Executing " + command
173
- system command
174
- puts "Ok"
202
+ output = %x[#{command}];
203
+ return output
175
204
  end
176
205
 
177
206
  end
@@ -11,9 +11,9 @@ Gem::Specification.new do |s|
11
11
  s.files = `git ls-files`.split("\n")
12
12
 
13
13
  # Gem dependencies
14
- s.add_runtime_dependency('social_stream-base', '~> 0.9.23')
15
- s.add_runtime_dependency('social_stream-documents', '~> 0.4.0')
16
- s.add_runtime_dependency('social_stream-events', '~> 0.0.15')
14
+ s.add_runtime_dependency('social_stream-base', '~> 0.9.24')
15
+ s.add_runtime_dependency('social_stream-documents', '~> 0.4.1')
16
+ s.add_runtime_dependency('social_stream-events', '~> 0.0.16')
17
17
 
18
18
  # Development Gem dependencies
19
19
  #
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream
3
3
  version: !ruby/object:Gem::Version
4
- hash: 47
4
+ hash: 45
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 12
9
- - 0
10
- version: 0.12.0
9
+ - 1
10
+ version: 0.12.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - GING - DIT - UPM
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-10-28 00:00:00 +02:00
19
+ date: 2011-10-31 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -27,12 +27,12 @@ dependencies:
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
- hash: 21
30
+ hash: 11
31
31
  segments:
32
32
  - 0
33
33
  - 9
34
- - 23
35
- version: 0.9.23
34
+ - 24
35
+ version: 0.9.24
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
@@ -43,12 +43,12 @@ dependencies:
43
43
  requirements:
44
44
  - - ~>
45
45
  - !ruby/object:Gem::Version
46
- hash: 15
46
+ hash: 13
47
47
  segments:
48
48
  - 0
49
49
  - 4
50
- - 0
51
- version: 0.4.0
50
+ - 1
51
+ version: 0.4.1
52
52
  type: :runtime
53
53
  version_requirements: *id002
54
54
  - !ruby/object:Gem::Dependency
@@ -59,12 +59,12 @@ dependencies:
59
59
  requirements:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
- hash: 1
62
+ hash: 63
63
63
  segments:
64
64
  - 0
65
65
  - 0
66
- - 15
67
- version: 0.0.15
66
+ - 16
67
+ version: 0.0.16
68
68
  type: :runtime
69
69
  version_requirements: *id003
70
70
  - !ruby/object:Gem::Dependency
@@ -860,7 +860,6 @@ files:
860
860
  - documents/app/assets/stylesheets/show.css.scss
861
861
  - documents/app/assets/stylesheets/social_stream-documents.css
862
862
  - documents/app/controllers/audios_controller.rb
863
- - documents/app/controllers/common_documents_controller.rb
864
863
  - documents/app/controllers/documents_controller.rb
865
864
  - documents/app/controllers/pictures_controller.rb
866
865
  - documents/app/controllers/videos_controller.rb
@@ -882,9 +881,10 @@ files:
882
881
  - documents/app/views/audios/index.html.erb
883
882
  - documents/app/views/audios/index.js.erb
884
883
  - documents/app/views/audios/show.html.erb
885
- - documents/app/views/common_documents/_document_info.html.erb
886
- - documents/app/views/common_documents/_index.html.erb
887
- - documents/app/views/common_documents/_show.html.erb
884
+ - documents/app/views/common/_document_info.html.erb
885
+ - documents/app/views/common/_edit_form.html.erb
886
+ - documents/app/views/common/_index.html.erb
887
+ - documents/app/views/common/_show.html.erb
888
888
  - documents/app/views/documents/_document.html.erb
889
889
  - documents/app/views/documents/_document_focus_search.html.erb
890
890
  - documents/app/views/documents/_document_global_search.html.erb
@@ -1,45 +0,0 @@
1
- class CommonDocumentsController < InheritedResources::Base
2
- respond_to :html, :js
3
-
4
- belongs_to_subjects :optional => true
5
-
6
- before_filter :profile_subject!, :only => :index
7
-
8
- load_and_authorize_resource :except => :index
9
-
10
-
11
- def show
12
- respond_to do |format|
13
- format.html {render :action => :show}
14
- format.all {
15
- path = resource.file.path(params[:style] || params[:format])
16
-
17
- send_file path,
18
- :filename => resource.file_file_name,
19
- :disposition => "inline"
20
- }
21
- end
22
- end
23
-
24
- def destroy
25
- @post_activity = resource.post_activity
26
-
27
- destroy!
28
- end
29
-
30
- private
31
-
32
- def collection
33
- @activities = profile_subject.wall(:profile,
34
- :for => current_subject,
35
- :object_type => Array(self.class.index_object_type)).
36
- page(params[:page]).
37
- per(params[:per])
38
- end
39
-
40
- class << self
41
- def index_object_type
42
- controller_name.classify
43
- end
44
- end
45
- end