social_stream 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/Rakefile +0 -12
  2. data/app/controllers/activities_controller.rb +17 -1
  3. data/app/controllers/api_controller.rb +2 -2
  4. data/app/controllers/avatars_controller.rb +44 -0
  5. data/app/controllers/contacts_controller.rb +13 -21
  6. data/app/controllers/conversations_controller.rb +107 -0
  7. data/app/controllers/groups_controller.rb +7 -11
  8. data/app/controllers/messages_controller.rb +21 -88
  9. data/app/controllers/profiles_controller.rb +3 -1
  10. data/app/controllers/pshb_controller.rb +37 -1
  11. data/app/controllers/ties_controller.rb +7 -8
  12. data/app/controllers/users_controller.rb +19 -43
  13. data/app/helpers/location_helper.rb +34 -0
  14. data/app/helpers/subjects_helper.rb +18 -1
  15. data/app/models/activity.rb +67 -27
  16. data/app/models/activity_verb.rb +1 -1
  17. data/app/models/actor.rb +85 -37
  18. data/app/models/avatar.rb +90 -0
  19. data/app/models/group.rb +2 -2
  20. data/app/models/profile.rb +8 -0
  21. data/app/models/tie.rb +20 -22
  22. data/app/models/user.rb +2 -8
  23. data/app/views/activities/_index.html.erb +22 -0
  24. data/app/views/activities/_options.html.erb +3 -1
  25. data/app/views/activities/_root.html.erb +4 -2
  26. data/app/views/activities/_walls.html.erb +34 -0
  27. data/app/views/activities/index.js.erb +1 -0
  28. data/app/views/avatars/_form.html.erb +23 -0
  29. data/app/views/{logos → avatars}/_precrop.html.erb +23 -15
  30. data/app/views/avatars/edit.html.erb +6 -0
  31. data/app/views/avatars/index.html.erb +42 -0
  32. data/app/views/{logos → avatars}/new.html.erb +7 -11
  33. data/app/views/avatars/show.html.erb +5 -0
  34. data/app/views/contacts/_index.html.erb +33 -0
  35. data/app/views/contacts/index.html.erb +35 -2
  36. data/app/views/contacts/index.js.erb +1 -0
  37. data/app/views/conversations/_conversation.html.erb +37 -0
  38. data/app/views/conversations/_conversation_full.html.erb +52 -0
  39. data/app/views/{messages → conversations}/_conversations.html.erb +2 -1
  40. data/app/views/conversations/_index.html.erb +23 -0
  41. data/app/views/{messages → conversations}/_menu_options.html.erb +2 -2
  42. data/app/views/conversations/_show.html.erb +21 -0
  43. data/app/views/{messages → conversations}/edit.html.erb +0 -0
  44. data/app/views/{messages → conversations}/index.html.erb +1 -3
  45. data/app/views/conversations/index.js.erb +7 -0
  46. data/app/views/conversations/show.html.erb +47 -0
  47. data/app/views/conversations/show.js.erb +39 -0
  48. data/app/views/frontpage/_header.html.erb +5 -1
  49. data/app/views/groups/_new.html.erb +50 -48
  50. data/app/views/groups/_sidebar_show.html.erb +1 -1
  51. data/app/views/groups/index.html.erb +1 -1
  52. data/app/views/groups/new.html.erb +6 -1
  53. data/app/views/groups/show.html.erb +1 -3
  54. data/app/views/home/_menu.html.erb +46 -0
  55. data/app/views/home/_sidebar.html.erb +12 -0
  56. data/app/views/home/index.html.erb +3 -3
  57. data/app/views/layouts/application.html.erb +1 -1
  58. data/app/views/layouts/test.html +58 -41
  59. data/app/views/location/_location.html.erb +3 -0
  60. data/app/views/messages/_form.html.erb +5 -52
  61. data/app/views/messages/_message.html.erb +31 -0
  62. data/app/views/messages/_new.html.erb +10 -16
  63. data/app/views/messages/new.html.erb +48 -3
  64. data/app/views/messages/new.js.erb +38 -1
  65. data/app/views/profiles/_profile.html.erb +194 -0
  66. data/app/views/profiles/edit.html.erb +168 -0
  67. data/app/views/profiles/show.html.erb +2 -175
  68. data/app/views/{users → profiles}/update.js.erb +12 -15
  69. data/app/views/subjects/_contacts.html.erb +2 -3
  70. data/app/views/subjects/_toolbar_home.html.erb +1 -1
  71. data/app/views/subjects/_toolbar_home_menu.html.erb +4 -1
  72. data/app/views/subjects/_toolbar_home_menu_options.html.erb +4 -7
  73. data/app/views/subjects/_toolbar_home_menu_options_subjects.html.erb +0 -3
  74. data/app/views/subjects/_toolbar_logo.html.erb +1 -1
  75. data/app/views/subjects/_toolbar_message_menu.html.erb +17 -0
  76. data/app/views/subjects/_toolbar_profile.html.erb +4 -12
  77. data/app/views/subjects/_toolbar_profile_menu.html.erb +9 -10
  78. data/app/views/subjects/_toolbar_profile_menu_basic_options.html.erb +6 -5
  79. data/app/views/subjects/_toolbar_profile_menu_tie_options.html.erb +13 -13
  80. data/app/views/ties/_new.html.erb +30 -25
  81. data/app/views/ties/_suggestions.html.erb +1 -0
  82. data/app/views/ties/new.js.erb +2 -0
  83. data/app/views/users/_index.html.erb +1 -1
  84. data/app/views/users/index.html.erb +1 -3
  85. data/app/views/users/show.html.erb +4 -3
  86. data/config/locales/en.yml +79 -24
  87. data/config/routes.rb +8 -2
  88. data/lib/generators/social_stream/install_generator.rb +1 -1
  89. data/lib/generators/social_stream/templates/migration.rb +17 -11
  90. data/lib/generators/social_stream/templates/public/images/btn/message_conversation.png +0 -0
  91. data/lib/generators/social_stream/templates/public/images/btn/message_inbox.png +0 -0
  92. data/lib/generators/social_stream/templates/public/images/btn/message_new.png +0 -0
  93. data/lib/generators/social_stream/templates/public/images/btn/message_sentbox.png +0 -0
  94. data/lib/generators/social_stream/templates/public/images/btn/message_trash.png +0 -0
  95. data/lib/generators/social_stream/templates/public/javascripts/ajax.paginate.js +1 -1
  96. data/lib/generators/social_stream/templates/public/javascripts/menu.js +9 -99
  97. data/lib/generators/social_stream/templates/public/stylesheets/default/base.css +14 -5
  98. data/lib/generators/social_stream/templates/public/stylesheets/default/home.css +1 -0
  99. data/lib/generators/social_stream/templates/public/stylesheets/default/jquery-ui.css +13 -10
  100. data/lib/generators/social_stream/templates/public/stylesheets/default/menu.css +5 -11
  101. data/lib/generators/social_stream/templates/public/stylesheets/default/messages.css +96 -20
  102. data/lib/generators/social_stream/templates/relations.yml +1 -0
  103. data/lib/paperclip/social_stream.rb +1 -1
  104. data/lib/social_stream/ability.rb +1 -0
  105. data/lib/social_stream/controllers/helpers.rb +20 -0
  106. data/lib/social_stream/models/subject.rb +13 -12
  107. data/lib/social_stream/rails.rb +4 -1
  108. data/lib/social_stream/version.rb +1 -1
  109. data/lib/tasks/db/populate.rake +14 -4
  110. data/social_stream.gemspec +31 -5
  111. data/spec/controllers/contacts_controller_spec.rb +6 -0
  112. data/spec/controllers/profiles_controller_spec.rb +3 -4
  113. data/spec/dummy/config/initializers/devise.rb +4 -1
  114. data/spec/dummy/config/relations.yml +1 -0
  115. data/spec/models/activity_spec.rb +24 -0
  116. metadata +91 -89
  117. data/app/controllers/logos_controller.rb +0 -37
  118. data/app/models/logo.rb +0 -88
  119. data/app/views/activities/_activities.html.erb +0 -46
  120. data/app/views/groups/_profile.html.erb +0 -142
  121. data/app/views/groups/edit.html.erb +0 -135
  122. data/app/views/groups/update.js.erb +0 -39
  123. data/app/views/logos/_form.html.erb +0 -33
  124. data/app/views/logos/edit.html.erb +0 -6
  125. data/app/views/logos/index.html.erb +0 -27
  126. data/app/views/logos/show.html.erb +0 -5
  127. data/app/views/menu/_group.html.erb +0 -15
  128. data/app/views/menu/_home_user.html.erb +0 -0
  129. data/app/views/menu/_optionsGroups.html.erb +0 -11
  130. data/app/views/menu/_optionsUser.html.erb +0 -11
  131. data/app/views/menu/_services.html.erb +0 -11
  132. data/app/views/menu/_tiesGroup.html.erb +0 -14
  133. data/app/views/menu/_tiesUser.html.erb +0 -11
  134. data/app/views/menu/_user.html.erb +0 -15
  135. data/app/views/messages/_conversation.html.erb +0 -34
  136. data/app/views/messages/_conversation_full.html.erb +0 -65
  137. data/app/views/messages/_index.html.erb +0 -19
  138. data/app/views/messages/_location.html.erb +0 -3
  139. data/app/views/messages/_show.html.erb +0 -22
  140. data/app/views/messages/index.js.erb +0 -1
  141. data/app/views/messages/show.html.erb +0 -10
  142. data/app/views/messages/show.js.erb +0 -1
  143. data/app/views/users/_profile.html.erb +0 -171
  144. data/app/views/users/_sidebar_show.html.erb +0 -1
  145. data/app/views/users/edit.html.erb +0 -194
data/Rakefile CHANGED
@@ -25,16 +25,4 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
25
25
  rdoc.rdoc_files.include('lib/**/*.rb', 'app/**/*.rb')
26
26
  end
27
27
 
28
- class Bundler::GemHelper
29
- def install_gem
30
- built_gem_path = build_gem
31
- out, err, code = sh_with_code("sudo gem install #{built_gem_path} --no-rdoc --no-ri")
32
- if err[/ERROR/]
33
- Bundler.ui.error err
34
- else
35
- Bundler.ui.confirm "#{name} (#{version}) installed"
36
- end
37
- end
38
- end
39
-
40
28
  Bundler::GemHelper.install_tasks
@@ -1,2 +1,18 @@
1
- class ActivitiesController < ApplicationController
1
+ class ActivitiesController < InheritedResources::Base
2
+ belongs_to_subjects
3
+
4
+ respond_to :js
5
+
6
+ protected
7
+
8
+ def collection
9
+ rel = params[:section].to_i if params[:section].present?
10
+
11
+ # should be activities.paginate(:page => params[:page], :count => { :select => 'activity.id', :distinct => true }) but it is not working in Rails 3.0.3
12
+ @activities ||= association_chain[-1].
13
+ wall(:profile,
14
+ :for => current_subject,
15
+ :relation => rel).
16
+ paginate(:page => params[:page])
17
+ end
2
18
  end
@@ -1,6 +1,6 @@
1
1
  class ApiController < ApplicationController
2
2
 
3
- before_filter :authenticate_user!, :only => [:create_key, :users, :activity_atom_feed]
3
+ before_filter :authenticate_user!, :only => [:create_key, :users]#, :activity_atom_feed]
4
4
 
5
5
  def create_key
6
6
  current_user.reset_authentication_token!
@@ -26,7 +26,7 @@ class ApiController < ApplicationController
26
26
  end
27
27
 
28
28
  @page = params[:page]
29
- @activities = current_user.home_wall.paginate(:page => params[:page], :per_page => 10)
29
+ @activities = @user.wall(:home).paginate(:page => params[:page], :per_page => 10)
30
30
  respond_to do |format|
31
31
  format.atom
32
32
  end
@@ -0,0 +1,44 @@
1
+ class AvatarsController < InheritedResources::Base
2
+
3
+ before_filter :authenticate_user!
4
+ def update
5
+
6
+ if !current_subject.avatars.blank?
7
+
8
+ new_logo = Avatar.find(params[:id])
9
+
10
+ if (new_logo.actor == current_subject.actor)
11
+
12
+ actual_logo = current_subject.avatars.active.first
13
+ if !actual_logo.blank?
14
+ actual_logo.active = false
15
+ actual_logo.save
16
+ end
17
+
18
+ new_logo.active = true
19
+ new_logo.save
20
+ end
21
+ end
22
+ redirect_to avatars_path
23
+ end
24
+
25
+ def create
26
+ @avatar = Avatar.create(params[:logo])
27
+
28
+ if @avatar.new_record?
29
+ render :new
30
+ else
31
+ @avatar.updating_logo = true
32
+ @avatar.actor_id = current_subject.actor.id
33
+ if !current_subject.avatars.blank?
34
+ actual_logo = current_subject.avatars.active.first
35
+ actual_logo.active = false
36
+ actual_logo.save
37
+ end
38
+ @avatar.active = true
39
+ @avatar.save
40
+ redirect_to [current_subject, :profile]
41
+ end
42
+ end
43
+
44
+ end
@@ -1,28 +1,20 @@
1
1
  class ContactsController < ApplicationController
2
+ before_filter :authenticate_user!
2
3
 
3
4
  def index
4
-
5
-
6
- return if current_subject.blank?
7
-
8
- myContacts = Array.new
9
- mySubjects = current_subject.subjects(:direction => :receivers)
10
-
11
- return if mySubjects.blank?
12
-
13
- #Fill the array with actor name/actorId of all the actors which has a tie with current_subject
14
- mySubjects.each do |aSubject|
15
- aSubjectD = {}
16
- aSubjectD['key'] = aSubject.name
17
- aSubjectD['value'] = aSubject.actor_id.to_s
18
- myContacts << aSubjectD
19
- end
20
-
5
+ @contacts =
6
+ current_subject.
7
+ contacts(:direction => :sent){ |q|
8
+ q.alphabetic.
9
+ letter(params[:letter]).
10
+ search(params[:search]).
11
+ merge(Tie.original.related_by(current_subject.relations.find_by_id(params[:relation])))
12
+ }
13
+
21
14
  respond_to do |format|
22
- format.html #index.html.erb
23
- format.json { render :text => myContacts.to_json }
15
+ format.html { @contacts = @contacts.paginate(:page => params[:page], :per_page => 10) }
16
+ format.js { @contacts = @contacts.paginate(:page => params[:page], :per_page => 10) }
17
+ format.json { render :text => @contacts.map{ |c| { 'key' => c.name, 'value' => c.actor_id.to_s } }.to_json }
24
18
  end
25
-
26
19
  end
27
-
28
20
  end
@@ -0,0 +1,107 @@
1
+ class ConversationsController < ApplicationController
2
+
3
+ before_filter :get_mailbox, :get_box, :get_actor
4
+ def index
5
+ if @box.eql?"inbox"
6
+ @conversations = @mailbox.inbox.paginate(:per_page => 9, :page => params[:page])
7
+ elsif @box.eql?"sentbox"
8
+ @conversations = @mailbox.sentbox.paginate(:per_page => 9, :page => params[:page])
9
+ else
10
+ @conversations = @mailbox.trash.paginate(:per_page => 9, :page => params[:page])
11
+ end
12
+ end
13
+
14
+ def show
15
+ @conversation = Conversation.find_by_id(params[:id])
16
+ if @conversation.nil? or !@conversation.is_participant?(@actor)
17
+ redirect_to conversations_path(:box => @box)
18
+ return
19
+ end
20
+ if @box.eql? 'trash'
21
+ @receipts = @conversation.receipts(@actor).trash
22
+ else
23
+ @receipts = @conversation.receipts(@actor).not_trash
24
+ end
25
+ render :action => :show
26
+ @receipts.mark_as_read
27
+ end
28
+
29
+ def new
30
+
31
+ end
32
+
33
+ def edit
34
+
35
+ end
36
+
37
+ def create
38
+
39
+ end
40
+
41
+ def update
42
+ @conversation = Conversation.find_by_id(params[:id])
43
+ if @conversation.nil? or !@conversation.is_participant?(@actor)
44
+ redirect_to conversations_path(:box => @box)
45
+ return
46
+ end
47
+
48
+ if params[:untrash].present?
49
+ @conversation.untrash(@actor)
50
+ end
51
+
52
+ if params[:reply_all].present?
53
+ last_receipt = @conversation.receipts(@actor).last
54
+ @receipt = @actor.reply_to_all(last_receipt, params[:body])
55
+ end
56
+
57
+ if @box.eql? 'trash'
58
+ @receipts = @conversation.receipts(@actor).trash
59
+ else
60
+ @receipts = @conversation.receipts(@actor).not_trash
61
+ end
62
+ render :action => :show
63
+ @receipts.mark_as_read
64
+
65
+ end
66
+
67
+ def destroy
68
+ @conversation = Conversation.find_by_id(params[:id])
69
+ if @conversation.nil? or !@conversation.is_participant?(@actor)
70
+ redirect_to conversations_path(:box => @box)
71
+ return
72
+ end
73
+
74
+ @conversation.move_to_trash(@actor)
75
+
76
+ if params[:location].present?
77
+ case params[:location]
78
+ when 'conversation'
79
+ redirect_to conversations_path(:box => :trash)
80
+ return
81
+ else
82
+ redirect_to conversations_path(:box => @box,:page => params[:page])
83
+ return
84
+ end
85
+ end
86
+ redirect_to conversations_path(:box => @box,:page => params[:page])
87
+ end
88
+
89
+ private
90
+
91
+ def get_mailbox
92
+ @mailbox = current_subject.mailbox
93
+ end
94
+
95
+ def get_actor
96
+ @actor = Actor.normalize(current_subject)
97
+ end
98
+
99
+ def get_box
100
+ if params[:box].blank? or !["inbox","sentbox","trash"].include?params[:box]
101
+ @box = "inbox"
102
+ return
103
+ end
104
+ @box = params[:box]
105
+ end
106
+
107
+ end
@@ -1,21 +1,17 @@
1
1
  class GroupsController < InheritedResources::Base
2
-
3
2
  respond_to :html, :xml, :js
4
3
 
5
4
  def index
6
- if params[:search]
7
- @groups = Group.search("%"+params[:search]+"%").paginate(:per_page => 10, :page => params[:page])
8
- else
9
- if params[:letter] && params[:letter]!="undefined"
10
- @groups = Group.search(params[:letter]+"%").paginate(:per_page => 10, :page => params[:page])
11
- else
12
- @groups = Group.alphabetic.paginate(:per_page => 10, :page => params[:page])
13
- end
5
+ @groups = Group.alphabetic.
6
+ letter(params[:letter]).
7
+ search(params[:search]).
8
+ paginate(:per_page => 10, :page => params[:page])
9
+
10
+ index! do |format|
11
+ format.html { render :layout => (user_signed_in? ? 'application' : 'frontpage') }
14
12
  end
15
13
  end
16
14
 
17
-
18
-
19
15
  protected
20
16
 
21
17
  # Overwrite resource method to support slug
@@ -1,32 +1,15 @@
1
1
  class MessagesController < ApplicationController
2
2
 
3
- before_filter :get_mailbox, :get_box
4
- def index
5
- if @box.eql?"inbox"
6
- @conversations = @mailbox.inbox.paginate(:per_page => 9, :page => params[:page])
7
- elsif @box.eql?"sentbox"
8
- @conversations = @mailbox.sentbox.paginate(:per_page => 9, :page => params[:page])
9
- else
10
- @conversations = @mailbox.trash.paginate(:per_page => 9, :page => params[:page])
11
- end
12
- end
13
-
3
+ before_filter :get_mailbox, :get_box, :get_actor
14
4
  # GET /messages/1
15
5
  # GET /messages/1.xml
16
6
  def show
17
- @actor = Actor.normalize(current_subject)
18
- @conversation = Conversation.find_by_id(params[:id])
19
- if @conversation.nil? or !@conversation.is_participant?(@actor)
20
- redirect_to mailbox_index_path
21
- return
22
- end
23
- if @box.eql? 'trash'
24
- @receipts = @conversation.receipts(@actor).trash
25
- else
26
- @conversation.mark_as_read(@actor)
27
- @receipts = @conversation.receipts(@actor).not_trash
7
+ if @message = Message.find_by_id(params[:id]) and @conversation = @message.conversation
8
+ if @conversation.is_participant?(@actor)
9
+ redirect_to conversation_path(@conversation, :box => @box, :anchor => "message_" + @message.id.to_s)
10
+ return
11
+ end
28
12
  end
29
-
30
13
  end
31
14
 
32
15
  # GET /messages/new
@@ -34,6 +17,7 @@ class MessagesController < ApplicationController
34
17
  def new
35
18
  if params[:receiver].present?
36
19
  @recipient = Actor.find_by_slug(params[:receiver])
20
+ return if @recipient.nil?
37
21
  @recipient = nil if Actor.normalize(@recipient)==Actor.normalize(current_subject)
38
22
  end
39
23
  end
@@ -46,31 +30,19 @@ class MessagesController < ApplicationController
46
30
  # POST /messages
47
31
  # POST /messages.xml
48
32
  def create
49
- @conversation = Conversation.new
50
- if params[:subject].blank?
51
- @conversation.errors.add("subject", "can't be empty")
52
- end
53
- if params[:body].blank?
54
- @conversation.errors.add("body", "can't be empty")
55
- end
56
- if params[:_recipients].nil? or params[:_recipients]==[]
57
- @conversation.errors.add("recipients", "can't be empty")
58
- end
59
- if @conversation.errors.any?
60
- render :action => :new
61
- return
62
- end
63
33
  @actor = current_subject
64
34
  @recipients = Array.new
65
- params[:_recipients].each do |recp_id|
66
- recp = Actor.find_by_id(recp_id)
67
- next if recp.nil?
68
- @recipients << recp
35
+ if params[:_recipients].present?
36
+ params[:_recipients].each do |recp_id|
37
+ recp = Actor.find_by_id(recp_id)
38
+ next if recp.nil?
39
+ @recipients << recp
40
+ end
69
41
  end
70
-
71
- if (mail = @actor.send_message(@recipients, params[:body], params[:subject]))
72
- @conversation = mail.conversation
73
- redirect_to message_path(@conversation, :box => :sentbox)
42
+ @receipt = @actor.send_message(@recipients, params[:body], params[:subject])
43
+ if (@receipt.errors.blank?)
44
+ @conversation = @receipt.conversation
45
+ redirect_to conversation_path(@conversation, :box => :sentbox)
74
46
  else
75
47
  render :action => :new
76
48
  end
@@ -79,56 +51,13 @@ class MessagesController < ApplicationController
79
51
  # PUT /messages/1
80
52
  # PUT /messages/1.xml
81
53
  def update
82
- @actor = Actor.normalize(current_subject)
83
- @conversation = Conversation.find_by_id(params[:id])
84
- if @conversation.nil? or !@conversation.is_participant?(@actor)
85
- redirect_to messages_path(:box => @box)
86
- return
87
- end
88
-
89
- if params[:untrash].present?
90
- @conversation.untrash(@actor)
91
- end
92
-
93
- if params[:reply_all].present?
94
- if params[:body].present?
95
- last_receipt = @conversation.receipts(@actor).last
96
- @actor.reply_to_all(last_receipt, params[:body])
97
- end
98
- end
99
54
 
100
- if @box.eql? 'trash'
101
- @receipts = @conversation.receipts(@actor).trash
102
- else
103
- @conversation.mark_as_read(@actor)
104
- @receipts = @conversation.receipts(@actor).not_trash
105
- end
106
- render :action => :show
107
55
  end
108
56
 
109
57
  # DELETE /messages/1
110
58
  # DELETE /messages/1.xml
111
59
  def destroy
112
- @actor = Actor.normalize(current_subject)
113
- @conversation = Conversation.find_by_id(params[:id])
114
- if @conversation.nil? or !@conversation.is_participant?(@actor)
115
- redirect_to messages_path(:box => @box)
116
- return
117
- end
118
-
119
- @conversation.move_to_trash(@actor)
120
60
 
121
- if params[:location].present?
122
- case params[:location]
123
- when 'conversation'
124
- redirect_to messages_path(:box => :trash)
125
- return
126
- else
127
- redirect_to messages_path(:box => @box)
128
- return
129
- end
130
- end
131
- redirect_to messages_path(:box => @box)
132
61
  end
133
62
 
134
63
  private
@@ -137,6 +66,10 @@ class MessagesController < ApplicationController
137
66
  @mailbox = current_subject.mailbox
138
67
  end
139
68
 
69
+ def get_actor
70
+ @actor = Actor.normalize(current_subject)
71
+ end
72
+
140
73
  def get_box
141
74
  if params[:box].blank? or !["inbox","sentbox","trash"].include?params[:box]
142
75
  @box = "inbox"
@@ -1,3 +1,5 @@
1
1
  class ProfilesController < InheritedResources::Base
2
- belongs_to *(SocialStream.subjects + [{ :polymorphic => true, :finder => :find_by_slug!, :singleton => true }])
2
+ belongs_to_subjects(:singleton => true)
3
+
4
+ respond_to :html, :xml, :js
3
5
  end
@@ -15,5 +15,41 @@ class PshbController < ApplicationController
15
15
  # requested unsubscription by someone in this node
16
16
  # and delete permissions/remote actor if necessary
17
17
  end
18
+
19
+ logger.debug request.body.read
18
20
  end
19
- end
21
+
22
+ require "net/http"
23
+ require "uri"
24
+
25
+ def pshb_subscription_request#(topic,hub,mode)
26
+ t = Thread.new do
27
+ #test
28
+ hub = 'http://138.4.7.113:4567/' # last '/' is mandatory!
29
+ topic = 'http://138.4.7.69:3000/api/user/demo/home.atom'
30
+ mode = 'subscribe'
31
+ #
32
+ uri = URI.parse(hub)
33
+ response = Net::HTTP::post_form(uri,{ 'hub.callback' => pshb_callback_url,
34
+ 'hub.mode' => mode,
35
+ 'hub.topic' => topic,
36
+ 'hub.verify' => 'sync'})
37
+ puts response.body
38
+ #TO-DO: process 4XX response.status
39
+ end
40
+ end
41
+
42
+ def pshb_publish#(topic,hub)
43
+ t = Thread.new do
44
+ #test params
45
+ hub = 'http://138.4.7.113:4567/' # last '/' is mandatory!
46
+ topic = 'http://138.4.7.69:3000/api/user/demo/home.atom'
47
+ #
48
+ uri = URI.parse(hub)
49
+ response = Net::HTTP::post_form(uri,{ 'hub.mode' => 'publish',
50
+ 'hub.url' => topic})
51
+ #TO-DO: process 4XX response.status
52
+ end
53
+ end
54
+
55
+ end