bootstrap_helper 2.0.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'http://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in bootstrap-rails.gemspec
4
4
  gemspec
5
-
6
- gem 'will_paginate', '3.0.pre4'
data/README.md CHANGED
@@ -99,17 +99,21 @@ write notice message in your action, will generate bootstrap style notice messag
99
99
  # ….
100
100
  redirect_to posts_path, :notice => "Create Success!"
101
101
  end
102
+
103
+ def update
104
+ redirect_to root_path, :flash => { :warning => "Update Success!" }
105
+ end
106
+ def no_permission
107
+ redirect_to root_path, :flash => { :error => "no permission" }
108
+ end
109
+
110
+
102
111
 
103
112
  ### Pagination
104
113
 
105
- Support `will_paginate`, `3.0.3`
106
-
107
- copy `will_paginate.rb` to `config/initializers`
108
-
109
- <https://gist.github.com/2760885>
110
-
111
-
112
- ## Example
114
+ Support `will_paginate`, `~> 3.0.3`
115
+
116
+ ## Markup Example
113
117
 
114
118
  see [example](bootstrap-helper/tree/master/example/application.html.erb)
115
119
 
@@ -117,15 +121,9 @@ see [example](bootstrap-helper/tree/master/example/application.html.erb)
117
121
 
118
122
  ### Form
119
123
 
120
- You can use simple_form 2.0 with bootstrap form template
121
-
122
- * Gemfile
124
+ Support `simple_form`, `~> 2.0.2`
123
125
 
124
- ```
125
- gem "simple_form", :git => "git://github.com/plataformatec/simple_form.git"
126
- ```
127
-
128
- place <https://github.com/rafaelfranca/simple_form-bootstrap/blob/master/config/initializers/simple_form.rb> to `config/initailizers/simple_form.rb`
126
+ You can use simple_form 2.0 with bootstrap form template
129
127
 
130
128
  ```
131
129
  <%= simple_form_for @article do |f| %>
@@ -13,10 +13,11 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
14
  gem.name = "bootstrap_helper"
15
15
  gem.require_paths = ["lib"]
16
- gem.version = "2.0.0.3"
16
+ gem.version = "2.1.0"
17
17
 
18
18
  gem.add_dependency "railties", "~> 3.0"
19
19
  gem.add_dependency "thor", "~> 0.14"
20
+ gem.add_dependency "simple_form", "~> 2.0.2"
20
21
  gem.add_dependency "will_paginate", '>= 3.0.3'
21
22
  gem.add_development_dependency "bundler", ">= 1.0.0"
22
23
  gem.add_development_dependency "rails", "~> 3.0"
@@ -0,0 +1,171 @@
1
+ # -*- encoding : utf-8 -*-
2
+ # Use this setup block to configure all options available in SimpleForm.
3
+ SimpleForm.setup do |config|
4
+ # Wrappers are used by the form builder to generate a
5
+ # complete input. You can remove any component from the
6
+ # wrapper, change the order or even add your own to the
7
+ # stack. The options given below are used to wrap the
8
+ # whole input.
9
+ config.wrappers :default, :class => :input,
10
+ :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
11
+ ## Extensions enabled by default
12
+ # Any of these extensions can be disabled for a
13
+ # given input by passing: `f.input EXTENSION_NAME => false`.
14
+ # You can make any of these extensions optional by
15
+ # renaming `b.use` to `b.optional`.
16
+
17
+ # Determines whether to use HTML5 (:email, :url, ...)
18
+ # and required attributes
19
+ b.use :html5
20
+
21
+ # Calculates placeholders automatically from I18n
22
+ # You can also pass a string as f.input :placeholder => "Placeholder"
23
+ b.use :placeholder
24
+
25
+ ## Optional extensions
26
+ # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
27
+ # to the input. If so, they will retrieve the values from the model
28
+ # if any exists. If you want to enable the lookup for any of those
29
+ # extensions by default, you can change `b.optional` to `b.use`.
30
+
31
+ # Calculates maxlength from length validations for string inputs
32
+ b.optional :maxlength
33
+
34
+ # Calculates pattern from format validations for string inputs
35
+ b.optional :pattern
36
+
37
+ # Calculates min and max from length validations for numeric inputs
38
+ b.optional :min_max
39
+
40
+ # Calculates readonly automatically from readonly attributes
41
+ b.optional :readonly
42
+
43
+ ## Inputs
44
+ b.use :label_input
45
+ b.use :hint, :tag => :span, :class => :hint
46
+ b.use :error, :tag => :span, :class => :error
47
+ end
48
+
49
+ config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
50
+ b.use :placeholder
51
+ b.use :label, :class => 'control-label'
52
+ b.use :tag => 'div', :class => 'controls' do |ba|
53
+ ba.use :input
54
+ ba.use :error, :tag => 'span', :class => 'help-inline'
55
+ ba.use :hint, :tag => 'p', :class => 'help-block'
56
+ end
57
+ end
58
+
59
+ config.wrappers :prepend, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
60
+ b.use :placeholder
61
+ b.use :label, :class => 'control-label'
62
+ b.use :hint, :tag => 'span', :class => 'help-block'
63
+ b.use :tag => 'div', :class => 'controls' do |input|
64
+ input.use :tag => 'div', :class => 'input-prepend' do |prepend|
65
+ prepend.use :input
66
+ end
67
+ input.use :error, :tag => 'span', :class => 'help-inline'
68
+ end
69
+ end
70
+
71
+ config.wrappers :append, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
72
+ b.use :placeholder
73
+ b.use :label, :class => 'control-label'
74
+ b.use :hint, :tag => 'span', :class => 'help-block'
75
+ b.use :tag => 'div', :class => 'controls' do |input|
76
+ input.use :tag => 'div', :class => 'input-append' do |append|
77
+ append.use :input
78
+ end
79
+ input.use :error, :tag => 'span', :class => 'help-inline'
80
+ end
81
+ end
82
+
83
+ # Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
84
+ # Check the Bootstrap docs (http://twitter.github.com/bootstrap)
85
+ # to learn about the different styles for forms and inputs,
86
+ # buttons and other elements.
87
+ config.default_wrapper = :bootstrap
88
+
89
+ # Define the way to render check boxes / radio buttons with labels.
90
+ # Defaults to :nested for bootstrap config.
91
+ # :inline => input + label
92
+ # :nested => label > input
93
+ config.boolean_style = :nested
94
+
95
+ # Default class for buttons
96
+ config.button_class = 'btn'
97
+
98
+ # Method used to tidy up errors.
99
+ # config.error_method = :first
100
+
101
+ # Default tag used for error notification helper.
102
+ # config.error_notification_tag = :p
103
+
104
+ # CSS class to add for error notification helper.
105
+ # config.error_notification_class = :error_notification
106
+
107
+ # ID to add for error notification helper.
108
+ # config.error_notification_id = nil
109
+
110
+ # Series of attempts to detect a default label method for collection.
111
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
112
+
113
+ # Series of attempts to detect a default value method for collection.
114
+ # config.collection_value_methods = [ :id, :to_s ]
115
+
116
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
117
+ # config.collection_wrapper_tag = nil
118
+
119
+ # You can define the class to use on all collection wrappers. Defaulting to none.
120
+ # config.collection_wrapper_class = nil
121
+
122
+ # You can wrap each item in a collection of radio/check boxes with a tag,
123
+ # defaulting to :span. Please note that when using :boolean_style = :nested,
124
+ # SimpleForm will force this option to be a label.
125
+ # config.item_wrapper_tag = :span
126
+
127
+ # You can define a class to use in all item wrappers. Defaulting to none.
128
+ # config.item_wrapper_class = nil
129
+
130
+ # How the label text should be generated altogether with the required text.
131
+ # config.label_text = lambda { |label, required| "#{required} #{label}" }
132
+
133
+ # You can define the class to use on all labels. Default is nil.
134
+ # config.label_class = nil
135
+
136
+ # You can define the class to use on all forms. Default is simple_form.
137
+ # config.form_class = :simple_form
138
+
139
+ # Whether attributes are required by default (or not). Default is true.
140
+ # config.required_by_default = true
141
+
142
+ # Tell browsers whether to use default HTML5 validations (novalidate option).
143
+ # Default is enabled.
144
+ config.browser_validations = false
145
+
146
+ # Collection of methods to detect if a file type was given.
147
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
148
+
149
+ # Custom mappings for input types. This should be a hash containing a regexp
150
+ # to match as key, and the input type that will be used when the field name
151
+ # matches the regexp as value.
152
+ # config.input_mappings = { /count/ => :integer }
153
+
154
+ # Default priority for time_zone inputs.
155
+ # config.time_zone_priority = nil
156
+
157
+ # Default priority for country inputs.
158
+ # config.country_priority = nil
159
+
160
+ # Default size for text inputs.
161
+ # config.default_input_size = 50
162
+
163
+ # When false, do not use translations for labels.
164
+ # config.translate_labels = true
165
+
166
+ # Automatically discover new inputs in Rails' autoload path.
167
+ # config.inputs_discovery = true
168
+
169
+ # Cache simple form inputs discovery
170
+ # config.cache_discovery = !Rails.env.development?
171
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding : utf-8 -*-
2
+ if defined?(WillPaginate)
3
+ module WillPaginate
4
+ module ActionView
5
+ def will_paginate(collection = nil, options = {})
6
+ options[:renderer] ||= BootstrapLinkRenderer
7
+ super.try :html_safe
8
+ end
9
+
10
+ class BootstrapLinkRenderer < LinkRenderer
11
+ protected
12
+
13
+ def html_container(html)
14
+ tag :div, tag(:ul, html), container_attributes
15
+ end
16
+
17
+ def page_number(page)
18
+ tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
19
+ end
20
+
21
+ def previous_or_next_page(page, text, classname)
22
+ tag :li, link(text, page || '#'), :class => [classname[0..3], classname, ('disabled' unless page)].join(' ')
23
+ end
24
+
25
+ def gap
26
+ tag :li, link(super, '#'), :class => 'disabled'
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.3
4
+ version: 2.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-07-04 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &70253607622520 !ruby/object:Gem::Requirement
16
+ requirement: &70291938989700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70253607622520
24
+ version_requirements: *70291938989700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &70253607621940 !ruby/object:Gem::Requirement
27
+ requirement: &70291938989220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,21 @@ dependencies:
32
32
  version: '0.14'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70253607621940
35
+ version_requirements: *70291938989220
36
+ - !ruby/object:Gem::Dependency
37
+ name: simple_form
38
+ requirement: &70291938988760 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.0.2
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70291938988760
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: will_paginate
38
- requirement: &70253607621380 !ruby/object:Gem::Requirement
49
+ requirement: &70291938988300 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: 3.0.3
44
55
  type: :runtime
45
56
  prerelease: false
46
- version_requirements: *70253607621380
57
+ version_requirements: *70291938988300
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: bundler
49
- requirement: &70253607620820 !ruby/object:Gem::Requirement
60
+ requirement: &70291938987840 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: 1.0.0
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *70253607620820
68
+ version_requirements: *70291938987840
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: rails
60
- requirement: &70253607620260 !ruby/object:Gem::Requirement
71
+ requirement: &70291938987380 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ~>
@@ -65,7 +76,7 @@ dependencies:
65
76
  version: '3.0'
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *70253607620260
79
+ version_requirements: *70291938987380
69
80
  description: Twitter Bootstrap HTML Helper
70
81
  email:
71
82
  - xuite.joke@gmail.com
@@ -78,6 +89,8 @@ files:
78
89
  - README.md
79
90
  - Rakefile
80
91
  - bootstrap_helper.gemspec
92
+ - config/initializers/simple_form.rb
93
+ - config/initializers/will_paginate.rb
81
94
  - example/application.html.erb
82
95
  - lib/bootstrap_helper.rb
83
96
  - lib/bootstrap_helper/breadcrumb.rb