social_stream 2.0.4 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/README.rdoc +2 -1
  4. data/base/README.rdoc +2 -0
  5. data/base/app/assets/javascripts/social_stream/relation_customs.js +8 -3
  6. data/base/app/assets/javascripts/social_stream/timeline.js +1 -2
  7. data/base/app/assets/javascripts/social_stream/wall.js +11 -0
  8. data/base/app/assets/stylesheets/social_stream/base/contacts/_contacts.css.sass +1 -0
  9. data/base/app/assets/stylesheets/social_stream/base/contacts/layouts/_contacts.css.sass +1 -42
  10. data/base/app/assets/stylesheets/social_stream/base/footer/layout/_footer.css.sass +3 -2
  11. data/base/app/assets/stylesheets/social_stream/base/layouts/_layout.css.sass +4 -1
  12. data/base/app/assets/stylesheets/social_stream/base/mixins/_layout.css.sass +48 -0
  13. data/base/app/assets/stylesheets/social_stream/base/profile/_profile.css.sass +21 -25
  14. data/base/app/assets/stylesheets/social_stream/base/sidebar/_sidebar.css.sass +1 -27
  15. data/base/app/assets/stylesheets/social_stream/base/sidebar/layout/_sidebar.css.sass +1 -24
  16. data/base/app/assets/stylesheets/social_stream/base/toolbar/_toolbar.css.sass +2 -11
  17. data/base/app/assets/stylesheets/social_stream/base/toolbar/layout/_toolbar.css.sass +18 -5
  18. data/base/app/controllers/contacts_controller.rb +17 -22
  19. data/base/app/controllers/permissions_controller.rb +3 -1
  20. data/base/app/helpers/contacts_helper.rb +9 -14
  21. data/base/app/models/actor.rb +28 -2
  22. data/base/app/models/contact.rb +18 -1
  23. data/base/app/models/permission.rb +21 -1
  24. data/base/app/models/relation.rb +14 -15
  25. data/base/app/models/relation/custom.rb +27 -24
  26. data/base/app/views/activities/_new.html.erb +1 -1
  27. data/base/app/views/contacts/{_link_custom.html.erb → _button.html.erb} +0 -0
  28. data/base/app/views/contacts/_contact.html.erb +1 -1
  29. data/base/app/views/contacts/index.html.erb +1 -1
  30. data/base/app/views/devise/passwords/new.html.erb +6 -8
  31. data/base/app/views/devise/registrations/new.html.erb +5 -7
  32. data/base/app/views/layouts/application.html.erb +7 -8
  33. data/base/app/views/permissions/_index.html.erb +12 -12
  34. data/base/app/views/permissions/_list.html.erb +10 -0
  35. data/base/app/views/permissions/index.js.erb +1 -15
  36. data/base/app/views/posts/create.js.erb +5 -4
  37. data/base/app/views/profiles/_personal.html.erb +2 -2
  38. data/base/app/views/relation/customs/_custom.html.erb +2 -27
  39. data/base/app/views/relation/customs/_form.html.erb +1 -1
  40. data/base/app/views/relation/customs/_index.html.erb +1 -1
  41. data/base/app/views/relation/customs/_list.html.erb +5 -4
  42. data/base/app/views/relation/customs/index.html.erb +1 -1
  43. data/base/app/views/relations/_relation.html.erb +33 -0
  44. data/base/config/locales/en.yml +10 -5
  45. data/base/config/locales/es.yml +20 -40
  46. data/base/config/locales/pt.yml +5 -1
  47. data/base/config/locales/zh.yml +17 -9
  48. data/base/lib/generators/social_stream/base/install_generator.rb +0 -4
  49. data/base/lib/generators/social_stream/base/templates/initializer.rb +24 -0
  50. data/base/lib/social_stream/base.rb +70 -0
  51. data/base/lib/social_stream/base/ability.rb +13 -1
  52. data/base/lib/social_stream/base/version.rb +1 -1
  53. data/base/lib/social_stream/test_helpers/controllers.rb +12 -6
  54. data/base/social_stream-base.gemspec +1 -1
  55. data/base/spec/controllers/permissions_controller_spec.rb +2 -6
  56. data/documents/app/assets/stylesheets/social_stream-documents.css.sass +2 -0
  57. data/documents/app/assets/stylesheets/social_stream/documents/explore/_explore-documents.css.sass +1 -2
  58. data/documents/app/assets/stylesheets/social_stream/documents/explore/layout/_explore-documents.css.sass +2 -13
  59. data/documents/app/assets/stylesheets/social_stream/documents/mixins/_mixins.css.sass +19 -0
  60. data/documents/lib/social_stream-documents.rb +0 -2
  61. data/documents/lib/social_stream/documents/version.rb +1 -1
  62. data/documents/social_stream-documents.gemspec +1 -1
  63. data/events/lib/social_stream/events/version.rb +1 -1
  64. data/events/social_stream-events.gemspec +1 -1
  65. data/lib/social_stream/version.rb +1 -1
  66. data/linkser/app/assets/javascripts/social_stream/linkser.wall.js +11 -14
  67. data/linkser/app/views/links/create.js.erb +3 -4
  68. data/linkser/lib/social_stream/linkser/version.rb +1 -1
  69. data/linkser/social_stream-linkser.gemspec +1 -1
  70. data/oauth2_server/app/assets/stylesheets/social_stream-oauth2_server.css.sass +1 -1
  71. data/oauth2_server/app/assets/stylesheets/social_stream/oauth2_server/applications/_applications-oauth2server.css.sass +1 -1
  72. data/oauth2_server/app/assets/stylesheets/social_stream/oauth2_server/applications/layout/_applications-oauth2server.css.sass +4 -0
  73. data/oauth2_server/app/assets/stylesheets/social_stream/oauth2_server/create/_create-oauth2server.css.sass +3 -7
  74. data/oauth2_server/app/assets/stylesheets/social_stream/oauth2_server/mixins/_mixin.css.sass +10 -0
  75. data/oauth2_server/app/assets/stylesheets/social_stream/oauth2_server/show/layout/_show-oauth2server.css.sass +15 -6
  76. data/oauth2_server/app/controllers/site/clients_controller.rb +14 -11
  77. data/oauth2_server/app/models/relation/manager.rb +19 -0
  78. data/oauth2_server/app/models/site/client.rb +10 -6
  79. data/oauth2_server/app/views/site/clients/_avatar.html.erb +15 -0
  80. data/oauth2_server/app/views/site/clients/_edit.html.erb +6 -0
  81. data/oauth2_server/app/views/site/clients/_edit_step_2.html.erb +11 -0
  82. data/oauth2_server/app/views/site/clients/_edit_step_3.html.erb +10 -0
  83. data/oauth2_server/app/views/site/clients/_list.html.erb +20 -17
  84. data/oauth2_server/app/views/site/clients/edit.html.erb +5 -6
  85. data/oauth2_server/app/views/site/clients/index.html.erb +1 -1
  86. data/oauth2_server/app/views/site/clients/new.html.erb +4 -2
  87. data/oauth2_server/app/views/site/clients/show.html.erb +49 -42
  88. data/oauth2_server/config/locales/en.yml +21 -3
  89. data/oauth2_server/config/locales/es.yml +26 -11
  90. data/oauth2_server/config/locales/zh.yml +25 -0
  91. data/oauth2_server/db/migrate/20130619134332_site_client_admin_to_manager.rb +24 -0
  92. data/oauth2_server/lib/social_stream-oauth2_server.rb +1 -19
  93. data/oauth2_server/lib/social_stream/oauth2_server.rb +33 -5
  94. data/oauth2_server/lib/social_stream/oauth2_server/ability.rb +23 -0
  95. data/oauth2_server/lib/social_stream/oauth2_server/engine.rb +6 -0
  96. data/oauth2_server/lib/social_stream/oauth2_server/models/actor.rb +2 -2
  97. data/oauth2_server/lib/social_stream/oauth2_server/version.rb +1 -1
  98. data/oauth2_server/social_stream-oauth2_server.gemspec +1 -1
  99. data/oauth2_server/spec/controllers/site_clients_controller_authorization_spec.rb +112 -0
  100. data/oauth2_server/spec/factories/site_client.rb +2 -2
  101. data/oauth2_server/spec/models/site/client_authorization_spec.rb +20 -0
  102. data/ostatus/lib/social_stream-ostatus.rb +0 -4
  103. data/ostatus/lib/social_stream/ostatus/engine.rb +11 -0
  104. data/ostatus/lib/social_stream/ostatus/version.rb +1 -1
  105. data/ostatus/social_stream-ostatus.gemspec +1 -1
  106. data/places/config/locales/en.yml +0 -1
  107. data/places/config/locales/es.yml +1 -2
  108. data/presence/lib/social_stream/presence/version.rb +1 -1
  109. data/presence/social_stream-presence.gemspec +1 -1
  110. data/social_stream.gemspec +7 -7
  111. metadata +30 -26
  112. data/base/app/helpers/permissions_helper.rb +0 -21
  113. data/base/lib/generators/social_stream/base/templates/relations.yml +0 -39
  114. data/oauth2_server/app/assets/stylesheets/social_stream/oauth2_server/mixins/_mixins.css.sass +0 -5
  115. data/oauth2_server/app/models/relation/admin.rb +0 -9
  116. data/oauth2_server/app/views/site/clients/_form_step1.html.erb +0 -7
  117. data/oauth2_server/app/views/site/clients/_form_step2.html.erb +0 -20
  118. data/ostatus/app/decorators/social_stream/base/relation/custom_decorator.rb +0 -3
  119. data/ostatus/lib/social_stream/ostatus/models/relation/custom.rb +0 -22
  120. data/spec/dummy/config/relations.yml +0 -39
@@ -21,12 +21,30 @@ en:
21
21
  helpers:
22
22
  submit:
23
23
  site_client:
24
- create: "Next"
25
- update: "Save"
24
+ create: Next
25
+ update: Save
26
26
  permission:
27
+ description:
28
+ default:
29
+ brief:
30
+ manage:
31
+ contact: Manage authorizations
32
+ nil: Manage the site
33
+ relation/custom: Manage roles
34
+ detailed:
35
+ manage:
36
+ nil:
37
+ positive: They WILL BE ABLE to update the details of the client site
38
+ negative: They WILL NOT BE ABLE to update the details of the client
39
+ site
40
+ relation/custom:
41
+ positive: They WILL BE ABLE to create, update and delete the roles of
42
+ the client site
43
+ negative: They WILL NOT BE ABLE to create, update and delete the roles
44
+ of the client site
27
45
  public_info: Read your public information
28
46
  relation_admin:
29
- name: "Site Client Admin"
47
+ name: Site Client Admin
30
48
  site:
31
49
  client:
32
50
  added: Added sites
@@ -10,15 +10,38 @@ es:
10
10
  name: Nombre
11
11
  secret: Client Secret
12
12
  url: URL
13
+ authorization:
14
+ form:
15
+ accept: Accept
16
+ cancel: Cancel
17
+ new:
18
+ title: Authorize %{client}?
19
+ permission:
20
+ title: 'The site %{client} will be able to:'
13
21
  helpers:
14
22
  submit:
15
23
  site_client:
16
- create: "Siguiente"
17
- update: "Guardar"
24
+ create: Siguiente
25
+ update: Guardar
18
26
  permission:
27
+ description:
28
+ default:
29
+ brief:
30
+ manage:
31
+ nil: Gestionar el sitio
32
+ relation/custom: Gestionar los roles
33
+ contact: Manage authorizations
34
+ detailed:
35
+ manage:
36
+ nil:
37
+ positive: PODRÁN actualizar los detalles del sitio
38
+ negative: NO PODRÁN actualizar los detalles del sitio
39
+ relation/custom:
40
+ positive: PODRÁN crear, actualizar y borrar los roles del sitio
41
+ negative: NO PODRÁN crear, actualizar y borrar los roles del sitio
19
42
  public_info: Acceder a tu información pública
20
43
  relation_admin:
21
- name: "Administrador de Sitio"
44
+ name: Administrador de Sitio
22
45
  site:
23
46
  client:
24
47
  added: Sitios añadidos
@@ -27,11 +50,3 @@ es:
27
50
  new:
28
51
  link: Añadir sitio
29
52
  title: Registrar nuevo sitio
30
- authorization:
31
- form:
32
- accept: Accept
33
- cancel: Cancel
34
- new:
35
- title: Authorize %{client}?
36
- permission:
37
- title: 'The site %{client} will be able to:'
@@ -20,6 +20,24 @@ zh:
20
20
  title: 'The site %{client} will be able to:'
21
21
  permission:
22
22
  public_info: Read your public information
23
+ description:
24
+ default:
25
+ brief:
26
+ manage:
27
+ nil: Manage the site
28
+ relation/custom: Manage roles
29
+ contact: Manage authorizations
30
+ detailed:
31
+ manage:
32
+ nil:
33
+ positive: They WILL BE ABLE to update the details of the client site
34
+ negative: They WILL NOT BE ABLE to update the details of the client
35
+ site
36
+ relation/custom:
37
+ positive: They WILL BE ABLE to create, update and delete the roles of
38
+ the client site
39
+ negative: They WILL NOT BE ABLE to create, update and delete the roles
40
+ of the client site
23
41
  site:
24
42
  client:
25
43
  added: Added sites
@@ -28,3 +46,10 @@ zh:
28
46
  new:
29
47
  link: Add site
30
48
  title: Register new client site
49
+ helpers:
50
+ submit:
51
+ site_client:
52
+ create: Next
53
+ update: Save
54
+ relation_admin:
55
+ name: Site Client Admin
@@ -0,0 +1,24 @@
1
+ class SiteClientAdminToManager < ActiveRecord::Migration
2
+
3
+ class Relation::Admin < Relation; end
4
+
5
+ def up
6
+ admin = Relation::Admin.first
7
+
8
+ if admin.present?
9
+ rt = Tie.record_timestamps
10
+ Tie.record_timestamps = false
11
+
12
+ admin.ties.each do |t|
13
+ t.relation = Relation::Manager.instance
14
+ t.save!
15
+ end
16
+
17
+ Tie.record_timestamps = rt
18
+ end
19
+ end
20
+
21
+ def down
22
+ raise ActiveRecord::IrreversibleMigration
23
+ end
24
+ end
@@ -1,19 +1 @@
1
- require 'social_stream-base'
2
-
3
- require 'rack/oauth2'
4
-
5
- module SocialStream
6
- module Oauth2Server
7
- module Controllers
8
- autoload :Helpers, 'social_stream/oauth2_server/controllers/helpers'
9
- end
10
-
11
- module Models
12
- autoload :Actor, 'social_stream/oauth2_server/models/actor'
13
- autoload :User, 'social_stream/oauth2_server/models/user'
14
- end
15
- autoload :TokenEndpoint, 'social_stream/oauth2_server/token_endpoint'
16
- end
17
- end
18
-
19
- require 'social_stream/oauth2_server/engine'
1
+ require 'social_stream/oauth2_server'
@@ -1,5 +1,33 @@
1
- # Bundler 1.2 tries to load this file instead of the gem name,
2
- # so we delegate to it
3
- #
4
- # We will probably change this in the future
5
- require 'social_stream-oauth2_server'
1
+ require 'social_stream-base'
2
+
3
+ require 'rack/oauth2'
4
+
5
+ module SocialStream
6
+ module Oauth2Server
7
+ module Controllers
8
+ autoload :Helpers, 'social_stream/oauth2_server/controllers/helpers'
9
+ end
10
+
11
+ module Models
12
+ autoload :Actor, 'social_stream/oauth2_server/models/actor'
13
+ autoload :User, 'social_stream/oauth2_server/models/user'
14
+ end
15
+
16
+ autoload :Ability, 'social_stream/oauth2_server/ability'
17
+ autoload :TokenEndpoint, 'social_stream/oauth2_server/token_endpoint'
18
+ end
19
+
20
+ # Define default custom relations for Site::Client
21
+ SocialStream.custom_relations['site/client'] = {}
22
+
23
+ # Relations that appear in the Site::Client list
24
+ SocialStream.list_relations['site/client'] = [ :manager ]
25
+
26
+ SocialStream.available_permissions['site/client'] = [
27
+ [ 'manage', nil ],
28
+ [ 'manage', 'relation/custom' ],
29
+ [ 'manage', 'contact' ]
30
+ ]
31
+ end
32
+
33
+ require 'social_stream/oauth2_server/engine'
@@ -0,0 +1,23 @@
1
+ module SocialStream
2
+ module Oauth2Server
3
+ module Ability
4
+ def initialize(subject)
5
+ super
6
+
7
+ can :read, Site::Client
8
+
9
+ can :create, Site::Client do |c|
10
+ subject.present? &&
11
+ c.author_id == subject.actor_id
12
+ end
13
+
14
+ can [:update, :destroy], Site::Client do |c|
15
+ c.allow? subject, 'manage'
16
+ end
17
+
18
+ can :read, Relation::Manager
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -5,6 +5,12 @@ module SocialStream
5
5
  Oauth2Token::AccessToken.valid.find_by_token(req.access_token) || req.invalid_token!
6
6
  end
7
7
 
8
+ initializer "social_stream-oauth2_server.ability" do
9
+ SocialStream::Ability.module_eval do
10
+ include SocialStream::Oauth2Server::Ability
11
+ end
12
+ end
13
+
8
14
  initializer "social_stream-oauth2_server.controller.helpers",
9
15
  after: "social_stream-base.controller.helpers" do
10
16
  ActiveSupport.on_load(:action_controller) do
@@ -2,8 +2,8 @@ module SocialStream
2
2
  module Oauth2Server
3
3
  module Models
4
4
  module Actor
5
- def developer_site_clients
6
- Site::Client.administered_by(self)
5
+ def managed_site_clients
6
+ Site::Client.managed_by(self)
7
7
  end
8
8
  end
9
9
  end
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Oauth2Server
3
- VERSION = "2.0.3".freeze
3
+ VERSION = "2.1.0".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 2.0.4')
15
+ s.add_runtime_dependency('social_stream-base', '~> 2.1.0')
16
16
  s.add_runtime_dependency('rack-oauth2', '~> 1.0.0')
17
17
 
18
18
  s.add_development_dependency('rspec-rails', '~> 2.8.0')
@@ -0,0 +1,112 @@
1
+ require 'spec_helper'
2
+
3
+ describe Site::ClientsController do
4
+ include SocialStream::TestHelpers
5
+ include SocialStream::TestHelpers::Controllers
6
+
7
+ render_views
8
+
9
+ describe "when Anonymous" do
10
+ it "should not render new" do
11
+ get :new
12
+
13
+ response.should redirect_to(new_user_session_path)
14
+ end
15
+
16
+ context "faking a new client" do
17
+ it "should deny creating" do
18
+ post :create, :client => { :name => "Test" }
19
+
20
+ response.should redirect_to(new_user_session_path)
21
+ end
22
+ end
23
+
24
+ context "an existing client" do
25
+ before do
26
+ @current_model = Factory(:"site/client")
27
+ end
28
+
29
+ it_should_behave_like "Deny Updating"
30
+ it_should_behave_like "Deny Destroying"
31
+ end
32
+ end
33
+
34
+ describe "when authenticated" do
35
+ before do
36
+ @user = Factory(:user)
37
+
38
+ sign_in @user
39
+ end
40
+
41
+ it "should render client" do
42
+ @client = Factory(:"site/client", author: @user.actor )
43
+ get :show, :id => @client.to_param
44
+
45
+ response.should be_success
46
+ end
47
+
48
+ it "should render other group" do
49
+ get :show, :id => Factory(:"site/client").to_param
50
+
51
+ response.should be_success
52
+ end
53
+
54
+ it "should render new" do
55
+ get :new
56
+
57
+ response.should be_success
58
+ end
59
+
60
+ context "a new own client" do
61
+ it "should allow creating" do
62
+ count = Site::Client.count
63
+ post :create, site_client: { name: "Test",
64
+ url: "http://test.com/",
65
+ callback_url: "http://test.com/callback"
66
+ }
67
+
68
+ client = assigns(:client)
69
+
70
+ client.should be_valid
71
+ Site::Client.count.should eq(count + 1)
72
+ client.receivers.should include(@user.actor)
73
+ end
74
+ end
75
+
76
+ context "a new fake client" do
77
+ before do
78
+ user = Factory(:user)
79
+
80
+ model_attributes[:author_id] = user.actor_id
81
+ model_attributes[:user_author_id] = user.actor_id
82
+ end
83
+
84
+ it_should_behave_like "Deny Creating"
85
+ end
86
+
87
+ context "a external client" do
88
+ before do
89
+ @current_model = Factory(:"site/client")
90
+ end
91
+
92
+ it_should_behave_like "Deny Updating"
93
+ it_should_behave_like "Deny Destroying"
94
+ end
95
+
96
+ context "a existing own client" do
97
+ before do
98
+ @current_model = Factory(:"site/client", author: @user.actor)
99
+ end
100
+
101
+ it "should update client" do
102
+ put :update, :id => @current_model.to_param,
103
+ "client" => { name: "Update name" }
104
+
105
+ response.should redirect_to(@current_model)
106
+ end
107
+
108
+ it_should_behave_like "Allow Destroying"
109
+ end
110
+ end
111
+ end
112
+
@@ -1,6 +1,6 @@
1
- Factory.define(:site_client, :class => Site::Client) do |c|
1
+ Factory.define(:"site/client", :class => Site::Client) do |c|
2
2
  c.sequence(:name) { |n| "Site client #{ n }" }
3
3
  c.url { 'https://test.com' }
4
4
  c.callback_url { 'https://test.com/callback' }
5
- c.actor { Factory(:user).actor }
5
+ c.author { Factory(:user).actor }
6
6
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Site::Client do
4
+ before do
5
+ @user = Factory(:user)
6
+
7
+ @client = Site::Client.create name: "Test",
8
+ url: "http://test.com",
9
+ callback_url: "http://test.com/callback",
10
+ author: @user
11
+ end
12
+
13
+ it "should allow update to author" do
14
+ Ability.new(@user).should be_able_to(:update, @client)
15
+ end
16
+
17
+ it "should not allow update to other" do
18
+ Ability.new(Factory(:user)).should_not be_able_to(:update, @client)
19
+ end
20
+ end
@@ -40,10 +40,6 @@ module SocialStream
40
40
  module Object
41
41
  autoload :ClassMethods, 'social_stream/ostatus/models/object'
42
42
  end
43
-
44
- module Relation
45
- autoload :Custom, 'social_stream/ostatus/models/relation/custom'
46
- end
47
43
  end
48
44
 
49
45
  module Controllers
@@ -16,6 +16,17 @@ module SocialStream
16
16
  initializer "social_stream-ostatus.remote_subject_in_social_stream_subjects" do
17
17
  SocialStream.subjects << :remote_subject unless SocialStream.subjects.include?(:remote_subject)
18
18
  end
19
+
20
+ initializer "social_stream-ostatus.custom_relations" do
21
+ SocialStream.custom_relations['remote_subject'] = {
22
+ 'default' => {
23
+ 'name' => 'default',
24
+ 'permissions' => [
25
+ [ 'read', 'activity' ]
26
+ ]
27
+ }
28
+ }
29
+ end
19
30
  end
20
31
  end
21
32
  end