jekyll-code-tabs 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6648319a6f379058f0e3b7fe9feb4b321f561d8d6e6c36aecd2c91a510f5c0cb
4
+ data.tar.gz: ad2af55ddd634cea856e9fd1534f9500cd558677d72e571c7dc38941c57802d7
5
+ SHA512:
6
+ metadata.gz: b40a46bc199c9d0d868c767983c5e9b03e8ba1d567a7f774b61c004139fa32bbacce9555b9d02316e21753f42560dfa9cf3a7a625efb85f20bd693a44122fe49
7
+ data.tar.gz: a1c4223d625ee9bd9a1b99315e9c1f682674a4c65c7f6af6a19937d22a4914fe311f20af11c0c56897fa492b239f8135e4f601ce893a1c007ce590e657a961c2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Brett Fowle <brettfowle@gmail.com> (https://clustergarage.io
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.
@@ -0,0 +1,25 @@
1
+ # jekyll-code-tabs
2
+
3
+ > 💎 Separate language snippets with fenced code tabs for documentation pages
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ {% codetabs %}
9
+
10
+ {% codetab Foo %}
11
+ Lorem ipsum dolor sit amet
12
+ {% endcodetab %}
13
+
14
+ {% codetab Bar %}
15
+ Consectetur adipiscing elit
16
+ {% endcodetab %}
17
+
18
+ {% endcodetabs %}
19
+ ```
20
+
21
+ This will create a tabbed-view (hardcoded to UIkit classes for now) that will
22
+ allow the user to toggle between content.
23
+
24
+ ![alt
25
+ text](https://raw.githubusercontent.com/clustergarage/jekyll-code-tabs/master/docs/screencap.gif)
@@ -0,0 +1 @@
1
+ require_relative "../lib/jekyll-code-tabs"
Binary file
@@ -0,0 +1,19 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "jekyll-code-tabs/version"
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "jekyll-code-tabs"
6
+ spec.summary = "Fenced code tabs for Jekyll"
7
+ spec.description = "Separate language snippets with fenced code tabs for documentation pages"
8
+ spec.version = Jekyll::CodeTabs::VERSION
9
+ spec.authors = ["Brett Fowle"]
10
+ spec.email = ["brettfowle@gmail.com"]
11
+ spec.homepage = "https://github.com/clustergarage/jekyll-code-tabs"
12
+ spec.licenses = ["MIT"]
13
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
14
+ spec.require_paths = ["lib"]
15
+ spec.add_dependency "jekyll", "~> 3.0"
16
+ spec.add_development_dependency "rake", "~> 11.0"
17
+ spec.add_development_dependency "rspec", "~> 3.5"
18
+ spec.add_development_dependency "rubocop", "~> 0.52"
19
+ end
@@ -0,0 +1,52 @@
1
+ require "erb"
2
+ require_relative "jekyll-code-tabs/version"
3
+
4
+ module Jekyll
5
+ module CodeTabs
6
+ class CodeTabsBlock < Liquid::Block
7
+ def render(context)
8
+ environment = context.environments.first
9
+ environment['codetabs'] = {} # reset each time
10
+ super
11
+
12
+ template = ERB.new <<-EOF
13
+ <ul uk-tab>
14
+ <% environment['codetabs'].each_with_index do |(key, _), index| %>
15
+ <li<%= index == 0 ? ' class="uk-active"' : ''%>><a href="#"><%= key %></a></li>
16
+ <% end %>
17
+ </ul>
18
+
19
+ <ul class="uk-switcher uk-margin">
20
+ <% environment['codetabs'].each do |_, value| %>
21
+ <li><%= value %></li>
22
+ <% end %>
23
+ </ul>
24
+ EOF
25
+ template.result(binding)
26
+ end
27
+ end
28
+
29
+ class CodeTabBlock < Liquid::Block
30
+ alias_method :render_block, :render
31
+
32
+ def initialize(tag_name, markup, tokens)
33
+ super
34
+ if markup == ""
35
+ raise SyntaxError.new("No toggle name given in #{tag_name} tag")
36
+ end
37
+ @toggle = markup.strip
38
+ end
39
+
40
+ def render(context)
41
+ site = context.registers[:site]
42
+ converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
43
+ environment = context.environments.first
44
+ environment['codetabs'] ||= {}
45
+ environment['codetabs'][@toggle] = converter.convert(render_block(context))
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ Liquid::Template.register_tag("codetab", Jekyll::CodeTabs::CodeTabBlock)
52
+ Liquid::Template.register_tag("codetabs", Jekyll::CodeTabs::CodeTabsBlock)
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module CodeTabs
3
+ VERSION = "1.0.0".freeze
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-code-tabs
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brett Fowle
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
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: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '11.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.52'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.52'
69
+ description: Separate language snippets with fenced code tabs for documentation pages
70
+ email:
71
+ - brettfowle@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - LICENSE
77
+ - README.md
78
+ - _plugins/jekyll-code-tabs.rb
79
+ - docs/screencap.gif
80
+ - jekyll-code-tabs.gemspec
81
+ - lib/jekyll-code-tabs.rb
82
+ - lib/jekyll-code-tabs/version.rb
83
+ homepage: https://github.com/clustergarage/jekyll-code-tabs
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.7.7
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Fenced code tabs for Jekyll
107
+ test_files: []