administrate-field-simple_markdown 0.2.0 → 0.4.0

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: 6d97fa1cbb30ca70317f3d92f56b3551a4b587ecdf2f0bfced6878971ee6fe0f
4
- data.tar.gz: 7b437834f9a976fd3c324fb9c31bb39c08e13827c4c2ab7f7f9ffd33073db507
3
+ metadata.gz: 20ba6e4e6b790c6e61e3fcd60c18ef07082ab5f71e0bf072afd39ee4422cf516
4
+ data.tar.gz: 248218c9d2e5995595d7f5b22664b161b77ae6d556543c87bc8f797c3a6dfc4e
5
5
  SHA512:
6
- metadata.gz: a61a8f189664493becc332853733603648ef9fde9deac1a43c21209ea0ecdc4c2f910c134b40e1b7d80114736b1b4221509b9cd5502ba1588301467107d2bfc5
7
- data.tar.gz: e9acb7b3351702ee55b1624032fc613cec3822c6c6fadb16f36a53c3c381d716544f79213d8365c3d2e08f4af4efe3d7e2d13bfd6f07531fe9d341bf1c255fc4
6
+ metadata.gz: aa5d4a831c2bbfe32a5ecff7e27d9176d5bc436988f2cfff3c43e79b45137bbfbf462431ea95b282a73139926d214f3091ea765b8ac57a7af339e0ef88e6309d
7
+ data.tar.gz: 91caa267dedefcfb98da7c88abdc9b9aa129a0f1b234c33b2232fb636e8583d6293558e1c5303bb9389004ba3ae5e454bbb5e57143e80a5e2a211f841775c127
@@ -1 +1 @@
1
- 2.6.3
1
+ 2.7.0
@@ -1,49 +1,70 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.4.0](https://github.com/zooppa/administrate-field-simple_markdown/tree/v0.4.0) (2020-05-28)
4
+
5
+ [Full Changelog](https://github.com/zooppa/administrate-field-simple_markdown/compare/v0.3.0...v0.4.0)
6
+
7
+ - Revert initialization logic to HTML ID. This won’t be compatible with other
8
+ Administrate plugin (e.g. Administrate::Field::NestedHasMany)
9
+ - Switch to EasyMDE (thanks @casaper)
10
+
11
+ ## [v0.3.0](https://github.com/zooppa/administrate-field-simple_markdown/tree/v0.3.0) (2020-03-16)
12
+
13
+ [Full Changelog](https://github.com/zooppa/administrate-field-simple_markdown/compare/v0.2.1...v0.3.0)
14
+
15
+ - Support namespaced models and injected fields (thanks @sedubois)
16
+ - Add support for Redcarpet options (thanks @casaper)
17
+
18
+ ## [v0.2.1](https://github.com/zooppa/administrate-field-simple_markdown/tree/v0.2.1) (2019-01-15)
19
+
20
+ [Full Changelog](https://github.com/zooppa/administrate-field-simple_markdown/compare/v0.2.0...v0.2.1)
21
+
22
+ - Require Rack greater than 2.0.8
23
+
3
24
  ## [v0.2.0](https://github.com/zooppa/administrate-field-simple_markdown/tree/v0.2.0) (2018-08-27)
4
25
 
5
26
  [Full Changelog](https://github.com/zooppa/administrate-field-simple_markdown/compare/v0.1.2...v0.2.0)
6
27
 
7
- * Update the requirements on Rails to permit the latest version
28
+ - Update the requirements on Rails to permit the latest version
8
29
 
9
30
  ## [v0.1.2](https://github.com/zooppa/administrate-field-simple_markdown/tree/v0.1.2) (2018-05-24)
10
31
 
11
32
  [Full Changelog](https://github.com/zooppa/administrate-field-simple_markdown/compare/v0.1.1...v0.1.2)
12
33
 
13
- * Use snakecase when generating ID (thanks @golmansax)
34
+ - Use snakecase when generating ID (thanks @golmansax)
14
35
 
15
36
  ## [v0.1.1](https://github.com/zooppa/administrate-field-simple_markdown/tree/v0.1.1) (2018-03-09)
16
37
 
17
38
  [Full Changelog](https://github.com/zooppa/administrate-field-simple_markdown/compare/v0.1.0...v0.1.1)
18
39
 
19
- * Restore list styles for Markdown elements (thanks @pedantic-git)
40
+ - Restore list styles for Markdown elements (thanks @pedantic-git)
20
41
 
21
42
  ## [v0.1.0](https://github.com/zooppa/administrate-field-simple_markdown/tree/v0.1.0) (2018-01-23)
22
43
 
23
44
  [Full Changelog](https://github.com/zooppa/administrate-field-simple_markdown/compare/v0.0.4...v0.1.0)
24
45
 
25
- * Require Redcarpet
26
- * Add RSpec and tests
27
- * Handle null data
28
- * Update documentation
46
+ - Require Redcarpet
47
+ - Add RSpec and tests
48
+ - Handle null data
49
+ - Update documentation
29
50
 
30
51
  ## [v0.0.4](https://github.com/zooppa/administrate-field-simple_markdown/tree/v0.0.4) (2017-04-03)
31
52
 
32
53
  [Full Changelog](https://github.com/zooppa/administrate-field-simple_markdown/compare/v0.0.3...v0.0.4)
33
54
 
34
- * Bump up Administrate dependency
55
+ - Bump up Administrate dependency
35
56
 
36
57
  ## [v0.0.3](https://github.com/zooppa/administrate-field-simple_markdown/tree/v0.0.3) (2017-03-20)
37
58
 
38
59
  [Full Changelog](https://github.com/zooppa/administrate-field-simple_markdown/compare/v0.0.2...v0.0.3)
39
60
 
40
- * Bump up Administrate dependency
61
+ - Bump up Administrate dependency
41
62
 
42
63
  ## [v0.0.2](https://github.com/zooppa/administrate-field-simple_markdown/tree/v0.0.2) (2016-11-22)
43
64
 
44
65
  [Full Changelog](https://github.com/zooppa/administrate-field-simple_markdown/compare/v0.0.1...v0.0.2)
45
66
 
46
- * Bump up Administrate dependency
67
+ - Bump up Administrate dependency
47
68
 
48
69
  ## [v0.0.1](https://github.com/zooppa/administrate-field-simple_markdown/tree/v0.0.1) (2016-11-16)
49
70
 
data/README.md CHANGED
@@ -12,7 +12,7 @@ A plugin to edit Markdown text in [Administrate] using [SimpleMDE] v1.11.2.
12
12
  Add it to your `Gemfile`:
13
13
 
14
14
  ```ruby
15
- gem 'administrate-field-simple_markdown', '~> 0.2.0'
15
+ gem 'administrate-field-simple_markdown', '~> 0.4.0'
16
16
  ```
17
17
 
18
18
  Run:
@@ -25,7 +25,19 @@ Add to your `FooDashboard`:
25
25
 
26
26
  ```ruby
27
27
  ATTRIBUTE_TYPES = {
28
- bar: Field::SimpleMarkdown
28
+ bar: Field::SimpleMarkdown.with_options({
29
+ safe_links_only: true,
30
+ filter_html: true,
31
+ with_toc_data: true,
32
+ hard_wrap: true,
33
+ link_attributes: { rel: 'follow' },
34
+ autolink: true,
35
+ tables: true,
36
+ no_intra_emphasis: true,
37
+ strikethrough: true,
38
+ highlight: true,
39
+ space_after_headers: true
40
+ })
29
41
  }.freeze
30
42
  ```
31
43
 
@@ -36,5 +48,5 @@ Administrate::Field::SimpleMarkdown is maintained by [Zooppa].
36
48
  See also the list of [contributors](https://github.com/zooppa/administrate-field-simple_markdown/contributors) who participated in this project.
37
49
 
38
50
  [administrate]: https://github.com/thoughtbot/administrate
39
- [simplemde]: https://github.com/NextStepWebs/simplemde-markdown-editor
51
+ [simplemde]: https://github.com/sparksuite/simplemde-markdown-editor
40
52
  [zooppa]: https://www.zooppa.com/
@@ -2,7 +2,7 @@ $:.push File.expand_path('../lib', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'administrate-field-simple_markdown'
5
- gem.version = '0.2.0'
5
+ gem.version = '0.4.0'
6
6
  gem.authors = ['Zooppa']
7
7
  gem.email = ['dev@zooppa.com']
8
8
  gem.homepage = 'https://github.com/zooppa/administrate-field-simple_markdown'
@@ -17,7 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.add_runtime_dependency 'administrate', '< 1.0.0'
18
18
  gem.add_runtime_dependency 'rails', '>= 4.2', '< 7'
19
19
  gem.add_runtime_dependency 'redcarpet', '~> 3.3'
20
+ gem.add_runtime_dependency 'rack', '~> 2.0', '>= 2.0.8'
20
21
 
21
- gem.add_development_dependency 'rake', '~> 12.3'
22
+ gem.add_development_dependency 'rake', '~> 13.0'
22
23
  gem.add_development_dependency 'rspec', '~> 3.7'
23
24
  end
@@ -21,7 +21,7 @@ This partial renders a WYSIWYG text area to help writing Markdown text
21
21
  <script type="text/javascript">
22
22
  $(function() {
23
23
  new SimpleMDE({
24
- element: document.getElementById('<%= f.object.class.name.underscore %>_<%= field.attribute %>')
24
+ element: document.getElementById('<%= field.html_id %>')
25
25
  });
26
26
  });
27
27
  </script>
@@ -24,15 +24,22 @@ module Administrate
24
24
  markdown(plaintext_renderer).render(data)
25
25
  end
26
26
 
27
+ def html_id
28
+ [
29
+ resource.class.name.underscore.gsub('/', '_'),
30
+ attribute
31
+ ].join('_')
32
+ end
33
+
27
34
  private
28
35
 
29
36
  def html_renderer
30
37
  @html_renderer ||= Redcarpet::Render::HTML.new({
31
- safe_links_only: true,
32
- filter_html: true,
33
- with_toc_data: true,
34
- hard_wrap: true,
35
- link_attributes: { rel: 'nofollow' }
38
+ safe_links_only: options.fetch(:safe_links_only, true),
39
+ filter_html: options.fetch(:filter_html, true),
40
+ with_toc_data: options.fetch(:with_toc_data, true),
41
+ hard_wrap: options.fetch(:hard_wrap, true),
42
+ link_attributes: options.fetch(:link_attributes, { rel: 'nofollow' })
36
43
  })
37
44
  end
38
45
 
@@ -42,12 +49,12 @@ module Administrate
42
49
 
43
50
  def markdown(renderer)
44
51
  @markdown ||= Redcarpet::Markdown.new(renderer, {
45
- autolink: true,
46
- tables: true,
47
- no_intra_emphasis: true,
48
- strikethrough: true,
49
- highlight: true,
50
- space_after_headers: true
52
+ autolink: options.fetch(:autolink, true),
53
+ tables: options.fetch(:tables, true),
54
+ no_intra_emphasis: options.fetch(:no_intra_emphasis, true),
55
+ strikethrough: options.fetch(:strikethrough, true),
56
+ highlight: options.fetch(:highlight, true),
57
+ space_after_headers: options.fetch(:space_after_headers, true)
51
58
  })
52
59
  end
53
60
  end
@@ -82,4 +82,31 @@ describe Administrate::Field::SimpleMarkdown do
82
82
  end
83
83
  end
84
84
  end
85
+
86
+ describe '#html_id' do
87
+ let(:data) { nil }
88
+ let(:output) { subject.html_id }
89
+
90
+ context 'with a non-namespaced model' do
91
+ before { stub_const 'Foo', Class.new}
92
+
93
+ let(:resource) { Foo.new }
94
+
95
+ it 'returns the expected HTML id' do
96
+ allow(subject).to receive(:resource).and_return(resource)
97
+ expect(output).to eq 'foo_simple_markdown'
98
+ end
99
+ end
100
+
101
+ context 'with a namespaced model' do
102
+ before { stub_const 'Foo::Bar', Class.new}
103
+
104
+ let(:resource) { Foo::Bar.new }
105
+
106
+ it 'returns the expected HTML id' do
107
+ allow(subject).to receive(:resource).and_return(resource)
108
+ expect(output).to eq 'foo_bar_simple_markdown'
109
+ end
110
+ end
111
+ end
85
112
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administrate-field-simple_markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zooppa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-27 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate
@@ -58,20 +58,40 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '3.3'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rack
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '2.0'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 2.0.8
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '2.0'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 2.0.8
61
81
  - !ruby/object:Gem::Dependency
62
82
  name: rake
63
83
  requirement: !ruby/object:Gem::Requirement
64
84
  requirements:
65
85
  - - "~>"
66
86
  - !ruby/object:Gem::Version
67
- version: '12.3'
87
+ version: '13.0'
68
88
  type: :development
69
89
  prerelease: false
70
90
  version_requirements: !ruby/object:Gem::Requirement
71
91
  requirements:
72
92
  - - "~>"
73
93
  - !ruby/object:Gem::Version
74
- version: '12.3'
94
+ version: '13.0'
75
95
  - !ruby/object:Gem::Dependency
76
96
  name: rspec
77
97
  requirement: !ruby/object:Gem::Requirement
@@ -133,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
153
  - !ruby/object:Gem::Version
134
154
  version: '0'
135
155
  requirements: []
136
- rubygems_version: 3.0.3
156
+ rubygems_version: 3.1.2
137
157
  signing_key:
138
158
  specification_version: 4
139
159
  summary: Markdown editor for Administrate