administrate-field-simple_markdown 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6879b226c35c288b6a1fd83203d7d415dc344d03
4
+ data.tar.gz: 7d8b47f11558cb3363453cccc4a17d0e192909df
5
+ SHA512:
6
+ metadata.gz: d846b8af7b63ab59a40428ea0446636d9fc7829c0a65efd60385cffc94e74d66904ea5491b36f9556f201b93c20a1089403e32947c40347b65d0b70f2e6098f2
7
+ data.tar.gz: 7209b833838e100fc69868449286213954fe554ee3a84e35547f6da2cce5a4c60004da8693552541946fc1e9a0819db5e682140eb300e72270911f93a66ef9e6
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ # Changelog
2
+
3
+ ## [v0.0.1](https://github.com/z-productions/administrate-field-simple_markdown/tree/v0.0.1) (2016-11-16)
4
+ First release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,152 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ administrate-field-simple_markdown (0.0.1)
5
+ administrate (~> 0.2.1)
6
+ rails (>= 4.2)
7
+ redcarpet (~> 3.3)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionmailer (4.2.7.1)
13
+ actionpack (= 4.2.7.1)
14
+ actionview (= 4.2.7.1)
15
+ activejob (= 4.2.7.1)
16
+ mail (~> 2.5, >= 2.5.4)
17
+ rails-dom-testing (~> 1.0, >= 1.0.5)
18
+ actionpack (4.2.7.1)
19
+ actionview (= 4.2.7.1)
20
+ activesupport (= 4.2.7.1)
21
+ rack (~> 1.6)
22
+ rack-test (~> 0.6.2)
23
+ rails-dom-testing (~> 1.0, >= 1.0.5)
24
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
25
+ actionview (4.2.7.1)
26
+ activesupport (= 4.2.7.1)
27
+ builder (~> 3.1)
28
+ erubis (~> 2.7.0)
29
+ rails-dom-testing (~> 1.0, >= 1.0.5)
30
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
31
+ activejob (4.2.7.1)
32
+ activesupport (= 4.2.7.1)
33
+ globalid (>= 0.3.0)
34
+ activemodel (4.2.7.1)
35
+ activesupport (= 4.2.7.1)
36
+ builder (~> 3.1)
37
+ activerecord (4.2.7.1)
38
+ activemodel (= 4.2.7.1)
39
+ activesupport (= 4.2.7.1)
40
+ arel (~> 6.0)
41
+ activesupport (4.2.7.1)
42
+ i18n (~> 0.7)
43
+ json (~> 1.7, >= 1.7.7)
44
+ minitest (~> 5.1)
45
+ thread_safe (~> 0.3, >= 0.3.4)
46
+ tzinfo (~> 1.1)
47
+ administrate (0.2.2)
48
+ autoprefixer-rails (~> 6.0)
49
+ datetime_picker_rails (~> 0.0.7)
50
+ jquery-rails (~> 4.0)
51
+ kaminari (~> 0.16)
52
+ momentjs-rails (~> 2.8)
53
+ neat (~> 1.1)
54
+ normalize-rails (~> 3.0)
55
+ rails (~> 4.2)
56
+ sass-rails (~> 5.0)
57
+ selectize-rails (~> 0.6)
58
+ arel (6.0.3)
59
+ autoprefixer-rails (6.5.3)
60
+ execjs
61
+ builder (3.2.2)
62
+ concurrent-ruby (1.0.2)
63
+ datetime_picker_rails (0.0.7)
64
+ momentjs-rails (>= 2.8.1)
65
+ erubis (2.7.0)
66
+ execjs (2.7.0)
67
+ globalid (0.3.7)
68
+ activesupport (>= 4.1.0)
69
+ i18n (0.7.0)
70
+ jquery-rails (4.2.1)
71
+ rails-dom-testing (>= 1, < 3)
72
+ railties (>= 4.2.0)
73
+ thor (>= 0.14, < 2.0)
74
+ json (1.8.3)
75
+ kaminari (0.17.0)
76
+ actionpack (>= 3.0.0)
77
+ activesupport (>= 3.0.0)
78
+ loofah (2.0.3)
79
+ nokogiri (>= 1.5.9)
80
+ mail (2.6.4)
81
+ mime-types (>= 1.16, < 4)
82
+ mime-types (3.1)
83
+ mime-types-data (~> 3.2015)
84
+ mime-types-data (3.2016.0521)
85
+ mini_portile2 (2.1.0)
86
+ minitest (5.9.1)
87
+ momentjs-rails (2.15.1)
88
+ railties (>= 3.1)
89
+ neat (1.8.0)
90
+ sass (>= 3.3)
91
+ thor (~> 0.19)
92
+ nokogiri (1.6.8.1)
93
+ mini_portile2 (~> 2.1.0)
94
+ normalize-rails (3.0.3)
95
+ rack (1.6.5)
96
+ rack-test (0.6.3)
97
+ rack (>= 1.0)
98
+ rails (4.2.7.1)
99
+ actionmailer (= 4.2.7.1)
100
+ actionpack (= 4.2.7.1)
101
+ actionview (= 4.2.7.1)
102
+ activejob (= 4.2.7.1)
103
+ activemodel (= 4.2.7.1)
104
+ activerecord (= 4.2.7.1)
105
+ activesupport (= 4.2.7.1)
106
+ bundler (>= 1.3.0, < 2.0)
107
+ railties (= 4.2.7.1)
108
+ sprockets-rails
109
+ rails-deprecated_sanitizer (1.0.3)
110
+ activesupport (>= 4.2.0.alpha)
111
+ rails-dom-testing (1.0.7)
112
+ activesupport (>= 4.2.0.beta, < 5.0)
113
+ nokogiri (~> 1.6.0)
114
+ rails-deprecated_sanitizer (>= 1.0.1)
115
+ rails-html-sanitizer (1.0.3)
116
+ loofah (~> 2.0)
117
+ railties (4.2.7.1)
118
+ actionpack (= 4.2.7.1)
119
+ activesupport (= 4.2.7.1)
120
+ rake (>= 0.8.7)
121
+ thor (>= 0.18.1, < 2.0)
122
+ rake (11.3.0)
123
+ redcarpet (3.3.4)
124
+ sass (3.4.22)
125
+ sass-rails (5.0.6)
126
+ railties (>= 4.0.0, < 6)
127
+ sass (~> 3.1)
128
+ sprockets (>= 2.8, < 4.0)
129
+ sprockets-rails (>= 2.0, < 4.0)
130
+ tilt (>= 1.1, < 3)
131
+ selectize-rails (0.12.4)
132
+ sprockets (3.7.0)
133
+ concurrent-ruby (~> 1.0)
134
+ rack (> 1, < 3)
135
+ sprockets-rails (3.2.0)
136
+ actionpack (>= 4.0)
137
+ activesupport (>= 4.0)
138
+ sprockets (>= 3.0.0)
139
+ thor (0.19.1)
140
+ thread_safe (0.3.5)
141
+ tilt (2.0.5)
142
+ tzinfo (1.2.2)
143
+ thread_safe (~> 0.1)
144
+
145
+ PLATFORMS
146
+ ruby
147
+
148
+ DEPENDENCIES
149
+ administrate-field-simple_markdown!
150
+
151
+ BUNDLED WITH
152
+ 1.13.6
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2016 z.productions.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Administrate::Field::SimpleMarkdown
2
+
3
+ [![Code Climate](https://codeclimate.com/github/z-productions/administrate-field-simple_markdown/badges/gpa.svg)](https://codeclimate.com/github/z-productions/administrate-field-simple_markdown)
4
+
5
+ A plugin to edit Markdown text in [Administrate] using [SimpleMDE] v1.11.2.
6
+
7
+ ![Demo](https://raw.githubusercontent.com/z-productions/administrate-field-simple_markdown/master/demo.gif)
8
+
9
+ ## Usage
10
+
11
+ Add it to your `Gemfile`:
12
+
13
+ ```ruby
14
+ gem 'administrate-field-simple_markdown', '~> 0.0.1'
15
+ ```
16
+
17
+ Run:
18
+
19
+ ```bash
20
+ $ bundle install
21
+ ```
22
+
23
+ Add to your `FooDashboard`:
24
+
25
+ ```ruby
26
+ ATTRIBUTE_TYPES = {
27
+ bar: Field::SimpleMarkdown
28
+ }.freeze
29
+ ```
30
+ The field will figure out the appropriate thousand separator and decimal delimiter for the unit.
31
+
32
+ ## About
33
+
34
+ Administrate::Field::SimpleMarkdown is maintained by [z.productions].
35
+
36
+ [Administrate]: https://github.com/thoughtbot/administrate
37
+ [SimpleMDE]: https://github.com/NextStepWebs/simplemde-markdown-editor
38
+ [z.productions]: https://www.z.productions/
@@ -0,0 +1,20 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'administrate-field-simple_markdown'
5
+ gem.version = '0.0.1'
6
+ gem.authors = ['Michele Gerarduzzi']
7
+ gem.email = ['michele.gerarduzzi@gmail.com']
8
+ gem.homepage = 'https://github.com/z-productions/administrate-field-simple_markdown'
9
+ gem.summary = 'A plugin to edit Markdown text in Administrate'
10
+ gem.description = gem.summary
11
+ gem.license = 'MIT'
12
+
13
+ gem.require_paths = ['lib']
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+
17
+ gem.add_runtime_dependency 'administrate', '~> 0.2.1'
18
+ gem.add_runtime_dependency 'rails', '>= 4.2'
19
+ gem.add_runtime_dependency 'redcarpet', '~> 3.3'
20
+ end
@@ -0,0 +1 @@
1
+ //= require simplemde.min
@@ -0,0 +1,4 @@
1
+ /*
2
+ *= require_self
3
+ *= require simplemde.min
4
+ */
@@ -0,0 +1,28 @@
1
+ <%#
2
+ # SimpleMarkdown Form Partial
3
+
4
+ This partial renders a WYSIWYG text area to help writing Markdown text
5
+
6
+ ## Local variables:
7
+
8
+ - `f`:
9
+ A Rails form generator, used to help create the appropriate input fields.
10
+ - `field`:
11
+ An instance of Administrate::Field::SimpleMarkdown.
12
+ %>
13
+
14
+ <div class="field-unit__label">
15
+ <%= f.label field.attribute %>
16
+ </div>
17
+ <div class="field-unit__field">
18
+ <%= f.text_field field.attribute %>
19
+ </div>
20
+ <%= content_for :javascript do %>
21
+ <script type="text/javascript">
22
+ $(function() {
23
+ new SimpleMDE({
24
+ element: document.getElementById('<%= f.object.class.name.downcase %>_<%= field.attribute %>')
25
+ });
26
+ });
27
+ </script>
28
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <%#
2
+ # SimpleMarkdown Index Partial
3
+
4
+ This partial renders a Markdown field to text
5
+
6
+ ## Local variables:
7
+
8
+ - `field`:
9
+ An instance of Administrate::Field::SimpleMarkdown.
10
+ %>
11
+
12
+ <%= truncate field.to_s %>
@@ -0,0 +1,12 @@
1
+ <%#
2
+ # SimpleMarkdown Show Partial
3
+
4
+ This partial renders a Markdown field to HTML
5
+
6
+ ## Local variables:
7
+
8
+ - `field`:
9
+ An instance of Administrate::Field::SimpleMarkdown.
10
+ %>
11
+
12
+ <%= field.to_html %>
data/demo.gif ADDED
Binary file
@@ -0,0 +1,49 @@
1
+ require 'administrate/field/text'
2
+ require 'administrate/engine'
3
+ require 'redcarpet/render_strip'
4
+
5
+ module Administrate
6
+ module Field
7
+ class SimpleMarkdown < Administrate::Field::Text
8
+ class Engine < ::Rails::Engine
9
+ Administrate::Engine.add_javascript 'administrate-field-simple_markdown/application'
10
+ Administrate::Engine.add_stylesheet 'administrate-field-simple_markdown/application'
11
+ end
12
+
13
+ def to_html
14
+ markdown(html_renderer).render(data).html_safe
15
+ end
16
+
17
+ def to_s
18
+ markdown(plaintext_renderer).render(data)
19
+ end
20
+
21
+ private
22
+
23
+ def html_renderer
24
+ @html_renderer ||= Redcarpet::Render::HTML.new({
25
+ safe_links_only: true,
26
+ filter_html: true,
27
+ with_toc_data: true,
28
+ hard_wrap: true,
29
+ link_attributes: { rel: 'nofollow' }
30
+ })
31
+ end
32
+
33
+ def plaintext_renderer
34
+ @plaintext_renderer ||= Redcarpet::Render::StripDown
35
+ end
36
+
37
+ def markdown(renderer)
38
+ @markdown ||= Redcarpet::Markdown.new(renderer, {
39
+ autolink: true,
40
+ tables: true,
41
+ no_intra_emphasis: true,
42
+ strikethrough: true,
43
+ highlight: true,
44
+ space_after_headers: true
45
+ })
46
+ end
47
+ end
48
+ end
49
+ end