social_stream-base 0.17.3 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/app/assets/images/flags/pt.png +0 -0
  2. data/app/assets/javascripts/social_stream.toolbar.js +41 -0
  3. data/app/assets/stylesheets/settings.css +1 -0
  4. data/app/controllers/activity_actions_controller.rb +44 -0
  5. data/app/controllers/followers_controller.rb +39 -0
  6. data/app/helpers/activities_helper.rb +10 -10
  7. data/app/helpers/activity_actions_helper.rb +35 -0
  8. data/app/helpers/contacts_helper.rb +1 -1
  9. data/app/helpers/followers_helper.rb +5 -0
  10. data/app/helpers/toolbar_helper.rb +55 -68
  11. data/app/models/activity_action.rb +28 -0
  12. data/app/models/activity_object.rb +11 -2
  13. data/app/models/actor.rb +23 -33
  14. data/app/models/contact.rb +32 -43
  15. data/app/models/group.rb +2 -6
  16. data/app/models/relation.rb +1 -1
  17. data/app/models/relation/follow.rb +14 -0
  18. data/app/models/tie.rb +30 -30
  19. data/app/models/user.rb +8 -0
  20. data/app/views/activities/_options.html.erb +0 -1
  21. data/app/views/activity_actions/_follow_form.html.erb +10 -0
  22. data/app/views/activity_actions/_follow_sentence.html.erb +3 -0
  23. data/app/views/activity_actions/_update_form.js.erb +2 -0
  24. data/app/views/activity_actions/create.js.erb +1 -0
  25. data/app/views/activity_actions/update.js.erb +1 -0
  26. data/app/views/avatars/index.html.erb +1 -1
  27. data/app/views/cheesecake/index.html.erb +1 -1
  28. data/app/views/contacts/{_link.html.erb → _link_custom.html.erb} +0 -0
  29. data/app/views/contacts/_link_follow.html.erb +12 -0
  30. data/app/views/contacts/edit.html.erb +1 -1
  31. data/app/views/contacts/index.html.erb +1 -1
  32. data/app/views/contacts/index.js.erb +1 -1
  33. data/app/views/contacts/new.html.erb +1 -1
  34. data/app/views/conversations/index.html.erb +1 -1
  35. data/app/views/conversations/index.js.erb +1 -1
  36. data/app/views/conversations/show.html.erb +1 -1
  37. data/app/views/conversations/show.js.erb +1 -1
  38. data/app/views/devise/registrations/edit.html.erb +1 -1
  39. data/app/views/followers/destroy.js.erb +1 -0
  40. data/app/views/followers/index.html.erb +5 -0
  41. data/app/views/followers/update.js.erb +1 -0
  42. data/app/views/groups/_show.html.erb +1 -1
  43. data/app/views/groups/new.html.erb +1 -1
  44. data/app/views/layouts/_header_dropdown_menu.html.erb +5 -3
  45. data/app/views/messages/new.html.erb +1 -1
  46. data/app/views/messages/new.js.erb +1 -1
  47. data/app/views/objects/_show.html.erb +1 -1
  48. data/app/views/profiles/edit.html.erb +1 -1
  49. data/app/views/profiles/show.html.erb +1 -1
  50. data/app/views/relation/customs/index.html.erb +1 -1
  51. data/app/views/settings/index.html.erb +1 -1
  52. data/app/views/settings/index.js.erb +1 -0
  53. data/app/views/ties/index.html.erb +1 -1
  54. data/app/views/toolbar/_logo.html.erb +0 -7
  55. data/app/views/users/_show.html.erb +1 -1
  56. data/config/locales/en.yml +16 -6
  57. data/config/locales/es.yml +15 -6
  58. data/config/locales/pt.yml +507 -0
  59. data/config/locales/rails.pt.yml +192 -0
  60. data/config/routes.rb +20 -7
  61. data/db/migrate/20120316093946_create_activity_actions.rb +15 -0
  62. data/db/migrate/20120316113728_activity_action_follow.rb +23 -0
  63. data/lib/generators/social_stream/base/install_generator.rb +0 -4
  64. data/lib/generators/social_stream/base/templates/initializer.rb +7 -0
  65. data/lib/inherited_resources/social_stream.rb +18 -0
  66. data/lib/rails/social_stream.rb +23 -0
  67. data/lib/social_stream-base.rb +7 -3
  68. data/lib/social_stream/base/dependencies.rb +3 -2
  69. data/lib/social_stream/base/engine.rb +6 -6
  70. data/lib/social_stream/base/version.rb +1 -1
  71. data/lib/social_stream/models/channeled.rb +8 -0
  72. data/lib/social_stream/models/object.rb +1 -3
  73. data/lib/social_stream/models/subtype.rb +31 -25
  74. data/lib/social_stream/models/supertype.rb +54 -19
  75. data/lib/social_stream/views/toolbar/base.rb +143 -0
  76. data/lib/tasks/db/populate.rake +1 -1
  77. data/social_stream-base.gemspec +1 -3
  78. data/spec/dummy/config/initializers/social_stream.rb +7 -0
  79. data/spec/models/activity_action_spec.rb +26 -0
  80. data/spec/models/tie_spec.rb +2 -2
  81. metadata +91 -84
  82. data/app/assets/javascripts/toolbar.js +0 -22
  83. data/app/views/layouts/_settings.html.erb +0 -18
  84. data/app/views/toolbar/_home.html.erb +0 -15
  85. data/app/views/toolbar/_messages.html.erb +0 -15
  86. data/app/views/toolbar/_profile.html.erb +0 -28
  87. data/lib/generators/social_stream/base/templates/navigation.rb +0 -4
  88. data/lib/social_stream/toolbar_config/base.rb +0 -94
@@ -0,0 +1,192 @@
1
+ pt:
2
+ date:
3
+ abbr_day_names:
4
+ - dom
5
+ - seg
6
+ - ter
7
+ - qua
8
+ - qui
9
+ - sex
10
+ - sáb
11
+ abbr_month_names:
12
+ -
13
+ - jan
14
+ - fev
15
+ - mar
16
+ - abr
17
+ - mai
18
+ - jun
19
+ - jul
20
+ - ago
21
+ - set
22
+ - out
23
+ - nov
24
+ - dez
25
+ day_names:
26
+ - domingo
27
+ - segunda
28
+ - terça
29
+ - quarta
30
+ - quinta
31
+ - sexta
32
+ - sábado
33
+ formats:
34
+ default: ! '%d/%m/%Y'
35
+ long: ! '%d de %B de %Y'
36
+ short: ! '%d de %b'
37
+ month_names:
38
+ -
39
+ - janeiro
40
+ - fevereiro
41
+ - março
42
+ - abril
43
+ - maio
44
+ - junho
45
+ - julho
46
+ - agosto
47
+ - setembro
48
+ - outubro
49
+ - novembro
50
+ - dezembro
51
+ order:
52
+ - :dia
53
+ - :mês
54
+ - :ano
55
+ datetime:
56
+ distance_in_words:
57
+ about_x_hours:
58
+ one: aproximadamente 1 hora
59
+ other: aproximadamente %{count} horas
60
+ about_x_months:
61
+ one: aproximadamente 1 mês
62
+ other: aproximadamente %{count} meses
63
+ about_x_years:
64
+ one: aproximadamente 1 ano
65
+ other: aproximadamente %{count} anos
66
+ almost_x_years:
67
+ one: quase 1 ano
68
+ other: quase %{count} anos
69
+ half_a_minute: meio minuto
70
+ less_than_x_minutes:
71
+ one: menos de 1 minuto
72
+ other: menos de %{count} minutos
73
+ less_than_x_seconds:
74
+ one: menos de 1 segundo
75
+ other: menos de %{count} segundos
76
+ over_x_years:
77
+ one: mais de 1 ano
78
+ other: mais de %{count} anos
79
+ x_days:
80
+ one: 1 dia
81
+ other: ! '%{count} dias'
82
+ x_minutes:
83
+ one: 1 minuto
84
+ other: ! '%{count} minutos'
85
+ x_months:
86
+ one: 1 mês
87
+ other: ! '%{count} meses'
88
+ x_seconds:
89
+ one: 1 segundo
90
+ other: ! '%{count} segundos'
91
+ prompts:
92
+ day: Dia
93
+ hour: Hora
94
+ minute: Minuto
95
+ month: Mês
96
+ second: Segundo
97
+ year: Ano
98
+ errors:
99
+ format: ! '%{attribute} %{message}'
100
+ messages:
101
+ accepted: deve ser aceito
102
+ blank: não pode ficar em branco
103
+ confirmation: não está de acordo com a confirmação
104
+ empty: não pode ficar vazio
105
+ equal_to: deve ser igual a %{count}
106
+ even: deve ser par
107
+ exclusion: não está disponível
108
+ greater_than: deve ser maior que %{count}
109
+ greater_than_or_equal_to: deve ser maior ou igual a %{count}
110
+ inclusion: não está incluído na lista
111
+ invalid: não é válido
112
+ less_than: deve ser menor que %{count}
113
+ less_than_or_equal_to: deve ser menor ou igual a %{count}
114
+ not_a_number: não é um número
115
+ not_an_integer: não é um número inteiro
116
+ odd: deve ser ímpar
117
+ record_invalid: ! 'A validação falhou: %{errors}'
118
+ taken: já está em uso
119
+ too_long: ! 'é muito longo (máximo: %{count} caracteres)'
120
+ too_short: ! 'é muito curto (mínimo: %{count} caracteres)'
121
+ wrong_length: não possui o tamanho esperado (%{count} caracteres)
122
+ template:
123
+ body: ! 'Por favor, verifique o(s) seguinte(s) campo(s):'
124
+ header:
125
+ one: ! 'Não foi possível gravar %{model}: 1 erro'
126
+ other: ! 'Não foi possível gravar %{model}: %{count} erros.'
127
+ helpers:
128
+ select:
129
+ prompt: Por favor selecione
130
+ submit:
131
+ create: Criar %{model}
132
+ submit: Salvar %{model}
133
+ update: Atualizar %{model}
134
+ number:
135
+ currency:
136
+ format:
137
+ delimiter: .
138
+ format: ! '%u %n'
139
+ precision: 2
140
+ separator: ! ','
141
+ significant: false
142
+ strip_insignificant_zeros: false
143
+ unit: R$
144
+ format:
145
+ delimiter: .
146
+ precision: 3
147
+ separator: ! ','
148
+ significant: false
149
+ strip_insignificant_zeros: false
150
+ human:
151
+ decimal_units:
152
+ format: ! '%n %u'
153
+ units:
154
+ billion: bilhão
155
+ million: milhão
156
+ quadrillion: quatrilhão
157
+ thousand: mil
158
+ trillion: trilhão
159
+ unit: ''
160
+ format:
161
+ delimiter: ''
162
+ precision: 2
163
+ significant: true
164
+ strip_insignificant_zeros: true
165
+ storage_units:
166
+ format: ! '%n %u'
167
+ units:
168
+ byte:
169
+ one: Byte
170
+ other: Bytes
171
+ gb: GB
172
+ kb: KB
173
+ mb: MB
174
+ tb: TB
175
+ percentage:
176
+ format:
177
+ delimiter: ''
178
+ precision:
179
+ format:
180
+ delimiter: ''
181
+ support:
182
+ array:
183
+ last_word_connector: ! ', e '
184
+ two_words_connector: ! ' e'
185
+ words_connector: ! ', '
186
+ time:
187
+ am: ''
188
+ formats:
189
+ default: ! '%A, %d de %B de %Y, %H:%M h'
190
+ long: ! '%A, %d de %B de %Y, %H:%M h'
191
+ short: ! '%d/%m, %H:%M h'
192
+ pm: ''
data/config/routes.rb CHANGED
@@ -40,16 +40,29 @@ Rails.application.routes.draw do
40
40
  resources object.to_s.pluralize
41
41
  end
42
42
 
43
- resources :contacts do
44
- collection do
45
- get 'pending'
43
+ case SocialStream.relation_model
44
+ when :follow
45
+ resources :followers
46
+ resources :contacts do
47
+ collection do
48
+ get 'pending'
49
+ end
50
+ end
51
+ when :custom
52
+ resources :contacts do
53
+ collection do
54
+ get 'pending'
55
+ end
56
+ end
57
+
58
+ namespace "relation" do
59
+ resources :customs
46
60
  end
47
- end
48
61
 
49
- namespace "relation" do
50
- resources :customs
62
+ resources :permissions
51
63
  end
52
- resources :permissions
64
+
65
+ resources :activity_actions
53
66
 
54
67
  match 'tags' => 'tags#index', :as => 'tags'
55
68
 
@@ -0,0 +1,15 @@
1
+ class CreateActivityActions < ActiveRecord::Migration
2
+ def change
3
+ create_table :activity_actions do |t|
4
+ t.references :actor
5
+ t.references :activity_object
6
+
7
+ t.timestamps
8
+ end
9
+ add_index :activity_actions, :actor_id
10
+ add_index :activity_actions, :activity_object_id
11
+
12
+ add_foreign_key "activity_actions", "actors", :name => "index_activity_actions_on_actor_id"
13
+ add_foreign_key "activity_actions", "activity_objects", :name => "index_activity_actions_on_activity_object_id"
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ class ActivityActionFollow < ActiveRecord::Migration
2
+ def up
3
+ add_column :activity_actions, :follow, :boolean, :default => false
4
+ add_column :activity_objects, :follower_count, :integer, :default => 0
5
+ remove_column :actors, :follower_count
6
+
7
+ ActivityObject.reset_column_information
8
+ Actor.reset_column_information
9
+
10
+ Tie.
11
+ joins(:relation).
12
+ with_permissions('follow', nil).
13
+ each do |t|
14
+ t.set_follow_action
15
+ end
16
+ end
17
+
18
+ def down
19
+ remove_column :activity_actions, :follow
20
+ remove_column :activity_objects, :follower_count
21
+ add_column :actors, :follower_count, :integer, :default => 0
22
+ end
23
+ end
@@ -41,10 +41,6 @@ class SocialStream::Base::InstallGenerator < Rails::Generators::Base #:nodoc:
41
41
  remove_file 'app/views/layouts/application.html.erb'
42
42
  end
43
43
 
44
- def create_navigation_config
45
- copy_file 'navigation.rb', 'config/navigation.rb'
46
- end
47
-
48
44
  def require_javascripts
49
45
  inject_into_file 'app/assets/javascripts/application.js',
50
46
  "//= require social_stream-base\n",
@@ -20,6 +20,13 @@ SocialStream.setup do |config|
20
20
  # You can write your own activity objects
21
21
  #
22
22
  # config.activity_forms = [ :post, :document, :foo, :bar ]
23
+
24
+ # Config the relation model of your network
25
+ #
26
+ # :custom - users define their own relation types, and post with privacy, like Google+
27
+ # :follow - user just follow other users, like Twitter
28
+ #
29
+ # config.relation_model = :custom
23
30
 
24
31
  # Quick search (header) and Extended search models and its order. Remember to create
25
32
  # the indexes with thinking-sphinx if you are using customized models.
@@ -0,0 +1,18 @@
1
+ # Monkey path inherited_resources
2
+ #
3
+ #
4
+ # Fix https://github.com/josevalim/inherited_resources/issues/216
5
+ module InheritedResources::BaseHelpers
6
+ private
7
+
8
+ def resource_params
9
+ @resource_params ||=
10
+ build_resource_params
11
+ end
12
+
13
+ def build_resource_params
14
+ rparams = [params[resource_request_name] || params[resource_instance_name] || {}]
15
+ rparams << as_role if role_given?
16
+ rparams
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ # Monkey patches to Ruby on Rails
2
+ #
3
+ # Use unix file util to prove the content type sent by the browser
4
+ class ActionDispatch::Http::UploadedFile
5
+ def initialize_with_magic(*args, &block)
6
+ initialize_without_magic(*args, &block)
7
+
8
+ if (unix_file = `which file`.chomp).present? && File.exists?(unix_file)
9
+ `#{ unix_file } -v 2>&1` =~ /^file-(.*)$/
10
+ version = $1
11
+
12
+ @content_type =
13
+ if version >= "4.24"
14
+ `#{ unix_file } -b --mime-type #{ @tempfile.path }`.chomp
15
+ else
16
+ `#{ unix_file } -bi #{ @tempfile.path }`.chomp =~ /(\w*\/[\w+-\.]*)/
17
+ $1
18
+ end
19
+ end
20
+ end
21
+
22
+ alias_method_chain :initialize, :magic
23
+ end
@@ -36,15 +36,16 @@ module SocialStream
36
36
  module Sidebar
37
37
  autoload :Base, 'social_stream/views/sidebar/base'
38
38
  end
39
+
40
+ module Toolbar
41
+ autoload :Base, 'social_stream/views/toolbar/base'
42
+ end
39
43
  end
40
44
 
41
45
  module TestHelpers
42
46
  autoload :Controllers, 'social_stream/test_helpers/controllers'
43
47
  end
44
48
 
45
- module ToolbarConfig
46
- autoload :Base, 'social_stream/toolbar_config/base'
47
- end
48
49
 
49
50
  mattr_accessor :subjects
50
51
  @@subjects = [ :user, :group ]
@@ -58,6 +59,9 @@ module SocialStream
58
59
 
59
60
  mattr_accessor :activity_forms
60
61
  @@activity_forms = [ :post ]
62
+
63
+ mattr_accessor :relation_model
64
+ @@relation_model = :custom
61
65
 
62
66
  mattr_accessor :quick_search_models
63
67
  @@quick_search_models = [ :user, :group, :post ]
@@ -1,3 +1,5 @@
1
+ # Monkey path Ruby on Rails
2
+ require 'rails/social_stream'
1
3
  # Database foreign keys
2
4
  require 'foreigner'
3
5
  # jQuery
@@ -14,6 +16,7 @@ require 'devise'
14
16
  require 'cancan'
15
17
  # REST controllers
16
18
  require 'inherited_resources'
19
+ require 'inherited_resources/social_stream'
17
20
  # Scopes in controllers
18
21
  require 'has_scope'
19
22
  # Logo attachments
@@ -33,8 +36,6 @@ require 'acts_as_taggable_on/social_stream'
33
36
  require 'formtastic'
34
37
  #Background tasks
35
38
  require 'resque/server'
36
- #Simple Navigation for menu
37
- require 'simple-navigation'
38
39
  # Modernizr.js library
39
40
  require 'modernizr-rails'
40
41
  # Sphinx search engine
@@ -35,12 +35,6 @@ module SocialStream
35
35
  end
36
36
  end
37
37
 
38
- initializer "social_stream-base.toolbar_config" do
39
- SocialStream::ToolbarConfig.module_eval do
40
- include SocialStream::ToolbarConfig::Base
41
- end
42
- end
43
-
44
38
  initializer "social_stream-base.views.settings" do
45
39
  SocialStream::Views::Settings.module_eval do
46
40
  include SocialStream::Views::Settings::Base
@@ -53,6 +47,12 @@ module SocialStream
53
47
  end
54
48
  end
55
49
 
50
+ initializer "social_stream-base.views.toolbar" do
51
+ SocialStream::Views::Toolbar.module_eval do
52
+ include SocialStream::Views::Toolbar::Base
53
+ end
54
+ end
55
+
56
56
  initializer "social_stream-base.avatars_for_rails" do
57
57
  AvatarsForRails.setup do |config|
58
58
  config.avatarable_model = :actor
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Base
3
- VERSION = "0.17.3".freeze
3
+ VERSION = "0.18.0".freeze
4
4
  end
5
5
  end
@@ -23,6 +23,8 @@ module SocialStream
23
23
  subtype_of :channel,
24
24
  :belongs => { :dependent => nil }
25
25
 
26
+ # before_validation :set_owner_id, :on => :create
27
+
26
28
  before_validation :check_existing_channel
27
29
  end
28
30
 
@@ -43,6 +45,12 @@ module SocialStream
43
45
 
44
46
  self.channel = existing_channel
45
47
  end
48
+
49
+ private
50
+
51
+ def set_owner_id
52
+ self.owner_id ||= author_id
53
+ end
46
54
  end
47
55
  end
48
56
  end