jekyll_bootstrap5_tabs 1.0.0 → 1.1.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: 63ce06f23eb1d77f84b9d67685742a46d0eabc7adf6debb4eef596ba73681300
4
- data.tar.gz: e11c0c59467faa3d38f96006f7b5bb88ef980baac765f602414274f9bbfa760e
3
+ metadata.gz: 0001fdf1657866adc8d206052cb3ca8fa750ccb47cd3c6804ca9bdd12bf8bb0e
4
+ data.tar.gz: ca58073ce8c9c79c3a6be3cf557cbe14c5c33a5291bff829f6981c6f064cd981
5
5
  SHA512:
6
- metadata.gz: 83fdc5c10c81e75a6e97303888b2e09ea54f644722363c81d77b2b068310315377c770a81f95c526f1a32fbdbc93192f59f2c0cbff64706dc8ad0b38cad1d912
7
- data.tar.gz: c8f51ac97da8afee5d108b2d8b8d9bd27c3a801cc83db6b36d4d2b1213db04f3c52a9172b067cde867ad2c7947c54df3d43de2b909f27996c2e132f910b800ee
6
+ metadata.gz: f360a04ac5d004484ea0c87f063bd16471bb517cdc6a48074cb8c7dfff1695b972609996a77d933f73cd7124699c1d639895e26fe863bbbc274fc19cd5b43a13
7
+ data.tar.gz: f373db002d72ec38e5f3c0f49aace64c064fca11fd37d3fa6bdfda4a2a39c58a5363805ec2f87bdec59227abd11995cc56d035ad0467d5db7b21025ba31a2cb7
data/README.md CHANGED
@@ -2,15 +2,17 @@ Jekyll Bootstrap 5 Tabs
2
2
  [![Gem Version](https://badge.fury.io/rb/jekyll_bootstrap5_tabs.svg)](https://badge.fury.io/rb/jekyll_bootstrap5_tabs)
3
3
  ===========
4
4
 
5
+ <img src="docs/tabDemo.gif" width="500" height="auto" />
6
+
5
7
  The original version, written by Artur Gabitov, expected Markdown and Bootstrap 4.
6
- This version requires Bootstrap 5 and HTML, not Markdown.
8
+ [This version](https://rubygems.org/gems/jekyll_bootstrap5_tabs) requires Bootstrap 5 and HTML, not Markdown.
7
9
 
8
10
 
9
11
  ## Installation
10
12
 
11
13
  Add this to your project's `Gemfile`:
12
14
  ```ruby
13
- gem "jekyll_bootstrap5_tabs"
15
+ gem 'jekyll_bootstrap5_tabs'
14
16
  ```
15
17
 
16
18
  Add this to your project's `_config.yml`:
@@ -26,40 +28,56 @@ And then execute:
26
28
 
27
29
  Or install it yourself as:
28
30
 
29
- $ gem install jekyll-simple-tab5
31
+ $ gem install jekyll_bootstrap5_tabs
30
32
 
31
33
 
32
34
  ## Usage
33
35
 
34
- Bootstrap 5 is required. One way to include Bootstrap 5 in your project is to add the following HTML into the &lt;head> tag:
36
+ Bootstrap 5 is required.
37
+ One way to include Bootstrap 5 into a page within your project is to add the following HTML into the `<head/>` tag:
35
38
  ```html
36
39
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
37
40
  integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
38
41
  ```
39
- ...and add this to the bottom of the HTML file:
42
+ ...and add this to the bottom of the HTML file, within the `<body/>` tag:
40
43
  ```html
41
44
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
42
45
  ```
43
46
 
44
47
  See this [working minimal Bootstrap 5 tab example](https://codepen.io/mslinn/pen/OJOjVPR)
45
48
 
46
- For example, given the following content in a Jekyll page:
49
+
50
+ ## Two New Liquid Tags
51
+ The `jekyll_bootstrap5_tabs` plugin provides two new Liquid tags: `tabs` and `tab`.
52
+ Jekyll interprets the Liquid language when embedded into HTML pages.
53
+
54
+ For example, given the following content in a Jekyll page that has
55
+ [minimal front matter](https://jekyllrb.com/docs/front-matter/):
47
56
  ```
48
57
  ---
49
58
  ---
50
- {% tabs test %}
51
- {% tab test#home %}
59
+ {% tabs demo %}
60
+ {% tab demo#Home %}
52
61
  Home at last!
53
62
  {% endtab %}
54
- {% tab test#profile %}
63
+ {% tab demo#Profile %}
55
64
  Profile meeee...
56
65
  {% endtab %}
57
- {% tab test#messages %}
66
+ {% tab demo#Messages %}
58
67
  Messages - I have none
59
68
  {% endtab %}
60
69
  {% endtabs %}
61
70
  ```
62
- The jekyll_bootstrap5_tabs plugin will generate code similar to this:
71
+ The outer tabs tag has a name: `demo`.
72
+ Conceptually, this name defines a namespace scope for the inner `tab` tags, but actually this version does not use the name for any purpose.
73
+ The inner `tab` tags reference the outer `tabs` tag (yes, this is redundant),
74
+ and introduces the name of the tab that it defines after the octothorpe (aka hash mark, number sign, and pound sign: #). A Bootstrap 5 tab is created for every `tab` tag, and the `id` for each `tag` is defined by the characters following the octothorpe.
75
+ This `id` is also displayed as the label for the `tab`, so if you want it capitalized a certain way, specify the tag capitalization in the `tab` tag.
76
+
77
+ The current implementation does not allow spaces within tab labels.
78
+ Instead, tab labels may only consist of one word each.
79
+
80
+ The `jekyll_bootstrap5_tabs` plugin will generate code similar to the following.
63
81
  ```html
64
82
  <ul class="nav nav-tabs">
65
83
  <li class="nav-item">
@@ -74,13 +92,38 @@ The jekyll_bootstrap5_tabs plugin will generate code similar to this:
74
92
  </ul>
75
93
 
76
94
  <div class="tab-content">
77
- <div class="tab-pane active" id="home" aria-labelledby="home-tab">Home at last!</div>
78
- <div class="tab-pane" id="profile" aria-labelledby="profile-tab">Profile meeee...</div>
79
- <div class="tab-pane" id="messages" aria-labelledby="messages-tab">Messages - I have none</div>
95
+ <div class="tab-pane active" id="home" aria-labelledby="home-tab">
96
+ <editor_fold Home>
97
+ Home at last!
98
+ </editor_fold>
99
+ </div>
100
+ <div class="tab-pane" id="profile" aria-labelledby="profile-tab">
101
+ <editor_fold Profile>
102
+ Profile meeee...
103
+ </editor_fold>
104
+ </div>
105
+ <div class="tab-pane" id="messages" aria-labelledby="messages-tab">
106
+ <editor_fold Messages>
107
+ Messages - I have none
108
+ </editor_fold>
109
+ </div>
80
110
  </div>
81
111
  ```
82
112
 
83
- ![Image](docs/tab-screen.gif)
113
+ ### New for Version 1.1.0
114
+ By default, the output is not pretty-printed.
115
+ However, you can enable pretty-printing for a single set of tabs by including the `pretty` keyword in the `tabs` tag, like this:
116
+ ```
117
+ {% tabs demo pretty %}
118
+ ... tab tags go here
119
+ {% endtabs%}
120
+ ```
121
+
122
+ You can enable pretty-printing for the entire site by adding the following to `_config.yaml`:
123
+ ```yaml
124
+ jekyll_bootstrap5_tabs:
125
+ - pretty: true
126
+ ```
84
127
 
85
128
 
86
129
  ## Building
@@ -117,14 +160,18 @@ Now go use the gem in a Jekyll project!
117
160
 
118
161
  ## Development
119
162
 
120
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
163
+ After checking out the repo, run `bin/setup` to install dependencies.
164
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
121
165
 
122
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
166
+ To install this gem onto your local machine, run `bundle exec rake install`.
167
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
168
+ which will create a git tag for the version, push git commits and the created tag,
169
+ and push the `.gem` file to [rubygems.org](https://rubygems.org).
123
170
 
124
171
 
125
172
  ## Contributing
126
173
 
127
- Bug reports and pull requests are welcome on GitHub at https://github.com/mslinn/jekyll-simple-tab5.
174
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mslinn/jekyll-bootstrap5-tabs.
128
175
 
129
176
 
130
177
  ## License
data/docs/tabDemo.gif ADDED
Binary file
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/jekyll_bootstrap5_tabs/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'jekyll_bootstrap5_tabs'
7
+ spec.version = JekyllBootstrap5Tabs::VERSION
8
+ spec.authors = ['Artur Gabitov', 'Mike Slinn']
9
+ spec.email = ['applifort@gmail.com', 'mslinn@mslinn.com']
10
+
11
+ spec.summary = 'Jekyll plugin for Bootstrap 5 tabs'
12
+ spec.description = 'Enables Bootstrap 5 tabs in Jekyll 4 websites.'
13
+ spec.homepage = 'https://mslinn.com/blog/2022/02/13/jekyll-gem.html'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 2.6.0'
16
+
17
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = 'https://github.com/mslinn/jekyll_bootstrap5_tabs'
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
+ end
29
+ end
30
+
31
+ spec.bindir = 'bin'
32
+ spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
33
+ spec.require_paths = ['lib']
34
+
35
+ spec.add_dependency 'jekyll', '>= 3.0'
36
+ spec.add_dependency 'slim', '~> 3.0'
37
+
38
+ # For more information and examples about making a new gem, check out our
39
+ # guide at: https://bundler.io/guides/creating_gem.html
40
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllBootstrap5Tabs
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
@@ -13,7 +13,28 @@ module JekyllBootstrap5Tabs
13
13
 
14
14
  raise SyntaxError.new("#{tag} requires name") if args.empty?
15
15
 
16
- @tab_name = args.strip
16
+ argv = args.strip.split ' '
17
+ @tab_name = argv[0] # TODO @tab_name is never used. Should act as a namespace.
18
+
19
+ # Usage can override default and enable pretty-printing, not possible to disable per-tab
20
+ @pretty_print = false
21
+ if argv.length>1 && argv[1].downcase == 'pretty'
22
+ @pretty_print = true
23
+ puts "Bootstrap tab pretty-printing is enabled for {@tab_name}"
24
+ end
25
+ end
26
+
27
+ # @param config [YAML] Configuration data that might contain a entry for `jekyll_bootstrap5_tabs`
28
+ # @param progname [String] The name of the `option:` subentry to look for underneath the `jekyll_bootstrap5_tabs` entry
29
+ # @return [TrueClass, FalseClass]
30
+ def check_config_boolean(config, option)
31
+ tabs_options = config['jekyll_bootstrap5_tabs']
32
+ return false if tabs_options.nil?
33
+
34
+ hash = tabs_options.detect {|option| option["pretty"] }
35
+ # puts("*********** tabs_options = #{tabs_options}")
36
+ # puts("*********** hash = #{hash}")
37
+ return (not hash.nil?) && hash['pretty']
17
38
  end
18
39
 
19
40
  def template_path(template_name)
@@ -22,10 +43,20 @@ module JekyllBootstrap5Tabs
22
43
  end
23
44
 
24
45
  def render(context)
25
- @environment = context.environments.first
46
+ site = context.registers[:site]
47
+ # Set the pretty-print option for the Slim engine
48
+ # Global configuration provides the default value of @pretty_print
49
+ if check_config_boolean(site.config, 'pretty')
50
+ @pretty_print = true
51
+ puts "Bootstrap tab pretty-printing is enabled by default for the entire Jekyll site."
52
+ end
53
+
54
+ @environment = context.environments.first # Has type Jekyll::Drops::UnifiedPayloadDrop
55
+ #puts("TabsBlock.render: @environment = '#{@environment}'")
26
56
  super
27
57
 
28
58
  template_file_path = template_path(DEFAULT_TEMPLATE)
59
+ Slim::Engine.set_options pretty: @pretty_print
29
60
  template = Slim::Template.new(template_file_path)
30
61
  template.render(self)
31
62
  end
@@ -37,13 +68,14 @@ module JekyllBootstrap5Tabs
37
68
  super
38
69
 
39
70
  @tabs_group, @tab = split_params(args.strip)
71
+ #puts("TabBlock: @tabs_group = '#{@tabs_group}', @tab = '#{@tab}'")
40
72
  raise SyntaxError.new("Block #{tag} requires tabs name") if @tabs_group.empty? || @tab.empty?
41
73
  end
42
74
 
43
75
  def render(context)
44
76
  content = super
45
77
 
46
- environment = context.environments.first
78
+ environment = context.environments.first # Has type Jekyll::Drops::UnifiedPayloadDrop
47
79
  environment["tabs-#{@tabs_group}"] ||= {}
48
80
  environment["tabs-#{@tabs_group}"][@tab] = content
49
81
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_bootstrap5_tabs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artur Gabitov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-02-14 00:00:00.000000000 Z
12
+ date: 2022-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jekyll
@@ -52,11 +52,13 @@ files:
52
52
  - LICENSE.txt
53
53
  - README.md
54
54
  - Rakefile
55
- - docs/tab-screen.gif
55
+ - docs/tabDemo.gif
56
+ - jekyll_bootstrap5_tabs.gemspec
56
57
  - lib/jekyll_bootstrap5_tabs.rb
57
58
  - lib/jekyll_bootstrap5_tabs/version.rb
58
59
  - lib/template.slim
59
60
  - pkg/jekyll_bootstrap5_tabs-1.0.0.gem
61
+ - pkg/jekyll_bootstrap5_tabs-1.1.0.gem
60
62
  - sig/jekyll_bootstrap5_tabs.rbs
61
63
  homepage: https://mslinn.com/blog/2022/02/13/jekyll-gem.html
62
64
  licenses:
data/docs/tab-screen.gif DELETED
Binary file