bootstrap_pagedown 1.0.1 → 1.0.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
  SHA1:
3
- metadata.gz: 751d8a77576cc1a0de99944b339e62ee363e1e59
4
- data.tar.gz: e565e2fe825c7c1978be515cb6ba9cc4b3c3c68b
3
+ metadata.gz: 730e400d9cbbbe4553ca04e76ce3d3ba68a33e71
4
+ data.tar.gz: 881011d7ed015a771537f836b37252d2662b555b
5
5
  SHA512:
6
- metadata.gz: 22ccab361f8819313a9e0aba42937cfb0fbe3c3d2c5318edfc5df716ec0a4677dc3d3f36732634809a04d659c5351ccc4ec6b851e56151cc179cb4bf2dfc04c9
7
- data.tar.gz: 807455067bdb58dc6b8fbaa19d0f4b8bb90fdd4ea1e4a8c441bce85ff384dc3b8b75dabe509a9f991cf8d09ca7e81b584caa2ebe98020e4b2e585ce0d976788f
6
+ metadata.gz: 06174743ff7dec8f7cdc19e997d9f024efdd89c147185937504e072af44b4ff7219b7a1cb1d007fbd6745b8bb50cf5c3ca5d04ba1f73afc44a8bf5378c83b0b8
7
+ data.tar.gz: f990c0c27882ab147901367eeeb9f1cfdf48d7e3bbfd82e34d23bddba3d7590ec18091fa8a16a823d8d95c4cc089d7fdb8bf379e8ea3418e92bb11963951b9c4
data/README.md CHANGED
@@ -49,9 +49,48 @@ You may also add attributes to the generated text area as needed by simply addin
49
49
 
50
50
  The previous example would add `data-name="editor"` to the editor textarea element.
51
51
 
52
- ### Note
52
+ ### Custom options supported:
53
53
 
54
- You should only use one editor per page since `Pagedown`'s Javascript relies on the HTML id attribute for most of it's behavior.
54
+ By default bootstrap_pagedown will create the needed HTML elements to render a functional editor with a button bar and a preview div.
55
+ However you can change the different element classes, ids and even skip the preview div by passing different options to the `pagedown_editor`
56
+ method, here's the hash with different options and it's default values:
57
+
58
+ ```ruby
59
+ {
60
+ skip_preview: false, # Whether or not we should skip the preview div, skipping this will render an editor without HTML preview
61
+ panel_id: '', # HTML id of the editor panel div
62
+ panel_class: 'wmd-panel', # HTML class of the editor panel div
63
+ button_bar_id: 'wmd-button-bar', # HTML id of the editor's button bar div
64
+ button_bar_class: '', # HTML class of the editor's button bar div
65
+ editor_id: 'wmd-input', # HTML if of the editor textarea
66
+ editor_class: 'wmd-input', # HTML class of the editor textarea
67
+ preview_id: 'wmd-preview', # HTML id of the preview div
68
+ preview_class: '', # HTML class of the preview div
69
+ }
70
+ ```
71
+
72
+ This is a the default generated HTML, note that name will change depending on your form builder and method name.
73
+
74
+ ```html
75
+ <div class="wmd-panel">
76
+ <div id="wmd-button-bar"></div>
77
+ <textarea class="wmd-input" id="wmd-input" name="test[test]"></textarea>
78
+ <div id="wmd-preview"></div>
79
+ </div>
80
+ ```
81
+
82
+ If you change the any of the default ids or classes on the HTML elements the `pagedown_editor` will render the correct HTML, but the editor won't render
83
+ that is because by default Pagedown looks for those element attribute values, however you can still get the editor to render and behave correctly through the
84
+ [Pagedown API](https://code.google.com/p/pagedown/wiki/PageDown). I other words in order to have more than one editor in the same page you'll obviously have to
85
+ change the element attributes and the use the Pagedown API to create every aditional editor.
86
+
87
+ ## Stylesheets
88
+
89
+ If you need to change something on the stylesheets you don't need to start from scratch, you can simply generate the sass file with the sass generator as follows:
90
+
91
+ `rails g bootstrap_pagedown:sass`
92
+
93
+ This will generate a copy of bootstrap_pagedown styles into `app/assets/stylesheets`.
55
94
 
56
95
  ## Running the test suite
57
96
 
@@ -1,10 +1,32 @@
1
1
  module BootstrapPagedown
2
2
  module FormBuilder
3
- def pagedown_editor( method, options={})
4
- @template.content_tag( :div, class: 'wmd-panel' ) do
5
- @template.content_tag( :div, nil, id: 'wmd-button-bar' ) +
6
- @template.text_area( @object_name, method, objectify_options( options ).merge( id: 'wmd-input', class: 'wmd-input' ) )
3
+ def pagedown_editor(method, options={})
4
+ options = pagedown_default_values options
5
+ custom_options = pagedown_custom_attributes options
6
+
7
+ @template.content_tag( :div, id: options[:panel_id], class: options[:panel_class] ) do
8
+ @template.content_tag( :div, nil, id: options[:button_bar_id], class: options[:button_bar_class] ) +
9
+ @template.text_area( @object_name, method, objectify_options( custom_options ).merge( id: options[:editor_id], class: options[:editor_class] ) ) +
10
+
11
+ unless options[:skip_preview]
12
+ @template.content_tag :div, nil, id: options[:preview_id], class: options[:preview_class]
13
+ end
7
14
  end
8
15
  end
16
+
17
+ def pagedown_default_values( options )
18
+ options[:skip_preview] ||= false
19
+ options[:panel_class] ||= 'wmd-panel'
20
+ options[:button_bar_id] ||= 'wmd-button-bar'
21
+ options[:editor_id] ||= 'wmd-input'
22
+ options[:editor_class] ||= 'wmd-input'
23
+ options[:preview_id] ||= 'wmd-preview'
24
+
25
+ options
26
+ end
27
+
28
+ def pagedown_custom_attributes( options )
29
+ options.except :skip_preview, :panel_class, :panel_id, :button_bar_id, :button_bar_class, :editor_id, :editor_class, :preview_id, :preview_class
30
+ end
9
31
  end
10
32
  end
@@ -1,3 +1,3 @@
1
1
  module BootstrapPagedown
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -0,0 +1,15 @@
1
+ module BootstrapPagedown
2
+ module Generators
3
+ class SassGenerator < ::Rails::Generators::Base
4
+ VENDOR_PATH = File.expand_path( '../../../../vendor/assets/stylesheets/', __FILE__ )
5
+
6
+ source_root VENDOR_PATH
7
+
8
+ desc "Generates the editor stylesheet"
9
+
10
+ def copy_sass
11
+ directory VENDOR_PATH, 'app/assets/stylesheets'
12
+ end
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_pagedown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Enrique Vidal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-15 00:00:00.000000000 Z
11
+ date: 2013-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -35,6 +35,7 @@ files:
35
35
  - lib/bootstrap_pagedown/form_builder.rb
36
36
  - lib/bootstrap_pagedown/version.rb
37
37
  - lib/bootstrap_pagedown.rb
38
+ - lib/generators/bootstrap_pagedown/sass_generator.rb
38
39
  - lib/tasks/bootstrap_pagedown_tasks.rake
39
40
  - vendor/assets/images/Markdown.Editor.Icons.png
40
41
  - vendor/assets/javascripts/bootstrap_pagedown/load_editor.coffee