decidim-decidim_awesome 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3eed88558d87e79b6943a0fafa5e482129482f29d60de45cb30dabeb696a726d
4
- data.tar.gz: 3818b75fbfa54b2517e75c2873f443262afeb684735a348f4e4a110a4979fe30
3
+ metadata.gz: 3eae6aea754d4ce898a8631f7d8c3b03946a11fc0cb15c5e1d373d98774aabeb
4
+ data.tar.gz: 7f3107a8bfa4d3069c34cf28c7347686d38811fd7f9d6b1a18ff41e470216af2
5
5
  SHA512:
6
- metadata.gz: 1036da296077cd339bc14428b2c3bdcd8e47ebbc881ede6d96fe0f74c513d78f5e8691aff184754932c7e071d942d1d9c2dbb93bcbf5b32c6d2b1627f4c2bb60
7
- data.tar.gz: a0b3b5476eef71ab74b45bee55366bcd9c90918daa7e3aa043dd85aaa9adca6518b2984fe46d5d5567f72fadbfc3c72d653c99cea07f13e1f0a8fe220226daaf
6
+ metadata.gz: dbbaaea663e4c9d317e7f971e0da7446577d6427245da4f17993b971c166a951e7eaeeb2d0264f01eaded4b3eb65b79c07ecec9e216cafc7e45ed6dc1fc010a4
7
+ data.tar.gz: d77a435d6ebf77601d27344a744048e1eff43f599e64a330dcb9e7ea3f22e1efbbf808fb676891dd4404d334acc217a5a19fd892482631cc148992c342295893
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Usability and UX tweaks for Decidim.
8
8
 
9
- This plugin allows the administrators to expand the possibilities of Decidim beyond some existing limitations.
9
+ This plugin allows the administrators to expand the possibilities of Decidim beyond some existing limitations.
10
10
  All tweaks are provided in a optional fashion with granular permissions that let the administrator to choose exactly where to apply those mods. Some tweaks can be applied to any assembly, other in an specific participatory process or even in type of component only.
11
11
 
12
12
  **This in beta status, we do not accept any responsibility for breaking anything. Feedback is appreciated though.**
@@ -16,7 +16,7 @@ All tweaks are provided in a optional fashion with granular permissions that let
16
16
  At Platoniq, we like to explore and combine open tools for enriching democracy in many levels. And also for organizations or companies, not only governments.
17
17
  Currently we are working very closely with the team behind [Decidim](https://decidim.org) because we believe that it is a great software.
18
18
 
19
- However in Platoniq we have this slogan: "Democracy is fun if you take it seriously" (feel free to ask for T-shirts 😉).
19
+ However in Platoniq we have this slogan: "Democracy is fun if you take it seriously" (feel free to ask for T-shirts 😉).
20
20
  And, let's face it, sometimes we feel that Decidim lacks a bit of the "fun" part so we created this.
21
21
  Because Decidim is awesome and so is this!
22
22
 
@@ -89,7 +89,7 @@ This feature allows to customize each organization css without affecting the oth
89
89
  4. Modify that file as you like, you can use any SASS function available (such as `@import`)
90
90
  5. Restart your server, enjoy!
91
91
 
92
- See an example here:
92
+ See an example here:
93
93
  https://github.com/Platoniq/decidim-demo/tree/master/app/assets/themes
94
94
 
95
95
  NOTE: Files presents in the `app/assets/themes` folder are added automatically into the precompile list of Rails by this plugin.
@@ -109,7 +109,7 @@ With this feature you can have a support chat in Decidim. It is linked to a [Tel
109
109
 
110
110
  #### To be continued...
111
111
 
112
- Some things in the road-map:
112
+ Some things in the road-map:
113
113
 
114
114
  1. Improve the conversation in comments by allowing images
115
115
  1. Direct export of surveys in PDF
@@ -121,7 +121,7 @@ Some things in the road-map:
121
121
  Add this line to your application's Gemfile:
122
122
 
123
123
  ```ruby
124
- gem "decidim-decidim_awesome", "~> 0.6.1"
124
+ gem "decidim-decidim_awesome", "~> 0.6.2"
125
125
  ```
126
126
 
127
127
  And then execute:
@@ -141,7 +141,7 @@ Depending on your Decidim version, choose the corresponding Awesome version to e
141
141
 
142
142
  ## Configuration
143
143
 
144
- Each tweak can be enabled or disabled by default. It also can be deactivated so
144
+ Each tweak can be enabled or disabled by default. It also can be deactivated so
145
145
  admins do not even see it.
146
146
 
147
147
  In order to personalize default values, create an initializer such as:
@@ -244,15 +244,23 @@ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake test_
244
244
  DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rspec
245
245
  ```
246
246
 
247
- However, this project also make use of the gem [Appraisals](https://github.com/thoughtbot/appraisal) in order to test againts several versions of Decidim. The idea is to suport same supported versions of Decidim.
247
+ However, this project also make use of the gem [Appraisals](https://github.com/thoughtbot/appraisal) in order to test against several versions of Decidim. The idea is to support same supported versions of Decidim.
248
248
 
249
249
  You can run run all tests against all Decidim versions by using:
250
+
250
251
  ```bash
251
252
  bundle exec appraisal install
252
- DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake test_app
253
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal rake test_app
253
254
  DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal rspec
254
255
  ```
255
256
 
257
+ To test a specific apprasail configured version do the following:
258
+
259
+ ```
260
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.23 rake test_app
261
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.23 rspec
262
+ ```
263
+
256
264
  Note that the database user has to have rights to create and drop a database in
257
265
  order to create the dummy test app database.
258
266
 
@@ -276,13 +284,15 @@ the code coverage report.
276
284
 
277
285
  ### Appraisals commands
278
286
 
287
+ The [Appraisals](Appraisals) file contains the supported versions. In i each version defines the changes respect to the main `Gemfile`.
288
+
279
289
  Appraisal uses custom gems for testing in the folder `gemfiles`, these gemfiles are generated from the file `Appraisals`. To update definitions do:
280
290
 
281
291
  ```
282
292
  bundle exec appraisal install
283
293
  ```
284
294
 
285
- To update the Appraisal definitions manually do the following:
295
+ The former command will take care of updating all configured version. To update the Appraisal definitions manually (not usually necessary) do the following:
286
296
 
287
297
  ```
288
298
  cd gemfiles
@@ -12,7 +12,7 @@
12
12
  // Redefines Quill editor with images
13
13
  if(exports.DecidimAwesome.allow_images_in_full_editor || exports.DecidimAwesome.allow_images_in_small_editor || exports.DecidimAwesome.use_markdown_editor) {
14
14
 
15
- const quillFormats = ["bold", "italic", "link", "underline", "header", "list", "video", "image"];
15
+ const quillFormats = ["bold", "italic", "link", "underline", "header", "list", "video", "image", "alt"];
16
16
 
17
17
  const createQuillEditor = (container) => {
18
18
  const toolbar = $(container).data("toolbar");
@@ -2,8 +2,30 @@
2
2
 
3
3
  # Tune Proposal presenter to use markdown if configured
4
4
  Decidim::Proposals::ProposalPresenter.class_eval do
5
- def body(links: false, extras: true, strip_tags: false)
6
- if respond_to? :translated_attribute
5
+ # rubocop:disable Metrics/CyclomaticComplexity
6
+ # rubocop:disable Metrics/PerceivedComplexity
7
+ def body(links: false, extras: true, strip_tags: false, all_locales: false)
8
+ return unless proposal
9
+
10
+ if defined? handle_locales
11
+ return handle_locales(proposal.body, all_locales) do |content|
12
+ content = strip_tags(sanitize_text(content)) if strip_tags
13
+
14
+ renderer = Decidim::ContentRenderers::HashtagRenderer.new(content)
15
+ content = renderer.render(links: links, extras: extras).html_safe
16
+
17
+ if use_markdown?(proposal) && !all_locales # avoid rendering in editors
18
+ content = render_markdown(content)
19
+ elsif links
20
+ content = Decidim::ContentRenderers::LinkRenderer.new(content).render
21
+ end
22
+ content
23
+ end
24
+ end
25
+ # rubocop:enable Metrics/CyclomaticComplexity
26
+ # rubocop:enable Metrics/PerceivedComplexity
27
+
28
+ if defined? translated_attribute
7
29
  text = translated_attribute(proposal.body)
8
30
 
9
31
  text = strip_tags(sanitize_text(text)) if strip_tags
@@ -17,9 +39,7 @@ Decidim::Proposals::ProposalPresenter.class_eval do
17
39
  text = renderer.render(links: links, extras: extras).html_safe
18
40
 
19
41
  if use_markdown? proposal
20
- text = Decidim::DecidimAwesome::ContentRenderers::MarkdownRenderer.new(text).render
21
- # HACK: to avoid the replacement of lines to <br> that simple_format does
22
- text = text.gsub(">\n", ">").gsub("\n<", "<")
42
+ text = render_markdown(text)
23
43
  elsif links
24
44
  text = Decidim::ContentRenderers::LinkRenderer.new(text).render
25
45
  end
@@ -35,4 +55,10 @@ Decidim::Proposals::ProposalPresenter.class_eval do
35
55
  config.context_from_component proposal
36
56
  config.enabled_for? :use_markdown_editor
37
57
  end
58
+
59
+ def render_markdown(content)
60
+ content = Decidim::DecidimAwesome::ContentRenderers::MarkdownRenderer.new(content).render
61
+ # HACK: to avoid the replacement of lines to <br> that simple_format does
62
+ content.gsub(">\n", ">").gsub("\n<", "<")
63
+ end
38
64
  end
@@ -9,7 +9,9 @@ decidim-core:
9
9
  /app/assets/javascripts/decidim/editor.js.es6:
10
10
  decidim-0.22: 797d0ec1c9e79453cf6718f82d2fdd27
11
11
  decidim-0.23: cb059b8ff0ffc62c67eb99d8d7a6637b
12
+ decidim-0.23.1: 4787f73f0f33661e3897404f10019d26
12
13
  decidim-proposals:
13
14
  /app/presenters/decidim/proposals/proposal_presenter.rb:
14
15
  decidim-0.22: 7d60c8310d7fa4e38d9a27080c22b12c
15
16
  decidim-0.23: 437c0c25151f605401a4f14d090ba5ea
17
+ decidim-0.23.1: 892021b2ce9ac10c2e1b738e6948cde0
@@ -31,7 +31,7 @@ Decidim.register_component(:awesome_iframe) do |component|
31
31
  # end
32
32
 
33
33
  component.seeds do |participatory_space|
34
- # Create a Iframe and a few geolocated proposals
34
+ # Create a Iframe component in all participatory spaces
35
35
  admin_user = Decidim::User.find_by(
36
36
  organization: participatory_space.organization,
37
37
  email: "admin@example.org"
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples "has no drag and drop" do |rte|
4
+ it "has no help text" do
5
+ expect(page).not_to have_content("Add images by dragging & dropping or pasting them.")
6
+ end
7
+
8
+ if rte
9
+ it "has image button" do
10
+ expect(page).not_to have_xpath("//button[@class='ql-image']")
11
+ end
12
+ else
13
+ it "has no paste event" do
14
+ expect(page.execute_script("return typeof $._data($('#{editor_selector}')[0], 'events').paste")).to eq("undefined")
15
+ end
16
+
17
+ it "has no drop event" do
18
+ expect(page.execute_script("return typeof $._data($('#{editor_selector}')[0], 'events').drop")).to eq("undefined")
19
+ end
20
+ end
21
+ end
22
+
23
+ shared_examples "has drag and drop" do |rte|
24
+ it "has help text" do
25
+ expect(page).to have_content("Add images by dragging & dropping or pasting them.")
26
+ end
27
+
28
+ if rte
29
+ it "has image button" do
30
+ expect(page).to have_xpath("//button[@class='ql-image']")
31
+ end
32
+ else
33
+ it "has paste event" do
34
+ expect(page.execute_script("return typeof $._data($('#{editor_selector}')[0], 'events').paste")).to eq("object")
35
+ end
36
+
37
+ it "has drop event" do
38
+ expect(page.execute_script("return typeof $._data($('#{editor_selector}')[0], 'events').drop")).to eq("object")
39
+ end
40
+ end
41
+ end
42
+
43
+ shared_examples "has markdown editor" do |images|
44
+ it "has CodeMirror class" do
45
+ expect(page).to have_xpath("//div[@class='CodeMirror cm-s-paper CodeMirror-wrap']")
46
+ end
47
+
48
+ it "has toolbar" do
49
+ expect(page).to have_xpath("//div[@class='editor-toolbar']")
50
+ end
51
+
52
+ if images
53
+ it "has help text" do
54
+ expect(page).to have_content("Add images by dragging & dropping or pasting them.")
55
+ end
56
+ else
57
+ it "has no help text" do
58
+ expect(page).not_to have_content("Add images by dragging & dropping or pasting them.")
59
+ end
60
+ end
61
+ end
62
+
63
+ shared_examples "has no markdown editor" do
64
+ it "has CodeMirror class" do
65
+ expect(page).not_to have_xpath("//div[@class='CodeMirror cm-s-paper CodeMirror-wrap']")
66
+ end
67
+
68
+ it "has toolbar" do
69
+ expect(page).not_to have_xpath("//div[@class='editor-toolbar']")
70
+ end
71
+ end
@@ -3,8 +3,7 @@
3
3
  module Decidim
4
4
  # This holds the decidim-decidim_awesome version.
5
5
  module DecidimAwesome
6
- VERSION = "0.6.1"
6
+ VERSION = "0.6.2"
7
7
  COMPAT_DECIDIM_VERSION = [">= 0.22.0", "< 0.24"].freeze
8
- DECIDIM_VERSION = "0.23.1"
9
8
  end
10
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-decidim_awesome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Vergés
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-11 00:00:00.000000000 Z
11
+ date: 2021-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: decidim-admin
@@ -223,6 +223,7 @@ files:
223
223
  - lib/decidim/decidim_awesome/test/layouts/decidim/_head.html.erb
224
224
  - lib/decidim/decidim_awesome/test/layouts/decidim/admin/_header.html.erb
225
225
  - lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb
226
+ - lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb
226
227
  - lib/decidim/decidim_awesome/test/themes/css.lvh.me.css
227
228
  - lib/decidim/decidim_awesome/test/themes/erb.lvh.me.scss.erb
228
229
  - lib/decidim/decidim_awesome/test/themes/scss.lvh.me.scss