social_stream 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +16 -0
- data/Gemfile.lock +117 -0
- data/LICENSE +20 -0
- data/README.rdoc +63 -0
- data/Rakefile +43 -0
- data/app/controllers/home_controller.rb +3 -0
- data/app/helpers/activities_helper.rb +10 -0
- data/app/models/activity.rb +75 -0
- data/app/models/activity_object.rb +18 -0
- data/app/models/activity_object_activity.rb +4 -0
- data/app/models/activity_verb.rb +14 -0
- data/app/models/actor.rb +31 -0
- data/app/models/permission.rb +4 -0
- data/app/models/relation.rb +73 -0
- data/app/models/relation_permission.rb +4 -0
- data/app/models/tie.rb +207 -0
- data/app/models/user.rb +82 -0
- data/app/views/activities/_activity.html.erb +5 -0
- data/app/views/activities/_activity_options.html.erb +8 -0
- data/app/views/activities/_jquery.html.erb +52 -0
- data/app/views/activities/_new.html.erb +13 -0
- data/app/views/activities/_root_activity.html.erb +44 -0
- data/app/views/activities/_subactivity.html.erb +23 -0
- data/app/views/activities/_subactivity_options.html.erb +7 -0
- data/app/views/devise/registrations/new.html.erb +21 -0
- data/app/views/home/_activities.html.erb +19 -0
- data/app/views/home/_location.html.erb +3 -0
- data/app/views/home/index.html.erb +4 -0
- data/app/views/ties/_pending.html.erb +33 -0
- data/config/locales/en.yml +29 -0
- data/lib/generators/social_stream/USAGE +9 -0
- data/lib/generators/social_stream/install_generator.rb +30 -0
- data/lib/generators/social_stream/templates/initializer.rb +14 -0
- data/lib/generators/social_stream/templates/migration.rb +131 -0
- data/lib/generators/social_stream/templates/seeds.yml +29 -0
- data/lib/social_stream.rb +49 -0
- data/lib/social_stream/models/activity_object.rb +59 -0
- data/lib/social_stream/models/actor.rb +30 -0
- data/lib/social_stream/models/supertype.rb +41 -0
- data/lib/social_stream/rails.rb +13 -0
- data/lib/social_stream/rails/common.rb +34 -0
- data/lib/social_stream/rails/engine.rb +7 -0
- data/lib/social_stream/rails/railtie.rb +7 -0
- data/lib/social_stream/rails/routes.rb +17 -0
- data/lib/social_stream/seed.rb +47 -0
- data/lib/social_stream/version.rb +3 -0
- metadata +144 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module SocialStream
|
4
|
+
module Models
|
5
|
+
# Additional features for models that are actors
|
6
|
+
module Actor
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
belongs_to :actor,
|
11
|
+
:validate => true,
|
12
|
+
:autosave => true
|
13
|
+
|
14
|
+
delegate :name, :name=,
|
15
|
+
:email, :email=,
|
16
|
+
:permalink, :permalink=,
|
17
|
+
:disabled, :disabled=,
|
18
|
+
:ties, :sent_ties, :received_ties,
|
19
|
+
:wall,
|
20
|
+
:to => :actor!
|
21
|
+
end
|
22
|
+
|
23
|
+
module InstanceMethods
|
24
|
+
def actor!
|
25
|
+
actor || build_actor
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module SocialStream #:nodoc:
|
4
|
+
module Models
|
5
|
+
module Supertype
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
subtypes.each do |s|
|
10
|
+
has_one s, :dependent => :destroy
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
def subtypes
|
16
|
+
SocialStream.__send__ to_s.tableize
|
17
|
+
end
|
18
|
+
|
19
|
+
def load_subtype_features
|
20
|
+
features = "SocialStream::Models::#{ to_s }".constantize
|
21
|
+
|
22
|
+
subtypes.each do |s|
|
23
|
+
s = s.to_s.classify.constantize
|
24
|
+
s.__send__(:include, features) unless s.ancestors.include?(features)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module InstanceMethods
|
30
|
+
def subtype_instance
|
31
|
+
self.class.subtypes.each do |s|
|
32
|
+
i = __send__(s)
|
33
|
+
return i if i.present?
|
34
|
+
end
|
35
|
+
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Load Devise constant
|
2
|
+
require 'devise'
|
3
|
+
require 'social_stream/rails/common'
|
4
|
+
File.expand_path(__FILE__) =~ /#{ File.join('vendor', 'plugins') }/ ?
|
5
|
+
require('social_stream/rails/railtie') :
|
6
|
+
require('social_stream/rails/engine')
|
7
|
+
|
8
|
+
require 'social_stream/rails/routes'
|
9
|
+
|
10
|
+
module SocialStream
|
11
|
+
module Rails #:nodoc:
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module SocialStream
|
2
|
+
module Rails
|
3
|
+
# Common methods for Rails::Railtie and Rails::Engine
|
4
|
+
module Common #:nodoc:
|
5
|
+
class << self
|
6
|
+
def inflections
|
7
|
+
ActiveSupport::Inflector.inflections do |inflect|
|
8
|
+
inflect.singular /^([Tt]ie)s$/, '\1'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def included(base)
|
13
|
+
base.class_eval do
|
14
|
+
config.generators.authentication :devise
|
15
|
+
|
16
|
+
config.to_prepare do
|
17
|
+
%w( actor activity_object ).each do |supertype|
|
18
|
+
supertype.classify.constantize.load_subtype_features
|
19
|
+
end
|
20
|
+
|
21
|
+
# https://rails.lighthouseapp.com/projects/8994/tickets/1905-apphelpers-within-plugin-not-being-mixed-in
|
22
|
+
ApplicationController.helper ActivitiesHelper
|
23
|
+
end
|
24
|
+
|
25
|
+
initializer "social_stream.inflections" do
|
26
|
+
Common.inflections
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ActionDispatch::Routing
|
2
|
+
class Mapper
|
3
|
+
# Includes routes for SocialStream. Use it inside your routes file
|
4
|
+
# social_stream
|
5
|
+
def social_stream
|
6
|
+
devise_for :users
|
7
|
+
resources :users
|
8
|
+
|
9
|
+
match 'home' => 'home#index', :as => :home
|
10
|
+
|
11
|
+
resources :ties
|
12
|
+
resources :activities do
|
13
|
+
resource :like
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module SocialStream
|
2
|
+
# Seed you database with initial data for SocialStream
|
3
|
+
#
|
4
|
+
class Seed
|
5
|
+
def initialize(config)
|
6
|
+
s = YAML.load_file(config)
|
7
|
+
|
8
|
+
seed_activity_verbs
|
9
|
+
seed_relations(s['relations'])
|
10
|
+
end
|
11
|
+
|
12
|
+
def seed_activity_verbs
|
13
|
+
ActivityVerb::Available.each do |value|
|
14
|
+
ActivityVerb.find_or_create_by_name value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def seed_relations(rs)
|
19
|
+
relations = {}
|
20
|
+
|
21
|
+
rs.each_pair do |name, r|
|
22
|
+
relations[name] =
|
23
|
+
Relation.
|
24
|
+
find_or_create_by_sender_type_and_receiver_type_and_name(r['sender_type'],
|
25
|
+
r['receiver_type'],
|
26
|
+
r['name'])
|
27
|
+
# FIXME: optimize
|
28
|
+
relations[name].relation_permissions.destroy_all
|
29
|
+
|
30
|
+
if (ps = r['permissions']).present?
|
31
|
+
ps.each do |p|
|
32
|
+
relations[name].permissions <<
|
33
|
+
Permission.find_or_create_by_action_and_object_and_parameter(*p)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Parent, inverse and granted relations must be set after creation
|
39
|
+
rs.each_pair do |name, r|
|
40
|
+
%w( parent inverse granted ).each do |s|
|
41
|
+
relations[name].__send__("#{ s }=", relations[r[s]]) # relations[name].parent = relations[r['parent']]
|
42
|
+
end
|
43
|
+
relations[name].save!
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: social_stream
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Antonio Tapiador
|
14
|
+
- Diego Carrera
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2010-10-18 00:00:00 +02:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: atd-ancestry
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 27
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 3
|
34
|
+
- 0
|
35
|
+
version: 1.3.0
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: devise
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 21
|
47
|
+
segments:
|
48
|
+
- 1
|
49
|
+
- 1
|
50
|
+
- 3
|
51
|
+
version: 1.1.3
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
54
|
+
description: Ruby on Rails plug-in supporting social networking features and activity streams.
|
55
|
+
email:
|
56
|
+
executables: []
|
57
|
+
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
extra_rdoc_files: []
|
61
|
+
|
62
|
+
files:
|
63
|
+
- Gemfile.lock
|
64
|
+
- LICENSE
|
65
|
+
- Rakefile
|
66
|
+
- Gemfile
|
67
|
+
- README.rdoc
|
68
|
+
- app/helpers/activities_helper.rb
|
69
|
+
- app/models/activity_object.rb
|
70
|
+
- app/models/relation_permission.rb
|
71
|
+
- app/models/tie.rb
|
72
|
+
- app/models/user.rb
|
73
|
+
- app/models/permission.rb
|
74
|
+
- app/models/actor.rb
|
75
|
+
- app/models/activity_object_activity.rb
|
76
|
+
- app/models/activity.rb
|
77
|
+
- app/models/relation.rb
|
78
|
+
- app/models/activity_verb.rb
|
79
|
+
- app/controllers/home_controller.rb
|
80
|
+
- app/views/ties/_pending.html.erb
|
81
|
+
- app/views/devise/registrations/new.html.erb
|
82
|
+
- app/views/activities/_activity.html.erb
|
83
|
+
- app/views/activities/_activity_options.html.erb
|
84
|
+
- app/views/activities/_subactivity_options.html.erb
|
85
|
+
- app/views/activities/_jquery.html.erb
|
86
|
+
- app/views/activities/_new.html.erb
|
87
|
+
- app/views/activities/_root_activity.html.erb
|
88
|
+
- app/views/activities/_subactivity.html.erb
|
89
|
+
- app/views/home/_activities.html.erb
|
90
|
+
- app/views/home/index.html.erb
|
91
|
+
- app/views/home/_location.html.erb
|
92
|
+
- config/locales/en.yml
|
93
|
+
- lib/social_stream.rb
|
94
|
+
- lib/social_stream/seed.rb
|
95
|
+
- lib/social_stream/models/activity_object.rb
|
96
|
+
- lib/social_stream/models/actor.rb
|
97
|
+
- lib/social_stream/models/supertype.rb
|
98
|
+
- lib/social_stream/rails.rb
|
99
|
+
- lib/social_stream/rails/railtie.rb
|
100
|
+
- lib/social_stream/rails/common.rb
|
101
|
+
- lib/social_stream/rails/engine.rb
|
102
|
+
- lib/social_stream/rails/routes.rb
|
103
|
+
- lib/social_stream/version.rb
|
104
|
+
- lib/generators/social_stream/templates/migration.rb
|
105
|
+
- lib/generators/social_stream/templates/seeds.yml
|
106
|
+
- lib/generators/social_stream/templates/initializer.rb
|
107
|
+
- lib/generators/social_stream/install_generator.rb
|
108
|
+
- lib/generators/social_stream/USAGE
|
109
|
+
has_rdoc: true
|
110
|
+
homepage:
|
111
|
+
licenses: []
|
112
|
+
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 3
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
version: "0"
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
hash: 3
|
133
|
+
segments:
|
134
|
+
- 0
|
135
|
+
version: "0"
|
136
|
+
requirements: []
|
137
|
+
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 1.3.7
|
140
|
+
signing_key:
|
141
|
+
specification_version: 3
|
142
|
+
summary: Social networking features and activity streams.
|
143
|
+
test_files: []
|
144
|
+
|