bootstrap_views_generator 0.1.1 → 0.1.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
  SHA256:
3
- metadata.gz: 6a7a507f490b7ae5438db33f0141e7c6d19cb611335ae016242c958672b6e4f8
4
- data.tar.gz: 23916c6fb15ce3fff85579c5e4f122889ff2ac2a638a30a635469ac936ead3a0
3
+ metadata.gz: e973e3926bdfd81497bd96490b99c57bd5dd6a9fe092aa4ac3bec53d3433b99a
4
+ data.tar.gz: ca2ea8938d63e4cd49439fa0173cdc20a443ecf38f2d220378e02689b60c1fcb
5
5
  SHA512:
6
- metadata.gz: bd1419141de0306f659690ca02b2b215225fda7101af6a24cde0ceea76cc231dc0307f42b4ebb7deca7955199041b149f0d4c1b4b0771ff148cfcfa8b5619de9
7
- data.tar.gz: 432b0e234d3e057bacb05c1eda7f1d1ffa50daecd2ad943951d14d4c8753a784514ff5bf60ece2d8830c5028aa9f2d9c112c42624a12fee2a72c743c140b61bc
6
+ metadata.gz: 59e59402b519bbd88362cbb8d919d03e80507494551cc398b2a8bdef0790973041196317f994a4bdea12e0ee033d57c599e3f08d8d08f72dec89f463e5bde310
7
+ data.tar.gz: e1aab4fc44557206d7719935e6bfaad27e1a86748b3f6e39f6a7b150b203d5ff393e788490ab432500895cfc7995031bb9cde25ae57c868b41a7cfd73773a2ff
data/README.md CHANGED
@@ -79,7 +79,12 @@ rails g bootstrap:install --template_engine=slim
79
79
 
80
80
  Ensure you have [Pagy](https://github.com/ddnexus/pagy) gem installed
81
81
  ```ruby
82
+ # Gemfile
82
83
  gem 'pagy'
84
+
85
+ # Make sure you have the bootstrap pagy helper included
86
+ # config/initializers/pagy.rb
87
+ require 'pagy/extras/bootstrap'
83
88
  ```
84
89
 
85
90
 
@@ -1,3 +1,3 @@
1
1
  module BootstrapViewsGenerator
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
@@ -35,43 +35,45 @@ module Bootstrap
35
35
 
36
36
  # Inject Bootstrap helpers into teh application_helper file
37
37
  def inject_helpers
38
- helper_str = <<-HELPER
38
+ pagy_helper = (options[:pagination] ? 'include Pagy::Frontend' : '')
39
+ helper_str = <<~HELPER
40
+ #{pagy_helper}
39
41
 
40
- # https://gist.github.com/fjahr/b3828b9f4e333e74ba1894687d65e055
41
- def bootstrap_class_for(flash_type)
42
- { success: 'alert-success', error: 'alert-danger', alert: 'alert-warning', notice: 'alert-info' }.stringify_keys[flash_type.to_s] || flash_type.to_s
43
- end
42
+ # https://gist.github.com/fjahr/b3828b9f4e333e74ba1894687d65e055
43
+ def bootstrap_class_for(flash_type)
44
+ { success: 'alert-success', error: 'alert-danger', alert: 'alert-warning', notice: 'alert-info' }.stringify_keys[flash_type.to_s] || flash_type.to_s
45
+ end
44
46
 
45
- def flash_messages(_opts = [])
46
- return '' unless flash.any?
47
+ def flash_messages(_opts = [])
48
+ return '' unless flash.any?
47
49
 
48
- flash.each do |msg_type, message|
49
- next unless !message.nil? && message.to_s.length.positive?
50
+ flash.each do |msg_type, message|
51
+ next unless !message.nil? && message.to_s.length.positive?
50
52
 
51
- concat(content_tag(:div, message, class: "alert \#{bootstrap_class_for(msg_type)}", role: 'alert') do
52
- concat content_tag(:button, 'x', class: 'close', data: { dismiss: 'alert' })
53
- concat message
54
- end)
55
- end
56
- nil
57
- end
53
+ concat(content_tag(:div, message, class: "alert \#{bootstrap_class_for(msg_type)}", role: 'alert') do
54
+ concat content_tag(:button, 'x', class: 'close', data: { dismiss: 'alert' })
55
+ concat message
56
+ end)
57
+ end
58
+ nil
59
+ end
58
60
 
59
- # for outputting an objects error messages
60
- def errors_for(object)
61
- return '' unless object.errors.any?
61
+ # for outputting an objects error messages
62
+ def errors_for(object)
63
+ return '' unless object.errors.any?
62
64
 
63
- content_tag(:div, class: 'card border-danger') do
64
- concat(content_tag(:div, class: 'card-header bg-danger text-white') do
65
- concat "\#{pluralize(object.errors.count, 'error')} prohibited this \#{object.class.name.downcase} from being saved:"
66
- end)
67
- concat(content_tag(:ul, class: 'mb-0 list-group list-group-flush') do
68
- object.errors.full_messages.each do |msg|
69
- concat content_tag(:li, msg, class: 'list-group-item')
65
+ content_tag(:div, class: 'card border-danger') do
66
+ concat(content_tag(:div, class: 'card-header bg-danger text-white') do
67
+ concat "\#{pluralize(object.errors.count, 'error')} prohibited this \#{object.class.name.downcase} from being saved:"
68
+ end)
69
+ concat(content_tag(:ul, class: 'mb-0 list-group list-group-flush') do
70
+ object.errors.full_messages.each do |msg|
71
+ concat content_tag(:li, msg, class: 'list-group-item')
72
+ end
73
+ end)
74
+ end
70
75
  end
71
- end)
72
- end
73
- end
74
- HELPER
76
+ HELPER
75
77
 
76
78
  inject_into_file 'app/helpers/application_helper.rb', helper_str, after: "module ApplicationHelper\n"
77
79
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_views_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Hicks
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-09 00:00:00.000000000 Z
11
+ date: 2019-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap