decidim-plans 0.16.5 → 0.16.6

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: '08d56d238a66eca983dbe996717bb9387525e974336ce65ab9f8943e1e3afe5e'
4
- data.tar.gz: fe1204b85350bdea566562b75956c7eed3e989b793669b35b25be08b85cabe07
3
+ metadata.gz: 870133d81fb0fd7608a2087fbf2fdb7a434a37ebe3437334c9cdb604c2afd3f8
4
+ data.tar.gz: 4e28e6926fbdfe8339eb19ef66c1c455cef50ad9cf42a1940f2c2ec9df0a041f
5
5
  SHA512:
6
- metadata.gz: f8ac917fa65cc0f67ae41541ee8d9af242ecff01ed3b3936bba4f1dfe3b6de3d771dc830a6b9522596ab57a73d378b0ffe2be76454e9b96f530a3eb947144ed4
7
- data.tar.gz: 17df9cff118e3dc9be17afb6408a247e600da2018cef3220078bf5885a0ebbc3da04780e14fe074935e4cbfc4966f379f4e37a6c035b65986002b1e5a4428a1a
6
+ metadata.gz: 1cd3865a386f58d321ff9e077e7c8728b011dfe85cffcc52b0c6854759ee91592398eab98506fdb31d162f52022a532a0bc5e18d21191e88798d9fa29fc84858
7
+ data.tar.gz: 55e53122d62b560a70532c9ce0d3b2b8466b4ca2187cc54664df4f3710a8697b8f5112c200d597d39e19006271ae4402d6421d5a8dac83e8b5dd254201bfb56f
@@ -6,7 +6,7 @@ module Decidim
6
6
  # A command with all the business logic when an admin exports plans to a
7
7
  # single budget component.
8
8
  class ExportPlansToBudgets < Rectify::Command
9
- include ActionView::Helpers::TextHelper
9
+ include Decidim::Plans::RichPresenter
10
10
 
11
11
  # Public: Initializes the command.
12
12
  #
@@ -85,13 +85,14 @@ module Decidim
85
85
  original_plan.sections.each do |section|
86
86
  content = original_plan.contents.find_by(section: section)
87
87
  content.body.each do |locale, body_text|
88
- title = sanitize(section.body[locale])
88
+ title = plain_content(section.body[locale])
89
89
  pr_desc[locale] ||= ""
90
90
  pr_desc[locale] += "<h3>#{title}</h3>\n"
91
91
 
92
92
  # Wrap non-HTML strings within a <p> tag and replace newlines with
93
- # <br>. This also takes care of sanitization.
94
- pr_desc[locale] += simple_format(body_text)
93
+ # <br>. This also takes care of sanitization and specific styling
94
+ # of the text, such as bold, italics, etc.
95
+ pr_desc[locale] += rich_content(body_text)
95
96
  end
96
97
  end
97
98
 
@@ -103,7 +104,7 @@ module Decidim
103
104
 
104
105
  def sanitize_localized(hash)
105
106
  hash.each do |locale, value|
106
- hash[locale] = sanitize(value)
107
+ hash[locale] = plain_content(value)
107
108
  end
108
109
  end
109
110
  end
@@ -17,9 +17,9 @@ module Decidim
17
17
 
18
18
  helper_method :attached_proposals_picker_field
19
19
 
20
- before_action :authenticate_user!, only: [:new, :create, :edit, :update, :withdraw, :preview, :publish, :close, :reopen, :destroy]
20
+ before_action :authenticate_user!, only: [:new, :create, :edit, :update, :withdraw, :preview, :publish, :close, :destroy]
21
21
  before_action :check_draft, only: [:new]
22
- before_action :retrieve_plan, only: [:show, :edit, :update, :withdraw, :preview, :publish, :close, :reopen, :destroy]
22
+ before_action :retrieve_plan, only: [:show, :edit, :update, :withdraw, :preview, :publish, :close, :destroy]
23
23
  before_action :ensure_published!, only: [:show, :withdraw]
24
24
 
25
25
  def index
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Plans
5
5
  module LinksHelper
6
6
  # This is for generating the links so that they maintain the search status
7
- def request_params(extra_params={}, exclude_params=[])
7
+ def request_params(extra_params = {}, exclude_params = [])
8
8
  @request_params ||= request.params.except(
9
9
  *(exclude_params + [
10
10
  :action,
@@ -17,7 +17,7 @@ module Decidim
17
17
  ).merge(prepare_extra_params(extra_params))
18
18
  end
19
19
 
20
- def request_params_query(extra_params={}, exclude_params=[])
20
+ def request_params_query(extra_params = {}, exclude_params = [])
21
21
  return "" unless request_params(extra_params, exclude_params).any?
22
22
 
23
23
  "?#{request_params.to_query}"
@@ -6,8 +6,18 @@ module Decidim
6
6
  extend ActiveSupport::Concern
7
7
  include ActionView::Helpers::TextHelper
8
8
 
9
+ def plain_content(content)
10
+ sanitize(content, tags: [])
11
+ end
12
+
9
13
  def rich_content(content)
10
- simple_format(content, wrapper_tag: nil)
14
+ simple_format(sanitize(content, tags: allowed_rich_tags), wrapper_tag: nil)
15
+ end
16
+
17
+ protected
18
+
19
+ def allowed_rich_tags
20
+ %w(strong em b i)
11
21
  end
12
22
  end
13
23
  end
@@ -15,7 +15,7 @@ module Decidim
15
15
  end
16
16
 
17
17
  def title
18
- sanitize(translated_attribute(content.title))
18
+ plain_content(translated_attribute(content.title))
19
19
  end
20
20
 
21
21
  def body
@@ -29,7 +29,7 @@ module Decidim
29
29
  end
30
30
 
31
31
  def title
32
- sanitize(translated_attribute(plan.title))
32
+ plain_content(translated_attribute(plan.title))
33
33
  end
34
34
 
35
35
  def body
@@ -37,8 +37,8 @@ module Decidim
37
37
  content = plan.contents.find_by(section: section)
38
38
  next if content.nil?
39
39
 
40
- section_title = sanitize(translated_attribute(content.title))
41
- section_body = sanitize(translated_attribute(content.body))
40
+ section_title = plain_content(translated_attribute(content.title))
41
+ section_body = plain_content(translated_attribute(content.body))
42
42
  "<dt>#{section_title}</dt> <dd>#{section_body}</dd>"
43
43
  end
44
44
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module Plans
5
- VERSION = "0.16.5"
5
+ VERSION = "0.16.6"
6
6
  DECIDIM_VERSION = "~> 0.16.0"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-plans
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.5
4
+ version: 0.16.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antti Hukkanen