social_stream 0.12.1 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/Rakefile +3 -5
  2. data/base/app/assets/javascripts/social_stream-base.js +1 -0
  3. data/base/app/models/contact.rb +3 -1
  4. data/base/config/routes.rb +14 -4
  5. data/base/lib/social_stream/base/version.rb +1 -1
  6. data/base/vendor/assets/javascripts/jquery.screw.js +188 -0
  7. data/documents/app/assets/javascripts/documents.js.erb +6 -0
  8. data/documents/app/assets/stylesheets/documents.css.scss +5 -0
  9. data/documents/app/controllers/documents_controller.rb +31 -4
  10. data/documents/app/views/common/_headers.html.erb +76 -0
  11. data/documents/app/views/common/_index.html.erb +16 -30
  12. data/documents/config/routes.rb +1 -1
  13. data/documents/lib/social_stream/documents/version.rb +1 -1
  14. data/documents/social_stream-documents.gemspec +1 -1
  15. data/events/db/migrate/20111102145626_add_more_fields_to_events.rb +24 -0
  16. data/events/lib/social_stream/events/version.rb +1 -1
  17. data/events/social_stream-events.gemspec +1 -1
  18. data/lib/social_stream/version.rb +1 -1
  19. data/presence/app/assets/javascripts/store.js +6 -0
  20. data/presence/app/assets/javascripts/{xmpp_client.js → xmpp_client.js.erb} +53 -1
  21. data/presence/app/controllers/xmpp_controller.rb +2 -2
  22. data/presence/app/views/xmpp/_chat.html.erb +22 -36
  23. data/presence/app/views/xmpp/_chat_connecting.html.erb +1 -1
  24. data/presence/app/views/xmpp/_chat_contacts.html.erb +6 -6
  25. data/presence/app/views/xmpp/_chat_off.html.erb +29 -15
  26. data/presence/app/views/xmpp/index.html +0 -1
  27. data/presence/config/locales/en.yml +11 -0
  28. data/presence/config/locales/es.yml +11 -0
  29. data/presence/config/routes.rb +1 -0
  30. data/presence/ejabberd/conf/ssconfig_example.cfg +6 -0
  31. data/presence/ejabberd/ejabberd_scripts/authentication_script +61 -5
  32. data/presence/ejabberd/ejabberd_scripts/emanagement +123 -35
  33. data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
  34. data/presence/lib/generators/social_stream/presence/templates/initializer.rb +13 -6
  35. data/presence/lib/social_stream-presence.rb +9 -4
  36. data/presence/lib/social_stream/presence/models/buddy_manager.rb +10 -2
  37. data/presence/lib/social_stream/presence/version.rb +1 -1
  38. data/presence/lib/social_stream/presence/xmpp_server_order.rb +193 -121
  39. data/presence/lib/tasks/presence/synchronize.rake +2 -2
  40. data/presence/social_stream-presence.gemspec +2 -0
  41. data/social_stream.gemspec +3 -3
  42. metadata +19 -15
  43. data/presence/app/views/xmpp/chat.html.erb +0 -13
data/Rakefile CHANGED
@@ -1,15 +1,13 @@
1
1
  # encoding: UTF-8
2
- require 'rake'
3
- require 'rake/rdoctask'
2
+ require 'bundler/gem_tasks'
4
3
 
5
- require 'rubygems'
4
+ require 'rdoc/task'
6
5
 
6
+ require 'rspec/core'
7
7
  require 'rspec/core/rake_task'
8
8
 
9
9
  require 'ci/reporter/rake/rspec'
10
10
 
11
- require 'bundler'
12
-
13
11
  require File.join(File.dirname(__FILE__), 'lib', 'social_stream', 'version')
14
12
 
15
13
 
@@ -3,6 +3,7 @@
3
3
  //= require jquery-ui
4
4
  //= require modernizr
5
5
  //= require jquery.lightbox-with-resize-plugin
6
+ //= require jquery.screw
6
7
  //
7
8
  //= require avatars_for_rails
8
9
  //
@@ -126,7 +126,9 @@ class Contact < ActiveRecord::Base
126
126
  # We need to update that status here
127
127
  def relation_ids=(ids)
128
128
  remove_follower(ids)
129
-
129
+ if defined?(SocialStream::Presence) and SocialStream::Presence.enable
130
+ SocialStream::Presence::XmppServerOrder::removeBuddy(self)
131
+ end
130
132
  association(:relations).ids_writer(ids)
131
133
  end
132
134
 
@@ -23,9 +23,23 @@ Rails.application.routes.draw do
23
23
  resource :like
24
24
  resource :profile
25
25
  resources :activities
26
+
27
+ # Nested Social Stream objects configured in config/initializers/social_stream.rb
28
+ #
29
+ # /users/demo/posts
30
+ (SocialStream.objects - [ :actor ]).each do |object|
31
+ resources object.to_s.pluralize
32
+ end
26
33
  end
27
34
  end
28
35
 
36
+ # Social Stream objects configured in config/initializers/social_stream.rb
37
+ #
38
+ # /posts
39
+ (SocialStream.objects - [ :actor ]).each do |object|
40
+ resources object.to_s.pluralize
41
+ end
42
+
29
43
  resources :contacts do
30
44
  collection do
31
45
  get 'pending'
@@ -72,10 +86,6 @@ Rails.application.routes.draw do
72
86
 
73
87
  match 'ties' => 'ties#index', :as => :ties
74
88
 
75
- # Social Stream objects configured in config/initializers/social_stream.rb
76
- (SocialStream.objects - [ :actor ]).each do |object|
77
- resources object.to_s.pluralize
78
- end
79
89
 
80
90
  ##API###
81
91
  match 'api/keygen' => 'api#create_key', :as => :api_keygen
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Base
3
- VERSION = "0.9.24".freeze
3
+ VERSION = "0.9.25".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,188 @@
1
+ <!--
2
+ /*
3
+ Screw - A jQuery plugin
4
+ ==================================================================
5
+ ©2010-2011 JasonLau.biz - Version 1.0.4
6
+ ==================================================================
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ */
21
+
22
+ (function($){
23
+ $.fn.extend({
24
+ screw: function(options) {
25
+ var defaults = {
26
+ loadingHTML : 'Loading ... '
27
+ }
28
+ var option = $.extend(defaults, options);
29
+ var obj = $(this);
30
+
31
+ return this.each(function() {
32
+ $(window).scroll(function() {
33
+ screwIt($(this));
34
+ });
35
+
36
+ var screwIt = function(it){
37
+ var h = $(window).height(), w = $(window).width(), st = it.scrollTop(), t = h+st;
38
+ $(".screw-image").each(function(){
39
+ var pos = $(this).offset(), rand = Math.round(Math.random()*1000);
40
+ if(t >= pos.top && pos.left <= w){
41
+ if(!$(this).hasClass('screw-loaded') && !$(this).hasClass('screw-loading')){
42
+
43
+ $(this).addClass('screw-loading').html('<div id="screw-loading-' + rand + '">' + option.loadingHTML + '</div>');
44
+ // Stop cache
45
+ var url = $(this).attr('rel'), patt = /&/g;
46
+ if(patt.test(url)){
47
+ url += '&screw_rand=' + rand;
48
+ } else {
49
+ url += '?screw_rand=' + rand;
50
+ }
51
+ // Preload image
52
+ objImage = new Image();
53
+ objImage.src = url;
54
+ var o = $(this);
55
+ objImage.onload = function(){
56
+ o.append('<img style="display:none" id="screw-content-' + rand + '" class="screw-content" src="' + url + '" />');
57
+ $('#screw-loading-' + rand).fadeOut('slow', function(){
58
+ $('#screw-content-' + rand).fadeIn('slow');
59
+ o.removeClass('screw-loading').addClass('screw-loaded');
60
+ });
61
+ };
62
+ }
63
+ }
64
+ });
65
+
66
+ $(".screw").each(function(){
67
+ var pos = $(this).offset(), o = $(this), rand = Math.round(Math.random()*1000), data_type = 'html';
68
+ if(t >= pos.top && pos.left <= w){
69
+ if($(this).hasClass('screw-xml')){
70
+ data_type = 'xml';
71
+ } else if($(this).hasClass('screw-json')){
72
+ data_type = 'json';
73
+ } else if($(this).hasClass('screw-script')){
74
+ data_type = 'script';
75
+ }
76
+ if((!$(this).hasClass('screw-loaded') || $(this).hasClass('screw-repeat') && !$(this).hasClass('screw-loading'))){
77
+ o.addClass('screw-loading');
78
+ if(option.loadingHTML){
79
+ o.html('<div id="screw-loading-' + rand + '">' + option.loadingHTML + '</div>');
80
+ }
81
+
82
+ if(o.hasClass('screw-replace')){
83
+ if($(this).attr('rel')){
84
+ $.get($(this).attr('rel'), { screwrand : Math.round(Math.random()*1000) }, function(data) {
85
+ o.replaceWith(data);
86
+ }, data_type);
87
+ } else if($(this).attr('rev')){
88
+ o.replaceWith($(this).attr('rev'));
89
+ }
90
+ } else if(o.hasClass('screw-append')){
91
+ if($(this).attr('rel')){
92
+ $.get($(this).attr('rel'), { screwrand : Math.round(Math.random()*1000) }, function(data) {
93
+ o.append('<div style="display:none" id="screw-content-' + rand + '" class="screw-content">' + data + '</div>');
94
+ showContent(rand);
95
+ }, data_type);
96
+ } else if($(this).attr('rev')){
97
+ o.append('<div style="display:none" id="screw-content-' + rand + '" class="screw-content">' + $(this).attr('rev') + '</div>');
98
+ showContent(rand);
99
+ }
100
+ } else if(o.hasClass('screw-prepend')){
101
+ if($(this).attr('rel')){
102
+ $.get($(this).attr('rel'), { screwrand : Math.round(Math.random()*1000) }, function(data) {
103
+ o.prepend('<div style="display:none" id="screw-content-' + rand + '" class="screw-content">' + data + '</div>');
104
+ showContent(rand);
105
+ }, data_type);
106
+ } else if($(this).attr('rev')){
107
+ o.prepend('<div style="display:none" id="screw-content-' + rand + '" class="screw-content">' + $(this).attr('rev') + '</div>');
108
+ showContent(rand);
109
+ }
110
+ } else if(o.hasClass('screw-before')){
111
+ if($(this).attr('rel')){
112
+ $.get($(this).attr('rel'), { screwrand : Math.round(Math.random()*1000) }, function(data) {
113
+ o.before('<div style="display:none" id="screw-content-' + rand + '" class="screw-content">' + data + '</div>');
114
+ showContent(rand);
115
+ }, data_type);
116
+ } else if($(this).attr('rev')){
117
+ o.before('<div style="display:none" id="screw-content-' + rand + '" class="screw-content">' + $(this).attr('rev') + '</div>');
118
+ showContent(rand);
119
+ }
120
+
121
+ if(o.hasClass('screw-repeat') && pos.top < $(window).height() && pos.left < $(window).width()){
122
+ if($(this).attr('rel')){
123
+ $.get($(this).attr('rel'), { screwrand : Math.round(Math.random()*1000) }, function(data) {
124
+ o.before('<div style="display:none" id="screw-content-' + rand + '" class="screw-content">' + data + '</div>');
125
+ showContent(rand);
126
+ }, data_type);
127
+ } else if($(this).attr('rev')){
128
+ o.before('<div style="display:none" id="screw-content-' + rand + '" class="screw-content">' + $(this).attr('rev') + '</div>');
129
+ showContent(rand);
130
+ }
131
+ }
132
+
133
+ } else if(o.hasClass('screw-after')){
134
+ if($(this).attr('rel')){
135
+ $.get($(this).attr('rel'), { screwrand : Math.round(Math.random()*1000) }, function(data) {
136
+ o.after('<div style="display:none" id="screw-content-' + rand + '" class="screw-content">' + data + '</div>');
137
+ showContent(rand);
138
+ }, data_type);
139
+ } else if($(this).attr('rev')){
140
+ o.after('<div style="display:none" id="screw-content-' + rand + '" class="screw-content">' + $(this).attr('rev') + '</div>');
141
+ showContent(rand);
142
+ }
143
+ } else {
144
+ if($(this).attr('rel')){
145
+ $.get($(this).attr('rel'), { screwrand : Math.round(Math.random()*1000) }, function(data) {
146
+ o.append('<div style="display:none" id="screw-content-' + rand + '" class="screw-content">' + data + '</div>');
147
+ showContent(rand);
148
+ }, data_type);
149
+ } else if($(this).attr('rev')){
150
+ o.append('<div style="display:none" id="screw-content-' + rand + '" class="screw-content">' + $(this).attr('rev') + '</div>');
151
+ showContent(rand);
152
+ }
153
+ }
154
+ o.removeClass('screw-loading').addClass('screw-loaded');
155
+ }
156
+ }
157
+ });
158
+
159
+ $(".screw-remove").each(function(){
160
+ if($(this).hasClass('screw-loaded')){
161
+ var p = $(this).position();
162
+ if(p.top < st || p.left > w){
163
+ if($(this).is(':visible')){
164
+ $(this).fadeOut('slow');
165
+ }
166
+ }
167
+ }
168
+ });
169
+
170
+ };
171
+
172
+ var showContent = function(rand){
173
+ if(option.loadingHTML){
174
+ $('#screw-loading-' + rand).fadeOut('slow', function(){
175
+ $('#screw-content-' + rand).fadeIn('slow');
176
+ });
177
+ } else {
178
+ $('#screw-content-' + rand).fadeIn('slow');
179
+ }
180
+ };
181
+
182
+ screwIt($(window));
183
+ });
184
+ }
185
+ });
186
+
187
+ })(jQuery);
188
+ -->
@@ -59,3 +59,9 @@ toggleDocumentEdit = function(){
59
59
  $("#document_edit_action").removeClass("selected");
60
60
  }
61
61
  }
62
+
63
+ $(document).ready(function(){
64
+ $("body").screw({
65
+ loadingHTML: '<%= image_tag('loading.gif') %>'
66
+ });
67
+ });
@@ -222,3 +222,8 @@
222
222
  .processing_text{
223
223
  padding: 10px 0px 10px 50px;
224
224
  }
225
+
226
+ .screw{
227
+ width: 100%;
228
+ text-align: center;
229
+ }
@@ -1,4 +1,5 @@
1
1
  class DocumentsController < InheritedResources::Base
2
+ include ActionView::Helpers::SanitizeHelper
2
3
  respond_to :html, :js
3
4
 
4
5
  belongs_to_subjects :optional => true
@@ -7,7 +8,19 @@ class DocumentsController < InheritedResources::Base
7
8
 
8
9
  load_and_authorize_resource :except => :index
9
10
 
11
+ PER_PAGE=20
10
12
  SEND_FILE_METHOD = :default
13
+
14
+ def index
15
+ super do |format|
16
+ if params[:no_layout].present?
17
+ format.html { render :action => :index, :layout => false }
18
+ else
19
+ format.html { render :action => :index }
20
+ end
21
+ end
22
+ end
23
+
11
24
  def create
12
25
  super do |format|
13
26
  format.all {redirect_to request.referer || home_path}
@@ -64,10 +77,12 @@ class DocumentsController < InheritedResources::Base
64
77
 
65
78
  def collection
66
79
  @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])
80
+ :for => current_subject,
81
+ :object_type => Array(self.class.index_object_type))
82
+ if params[:query].present?
83
+ @activities = @activities.joins(:activity_objects => :document).where('documents.title LIKE ?', get_search_query)
84
+ end
85
+ @activities.page(params[:page]).per(PER_PAGE)
71
86
  end
72
87
 
73
88
  class << self
@@ -75,4 +90,16 @@ class DocumentsController < InheritedResources::Base
75
90
  [ :Audio, :Video, :Picture, :Document ]
76
91
  end
77
92
  end
93
+
94
+ def get_search_query
95
+ search_query = ""
96
+ param = strip_tags(params[:query]) || ""
97
+ bare_query = param unless bare_query.html_safe?
98
+ search_query_words = bare_query.strip.split
99
+ search_query_words.each_index do |i|
100
+ search_query+= search_query_words[i] + " " if i < (search_query_words.size - 1)
101
+ search_query+= "%" + search_query_words[i] + "% " if i == (search_query_words.size - 1)
102
+ end
103
+ return search_query.strip
104
+ end
78
105
  end
@@ -0,0 +1,76 @@
1
+ <% content_for :title do %>
2
+ <%= profile_subject.name + ": " + t('repository.title') %>
3
+ <% end %>
4
+
5
+ <% content_for :sidebar do %>
6
+ <%= render :partial => 'home/sidebar' %>
7
+ <% end %>
8
+
9
+ <%if profile_subject_is_current?%>
10
+ <%= location(
11
+ link_to(t('repository.title'), polymorphic_path(controller.controller_name),:remote => true)
12
+ ) %>
13
+ <%else%>
14
+ <%= location(
15
+ link_to(profile_subject.name, polymorphic_path(profile_subject),:remote => true),
16
+ link_to(t('repository.title'), polymorphic_path([profile_subject, controller.controller_name]),:remote => true)
17
+ ) %>
18
+ <%end%>
19
+
20
+ <% toolbar :profile => profile_subject %>
21
+ <br class="clearfloat" />
22
+ <div class="space_center"></div>
23
+ <div id="repository_filter">
24
+ <form action="<%= search_path%>" method="get" id="repository_filter">
25
+ <%= text_field_tag :filter_query, nil,:autocomplete => :off, :id => :repository_filter_input %>
26
+ </form>
27
+ <div id="order_by"><%= t('repository.order.by') %>: <%= t('repository.order.last_modified') %> · <%= t('repository.order.most_popular') %> </div>
28
+ </div>
29
+ <div class="space_center"></div>
30
+
31
+ <%= javascript_tag do %>
32
+ $(document).ready(function() {
33
+ var last_search = "";
34
+
35
+
36
+ $("#repository_filter_input").Watermark("<%= escape_javascript(I18n.t('search.name')) %>");
37
+
38
+ $("#repository_filter_input").keyup(function() {
39
+ var searchstring = $(this).val();
40
+ if((searchstring=="")){
41
+ if (last_search!=searchstring){last_search=searchstring;}
42
+ $("#documents_grid").html("<center><%= escape_javascript(image_tag('loading.gif', :class => :loading)) %></center>");
43
+ $.ajax({
44
+ type : "GET",
45
+ url : "<%= polymorphic_url([current_subject, Document.new]) %>?no_layout=true",
46
+ success : function(html) {
47
+ if ($("#repository_filter_input").val()==searchstring){ //Only show if input value is still the same
48
+ $("#documents_grid").html(html);
49
+ }
50
+ },
51
+ error: function(){
52
+ $("#header_search_display").html("<center><%= escape_javascript(content_tag(:span,I18n.t('search.wrong'), :class => :warning)) %></center>");
53
+ }
54
+ });
55
+ } else {
56
+ if (last_search!=searchstring){
57
+ last_search=searchstring;
58
+ $("#documents_grid").html("<center><%= escape_javascript(image_tag('loading.gif', :class => :loading)) %></center>");
59
+ $.ajax({
60
+ type : "GET",
61
+ url : "<%= polymorphic_url([current_subject, Document.new]) %>?query=" + searchstring + "&no_layout=true",
62
+ success : function(html) {
63
+ if ($("#repository_filter_input").val()==searchstring){ //Only show if input value is still the same
64
+ $("#documents_grid").html(html);
65
+ }
66
+ },
67
+ error: function(){
68
+ $("#header_search_display").html("<center><%= escape_javascript(content_tag(:span,I18n.t('search.wrong'), :class => :warning)) %></center>");
69
+ }
70
+ });
71
+ }
72
+ }
73
+ return false;
74
+ });
75
+ })
76
+ <% end %>
@@ -1,32 +1,7 @@
1
- <% content_for :title do %>
2
- <%= profile_subject.name + ": " + t('repository.title') %>
3
- <% end %>
4
-
5
- <% content_for :sidebar do %>
6
- <%= render :partial => 'home/sidebar' %>
7
- <% end %>
8
-
9
- <%if profile_subject_is_current?%>
10
- <%= location(
11
- link_to(t('repository.title'), polymorphic_path(controller.controller_name),:remote => true)
12
- ) %>
13
- <%else%>
14
- <%= location(
15
- link_to(profile_subject.name, polymorphic_path(profile_subject),:remote => true),
16
- link_to(t('repository.title'), polymorphic_path([profile_subject, controller.controller_name]),:remote => true)
17
- ) %>
18
- <%end%>
19
-
20
- <% toolbar :profile => profile_subject %>
21
- <br class="clearfloat" />
22
- <div class="space_center"></div>
23
- <div id="repository_filter">
24
- <form action="<%= search_path%>" method="get" id="repository_filter">
25
- <%= text_field_tag :filter_query, nil,:autocomplete => :off, :id => :repository_filter_input %>
26
- </form>
27
- <div id="order_by"><%= t('repository.order.by') %>: <%= t('repository.order.last_modified') %> · <%= t('repository.order.most_popular') %> </div>
28
- </div>
29
- <div class="space_center"></div>
1
+ <% unless params[:no_layout].present? %>
2
+ <%= render :partial => "common/headers" %>
3
+ <div id="documents_grid">
4
+ <% end %>
30
5
 
31
6
  <% @activities.each do |a| %>
32
7
  <% document = a.activity_objects.first.document %>
@@ -46,4 +21,15 @@
46
21
  :path => document_path(document) %>
47
22
  </div>
48
23
  </div>
49
- <% end %>
24
+ <% end %>
25
+
26
+ <% if @activities.size == DocumentsController::PER_PAGE %>
27
+ <% next_url = url_for(:no_layout => true,
28
+ :page => params[:page].present? ? params[:page].to_i + 1 : 2,
29
+ :query => params[:query].present? ? params[:query] : "") %>
30
+ <%= content_tag(:span, "", :class => "screw screw-after", :rel => next_url)%>
31
+ <% end %>
32
+
33
+ <% unless params[:no_layout].present? %>
34
+ </div>
35
+ <% end %>