jekyll-simple-tab 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 26ff3d32ca0acfb3bf45ddc0ab35fa79844814231edc55cc896b7bd50026fcbe
4
+ data.tar.gz: a31712b4af5fbae964b478610fa5b73a26c454ab841aa18828d1604e4be47246
5
+ SHA512:
6
+ metadata.gz: 8f45afaf4fd5d6b7d678b2734ae86b5f56ca43401e388760a2564f63883df970f843bef18b7bbd72a89ed98f39b7be359e63cbd21db08f064a2cdb4168c58c2e
7
+ data.tar.gz: a5bf584950355072e846dd84242803761542f0fe326408540257dd45cc142851d6a8c275ce57d654601ac72db6bf75d01fe76c8e42721ae44c6a1f36d260c93b
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in jekyll-simple-tab.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Artur Gabitov
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,54 @@
1
+ Jekyll Simple Tabs
2
+ ===========
3
+
4
+ This Jekyll plugin for adding tabs. It works with bootstrap 4
5
+
6
+ Installation
7
+ ------------
8
+
9
+ Add this line to your Gemfile:
10
+
11
+ ```ruby
12
+ group :jekyll_plugins do
13
+
14
+ gem "jekyll-simple-tab"
15
+ end
16
+ ```
17
+
18
+ Add in you _config.yml:
19
+
20
+ ```yaml
21
+ plugins_dev:
22
+ - jekyll-simple-tab
23
+ ```
24
+
25
+ Usage
26
+ -----
27
+
28
+ ````
29
+ {% tabs test %}
30
+
31
+ {% tab test#first %}
32
+ ```ruby
33
+ def render(context)
34
+ @environment = context.environments.first
35
+ super
36
+
37
+ templateFilePath = template_path(DEFAULT_TEMPLATE)
38
+ template = Slim::Template.new(templateFilePath)
39
+ template.render(self)
40
+ end
41
+ ```
42
+ {% endtab %}
43
+
44
+ {% tab test#second %}
45
+ ## Header
46
+
47
+ > Blockquotes
48
+
49
+ {% endtab %}
50
+
51
+ {% endtabs %}
52
+ ````
53
+
54
+ ![Image](docs/tab-screen.gif)
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,22 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "jekyll-simple-tab/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-simple-tab"
8
+ spec.version = Jekyll::Simple::Tab::VERSION
9
+ spec.authors = ["Artur Gabitov"]
10
+ spec.email = ["applifort@gmail.com"]
11
+
12
+ spec.summary = "Jekyll tabs plugin"
13
+ spec.description = "Add tabs for your jekyll site. Ready for bootstrap 4"
14
+ spec.homepage = "https://github.com/Applifort/jekyll-simple-tab"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features|docs)/!) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency 'slim', '>= 3.0'
21
+ spec.add_dependency 'jekyll', '>= 3.0'
22
+ end
@@ -0,0 +1,7 @@
1
+ module Jekyll
2
+ module Simple
3
+ module Tab
4
+ VERSION = "0.1.6"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,61 @@
1
+ require 'slim'
2
+
3
+ DEFAULT_TEMPLATE = 'template.slim'
4
+
5
+ module Jekyll
6
+ module Simple
7
+ module Tab
8
+ class TabsBlock < Liquid::Block
9
+ def initialize(tag, args, _)
10
+ super
11
+
12
+ raise SyntaxError.new("#{tag} requires name") if args.empty?
13
+
14
+ @tab_name = args.strip
15
+ end
16
+
17
+ def template_path(template_name)
18
+ dir = File.dirname(__FILE__)
19
+ File.join(dir, template_name.to_s)
20
+ end
21
+
22
+ def render(context)
23
+ @environment = context.environments.first
24
+ super
25
+
26
+ templateFilePath = template_path(DEFAULT_TEMPLATE)
27
+ template = Slim::Template.new(templateFilePath)
28
+ template.render(self)
29
+ end
30
+ end
31
+
32
+ class TabBlock < Liquid::Block
33
+ def initialize(tag, args, _)
34
+ super
35
+
36
+ @tabs_group, @tab = split_params(args.strip)
37
+ raise SyntaxError.new("Block #{tag} requires tabs name") if @tabs_group.empty? || @tab.empty?
38
+ end
39
+
40
+ def render(context)
41
+ site = context.registers[:site]
42
+ converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
43
+ content = converter.convert(super)
44
+
45
+ environment = context.environments.first
46
+ environment["tabs-#{@tabs_group}"] ||= {}
47
+ environment["tabs-#{@tabs_group}"][@tab] = content
48
+ end
49
+
50
+ private
51
+
52
+ def split_params(params)
53
+ params.split('#')
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ Liquid::Template.register_tag('tabs', Jekyll::Simple::Tab::TabsBlock)
61
+ Liquid::Template.register_tag('tab', Jekyll::Simple::Tab::TabBlock)
data/lib/template.slim ADDED
@@ -0,0 +1,15 @@
1
+ ul.nav.nav-tabs.mb-3 data-tab="#{@tab_name}" role="tablist"
2
+ - @environment["tabs-#{@tab_name}"].each_with_index do |(key, _), index|
3
+ li.nav-item
4
+ - if index == 0
5
+ a.nav-link.active id="#{key}-tab" data-toggle="tab" href="##{key}" role="tab" aria-controls="#{key}" aria-selected="true"= key
6
+ - else
7
+ a.nav-link id="#{key}-tab" data-toggle="tab" href="##{key}" role="tab" aria-controls="#{key}" aria-selected="false"= key
8
+ .tab-content id="#{@tab_name}Content"
9
+ - @environment["tabs-#{@tab_name}"].each_with_index do |(key, value), index|
10
+ - if index == 0
11
+ .tab-pane.fade.show.active id="#{key}" role="tabpanel" aria-labelledby="#{key}-tab"
12
+ == value
13
+ - else
14
+ .tab-pane.fade id="#{key}" role="tabpanel" aria-labelledby="#{key}-tab"
15
+ == value
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-simple-tab
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.6
5
+ platform: ruby
6
+ authors:
7
+ - Artur Gabitov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: slim
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jekyll
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ description: Add tabs for your jekyll site. Ready for bootstrap 4
42
+ email:
43
+ - applifort@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - jekyll-simple-tab.gemspec
54
+ - lib/jekyll-simple-tab.rb
55
+ - lib/jekyll-simple-tab/version.rb
56
+ - lib/template.slim
57
+ homepage: https://github.com/Applifort/jekyll-simple-tab
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 3.0.3
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Jekyll tabs plugin
80
+ test_files: []