decidim-comments 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.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +42 -0
  3. data/Rakefile +2 -0
  4. data/app/assets/config/decidim_comments_manifest.js +1 -0
  5. data/app/assets/javascripts/decidim/comments/bundle.js +504 -0
  6. data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -0
  7. data/app/assets/javascripts/decidim/comments/comments.js.erb +8 -0
  8. data/app/commands/decidim/comments/create_comment.rb +40 -0
  9. data/app/forms/decidim/comments/comment_form.rb +16 -0
  10. data/app/frontend/application/apollo_client.js +16 -0
  11. data/app/frontend/application/application.component.jsx +37 -0
  12. data/app/frontend/application/application.component.test.jsx +33 -0
  13. data/app/frontend/application/icon.component.jsx +21 -0
  14. data/app/frontend/application/icon.component.test.jsx +43 -0
  15. data/app/frontend/comments/add_comment_form.component.jsx +250 -0
  16. data/app/frontend/comments/add_comment_form.component.test.jsx +173 -0
  17. data/app/frontend/comments/add_comment_form.mutation.graphql +8 -0
  18. data/app/frontend/comments/comment.component.jsx +202 -0
  19. data/app/frontend/comments/comment.component.test.jsx +125 -0
  20. data/app/frontend/comments/comment.fragment.graphql +12 -0
  21. data/app/frontend/comments/comment_data.fragment.graphql +11 -0
  22. data/app/frontend/comments/comment_order_selector.component.jsx +28 -0
  23. data/app/frontend/comments/comment_order_selector.component.test.jsx +9 -0
  24. data/app/frontend/comments/comment_thread.component.jsx +64 -0
  25. data/app/frontend/comments/comment_thread.component.test.jsx +71 -0
  26. data/app/frontend/comments/comment_thread.fragment.graphql +9 -0
  27. data/app/frontend/comments/comments.component.jsx +139 -0
  28. data/app/frontend/comments/comments.component.test.jsx +106 -0
  29. data/app/frontend/comments/comments.query.graphql +10 -0
  30. data/app/frontend/comments/featured_comment.component.jsx +23 -0
  31. data/app/frontend/comments/featured_comment.component.test.jsx +15 -0
  32. data/app/frontend/entry.js +24 -0
  33. data/app/frontend/entry.test.js +29 -0
  34. data/app/frontend/support/asset_url.js +11 -0
  35. data/app/frontend/support/generate_comments_data.js +29 -0
  36. data/app/frontend/support/generate_current_user_data.js +13 -0
  37. data/app/frontend/support/load_translations.js +23 -0
  38. data/app/frontend/support/require_all.js +10 -0
  39. data/app/frontend/support/resolve_graphql_query.js +37 -0
  40. data/app/frontend/support/stub_component.js +29 -0
  41. data/app/helpers/decidim/comments/comments_helper.rb +51 -0
  42. data/app/models/decidim/comments/comment.rb +55 -0
  43. data/app/types/decidim/comments/add_comment_type.rb +12 -0
  44. data/app/types/decidim/comments/author_type.rb +15 -0
  45. data/app/types/decidim/comments/comment_type.rb +28 -0
  46. data/config/i18n-tasks.yml +124 -0
  47. data/config/locales/ca.yml +35 -0
  48. data/config/locales/en.yml +36 -0
  49. data/config/locales/es.yml +35 -0
  50. data/db/migrate/20161130143508_create_comments.rb +11 -0
  51. data/db/migrate/20161214082645_add_depth_to_comments.rb +5 -0
  52. data/db/migrate/20161216102820_add_alignment_to_comments.rb +5 -0
  53. data/db/seeds.rb +11 -0
  54. data/lib/decidim/comments.rb +10 -0
  55. data/lib/decidim/comments/engine.rb +34 -0
  56. data/lib/decidim/comments/mutation_extensions.rb +36 -0
  57. data/lib/decidim/comments/query_extensions.rb +33 -0
  58. metadata +228 -0
@@ -0,0 +1,35 @@
1
+ ca:
2
+ activerecord:
3
+ errors:
4
+ messages:
5
+ cannot_have_replies: no pot tenir respostes
6
+ decidim:
7
+ components:
8
+ add_comment_form:
9
+ form:
10
+ body:
11
+ label: Comentari
12
+ placeholder: Què en penses d'això?
13
+ submit: Envia
14
+ opinion:
15
+ against: Hi estic en contra
16
+ in_favor: Hi estic a favor
17
+ neutral: Sóc neutral
18
+ title: Deixa el teu comentari
19
+ comment:
20
+ alignment:
21
+ against: En contra
22
+ in_favor: A favor
23
+ reply: Respondre
24
+ comment_order_selector:
25
+ order:
26
+ most_voted: Més votat
27
+ older: Més antic
28
+ recent: Recent
29
+ title: 'Ordenar per:'
30
+ comment_thread:
31
+ title: Conversa amb %{authorName}
32
+ comments:
33
+ title: "%{count} comentaris"
34
+ featured_comment:
35
+ title: Comentari destacat
@@ -0,0 +1,36 @@
1
+ ---
2
+ en:
3
+ activerecord:
4
+ errors:
5
+ messages:
6
+ cannot_have_replies: can't have replies
7
+ decidim:
8
+ components:
9
+ add_comment_form:
10
+ form:
11
+ body:
12
+ label: Comment
13
+ placeholder: What do you think about this?
14
+ submit: Send
15
+ opinion:
16
+ against: I am against
17
+ in_favor: I am in favor
18
+ neutral: I am neutral
19
+ title: Leave your comment
20
+ comment:
21
+ alignment:
22
+ against: Against
23
+ in_favor: In favor
24
+ reply: Reply
25
+ comment_order_selector:
26
+ order:
27
+ most_voted: Most voted
28
+ older: Older
29
+ recent: Recent
30
+ title: 'Order by:'
31
+ comment_thread:
32
+ title: Conversation with %{authorName}
33
+ comments:
34
+ title: "%{count} comments"
35
+ featured_comment:
36
+ title: Featured comment
@@ -0,0 +1,35 @@
1
+ es:
2
+ activerecord:
3
+ errors:
4
+ messages:
5
+ cannot_have_replies: no pueden tener respuestas
6
+ decidim:
7
+ components:
8
+ add_comment_form:
9
+ form:
10
+ body:
11
+ label: Comentario
12
+ placeholder: '¿Qué piensas sobre esto?'
13
+ submit: Enviar
14
+ opinion:
15
+ against: Estoy en contra
16
+ in_favor: Estoy a favor
17
+ neutral: Soy neutral
18
+ title: Deje su comentario
19
+ comment:
20
+ alignment:
21
+ against: En contra
22
+ in_favor: A favor
23
+ reply: Respuesta
24
+ comment_order_selector:
25
+ order:
26
+ most_voted: Más votado
27
+ older: Más antiguo
28
+ recent: Reciente
29
+ title: 'Ordenar por:'
30
+ comment_thread:
31
+ title: Conversación con %{authorName}
32
+ comments:
33
+ title: "%{count} comentarios"
34
+ featured_comment:
35
+ title: Comentario destacado
@@ -0,0 +1,11 @@
1
+ class CreateComments < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :decidim_comments_comments do |t|
4
+ t.text :body, null: false
5
+ t.references :commentable, null: false, polymorphic: true, index: { name: "decidim_comments_comment_commentable" }
6
+ t.references :author, null: false, index: { name: "decidim_comments_comment_author" }
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class AddDepthToComments < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :decidim_comments_comments, :depth, :integer, null: false, default: 0
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddAlignmentToComments < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :decidim_comments_comments, :alignment, :integer, null: false, default: 0
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ # Since comments cannot exist without a real model we are not including
2
+ # specific seeds for this engine.
3
+ # Other engines are free to include comments on their seeds like this:
4
+ #
5
+ # n.times do
6
+ # Decidim::Comments::Comment.create!(
7
+ # author: author,
8
+ # commentable: commentable,
9
+ # body: Faker::Lorem.paragraph
10
+ # )
11
+ # end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "decidim/comments/engine"
3
+
4
+ module Decidim
5
+ # This module contains all the logic related to the comments feature.
6
+ # It exposes a single entry point as a rails helper method to render
7
+ # a React component which handle all the comments render and logic.
8
+ module Comments
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+ require "rails"
3
+ require "active_support/all"
4
+
5
+ require "decidim/core"
6
+ require "jquery-rails"
7
+ require "sassc-rails"
8
+ require "turbolinks"
9
+ require "foundation-rails"
10
+ require "foundation_rails_helper"
11
+
12
+ require "decidim/comments/query_extensions"
13
+ require "decidim/comments/mutation_extensions"
14
+
15
+ module Decidim
16
+ module Comments
17
+ # Decidim's core Rails Engine.
18
+ class Engine < ::Rails::Engine
19
+ isolate_namespace Decidim::Comments
20
+
21
+ initializer "decidim_comments.assets" do |app|
22
+ app.config.assets.precompile += %w(decidim_comments_manifest.js)
23
+ end
24
+
25
+ initializer "decidim_comments.query_extensions" do
26
+ Comments::QueryExtensions.extend!(Decidim::Api::QueryType)
27
+ end
28
+
29
+ initializer "decidim_comments.mutation_extensions" do
30
+ Comments::MutationExtensions.extend!(Decidim::Api::MutationType)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Comments
4
+ # This module's job is to extend the API with custom fields related to
5
+ # decidim-comments.
6
+ module MutationExtensions
7
+ # Public: Extends a type with `decidim-comments`'s fields.
8
+ #
9
+ # type - A GraphQL::BaseType to extend.
10
+ #
11
+ # Returns nothing.
12
+ def self.extend!(type)
13
+ type.define do
14
+ field :addComment, Decidim::Comments::CommentType do
15
+ description "Add a new comment to a commentable"
16
+ argument :commentableId, !types.String, "The commentable's ID"
17
+ argument :commentableType, !types.String, "The commentable's class name. i.e. `Decidim::ParticipatoryProcess`"
18
+ argument :body, !types.String, "The comments's body"
19
+ argument :alignment, types.Int, "The comment's alignment. Can be 0 (neutral), 1 (in favor) or -1 (against)'", default_value: 0
20
+
21
+ resolve lambda { |_obj, args, ctx|
22
+ params = { "comment" => { "body" => args[:body], "alignment" => args[:alignment] } }
23
+ form = Decidim::Comments::CommentForm.from_params(params)
24
+ commentable = args[:commentableType].constantize.find(args[:commentableId])
25
+ Decidim::Comments::CreateComment.call(form, ctx[:current_user], commentable) do
26
+ on(:ok) do |comment|
27
+ return comment
28
+ end
29
+ end
30
+ }
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Comments
4
+ # This module's job is to extend the API with custom fields related to
5
+ # decidim-comments.
6
+ module QueryExtensions
7
+ # Public: Extends a type with `decidim-comments`'s fields.
8
+ #
9
+ # type - A GraphQL::BaseType to extend.
10
+ #
11
+ # Returns nothing.
12
+ def self.extend!(type)
13
+ type.define do
14
+ field :comments do
15
+ description "Lists all commentable's comments."
16
+ type !types[CommentType]
17
+
18
+ argument :commentableId, !types.String, "The commentable's ID"
19
+ argument :commentableType, !types.String, "The commentable's class name. i.e. `Decidim::ParticipatoryProcess`"
20
+
21
+ resolve lambda { |_obj, args, _ctx|
22
+ Comment
23
+ .where(commentable_id: args[:commentableId])
24
+ .where(commentable_type: args[:commentableType])
25
+ .order(created_at: :asc)
26
+ .all
27
+ }
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,228 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: decidim-comments
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Josep Jaume Rey Peroy
8
+ - Marc Riera Casals
9
+ - Oriol Gual Oliva
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2016-12-21 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: decidim-core
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '='
27
+ - !ruby/object:Gem::Version
28
+ version: 0.0.1
29
+ - !ruby/object:Gem::Dependency
30
+ name: rails
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: 5.0.0
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: 5.0.0.1
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - "~>"
44
+ - !ruby/object:Gem::Version
45
+ version: 5.0.0
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 5.0.0.1
49
+ - !ruby/object:Gem::Dependency
50
+ name: foundation-rails
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 6.2.4.0
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 6.2.4.0
63
+ - !ruby/object:Gem::Dependency
64
+ name: sassc-rails
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 1.3.0
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: 1.3.0
77
+ - !ruby/object:Gem::Dependency
78
+ name: jquery-rails
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '4.0'
84
+ type: :runtime
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '4.0'
91
+ - !ruby/object:Gem::Dependency
92
+ name: turbolinks
93
+ requirement: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 5.0.0
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 5.0.0.1
101
+ type: :runtime
102
+ prerelease: false
103
+ version_requirements: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: 5.0.0
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 5.0.0.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: foundation_rails_helper
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 2.0.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 2.0.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: decidim-dev
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.0.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.0.1
139
+ description: Pluggable comments system for some components.
140
+ email:
141
+ - josepjaume@gmail.com
142
+ - mrc2407@gmail.com
143
+ - oriolgual@gmail.com
144
+ executables: []
145
+ extensions: []
146
+ extra_rdoc_files: []
147
+ files:
148
+ - README.md
149
+ - Rakefile
150
+ - app/assets/config/decidim_comments_manifest.js
151
+ - app/assets/javascripts/decidim/comments/bundle.js
152
+ - app/assets/javascripts/decidim/comments/bundle.js.map
153
+ - app/assets/javascripts/decidim/comments/comments.js.erb
154
+ - app/commands/decidim/comments/create_comment.rb
155
+ - app/forms/decidim/comments/comment_form.rb
156
+ - app/frontend/application/apollo_client.js
157
+ - app/frontend/application/application.component.jsx
158
+ - app/frontend/application/application.component.test.jsx
159
+ - app/frontend/application/icon.component.jsx
160
+ - app/frontend/application/icon.component.test.jsx
161
+ - app/frontend/comments/add_comment_form.component.jsx
162
+ - app/frontend/comments/add_comment_form.component.test.jsx
163
+ - app/frontend/comments/add_comment_form.mutation.graphql
164
+ - app/frontend/comments/comment.component.jsx
165
+ - app/frontend/comments/comment.component.test.jsx
166
+ - app/frontend/comments/comment.fragment.graphql
167
+ - app/frontend/comments/comment_data.fragment.graphql
168
+ - app/frontend/comments/comment_order_selector.component.jsx
169
+ - app/frontend/comments/comment_order_selector.component.test.jsx
170
+ - app/frontend/comments/comment_thread.component.jsx
171
+ - app/frontend/comments/comment_thread.component.test.jsx
172
+ - app/frontend/comments/comment_thread.fragment.graphql
173
+ - app/frontend/comments/comments.component.jsx
174
+ - app/frontend/comments/comments.component.test.jsx
175
+ - app/frontend/comments/comments.query.graphql
176
+ - app/frontend/comments/featured_comment.component.jsx
177
+ - app/frontend/comments/featured_comment.component.test.jsx
178
+ - app/frontend/entry.js
179
+ - app/frontend/entry.test.js
180
+ - app/frontend/support/asset_url.js
181
+ - app/frontend/support/generate_comments_data.js
182
+ - app/frontend/support/generate_current_user_data.js
183
+ - app/frontend/support/load_translations.js
184
+ - app/frontend/support/require_all.js
185
+ - app/frontend/support/resolve_graphql_query.js
186
+ - app/frontend/support/stub_component.js
187
+ - app/helpers/decidim/comments/comments_helper.rb
188
+ - app/models/decidim/comments/comment.rb
189
+ - app/types/decidim/comments/add_comment_type.rb
190
+ - app/types/decidim/comments/author_type.rb
191
+ - app/types/decidim/comments/comment_type.rb
192
+ - config/i18n-tasks.yml
193
+ - config/locales/ca.yml
194
+ - config/locales/en.yml
195
+ - config/locales/es.yml
196
+ - db/migrate/20161130143508_create_comments.rb
197
+ - db/migrate/20161214082645_add_depth_to_comments.rb
198
+ - db/migrate/20161216102820_add_alignment_to_comments.rb
199
+ - db/seeds.rb
200
+ - lib/decidim/comments.rb
201
+ - lib/decidim/comments/engine.rb
202
+ - lib/decidim/comments/mutation_extensions.rb
203
+ - lib/decidim/comments/query_extensions.rb
204
+ homepage: https://github.com/AjuntamentdeBarcelona/decidim
205
+ licenses:
206
+ - AGPLv3
207
+ metadata: {}
208
+ post_install_message:
209
+ rdoc_options: []
210
+ require_paths:
211
+ - lib
212
+ required_ruby_version: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ version: 2.3.1
217
+ required_rubygems_version: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ requirements: []
223
+ rubyforge_project:
224
+ rubygems_version: 2.5.2
225
+ signing_key:
226
+ specification_version: 4
227
+ summary: Pluggable comments system for some components.
228
+ test_files: []