decidim-comments 0.19.0 → 0.22.0

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 (81) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/comments/bundle.js +41 -41
  3. data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
  4. data/app/cells/decidim/comments/comment_activity_cell.rb +1 -1
  5. data/app/commands/decidim/comments/create_comment.rb +7 -7
  6. data/app/events/decidim/comments/comment_by_followed_user_group_event.rb +9 -0
  7. data/app/events/decidim/comments/comment_event.rb +15 -2
  8. data/app/events/decidim/comments/user_group_mentioned_event.rb +10 -0
  9. data/app/forms/decidim/comments/comment_form.rb +9 -0
  10. data/app/frontend/application/icon.component.tsx +16 -4
  11. data/app/frontend/comments/add_comment_form.component.test.tsx +4 -1
  12. data/app/frontend/comments/add_comment_form.component.tsx +16 -3
  13. data/app/frontend/comments/comment.component.test.tsx +1 -1
  14. data/app/frontend/comments/comment.component.tsx +287 -74
  15. data/app/frontend/comments/comment_order_selector.component.tsx +26 -7
  16. data/app/frontend/comments/comments.component.tsx +65 -8
  17. data/app/frontend/comments/down_vote_button.component.tsx +3 -0
  18. data/app/frontend/comments/up_vote_button.component.tsx +3 -0
  19. data/app/frontend/comments/vote_button.component.tsx +4 -0
  20. data/app/frontend/comments/vote_button_component.test.tsx +14 -8
  21. data/app/frontend/entry.ts +19 -0
  22. data/app/frontend/entry_test.ts +2 -0
  23. data/app/frontend/queries/comments.query.graphql +2 -2
  24. data/app/frontend/support/schema.ts +745 -744
  25. data/app/models/decidim/comments/comment.rb +30 -5
  26. data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +1 -6
  27. data/app/queries/decidim/comments/sorted_comments.rb +8 -2
  28. data/app/scrubbers/decidim/comments/user_input_scrubber.rb +20 -0
  29. data/app/services/decidim/comments/new_comment_notification_creator.rb +28 -3
  30. data/app/types/decidim/comments/commentable_interface.rb +2 -1
  31. data/app/types/decidim/comments/commentable_mutation_type.rb +2 -2
  32. data/config/locales/ar.yml +10 -1
  33. data/config/locales/bg-BG.yml +6 -0
  34. data/config/locales/ca.yml +23 -1
  35. data/config/locales/cs.yml +35 -13
  36. data/config/locales/da-DK.yml +1 -0
  37. data/config/locales/de.yml +23 -1
  38. data/config/locales/el-GR.yml +1 -0
  39. data/config/locales/el.yml +122 -0
  40. data/config/locales/en.yml +23 -1
  41. data/config/locales/es-MX.yml +23 -1
  42. data/config/locales/es-PY.yml +23 -1
  43. data/config/locales/es.yml +23 -1
  44. data/config/locales/et-EE.yml +1 -0
  45. data/config/locales/eu.yml +4 -1
  46. data/config/locales/fi-plain.yml +23 -1
  47. data/config/locales/fi.yml +29 -7
  48. data/config/locales/fr-CA.yml +122 -0
  49. data/config/locales/fr.yml +23 -1
  50. data/config/locales/ga-IE.yml +1 -0
  51. data/config/locales/gl.yml +4 -1
  52. data/config/locales/hr-HR.yml +1 -0
  53. data/config/locales/hu.yml +17 -1
  54. data/config/locales/id-ID.yml +4 -1
  55. data/config/locales/is-IS.yml +76 -0
  56. data/config/locales/it.yml +23 -1
  57. data/config/locales/ja-JP.yml +120 -0
  58. data/config/locales/lt-LT.yml +1 -0
  59. data/config/locales/lv-LV.yml +118 -0
  60. data/config/locales/mt-MT.yml +1 -0
  61. data/config/locales/nl.yml +35 -13
  62. data/config/locales/no.yml +118 -0
  63. data/config/locales/pl.yml +57 -35
  64. data/config/locales/pt-BR.yml +5 -2
  65. data/config/locales/pt.yml +47 -25
  66. data/config/locales/ro-RO.yml +124 -0
  67. data/config/locales/ru.yml +12 -1
  68. data/config/locales/sk-SK.yml +116 -0
  69. data/config/locales/sk.yml +120 -0
  70. data/config/locales/sl.yml +4 -0
  71. data/config/locales/sr-CS.yml +20 -0
  72. data/config/locales/sv.yml +25 -3
  73. data/config/locales/tr-TR.yml +4 -1
  74. data/config/locales/uk.yml +4 -1
  75. data/db/migrate/20200320105911_index_foreign_keys_in_decidim_comments_comments.rb +7 -0
  76. data/lib/decidim/comments.rb +1 -0
  77. data/lib/decidim/comments/markdown.rb +55 -0
  78. data/lib/decidim/comments/test/shared_examples/comment_event.rb +11 -1
  79. data/lib/decidim/comments/test/shared_examples/create_comment_context.rb +3 -2
  80. data/lib/decidim/comments/version.rb +1 -1
  81. metadata +46 -9
@@ -17,6 +17,7 @@ module Decidim
17
17
  autoload :CommentSerializer, "decidim/comments/comment_serializer"
18
18
  autoload :CommentVoteSerializer, "decidim/comments/comment_vote_serializer"
19
19
  autoload :Export, "decidim/comments/export"
20
+ autoload :Markdown, "decidim/comments/markdown"
20
21
 
21
22
  def self.data_portable_entities
22
23
  ["Decidim::Comments::Comment", "Decidim::Comments::CommentVote"]
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "redcarpet"
4
+
5
+ module Decidim
6
+ module Comments
7
+ # This class parses a string from plain text (markdown) and
8
+ # renders it as HTML.
9
+ class Markdown < ::Redcarpet::Render::Base
10
+ delegate :render, to: :markdown
11
+
12
+ private
13
+
14
+ def markdown
15
+ @markdown ||= ::Redcarpet::Markdown.new(renderer)
16
+ end
17
+
18
+ def renderer
19
+ @renderer ||= Decidim::Comments::MarkdownRender.new
20
+ end
21
+ end
22
+
23
+ # Custom markdown renderer for Comments
24
+ class MarkdownRender < ::Redcarpet::Render::Safe
25
+ def initialize(extensions = {})
26
+ super({
27
+ autolink: true,
28
+ escape_html: false,
29
+ filter_html: true,
30
+ hard_wrap: true,
31
+ lax_spacing: false,
32
+ no_images: true,
33
+ no_styles: true
34
+ }.merge(extensions))
35
+ end
36
+
37
+ # renders quotes with a custom css class
38
+ def block_quote(quote)
39
+ %(<blockquote class="comment__quote">#{quote}</blockquote>)
40
+ end
41
+
42
+ # removes header tags in comments
43
+ def header(title, _level)
44
+ title
45
+ end
46
+
47
+ # prevents empty <p/> in comments
48
+ def paragraph(text)
49
+ return if text.blank?
50
+
51
+ "<p>#{text}</p>"
52
+ end
53
+ end
54
+ end
55
+ end
@@ -12,10 +12,16 @@ shared_context "when it's a comment event" do
12
12
 
13
13
  let(:comment) { create :comment }
14
14
  let(:comment_author) { comment.author }
15
+ let(:normalized_comment_author) { comment.author }
15
16
  let(:comment_author_name) { decidim_html_escape comment.author.name }
16
17
 
17
18
  let(:extra) { { comment_id: comment.id } }
18
19
  let(:resource_title) { decidim_html_escape resource.title }
20
+ let(:user_group) do
21
+ user_group = create(:user_group, :verified, organization: organization, users: [comment_author])
22
+ comment.update!(user_group: user_group)
23
+ user_group
24
+ end
19
25
  end
20
26
 
21
27
  shared_examples_for "a comment event" do
@@ -23,7 +29,11 @@ shared_examples_for "a comment event" do
23
29
 
24
30
  describe "author" do
25
31
  it "returns the comment author" do
26
- expect(subject.author).to eq(comment_author)
32
+ if defined? user_group_author
33
+ expect(subject.author).to eq(user_group_author)
34
+ else
35
+ expect(subject.author).to eq(comment_author)
36
+ end
27
37
  end
28
38
  end
29
39
 
@@ -16,7 +16,8 @@ RSpec.shared_context "when creating a comment" do
16
16
  "comment" => {
17
17
  "body" => body,
18
18
  "alignment" => alignment,
19
- "user_group_id" => user_group_id
19
+ "user_group_id" => user_group_id,
20
+ "commentable" => commentable
20
21
  }
21
22
  }
22
23
  end
@@ -27,5 +28,5 @@ RSpec.shared_context "when creating a comment" do
27
28
  current_organization: organization
28
29
  )
29
30
  end
30
- let(:command) { described_class.new(form, author, commentable) }
31
+ let(:command) { described_class.new(form, author) }
31
32
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-comments version.
5
5
  module Comments
6
6
  def self.version
7
- "0.19.0"
7
+ "0.22.0"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-comments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-10-21 00:00:00.000000000 Z
13
+ date: 2020-09-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: decidim-core
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.19.0
21
+ version: 0.22.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 0.19.0
28
+ version: 0.22.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: jquery-rails
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -40,34 +40,48 @@ dependencies:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '4.3'
43
+ - !ruby/object:Gem::Dependency
44
+ name: redcarpet
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.4'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '3.4'
43
57
  - !ruby/object:Gem::Dependency
44
58
  name: decidim-admin
45
59
  requirement: !ruby/object:Gem::Requirement
46
60
  requirements:
47
61
  - - '='
48
62
  - !ruby/object:Gem::Version
49
- version: 0.19.0
63
+ version: 0.22.0
50
64
  type: :development
51
65
  prerelease: false
52
66
  version_requirements: !ruby/object:Gem::Requirement
53
67
  requirements:
54
68
  - - '='
55
69
  - !ruby/object:Gem::Version
56
- version: 0.19.0
70
+ version: 0.22.0
57
71
  - !ruby/object:Gem::Dependency
58
72
  name: decidim-dev
59
73
  requirement: !ruby/object:Gem::Requirement
60
74
  requirements:
61
75
  - - '='
62
76
  - !ruby/object:Gem::Version
63
- version: 0.19.0
77
+ version: 0.22.0
64
78
  type: :development
65
79
  prerelease: false
66
80
  version_requirements: !ruby/object:Gem::Requirement
67
81
  requirements:
68
82
  - - '='
69
83
  - !ruby/object:Gem::Version
70
- version: 0.19.0
84
+ version: 0.22.0
71
85
  description: Pluggable comments system for some components.
72
86
  email:
73
87
  - josepjaume@gmail.com
@@ -87,9 +101,11 @@ files:
87
101
  - app/commands/decidim/comments/create_comment.rb
88
102
  - app/commands/decidim/comments/vote_comment.rb
89
103
  - app/events/decidim/comments/comment_by_followed_user_event.rb
104
+ - app/events/decidim/comments/comment_by_followed_user_group_event.rb
90
105
  - app/events/decidim/comments/comment_created_event.rb
91
106
  - app/events/decidim/comments/comment_event.rb
92
107
  - app/events/decidim/comments/reply_created_event.rb
108
+ - app/events/decidim/comments/user_group_mentioned_event.rb
93
109
  - app/events/decidim/comments/user_mentioned_event.rb
94
110
  - app/forms/decidim/comments/comment_form.rb
95
111
  - app/frontend/application/apollo_client.ts
@@ -143,6 +159,7 @@ files:
143
159
  - app/queries/decidim/comments/metrics/comments_metric_manage.rb
144
160
  - app/queries/decidim/comments/sorted_comments.rb
145
161
  - app/resolvers/decidim/comments/vote_comment_resolver.rb
162
+ - app/scrubbers/decidim/comments/user_input_scrubber.rb
146
163
  - app/services/decidim/comments/comment_creation.rb
147
164
  - app/services/decidim/comments/new_comment_notification_creator.rb
148
165
  - app/types/decidim/comments/commentable_interface.rb
@@ -150,30 +167,48 @@ files:
150
167
  - app/types/decidim/comments/commentable_type.rb
151
168
  - config/locales/ar-SA.yml
152
169
  - config/locales/ar.yml
170
+ - config/locales/bg-BG.yml
153
171
  - config/locales/ca.yml
154
172
  - config/locales/cs-CZ.yml
155
173
  - config/locales/cs.yml
174
+ - config/locales/da-DK.yml
156
175
  - config/locales/de.yml
176
+ - config/locales/el-GR.yml
177
+ - config/locales/el.yml
157
178
  - config/locales/en.yml
158
179
  - config/locales/eo-UY.yml
159
180
  - config/locales/es-MX.yml
160
181
  - config/locales/es-PY.yml
161
182
  - config/locales/es.yml
183
+ - config/locales/et-EE.yml
162
184
  - config/locales/eu.yml
163
185
  - config/locales/fi-pl.yml
164
186
  - config/locales/fi-plain.yml
165
187
  - config/locales/fi.yml
188
+ - config/locales/fr-CA.yml
166
189
  - config/locales/fr.yml
190
+ - config/locales/ga-IE.yml
167
191
  - config/locales/gl.yml
192
+ - config/locales/hr-HR.yml
168
193
  - config/locales/hu.yml
169
194
  - config/locales/id-ID.yml
195
+ - config/locales/is-IS.yml
170
196
  - config/locales/it.yml
197
+ - config/locales/ja-JP.yml
198
+ - config/locales/lt-LT.yml
199
+ - config/locales/lv-LV.yml
200
+ - config/locales/mt-MT.yml
171
201
  - config/locales/nl.yml
172
202
  - config/locales/no.yml
173
203
  - config/locales/pl.yml
174
204
  - config/locales/pt-BR.yml
175
205
  - config/locales/pt.yml
206
+ - config/locales/ro-RO.yml
176
207
  - config/locales/ru.yml
208
+ - config/locales/sk-SK.yml
209
+ - config/locales/sk.yml
210
+ - config/locales/sl.yml
211
+ - config/locales/sr-CS.yml
177
212
  - config/locales/sv.yml
178
213
  - config/locales/tr-TR.yml
179
214
  - config/locales/uk.yml
@@ -188,6 +223,7 @@ files:
188
223
  - db/migrate/20181003080320_fix_user_groups_ids_in_comments.rb
189
224
  - db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
190
225
  - db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
226
+ - db/migrate/20200320105911_index_foreign_keys_in_decidim_comments_comments.rb
191
227
  - db/seeds.rb
192
228
  - lib/decidim/comments.rb
193
229
  - lib/decidim/comments/admin.rb
@@ -201,6 +237,7 @@ files:
201
237
  - lib/decidim/comments/comments_helper.rb
202
238
  - lib/decidim/comments/engine.rb
203
239
  - lib/decidim/comments/export.rb
240
+ - lib/decidim/comments/markdown.rb
204
241
  - lib/decidim/comments/mutation_extensions.rb
205
242
  - lib/decidim/comments/query_extensions.rb
206
243
  - lib/decidim/comments/test.rb
@@ -227,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
264
  - !ruby/object:Gem::Version
228
265
  version: '0'
229
266
  requirements: []
230
- rubygems_version: 3.0.3
267
+ rubygems_version: 3.1.2
231
268
  signing_key:
232
269
  specification_version: 4
233
270
  summary: Decidim comments module