social2social 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +6 -0
- data/.rspec +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +236 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +25 -0
- data/Rakefile +27 -0
- data/app/controllers/pshb_controller.rb +41 -0
- data/app/controllers/remoteusers_controller.rb +21 -0
- data/app/models/remote_user.rb +6 -0
- data/app/views/remoteusers/index.html.erb +8 -0
- data/lib/generators/social2social/install_generator.rb +36 -0
- data/lib/generators/social2social/templates/initializer.rb +4 -0
- data/lib/generators/social2social/templates/migration.rb +21 -0
- data/lib/social2social/engine.rb +21 -0
- data/lib/social2social/models/shareable.rb +35 -0
- data/lib/social2social/models/updatetriggerable.rb +20 -0
- data/lib/social2social.rb +23 -0
- data/social2social.gemspec +23 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +191 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/social2social_spec.rb +9 -0
- data/spec/spec_helper.rb +33 -0
- metadata +242 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,236 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
social2social (0.0.1)
|
5
|
+
social_stream (~> 0.4.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
abstract (1.0.0)
|
11
|
+
actionmailer (3.0.5)
|
12
|
+
actionpack (= 3.0.5)
|
13
|
+
mail (~> 2.2.15)
|
14
|
+
actionpack (3.0.5)
|
15
|
+
activemodel (= 3.0.5)
|
16
|
+
activesupport (= 3.0.5)
|
17
|
+
builder (~> 2.1.2)
|
18
|
+
erubis (~> 2.6.6)
|
19
|
+
i18n (~> 0.4)
|
20
|
+
rack (~> 1.2.1)
|
21
|
+
rack-mount (~> 0.6.13)
|
22
|
+
rack-test (~> 0.5.7)
|
23
|
+
tzinfo (~> 0.3.23)
|
24
|
+
activemodel (3.0.5)
|
25
|
+
activesupport (= 3.0.5)
|
26
|
+
builder (~> 2.1.2)
|
27
|
+
i18n (~> 0.4)
|
28
|
+
activerecord (3.0.5)
|
29
|
+
activemodel (= 3.0.5)
|
30
|
+
activesupport (= 3.0.5)
|
31
|
+
arel (~> 2.0.2)
|
32
|
+
tzinfo (~> 0.3.23)
|
33
|
+
activeresource (3.0.5)
|
34
|
+
activemodel (= 3.0.5)
|
35
|
+
activesupport (= 3.0.5)
|
36
|
+
activesupport (3.0.5)
|
37
|
+
addressable (2.2.4)
|
38
|
+
arel (2.0.9)
|
39
|
+
atd-ancestry (1.3.0)
|
40
|
+
bcrypt-ruby (2.1.4)
|
41
|
+
builder (2.1.2)
|
42
|
+
cancan (1.6.4)
|
43
|
+
capybara (0.3.9)
|
44
|
+
culerity (>= 0.2.4)
|
45
|
+
mime-types (>= 1.16)
|
46
|
+
nokogiri (>= 1.3.3)
|
47
|
+
rack (>= 1.0.0)
|
48
|
+
rack-test (>= 0.5.4)
|
49
|
+
selenium-webdriver (>= 0.0.3)
|
50
|
+
childprocess (0.1.8)
|
51
|
+
ffi (~> 1.0.6)
|
52
|
+
columnize (0.3.2)
|
53
|
+
culerity (0.2.15)
|
54
|
+
devise (1.2.1)
|
55
|
+
bcrypt-ruby (~> 2.1.2)
|
56
|
+
orm_adapter (~> 0.0.3)
|
57
|
+
warden (~> 1.0.3)
|
58
|
+
diff-lcs (1.1.2)
|
59
|
+
erubis (2.6.6)
|
60
|
+
abstract (>= 1.0.0)
|
61
|
+
factory_girl (1.3.3)
|
62
|
+
faraday (0.5.7)
|
63
|
+
addressable (~> 2.2.4)
|
64
|
+
multipart-post (~> 1.1.0)
|
65
|
+
rack (>= 1.1.0, < 2)
|
66
|
+
ffi (1.0.7)
|
67
|
+
rake (>= 0.8.7)
|
68
|
+
foreigner (0.9.1)
|
69
|
+
forgery (0.3.7)
|
70
|
+
nokogiri (~> 1.4)
|
71
|
+
has_scope (0.5.0)
|
72
|
+
i18n (0.5.0)
|
73
|
+
inherited_resources (1.1.2)
|
74
|
+
has_scope (~> 0.5.0)
|
75
|
+
responders (~> 0.6.0)
|
76
|
+
jquery-rails (0.2.7)
|
77
|
+
rails (~> 3.0)
|
78
|
+
thor (~> 0.14.4)
|
79
|
+
json_pure (1.5.1)
|
80
|
+
linecache (0.43)
|
81
|
+
mail (2.2.15)
|
82
|
+
activesupport (>= 2.3.6)
|
83
|
+
i18n (>= 0.4.0)
|
84
|
+
mime-types (~> 1.16)
|
85
|
+
treetop (~> 1.4.8)
|
86
|
+
mailboxer (0.0.14)
|
87
|
+
foreigner (~> 0.9.1)
|
88
|
+
mime-types (1.16)
|
89
|
+
multi_json (0.0.5)
|
90
|
+
multipart-post (1.1.0)
|
91
|
+
nested_set (1.5.4)
|
92
|
+
activerecord (>= 3.0.0)
|
93
|
+
railties (>= 3.0.0)
|
94
|
+
net-ldap (0.1.1)
|
95
|
+
nokogiri (1.4.4)
|
96
|
+
oa-basic (0.2.0)
|
97
|
+
multi_json (~> 0.0.2)
|
98
|
+
nokogiri (~> 1.4.2)
|
99
|
+
oa-core (= 0.2.0)
|
100
|
+
rest-client (~> 1.6.0)
|
101
|
+
oa-core (0.2.0)
|
102
|
+
rack (~> 1.1)
|
103
|
+
oa-enterprise (0.2.0)
|
104
|
+
net-ldap (~> 0.1.1)
|
105
|
+
nokogiri (~> 1.4.2)
|
106
|
+
oa-core (= 0.2.0)
|
107
|
+
pyu-ruby-sasl (~> 0.0.3.1)
|
108
|
+
rubyntlm (~> 0.1.1)
|
109
|
+
oa-more (0.2.0)
|
110
|
+
multi_json (~> 0.0.2)
|
111
|
+
oa-core (= 0.2.0)
|
112
|
+
rest-client (~> 1.6.0)
|
113
|
+
oa-oauth (0.2.0)
|
114
|
+
multi_json (~> 0.0.2)
|
115
|
+
nokogiri (~> 1.4.2)
|
116
|
+
oa-core (= 0.2.0)
|
117
|
+
oauth (~> 0.4.0)
|
118
|
+
oauth2 (~> 0.1.1)
|
119
|
+
oa-openid (0.2.0)
|
120
|
+
oa-core (= 0.2.0)
|
121
|
+
rack-openid (~> 1.2.0)
|
122
|
+
ruby-openid-apps-discovery
|
123
|
+
oauth (0.4.4)
|
124
|
+
oauth-plugin (0.4.0.pre4)
|
125
|
+
oauth (>= 0.4.4)
|
126
|
+
oauth2 (0.1.1)
|
127
|
+
faraday (~> 0.5.0)
|
128
|
+
multi_json (~> 0.0.4)
|
129
|
+
omniauth (0.2.0)
|
130
|
+
oa-basic (= 0.2.0)
|
131
|
+
oa-core (= 0.2.0)
|
132
|
+
oa-enterprise (= 0.2.0)
|
133
|
+
oa-more (= 0.2.0)
|
134
|
+
oa-oauth (= 0.2.0)
|
135
|
+
oa-openid (= 0.2.0)
|
136
|
+
orm_adapter (0.0.4)
|
137
|
+
paperclip (2.3.8)
|
138
|
+
activerecord
|
139
|
+
activesupport
|
140
|
+
polyglot (0.3.1)
|
141
|
+
pyu-ruby-sasl (0.0.3.2)
|
142
|
+
rack (1.2.2)
|
143
|
+
rack-mount (0.6.14)
|
144
|
+
rack (>= 1.0.0)
|
145
|
+
rack-openid (1.2.0)
|
146
|
+
rack (>= 1.1.0)
|
147
|
+
ruby-openid (>= 2.1.8)
|
148
|
+
rack-test (0.5.7)
|
149
|
+
rack (>= 1.0)
|
150
|
+
rails (3.0.5)
|
151
|
+
actionmailer (= 3.0.5)
|
152
|
+
actionpack (= 3.0.5)
|
153
|
+
activerecord (= 3.0.5)
|
154
|
+
activeresource (= 3.0.5)
|
155
|
+
activesupport (= 3.0.5)
|
156
|
+
bundler (~> 1.0)
|
157
|
+
railties (= 3.0.5)
|
158
|
+
rails_css_themes (1.0.0)
|
159
|
+
railties (3.0.5)
|
160
|
+
actionpack (= 3.0.5)
|
161
|
+
activesupport (= 3.0.5)
|
162
|
+
rake (>= 0.8.7)
|
163
|
+
thor (~> 0.14.4)
|
164
|
+
rake (0.8.7)
|
165
|
+
responders (0.6.2)
|
166
|
+
rest-client (1.6.1)
|
167
|
+
mime-types (>= 1.16)
|
168
|
+
rmagick (2.13.1)
|
169
|
+
rspec (2.5.0)
|
170
|
+
rspec-core (~> 2.5.0)
|
171
|
+
rspec-expectations (~> 2.5.0)
|
172
|
+
rspec-mocks (~> 2.5.0)
|
173
|
+
rspec-core (2.5.1)
|
174
|
+
rspec-expectations (2.5.0)
|
175
|
+
diff-lcs (~> 1.1.2)
|
176
|
+
rspec-mocks (2.5.0)
|
177
|
+
rspec-rails (2.5.0)
|
178
|
+
actionpack (~> 3.0)
|
179
|
+
activesupport (~> 3.0)
|
180
|
+
railties (~> 3.0)
|
181
|
+
rspec (~> 2.5.0)
|
182
|
+
ruby-debug (0.10.4)
|
183
|
+
columnize (>= 0.1)
|
184
|
+
ruby-debug-base (~> 0.10.4.0)
|
185
|
+
ruby-debug-base (0.10.4)
|
186
|
+
linecache (>= 0.3)
|
187
|
+
ruby-openid (2.1.8)
|
188
|
+
ruby-openid-apps-discovery (1.2.0)
|
189
|
+
ruby-openid (>= 2.1.7)
|
190
|
+
rubyntlm (0.1.1)
|
191
|
+
rubyzip (0.9.4)
|
192
|
+
selenium-webdriver (0.1.4)
|
193
|
+
childprocess (>= 0.1.7)
|
194
|
+
ffi (>= 1.0.7)
|
195
|
+
json_pure
|
196
|
+
rubyzip
|
197
|
+
social_stream (0.4.2)
|
198
|
+
atd-ancestry (= 1.3.0)
|
199
|
+
cancan (~> 1.6.2)
|
200
|
+
devise (~> 1.2.rc)
|
201
|
+
foreigner (~> 0.9.1)
|
202
|
+
inherited_resources (~> 1.1.2)
|
203
|
+
jquery-rails (~> 0.2.5)
|
204
|
+
mailboxer (~> 0.0.14)
|
205
|
+
nested_set (~> 1.5.3)
|
206
|
+
oauth-plugin (~> 0.4.0.pre1)
|
207
|
+
omniauth (~> 0.2.0.beta5)
|
208
|
+
paperclip (~> 2.3.4)
|
209
|
+
rails_css_themes (~> 1.0.0)
|
210
|
+
rmagick (~> 2.13.1)
|
211
|
+
stringex (~> 1.2.0)
|
212
|
+
will_paginate (~> 3.0.pre2)
|
213
|
+
sqlite3 (1.3.3)
|
214
|
+
sqlite3-ruby (1.3.3)
|
215
|
+
sqlite3 (>= 1.3.3)
|
216
|
+
stringex (1.2.1)
|
217
|
+
thor (0.14.6)
|
218
|
+
treetop (1.4.9)
|
219
|
+
polyglot (>= 0.3.1)
|
220
|
+
tzinfo (0.3.25)
|
221
|
+
warden (1.0.3)
|
222
|
+
rack (>= 1.0.0)
|
223
|
+
will_paginate (3.0.pre2)
|
224
|
+
|
225
|
+
PLATFORMS
|
226
|
+
ruby
|
227
|
+
|
228
|
+
DEPENDENCIES
|
229
|
+
capybara (~> 0.3.9)
|
230
|
+
factory_girl (~> 1.3.2)
|
231
|
+
forgery (~> 0.3.6)
|
232
|
+
rails (~> 3.0.5)
|
233
|
+
rspec-rails (~> 2.5.0)
|
234
|
+
ruby-debug (~> 0.10.3)
|
235
|
+
social2social!
|
236
|
+
sqlite3-ruby
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 VÍCTOR SÁNCHEZ BELMAR
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
= Social2social
|
2
|
+
|
3
|
+
#TO-DO: Say something amazing about social2social
|
4
|
+
|
5
|
+
= Installation
|
6
|
+
|
7
|
+
Add to your Gemfile:
|
8
|
+
|
9
|
+
gem 'social2social'
|
10
|
+
|
11
|
+
and run:
|
12
|
+
|
13
|
+
bundle update
|
14
|
+
|
15
|
+
Then:
|
16
|
+
|
17
|
+
rails generate social2social:install
|
18
|
+
|
19
|
+
You're almost there, now run:
|
20
|
+
|
21
|
+
rake db:migrate
|
22
|
+
|
23
|
+
And finally:
|
24
|
+
|
25
|
+
rails server
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
begin
|
5
|
+
Bundler.setup(:default, :development)
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
+
exit e.status_code
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rake'
|
13
|
+
require 'rake/rdoctask'
|
14
|
+
|
15
|
+
require 'rspec/core'
|
16
|
+
require 'rspec/core/rake_task'
|
17
|
+
|
18
|
+
RSpec::Core::RakeTask.new(:spec)
|
19
|
+
|
20
|
+
task :default => :spec
|
21
|
+
|
22
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
23
|
+
rdoc.rdoc_dir = 'rdoc'
|
24
|
+
rdoc.title = 'Social2social'
|
25
|
+
rdoc.rdoc_files.include('README*')
|
26
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
27
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class PshbController < ApplicationController
|
2
|
+
|
3
|
+
def callback
|
4
|
+
#sync subscription verification
|
5
|
+
if params['hub.mode']=='subscribe'
|
6
|
+
render :text => params['hub.challenge'], :status => 200
|
7
|
+
# TO-DO: confirm that params['hub.topic'] is a real
|
8
|
+
# requested subscription by someone in this node
|
9
|
+
end
|
10
|
+
|
11
|
+
#sync unsubscription verification
|
12
|
+
if params['hub.mode']=='unsubscribe'
|
13
|
+
render :text => params['hub.challenge'], :status => 200
|
14
|
+
# TO-DO: confirm that params['hub.topic'] is a real
|
15
|
+
# requested unsubscription by someone in this node
|
16
|
+
# and delete permissions/remote actor if necessary
|
17
|
+
end
|
18
|
+
|
19
|
+
logger.debug request.body.read
|
20
|
+
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
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class RemoteusersController < ApplicationController
|
2
|
+
before_filter :authenticate_user!
|
3
|
+
|
4
|
+
def index
|
5
|
+
if params[:slug].present?
|
6
|
+
wfslug = params[:slug].split('@')
|
7
|
+
a = RemoteUser.create!(:name => wfslug[0],
|
8
|
+
:webfinger_slug => params[:slug],
|
9
|
+
:origin_node_url => wfslug[1],
|
10
|
+
:hub_url => Social2social.hub)
|
11
|
+
home_feed = 'http://'+a.origin_node_url+'/api/user/'+a.name+'/home/'
|
12
|
+
puts home_feed
|
13
|
+
#TO-DO: I'M WORKING HERE
|
14
|
+
end
|
15
|
+
|
16
|
+
respond_to do |format|
|
17
|
+
format.html
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Social2social::InstallGenerator < Rails::Generators::Base
|
2
|
+
include Rails::Generators::Migration
|
3
|
+
|
4
|
+
hook_for :social_stream
|
5
|
+
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def route_pshb
|
9
|
+
route "match 'pshb/callback' => 'pshb#callback', :as => :pshb_callback"
|
10
|
+
end
|
11
|
+
|
12
|
+
def route_ru
|
13
|
+
route "match 'remoteuser/' => 'remoteusers#index', :as => :add_remote_user"
|
14
|
+
end
|
15
|
+
|
16
|
+
def config_initializer
|
17
|
+
copy_file 'initializer.rb', 'config/initializers/social2social.rb'
|
18
|
+
end
|
19
|
+
|
20
|
+
def inject_remote_user_relation
|
21
|
+
append_file 'config/relations.yml',
|
22
|
+
"\nremote_user:\n friend:\n name: friend\n permissions:\n - [ follow ]\n"+
|
23
|
+
" public:\n name: public\n permissions:\n - [ read, tie, star_tie ]"
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'rails/generators/active_record'
|
27
|
+
|
28
|
+
def self.next_migration_number(dirname)
|
29
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_migration_file
|
33
|
+
migration_template 'migration.rb', 'db/migrate/create_social2social.rb'
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateSocial2social < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
create_table :remote_users, :force => true do |t|
|
5
|
+
t.integer :actor_id
|
6
|
+
t.string :webfinger_slug
|
7
|
+
t.string :hub_url
|
8
|
+
t.string :origin_node_url
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index "remote_users", "actor_id"
|
13
|
+
add_foreign_key "remote_users", "actors", :name => "remote_users_on_actor_id"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.down
|
17
|
+
remove_foreign_key "remote_users", :name => "remote_users_on_actor_id"
|
18
|
+
drop_table :remote_users
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Social2social
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
config.app_generators.social_stream :social_stream
|
4
|
+
|
5
|
+
config.to_prepare do
|
6
|
+
SocialStream.subjects << :remote_user
|
7
|
+
::Actor.load_subtype_features
|
8
|
+
|
9
|
+
class ::Actor
|
10
|
+
include Social2social::Models::Shareable
|
11
|
+
end
|
12
|
+
|
13
|
+
TieActivity
|
14
|
+
|
15
|
+
class ::TieActivity
|
16
|
+
include Social2social::Models::UpdateTriggerable
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "uri"
|
3
|
+
|
4
|
+
module Social2social
|
5
|
+
module Models
|
6
|
+
module Shareable
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
after_create :init_feeds_to_hub
|
11
|
+
end
|
12
|
+
|
13
|
+
module InstanceMethods
|
14
|
+
def init_feeds_to_hub
|
15
|
+
publish_or_update_home_feed
|
16
|
+
#TO-DO: add calls to other public feeds if any
|
17
|
+
end
|
18
|
+
|
19
|
+
def publish_or_update_home_feed
|
20
|
+
t = Thread.new do
|
21
|
+
hub = Social2social.hub
|
22
|
+
topic = Social2social.node_base_url+'/api/user/'+self.slug+'/home.atom'
|
23
|
+
|
24
|
+
uri = URI.parse(hub)
|
25
|
+
response = Net::HTTP::post_form(uri,{ 'hub.mode' => 'publish',
|
26
|
+
'hub.url' => topic})
|
27
|
+
#TO-DO: process 4XX look at: response.status
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Social2social
|
2
|
+
module Models
|
3
|
+
module UpdateTriggerable
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
after_create :update_feed_to_hub
|
8
|
+
end
|
9
|
+
|
10
|
+
module InstanceMethods
|
11
|
+
def update_feed_to_hub
|
12
|
+
if self.original
|
13
|
+
self.tie.sender.publish_or_update_home_feed
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'social_stream'
|
2
|
+
|
3
|
+
module Social2social
|
4
|
+
|
5
|
+
mattr_accessor :hub
|
6
|
+
@@hub = :hub
|
7
|
+
|
8
|
+
mattr_accessor :node_base_url
|
9
|
+
@@node_base_url = :node_base_url
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def setup
|
13
|
+
yield self
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Models
|
18
|
+
autoload :Shareable, 'social2social/models/shareable'
|
19
|
+
autoload :UpdateTriggerable, 'social2social/models/updatetriggerable'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'social2social/engine'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "social2social"
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.authors = ["Víctor Sánchez Belmar"]
|
5
|
+
s.summary = "Provides a social stream node able to decentralize contents with the OStatus protocol"
|
6
|
+
s.description = "This gem allow you to connect several social stream nodes using PSHB hubs, also allows to follow, and share streams with social stream users in any node."
|
7
|
+
s.email = "v.sanchezbelmar@gmail.com"
|
8
|
+
s.homepage = "http://github.com/ging/social2social"
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
|
11
|
+
# Gem dependencies
|
12
|
+
s.add_runtime_dependency('social_stream','~> 0.4.3')
|
13
|
+
# Development Gem dependencies
|
14
|
+
s.add_development_dependency('rails', '~> 3.0.5')
|
15
|
+
s.add_development_dependency('sqlite3-ruby')
|
16
|
+
if RUBY_VERSION < '1.9'
|
17
|
+
s.add_development_dependency('ruby-debug', '~> 0.10.3')
|
18
|
+
end
|
19
|
+
s.add_development_dependency('rspec-rails', '~> 2.5.0')
|
20
|
+
s.add_development_dependency('factory_girl', '~> 1.3.2')
|
21
|
+
s.add_development_dependency('forgery', '~> 0.3.6')
|
22
|
+
s.add_development_dependency('capybara', '~> 0.3.9')
|
23
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "active_model/railtie"
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_view/railtie"
|
7
|
+
require "action_mailer/railtie"
|
8
|
+
|
9
|
+
Bundler.require
|
10
|
+
require "social2social"
|
11
|
+
|
12
|
+
module Dummy
|
13
|
+
class Application < Rails::Application
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
|
18
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
19
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
20
|
+
|
21
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
+
|
25
|
+
# Activate observers that should always be running.
|
26
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
+
|
28
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
+
|
32
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
+
# config.i18n.default_locale = :de
|
35
|
+
|
36
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
37
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
38
|
+
|
39
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
40
|
+
config.encoding = "utf-8"
|
41
|
+
|
42
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
43
|
+
config.filter_parameters += [:password]
|
44
|
+
end
|
45
|
+
end
|