social_stream 0.3.6 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +6 -0
  3. data/app/controllers/api_controller.rb +39 -0
  4. data/app/controllers/frontpage_controller.rb +2 -0
  5. data/app/controllers/groups_controller.rb +8 -2
  6. data/app/controllers/likes_controller.rb +9 -29
  7. data/app/controllers/logos_controller.rb +21 -0
  8. data/app/controllers/mailbox/conversation_controller.rb +110 -0
  9. data/app/controllers/mailbox_controller.rb +35 -0
  10. data/app/controllers/posts_controller.rb +2 -0
  11. data/app/controllers/profiles_controller.rb +3 -0
  12. data/app/controllers/ties_controller.rb +10 -0
  13. data/app/controllers/users_controller.rb +5 -5
  14. data/app/helpers/groups_helper.rb +0 -2
  15. data/app/helpers/subjects_helper.rb +11 -0
  16. data/app/helpers/ties_helper.rb +1 -1
  17. data/app/models/activity.rb +24 -1
  18. data/app/models/activity_object.rb +10 -0
  19. data/app/models/activity_object_activity.rb +10 -0
  20. data/app/models/actor.rb +87 -60
  21. data/app/models/group.rb +10 -4
  22. data/app/models/like.rb +34 -0
  23. data/app/models/logo.rb +51 -0
  24. data/app/models/permission.rb +7 -5
  25. data/app/models/profile.rb +24 -8
  26. data/app/models/tie.rb +15 -2
  27. data/app/models/user.rb +2 -2
  28. data/app/views/activities/_activities.html.erb +1 -1
  29. data/app/views/activities/_new.html.erb +12 -7
  30. data/app/views/api/activity_atom_feed.atom.builder +40 -0
  31. data/app/views/comments/_new.html.erb +1 -1
  32. data/app/views/devise/passwords/edit.html.erb +21 -0
  33. data/app/views/devise/passwords/new.html.erb +16 -0
  34. data/app/views/devise/registrations/new.html.erb +35 -19
  35. data/app/views/devise/sessions/new.html.erb +30 -0
  36. data/app/views/frontpage/_header.html.erb +18 -20
  37. data/app/views/frontpage/_search.html.erb +13 -0
  38. data/app/views/frontpage/_sponsor.html.erb +12 -13
  39. data/app/views/frontpage/index.html.erb +88 -80
  40. data/app/views/groups/_group.html.erb +2 -6
  41. data/app/views/groups/_index.html.erb +22 -25
  42. data/app/views/groups/_logo.html.erb +1 -1
  43. data/app/views/groups/_new.html.erb +56 -39
  44. data/app/views/groups/_profile.html.erb +142 -0
  45. data/app/views/groups/_sidebar_index.html.erb +73 -0
  46. data/app/views/groups/{_middle_show.html.erb → _sidebar_show.html.erb} +2 -2
  47. data/app/views/groups/_tabs.html.erb +37 -31
  48. data/app/views/groups/_toolbar_show.html.erb +12 -0
  49. data/app/views/groups/edit.html.erb +136 -0
  50. data/app/views/groups/index.html.erb +47 -46
  51. data/app/views/groups/new.html.erb +2 -0
  52. data/app/views/groups/show.html.erb +9 -4
  53. data/app/views/groups/update.js.erb +39 -0
  54. data/app/views/home/_groups.html.erb +4 -5
  55. data/app/views/{users/_middle_index.html.erb → home/_sidebar.html.erb} +0 -2
  56. data/app/views/home/index.html.erb +3 -5
  57. data/app/views/layouts/_footer.html.erb +4 -0
  58. data/app/views/layouts/_header.erb +29 -37
  59. data/app/views/layouts/_representation.html.erb +2 -2
  60. data/app/views/layouts/application.html.erb +47 -74
  61. data/app/views/layouts/frontpage.html.erb +27 -48
  62. data/app/views/layouts/test.html +44 -0
  63. data/app/views/likes/create.js.erb +1 -1
  64. data/app/views/likes/destroy.js.erb +1 -1
  65. data/app/views/logos/_form.html.erb +33 -0
  66. data/app/views/logos/_precrop.html.erb +48 -0
  67. data/app/views/logos/edit.html.erb +6 -0
  68. data/app/views/logos/index.html.erb +27 -0
  69. data/app/views/logos/new.html.erb +20 -0
  70. data/app/views/logos/show.html.erb +5 -0
  71. data/app/views/mailbox/_conversation.html.erb +23 -0
  72. data/app/views/mailbox/_conversations.html.erb +9 -0
  73. data/app/views/mailbox/_index.html.erb +16 -0
  74. data/app/views/{messages → mailbox}/_location.html.erb +0 -0
  75. data/app/views/mailbox/_menu_options.html.erb +19 -0
  76. data/app/views/mailbox/_show.html.erb +15 -0
  77. data/app/views/mailbox/conversation/_conversation.html.erb +40 -0
  78. data/app/views/mailbox/conversation/_form.html.erb +54 -0
  79. data/app/views/mailbox/conversation/_location.html.erb +3 -0
  80. data/app/views/mailbox/conversation/_new.html.erb +19 -0
  81. data/app/views/mailbox/conversation/_show.html.erb +27 -0
  82. data/app/views/mailbox/conversation/edit.html.erb +6 -0
  83. data/app/views/mailbox/conversation/new.html.erb +10 -0
  84. data/app/views/mailbox/conversation/new.js.erb +1 -0
  85. data/app/views/mailbox/conversation/show.html.erb +1 -0
  86. data/app/views/{messages → mailbox}/edit.html.erb +0 -0
  87. data/app/views/mailbox/index.html.erb +10 -0
  88. data/app/views/{messages → mailbox}/index.js.erb +0 -0
  89. data/app/views/mailbox/new.html.erb +14 -0
  90. data/app/views/mailbox/show.html.erb +11 -0
  91. data/app/views/mailbox/show.js.erb +1 -0
  92. data/app/views/menu/_group.html.erb +15 -0
  93. data/{lib/generators/social_stream/templates/public/stylesheets/users.css → app/views/menu/_home_user.html.erb} +0 -0
  94. data/app/views/menu/_options.html.erb +11 -0
  95. data/app/views/menu/_services.html.erb +11 -0
  96. data/app/views/menu/_tiesGroup.html.erb +14 -0
  97. data/app/views/menu/_tiesUser.html.erb +11 -0
  98. data/app/views/menu/_user.html.erb +15 -0
  99. data/app/views/profiles/show.html.erb +1 -0
  100. data/app/views/subjects/_contacts.html.erb +8 -9
  101. data/app/views/subjects/_menu_options.html.erb +14 -0
  102. data/app/views/subjects/_toolbar.html.erb +15 -0
  103. data/app/views/ties/_new.html.erb +3 -2
  104. data/app/views/ties/_pendings.html.erb +7 -12
  105. data/app/views/ties/_suggestions.html.erb +12 -12
  106. data/app/views/ties/_tie.html.erb +9 -7
  107. data/app/views/ties/new.js.erb +1 -2
  108. data/app/views/users/_groups.html.erb +4 -3
  109. data/app/views/users/_index.html.erb +24 -22
  110. data/app/views/users/_logo.html.erb +1 -1
  111. data/app/views/users/_profile.html.erb +167 -164
  112. data/app/views/users/_sidebar_index.html.erb +6 -0
  113. data/app/views/users/{_middle_show.html.erb → _sidebar_show.html.erb} +0 -0
  114. data/app/views/users/_toolbar_show.html.erb +17 -0
  115. data/app/views/users/edit.html.erb +193 -165
  116. data/app/views/users/index.html.erb +34 -47
  117. data/{spec/dummy/public/stylesheets/.gitkeep → app/views/users/info.html.erb} +0 -0
  118. data/app/views/users/show.html.erb +4 -4
  119. data/app/views/users/show.xml.builder +28 -0
  120. data/app/views/users/update.js.erb +3 -1
  121. data/config/locales/en.yml +88 -9
  122. data/config/routes.rb +30 -14
  123. data/lib/generators/social_stream/install_generator.rb +8 -2
  124. data/lib/generators/social_stream/templates/migration.rb +75 -81
  125. data/lib/generators/social_stream/templates/public/images/{frontpage/facebook.png → btn/1-facebook.png} +0 -0
  126. data/lib/generators/social_stream/templates/public/images/btn/edit.png +0 -0
  127. data/lib/generators/social_stream/templates/public/images/btn/facebook.png +0 -0
  128. data/lib/generators/social_stream/templates/public/images/btn/linkedin.png +0 -0
  129. data/lib/generators/social_stream/templates/public/images/btn/twitter-follow-icon.png +0 -0
  130. data/lib/generators/social_stream/templates/public/images/btn/twitter.png +0 -0
  131. data/lib/generators/social_stream/templates/public/images/frontpage/collaborate.png +0 -0
  132. data/lib/generators/social_stream/templates/public/images/frontpage/meet.png +0 -0
  133. data/lib/generators/social_stream/templates/public/images/frontpage/share.png +0 -0
  134. data/lib/generators/social_stream/templates/public/images/icons/favicon.ico +0 -0
  135. data/lib/generators/social_stream/templates/public/images/logo.png +0 -0
  136. data/lib/generators/social_stream/templates/public/images/w3c_css.png +0 -0
  137. data/lib/generators/social_stream/templates/public/images/w3c_xhtml.png +0 -0
  138. data/lib/generators/social_stream/templates/public/javascripts/jquery-ui-1.8.4.custom.min.js +3 -3
  139. data/lib/generators/social_stream/templates/public/javascripts/jquery-ui-personalized-1.5.2.packed.js +1 -0
  140. data/lib/generators/social_stream/templates/public/javascripts/jquery-ui.min.js +3 -3
  141. data/lib/generators/social_stream/templates/public/javascripts/jquery.Jcrop.min.js +163 -0
  142. data/lib/generators/social_stream/templates/public/javascripts/jquery.fcbkcomplete.min.js +76 -76
  143. data/lib/generators/social_stream/templates/public/javascripts/jquery.min.js +156 -5
  144. data/lib/generators/social_stream/templates/public/javascripts/main.js +9 -0
  145. data/lib/generators/social_stream/templates/public/javascripts/menu-collapsed.js +42 -0
  146. data/lib/generators/social_stream/templates/public/javascripts/menu.js +1 -1
  147. data/lib/generators/social_stream/templates/public/javascripts/rails.js +30 -29
  148. data/lib/generators/social_stream/templates/public/javascripts/superfish.js +121 -0
  149. data/lib/generators/social_stream/templates/public/stylesheets/default/activities.css +72 -0
  150. data/lib/generators/social_stream/templates/public/stylesheets/default/base.css +150 -0
  151. data/lib/generators/social_stream/templates/public/stylesheets/default/carousel.css +23 -0
  152. data/lib/generators/social_stream/templates/public/stylesheets/{fcbkComplete.css → default/fcbkComplete.css} +2 -2
  153. data/lib/generators/social_stream/templates/public/stylesheets/default/footer.css +25 -0
  154. data/lib/generators/social_stream/templates/public/stylesheets/default/frontpage.css +54 -0
  155. data/lib/generators/social_stream/templates/public/stylesheets/default/header.css +44 -0
  156. data/lib/generators/social_stream/templates/public/stylesheets/default/home.css +44 -0
  157. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  158. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_flat_75_ffffff_40x100.png +0 -0
  159. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  160. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_65_ffffff_1x400.png +0 -0
  161. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_75_dadada_1x400.png +0 -0
  162. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  163. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  164. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  165. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_222222_256x240.png +0 -0
  166. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_2e83ff_256x240.png +0 -0
  167. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_454545_256x240.png +0 -0
  168. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_888888_256x240.png +0 -0
  169. data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_cd0a0a_256x240.png +0 -0
  170. data/lib/generators/social_stream/templates/public/stylesheets/default/jqcloud.css +15 -0
  171. data/lib/generators/social_stream/templates/public/stylesheets/{jquery-ui.css → default/jquery-ui.css} +0 -0
  172. data/lib/generators/social_stream/templates/public/stylesheets/default/jquery.Jcrop.css +35 -0
  173. data/lib/generators/social_stream/templates/public/stylesheets/default/menu.css +33 -0
  174. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  175. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  176. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  177. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  178. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  179. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  180. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  181. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  182. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_222222_256x240.png +0 -0
  183. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_2e83ff_256x240.png +0 -0
  184. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_454545_256x240.png +0 -0
  185. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_888888_256x240.png +0 -0
  186. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_cd0a0a_256x240.png +0 -0
  187. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/jquery-ui-1.7.3.custom.css +0 -0
  188. data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/jquery-ui-1.8.4.custom.css +0 -0
  189. data/lib/social_stream.rb +11 -2
  190. data/lib/social_stream/ability.rb +21 -3
  191. data/lib/social_stream/models/object.rb +5 -3
  192. data/lib/social_stream/models/subject.rb +50 -31
  193. data/lib/social_stream/rails.rb +5 -0
  194. data/lib/social_stream/test_helpers.rb +11 -0
  195. data/lib/social_stream/test_helpers/controllers.rb +64 -0
  196. data/lib/social_stream/version.rb +1 -1
  197. data/lib/tasks/db/populate.rake +110 -25
  198. data/social_stream.gemspec +7 -1
  199. data/spec/controllers/contacts_controller_spec.rb +1 -1
  200. data/spec/controllers/groups_controller_spec.rb +8 -0
  201. data/spec/controllers/home_controller_spec.rb +15 -0
  202. data/spec/controllers/likes_controller_spec.rb +29 -0
  203. data/spec/controllers/posts_controller_spec.rb +41 -0
  204. data/spec/controllers/profiles_controller_spec.rb +46 -0
  205. data/spec/controllers/users_controller_spec.rb +2 -2
  206. data/spec/dummy/.gitignore +4 -0
  207. data/spec/dummy/config/database.yml +8 -0
  208. data/spec/dummy/config/environments/test_pg.rb +35 -0
  209. data/spec/dummy/config/routes.rb +2 -0
  210. data/spec/factories/group.rb +1 -1
  211. data/spec/integration/navigation_spec.rb +1 -1
  212. data/spec/models/actor_spec.rb +4 -4
  213. data/spec/models/user_spec.rb +2 -2
  214. data/spec/spec_helper.rb +1 -1
  215. data/spec/support/db.rb +7 -0
  216. metadata +198 -116
  217. data/app/controllers/messages_controller.rb +0 -3
  218. data/app/models/message.rb +0 -2
  219. data/app/views/groups/_middle_index.html.erb +0 -74
  220. data/app/views/groups/_right_index.html.erb +0 -19
  221. data/app/views/groups/_right_show.html.erb +0 -8
  222. data/app/views/home/_middle.html.erb +0 -4
  223. data/app/views/home/_options.html.erb +0 -8
  224. data/app/views/home/_right.html.erb +0 -17
  225. data/app/views/messages/_form.html.erb +0 -24
  226. data/app/views/messages/_index.html.erb +0 -24
  227. data/app/views/messages/_message.html.erb +0 -17
  228. data/app/views/messages/_messages.html.erb +0 -2
  229. data/app/views/messages/index.html.erb +0 -1
  230. data/app/views/messages/new.html.erb +0 -14
  231. data/app/views/messages/show.html.erb +0 -21
  232. data/app/views/users/_menu.html.erb +0 -7
  233. data/app/views/users/_options.html.erb +0 -5
  234. data/app/views/users/_right_index.html.erb +0 -19
  235. data/app/views/users/_right_show.html.erb +0 -14
  236. data/lib/generators/social_stream/templates/public/images/btn/btn_share.png +0 -0
  237. data/lib/generators/social_stream/templates/public/images/favicon.ico +0 -0
  238. data/lib/generators/social_stream/templates/public/images/frontpage/collaborate.gif +0 -0
  239. data/lib/generators/social_stream/templates/public/images/frontpage/meet.gif +0 -0
  240. data/lib/generators/social_stream/templates/public/images/frontpage/share.gif +0 -0
  241. data/lib/generators/social_stream/templates/public/javascripts/hoverIntent.js +0 -84
  242. data/lib/generators/social_stream/templates/public/stylesheets/activities.css +0 -235
  243. data/lib/generators/social_stream/templates/public/stylesheets/base.css +0 -68
  244. data/lib/generators/social_stream/templates/public/stylesheets/boxy.css +0 -49
  245. data/lib/generators/social_stream/templates/public/stylesheets/browse.css +0 -162
  246. data/lib/generators/social_stream/templates/public/stylesheets/carousel.css +0 -57
  247. data/lib/generators/social_stream/templates/public/stylesheets/edit_user.css +0 -104
  248. data/lib/generators/social_stream/templates/public/stylesheets/frontpage.css +0 -708
  249. data/lib/generators/social_stream/templates/public/stylesheets/header.css +0 -116
  250. data/lib/generators/social_stream/templates/public/stylesheets/home.css +0 -121
  251. data/lib/generators/social_stream/templates/public/stylesheets/index.css +0 -625
  252. data/lib/generators/social_stream/templates/public/stylesheets/jqcloud.css +0 -62
  253. data/lib/generators/social_stream/templates/public/stylesheets/menu.css +0 -83
  254. data/lib/generators/social_stream/templates/public/stylesheets/message.css +0 -46
  255. data/lib/generators/social_stream/templates/public/stylesheets/middle.css +0 -113
  256. data/lib/generators/social_stream/templates/public/stylesheets/right.css +0 -58
  257. data/lib/generators/social_stream/templates/public/stylesheets/social_stream.css +0 -78
  258. data/lib/generators/social_stream/templates/public/stylesheets/ui.dropdownchecklist.css +0 -21
  259. data/spec/dummy/db/.gitignore +0 -2
  260. data/spec/dummy/log/.gitignore +0 -1
  261. data/spec/dummy/public/javascripts/application.js +0 -2
  262. data/spec/dummy/public/javascripts/controls.js +0 -965
  263. data/spec/dummy/public/javascripts/dragdrop.js +0 -974
  264. data/spec/dummy/public/javascripts/effects.js +0 -1123
  265. data/spec/dummy/public/javascripts/prototype.js +0 -6001
  266. data/spec/dummy/public/javascripts/rails.js +0 -175
@@ -18,10 +18,12 @@ module SocialStream
18
18
  alias_method_chain :create_activity_object, :type
19
19
  before_create :create_activity_object
20
20
 
21
- before_create :create_post_activity
22
- before_update :create_update_activity
21
+ unless self == Actor
22
+ before_create :create_post_activity
23
+ before_update :create_update_activity
23
24
 
24
- validates_presence_of :_activity_tie
25
+ validates_presence_of :_activity_tie
26
+ end
25
27
  end
26
28
 
27
29
  module InstanceMethods
@@ -11,61 +11,80 @@ module SocialStream
11
11
  # extending them. Including the module in each {Subject} model is not required!
12
12
  # After declared in +config/initializers/social_stream.rb+, {SocialStream} is
13
13
  # responsible for adding subject features to each model.
14
+ #
15
+ # = Scopes
16
+ # There are several scopes available for subjects
17
+ #
18
+ # alphabetic:: sort subjects by name
19
+ # search:: simple search by name
20
+ # distinct_initials:: get only the first letter of the name
21
+ # popular:: sort by most incoming {Tie ties}
22
+ #
14
23
  module Subject
15
24
  extend ActiveSupport::Concern
16
-
25
+
17
26
  included do
18
27
  belongs_to :actor,
19
28
  :validate => true,
20
29
  :autosave => true
21
-
22
- delegate :name, :name=,
23
- :email, :email=,
24
- :permalink,
25
- :logo, :logo=,
26
- :ties, :sent_ties, :received_ties,
27
- :ties_to,
28
- :sent_ties_allowing,
29
- :pending_ties,
30
- :relation, :relations,
31
- :actors, :subjects,
32
- :suggestions, :suggestion,
33
- :home_wall, :profile_wall,
34
- :to => :actor!
35
-
30
+
36
31
  has_one :profile, :through => :actor
37
-
32
+
38
33
  accepts_nested_attributes_for :profile
39
-
34
+
40
35
  validates_presence_of :name
41
-
36
+
42
37
  scope :alphabetic, includes(:actor).order('actors.name')
43
- scope :search, lambda{|param|
44
- joins(:actor).where('actors.name like ?',param)}
38
+ scope :search, lambda{ |param|
39
+ joins(:actor).where('actors.name like ?', param)
40
+ }
45
41
  scope :with_sent_ties, joins(:actor => :sent_ties)
46
42
  scope :with_received_ties, joins(:actor => :received_ties)
43
+ scope :distinct_initials, joins(:actor).select('DISTINCT SUBSTR(actors.name,1,1) as initial').order("initial ASC")
44
+ scope :popular, lambda {
45
+ joins(:actor => :received_ties).
46
+ select("DISTINCT #{ table_name }.*, COUNT(#{ table_name}.id) AS popularity").
47
+ group("#{ table_name }.id").
48
+ order("popularity DESC")
49
+ }
47
50
  end
48
-
51
+
49
52
  module InstanceMethods
50
53
  def actor!
51
54
  actor || build_actor(:subject_type => self.class.to_s)
52
55
  end
53
-
56
+
54
57
  def to_param
55
- permalink
58
+ slug
56
59
  end
57
- end
58
60
 
59
- module ClassMethods
60
- def find_by_permalink(perm)
61
- joins(:actor).where('actors.permalink' => perm).first
61
+ # Delegate missing methods to {Actor}, if they are defined there
62
+ def method_missing(method, *args, &block)
63
+ super
64
+ rescue NameError => subject_error
65
+ begin
66
+ actor!.__send__ method, *args, &block
67
+ rescue NameError
68
+ raise subject_error
69
+ end
62
70
  end
63
71
 
64
- def find_by_permalink!(perm)
65
- find_by_permalink(perm) ||
66
- raise(ActiveRecord::RecordNotFound)
72
+ # {Actor} handles some methods
73
+ def respond_to? *args
74
+ super || actor!.respond_to?(*args)
67
75
  end
68
76
  end
77
+
78
+ module ClassMethods
79
+ def find_by_slug(perm)
80
+ includes(:actor).where('actors.slug' => perm).first
81
+ end
82
+
83
+ def find_by_slug!(perm)
84
+ find_by_slug(perm) ||
85
+ raise(ActiveRecord::RecordNotFound)
86
+ end
87
+ end
69
88
  end
70
89
  end
71
90
  end
@@ -8,6 +8,8 @@ require 'stringex'
8
8
  require 'nested_set'
9
9
  # Hierarchical relationships in Activity:
10
10
  require 'ancestry'
11
+ # Messages
12
+ require 'mailboxer'
11
13
  # User authentication
12
14
  require 'devise'
13
15
  # Authorization
@@ -21,6 +23,8 @@ require 'paperclip/social_stream'
21
23
  require 'will_paginate'
22
24
  # Oauth
23
25
  require 'omniauth/oauth'
26
+ # CSS themes
27
+ require 'rails_css_themes'
24
28
 
25
29
  module SocialStream
26
30
  class Engine < ::Rails::Engine #:nodoc:
@@ -34,6 +38,7 @@ module SocialStream
34
38
 
35
39
  # https://rails.lighthouseapp.com/projects/8994/tickets/1905-apphelpers-within-plugin-not-being-mixed-in
36
40
  ApplicationController.helper ActivitiesHelper
41
+ ApplicationController.helper SubjectsHelper
37
42
  ApplicationController.helper TiesHelper
38
43
  end
39
44
 
@@ -0,0 +1,11 @@
1
+ module SocialStream
2
+ module TestHelpers
3
+ # Represent this subject
4
+ def represent(subject)
5
+ session[:subject_type] = subject.class.to_s
6
+ session[:subject_id] = subject.id
7
+
8
+ subject
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,64 @@
1
+ module SocialStream
2
+ module TestHelpers
3
+ module Controllers
4
+ # Post for PostsController
5
+ def model_class
6
+ @model_class ||=
7
+ described_class.to_s.sub!("Controller", "").singularize.constantize
8
+ end
9
+
10
+ # :post for PostsController
11
+ def model_sym
12
+ @model_sym ||=
13
+ model_class.to_s.underscore.to_sym
14
+ end
15
+
16
+ # Factory.attributes_for(:post) for PostsController
17
+ def model_attributes
18
+ @model_attributes ||=
19
+ Factory.attributes_for(model_sym)
20
+ end
21
+
22
+ def attributes
23
+ { model_sym => model_attributes }
24
+ end
25
+
26
+ # Post.count
27
+ def model_count
28
+ model_class.count
29
+ end
30
+
31
+ def model_assigned_to tie
32
+ model_attributes[:_activity_tie_id] = tie.id
33
+ end
34
+
35
+ shared_examples_for "Allow Creating" do
36
+ it "should create" do
37
+ count = model_count
38
+ post :create, attributes
39
+
40
+ resource = assigns(model_sym)
41
+
42
+ model_count.should eq(count + 1)
43
+ assert resource.valid?
44
+ response.should redirect_to(resource)
45
+ end
46
+ end
47
+
48
+ shared_examples_for "Deny Creating" do
49
+ it "should not create" do
50
+ count = model_count
51
+ begin
52
+ post :create, attributes
53
+ rescue CanCan::AccessDenied
54
+ end
55
+
56
+ resource = assigns(model_sym)
57
+
58
+ model_count.should eq(count)
59
+ resource.should be_new_record
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -1,3 +1,3 @@
1
1
  module SocialStream
2
- VERSION = "0.3.6".freeze
2
+ VERSION = "0.4.0".freeze
3
3
  end
@@ -1,21 +1,21 @@
1
1
  namespace :db do
2
2
  desc 'Populate database with fake data for development'
3
3
  task :populate => [ 'db:seed', 'db:populate:create' ]
4
-
4
+
5
5
  namespace :populate do
6
-
6
+
7
7
  desc "Reload populate data"
8
8
  task :reload => [ 'db:reset', :create ]
9
-
9
+
10
10
  desc "Create populate data"
11
11
  task :create => :environment do
12
-
12
+
13
13
  LOGOS_PATH = File.join(Rails.root, 'lib', 'logos')
14
-
14
+
15
15
  def set_logos(klass)
16
16
  klass.all.each do |i|
17
17
  logo = Dir[File.join(LOGOS_PATH, klass.to_s.tableize, "#{ i.id }.*")].first
18
-
18
+
19
19
  if logo.present? && File.exists?(logo)
20
20
  i.logo = File.new(logo)
21
21
  i.logo.reprocess!
@@ -23,9 +23,12 @@ namespace :db do
23
23
  end
24
24
  end
25
25
  end
26
-
26
+
27
+ puts 'User population'
28
+ users_start = Time.now
29
+
27
30
  # = Users
28
-
31
+
29
32
  # Create demo user if not present
30
33
  if User.find_by_name('demo').blank?
31
34
  User.create! :name => 'Demo',
@@ -33,60 +36,142 @@ namespace :db do
33
36
  :password => 'demonstration',
34
37
  :password_confirmation => 'demonstration'
35
38
  end
36
-
39
+
37
40
  require 'forgery'
38
-
41
+
39
42
  9.times do
40
43
  User.create! :name => Forgery::Name.full_name,
41
44
  :email => Forgery::Internet.email_address,
42
45
  :password => 'demonstration',
43
46
  :password_confirmation => 'demonstration'
44
47
  end
45
-
48
+
46
49
  set_logos(User)
47
-
50
+
51
+ users_end = Time.now
52
+ puts ' -> ' + (users_end - users_start).round(4).to_s + 's'
53
+
54
+ puts 'Groups population'
55
+ groups_start = Time.now
56
+
48
57
  # = Groups
49
58
  available_actors = Actor.all
50
-
59
+
51
60
  10.times do
52
61
  founder = available_actors[rand(available_actors.size)]
53
-
62
+
54
63
  Group.create :name => Forgery::Name.company_name,
55
64
  :email => Forgery::Internet.email_address,
56
- :_founder => founder.permalink
65
+ :_founder => founder.slug
57
66
  end
58
-
67
+
59
68
  set_logos(Group)
60
-
69
+
70
+ groups_end = Time.now
71
+ puts ' -> ' + (groups_end - groups_start).round(4).to_s + 's'
72
+
73
+
74
+ puts 'Ties population'
75
+ ties_start = Time.now
76
+
61
77
  # Reload actors to include groups
62
- available_actors = Actor.all
63
-
78
+ available_actors = Actor.all
79
+
64
80
  # = Ties
65
81
  available_actors.each do |a|
66
82
  actors = available_actors.dup - Array(a)
67
83
  relations = a.relations
68
-
84
+
69
85
  Forgery::Basic.number(:at_most => actors.size).times do
70
86
  actor = actors.delete_at((rand * actors.size).to_i)
71
87
  a.sent_ties.create :receiver => actor,
72
88
  :relation => relations.random
73
89
  end
74
90
  end
75
-
91
+
92
+ ties_end = Time.now
93
+ puts ' -> ' + (ties_end - ties_start).round(4).to_s + 's'
94
+
76
95
  # = Posts
77
-
96
+
97
+ puts 'Post population'
98
+ posts_start = Time.now
99
+
78
100
  SocialStream::Populate.power_law(Tie.all) do |t|
79
101
  updated = Time.at(rand(Time.now))
80
-
102
+
81
103
  p = Post.create :text =>
82
104
  "This post should be for #{ t.relation.name } of #{ t.sender.name }.\n#{ Forgery::LoremIpsum.paragraph(:random => true) }",
83
105
  :created_at => Time.at(rand(updated)),
84
106
  :updated_at => updated,
85
- :_activity_tie_id => t.id
86
-
107
+ :_activity_tie_id => t.id
108
+
87
109
  p.post_activity.update_attributes(:created_at => p.created_at,
88
110
  :updated_at => p.updated_at)
89
111
  end
112
+
113
+ posts_end = Time.now
114
+ puts ' -> ' + (posts_end - posts_start).round(4).to_s + 's'
115
+
116
+ puts 'Mailboxer population'
117
+ mailboxer_start = Time.now
118
+
119
+ # = Mailboxer
120
+ available_actors = Actor.all
121
+
122
+ available_actors.each do |a|
123
+ actors = available_actors.dup - Array(a)
124
+
125
+ mult_recp = actors.uniq
126
+ if (demo = User.find_by_name('demo')) and !mult_recp.include? Actor.normalize(demo)
127
+ mult_recp << Actor.normalize(demo)
128
+ end
129
+ actor = mult_recp[(rand * mult_recp.size).to_i]
130
+ mult_recp.delete(actor)
131
+ mail = actor.send_message(mult_recp, "Hello all, I am #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}", Forgery::LoremIpsum.words(10,:random => true))
132
+ actor = mult_recp[(rand * mult_recp.size).to_i]
133
+ mail = actor.reply_to_all(mail, "Well, I am #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
134
+ actor = mult_recp[(rand * mult_recp.size).to_i]
135
+ mail = actor.reply_to_all(mail, "Ok, I am #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
136
+ actor = mult_recp[(rand * mult_recp.size).to_i]
137
+ mail = actor.reply_to_all(mail, "Pretty well, I am #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
138
+ actor = mult_recp[(rand * mult_recp.size).to_i]
139
+ actor.reply_to_all(mail, "Finally, I am #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
140
+
141
+
142
+ if (demo = User.find_by_name('demo'))
143
+ next if Actor.normalize(demo)==Actor.normalize(a)
144
+ mail = a.send_message(demo, "Hello, #{demo.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}", Forgery::LoremIpsum.words(10,:random => true))
145
+ if rand > 0.5
146
+ mail = demo.reply_to_sender(mail, "Pretty well #{a.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
147
+ if rand > 0.5
148
+ a.reply_to_sender(mail, "Ok #{demo.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
149
+ end
150
+ end
151
+ if rand > 0.75
152
+ mail.conversation.move_to_trash(demo)
153
+ end
154
+ end
155
+
156
+ Forgery::Basic.number(:at_most => actors.size).times do
157
+ actor = actors.delete_at((rand * actors.size).to_i)
158
+ next if Actor.normalize(actor)==Actor.normalize(a)
159
+ mail = a.send_message(actor, "Hello, #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}", Forgery::LoremIpsum.words(10,:random => true))
160
+ if rand > 0.5
161
+ mail = actor.reply_to_sender(mail, "Pretty well #{a.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
162
+ if rand > 0.5
163
+ a.reply_to_sender(mail, "Ok #{actor.name}. #{Forgery::LoremIpsum.sentences(2,:random => true)}")
164
+ end
165
+ end
166
+ if rand > 0.75
167
+ mail.conversation.move_to_trash(actor)
168
+ end
169
+ end
170
+ end
171
+
172
+ mailboxer_end = Time.now
173
+ puts ' -> ' + (mailboxer_end - mailboxer_start).round(4).to_s + 's'
174
+
90
175
  end
91
176
  end
92
177
  end
@@ -17,10 +17,11 @@ Gem::Specification.new do |s|
17
17
  s.add_runtime_dependency('stringex', '~> 1.2.0')
18
18
  s.add_runtime_dependency('paperclip', '~> 2.3.4')
19
19
  s.add_runtime_dependency('jquery-rails', '~> 0.2.5')
20
- s.add_runtime_dependency('cancan', '~> 1.5.1')
20
+ s.add_runtime_dependency('cancan', '~> 1.6.2')
21
21
  s.add_runtime_dependency('will_paginate', '~> 3.0.pre2')
22
22
  s.add_runtime_dependency('omniauth','~> 0.2.0.beta5')
23
23
  s.add_runtime_dependency('oauth-plugin','~> 0.4.0.pre1')
24
+ s.add_runtime_dependency('rails_css_themes','~> 1.0.0')
24
25
  s.add_development_dependency('rails', '~> 3.0.5')
25
26
  s.add_development_dependency('capybara', '~> 0.3.9')
26
27
  s.add_development_dependency('sqlite3-ruby')
@@ -32,4 +33,9 @@ Gem::Specification.new do |s|
32
33
  s.add_development_dependency('forgery', '~> 0.3.6')
33
34
  s.add_development_dependency('ci_reporter', '~> 1.6.4')
34
35
  s.add_development_dependency('nifty-generators','~> 0.4.5')
36
+
37
+ #mailboxer
38
+ s.add_runtime_dependency('mailboxer','~> 0.0.8')
39
+ s.add_runtime_dependency('rmagick','~> 2.13.1')
40
+
35
41
  end