jekyll-jelly 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -1
- data/README.md +1 -1
- data/jekyll-jelly.gemspec +2 -1
- data/lib/jekyll/jelly.rb +4 -0
- data/lib/jekyll/jelly/components/blocks/example.rb +86 -0
- data/lib/jekyll/jelly/components/blocks/section.rb +36 -0
- data/lib/jekyll/jelly/components/blocks/wistia_popover.rb +37 -0
- data/lib/jekyll/jelly/components/tags/wistia.rb +27 -0
- data/lib/jekyll/jelly/version.rb +1 -1
- metadata +24 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64802a3b7bfb485eed286ab12089ff1804ee1a65
|
4
|
+
data.tar.gz: bb69dc7cb8b5d6f16d6beeb9f7bbfdc021a9ea9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15697cffb4081714f2de6bb487f03ca697a4bf91d52ecdbcb3f435f6d2648dfe665a56072ed4aa3b7f8ed5ae99d075b05d54022d65b6b3493c63b7d98bb0f792
|
7
|
+
data.tar.gz: 8a6c699fc942d718e6aff62c012e8b64496be3737467254fb7ff317796418e62d01eb239c913e15c93e5b34406c3c5d241c49a30e76525fcf18da7498143c156
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Jelly 🍥 [![Build Status](https://travis-ci.org/helpscout/jekyll-jelly.svg?branch=master)](https://travis-ci.org/helpscout/jekyll-jelly)
|
1
|
+
# Jelly 🍥 [![Build Status](https://travis-ci.org/helpscout/jekyll-jelly.svg?branch=master)](https://travis-ci.org/helpscout/jekyll-jelly) [![Coverage Status](https://coveralls.io/repos/github/helpscout/jekyll-jelly/badge.svg?branch=master)](https://coveralls.io/github/helpscout/jekyll-jelly?branch=master)
|
2
2
|
|
3
3
|
Help Scout's Jekyll component library.
|
4
4
|
|
data/jekyll-jelly.gemspec
CHANGED
@@ -21,8 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
23
|
spec.add_runtime_dependency "jekyll", ">= 3.1.2"
|
24
|
-
spec.add_runtime_dependency "kramdown"
|
25
24
|
spec.add_runtime_dependency "jekyll-spark", "0.3.0"
|
25
|
+
spec.add_runtime_dependency "kramdown"
|
26
|
+
spec.add_runtime_dependency "rouge"
|
26
27
|
|
27
28
|
spec.add_development_dependency "bundler", "~> 1.13"
|
28
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/jekyll/jelly.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
1
|
require "jekyll/jelly/version"
|
2
2
|
|
3
|
+
require "jekyll/jelly/components/blocks/example"
|
4
|
+
require "jekyll/jelly/components/blocks/section"
|
5
|
+
require "jekyll/jelly/components/blocks/wistia_popover"
|
3
6
|
require "jekyll/jelly/components/tags/image"
|
7
|
+
require "jekyll/jelly/components/tags/wistia"
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require "jekyll-spark"
|
2
|
+
require "rouge"
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
class ExampleComponent < ComponentBlock
|
6
|
+
include Liquid::StandardFilters
|
7
|
+
|
8
|
+
# The regular expression syntax checker. Start with the language specifier.
|
9
|
+
# Follow that by zero or more space separated options that take one of three
|
10
|
+
# forms: name, name=value, or name="<quoted list>"
|
11
|
+
#
|
12
|
+
# <quoted list> is a space-separated list of numbers
|
13
|
+
SYNTAX = /^([a-zA-Z0-9.+#-]+)((\s+\w+(=((\w|[0-9_-])+|"([0-9]+\s)*[0-9]+"))?)*)$/
|
14
|
+
|
15
|
+
def initialize(tag_name, markup, tokens)
|
16
|
+
super
|
17
|
+
if markup.strip =~ SYNTAX
|
18
|
+
@lang = $1.downcase
|
19
|
+
@options = {}
|
20
|
+
# if defined?($2) && $2 != ''
|
21
|
+
# # Split along 3 possible forms -- key="<quoted list>", key=value, or key
|
22
|
+
# $2.scan(/(?:\w+(?:=(?:(?:\w|[0-9_-])+|"[^"]*")?)?)/) do |opt|
|
23
|
+
# key, value = opt.split('=')
|
24
|
+
# # If a quoted list, convert to array
|
25
|
+
# if value && value.include?("\"")
|
26
|
+
# value.gsub!(/"/, "")
|
27
|
+
# value = value.split
|
28
|
+
# end
|
29
|
+
# @options[key.to_sym] = value || true
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
@options[:linenos] = "inline" if @options.key?(:linenos) and @options[:linenos] == true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def example(code, output)
|
37
|
+
language = @lang.to_s
|
38
|
+
|
39
|
+
if(language == "html" or language == "")
|
40
|
+
output = "<div class=\"c-card hs-code u-mrg-t-4 u-mrg-b-7\" data-js=\""+@lang.to_s+"\"><div class=\"u-pad-5 hs-code__example\" data-example-id=\"#{@options[:id]}\">\n#{code}\n</div>"
|
41
|
+
else
|
42
|
+
output = "<div class=\"c-card hs-code u-mrg-t-4 u-mrg-b-7\" data-js=\""+@lang.to_s+"\">"
|
43
|
+
end
|
44
|
+
|
45
|
+
output
|
46
|
+
end
|
47
|
+
|
48
|
+
def render_rouge(code)
|
49
|
+
formatter = Rouge::Formatters::HTML.new(line_numbers: @options[:linenos], wrap: false)
|
50
|
+
lexer = Rouge::Lexer.find_fancy(@lang, code) || Rouge::Lexers::PlainText
|
51
|
+
code = formatter.format(lexer.lex(code))
|
52
|
+
"<div class=\"c-clipboard-copy-container js-code-snippet t-bdr-top\"><div class=\"u-pad-5 hs-code__highlight highlight\"><pre>#{code}</pre></div></div></div>"
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_code_tag(code)
|
56
|
+
# Add nested <code> tags to code blocks
|
57
|
+
code = code.sub(/<pre>\n*/,'<pre><code class="language-' + @lang.to_s.gsub("+", "-") + '" data-lang="' + @lang.to_s + '">')
|
58
|
+
code = code.sub(/\n*<\/pre>/,"</code></pre>")
|
59
|
+
code.strip
|
60
|
+
end
|
61
|
+
|
62
|
+
def template(context)
|
63
|
+
content = @props["content"]
|
64
|
+
prefix = context["highlighter_prefix"] || ""
|
65
|
+
suffix = context["highlighter_suffix"] || ""
|
66
|
+
code = content.to_s.strip
|
67
|
+
|
68
|
+
output = case context.registers[:site].highlighter
|
69
|
+
|
70
|
+
when 'rouge'
|
71
|
+
render_rouge(code)
|
72
|
+
end
|
73
|
+
|
74
|
+
if (@lang.to_s == "html")
|
75
|
+
rendered_output = example(code, output) + add_code_tag(output)
|
76
|
+
else
|
77
|
+
rendered_output = example(code, output) + '</div>'
|
78
|
+
end
|
79
|
+
prefix + rendered_output + suffix
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
Liquid::Template.register_tag("example", Jekyll::ExampleComponent)
|
86
|
+
Liquid::Template.register_tag("Example", Jekyll::ExampleComponent)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "jekyll-spark"
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class SectionComponent < ComponentBlock
|
5
|
+
DEFAULT_TAG_PROPS = [
|
6
|
+
"id",
|
7
|
+
"style",
|
8
|
+
]
|
9
|
+
|
10
|
+
def template(context)
|
11
|
+
class_name = @props["class"]
|
12
|
+
container = @props["container"].nil? ? true : @props["container"]
|
13
|
+
content = @props["content"]
|
14
|
+
default_props = selector_props(DEFAULT_TAG_PROPS)
|
15
|
+
|
16
|
+
if (container)
|
17
|
+
content = %Q[
|
18
|
+
<div class="o-container">
|
19
|
+
#{content}
|
20
|
+
</div>
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
render = %Q[
|
25
|
+
<div class="o-section #{class_name}" #{default_props}>
|
26
|
+
#{content}
|
27
|
+
</div>
|
28
|
+
]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Liquid::Template.register_tag(
|
34
|
+
"Section",
|
35
|
+
Jekyll::SectionComponent
|
36
|
+
)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "jekyll-spark"
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class WistiaPopoverComponent < ComponentBlock
|
5
|
+
def template(context)
|
6
|
+
unless @props["id"]
|
7
|
+
return ""
|
8
|
+
end
|
9
|
+
|
10
|
+
id = @props["id"].gsub("wistia_", "").gsub("Wistia_", "")
|
11
|
+
class_name = @props["class"]
|
12
|
+
content = @props["content"]
|
13
|
+
popover_content = @props["popoverContent"] || "link"
|
14
|
+
selector = @props["selector"] || "span"
|
15
|
+
style = @props["style"]
|
16
|
+
|
17
|
+
popover_content = "popoverContent=#{popover_content}"
|
18
|
+
|
19
|
+
render = %Q[
|
20
|
+
<script src="https://fast.wistia.com/embed/medias/#{id}.jsonp" async></script>
|
21
|
+
<#{selector}
|
22
|
+
class="
|
23
|
+
#{class_name}
|
24
|
+
wistia_embed wistia_async_#{id}
|
25
|
+
popover=true popoverAnimateThumbnail=true
|
26
|
+
#{popover_content}
|
27
|
+
"
|
28
|
+
style="#{style}"
|
29
|
+
>
|
30
|
+
#{content}
|
31
|
+
</#{selector}>
|
32
|
+
]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Liquid::Template.register_tag('WistiaPopover', Jekyll::WistiaPopoverComponent)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "jekyll-spark"
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class WistiaComponent < ComponentTag
|
5
|
+
def template(context)
|
6
|
+
unless @props["id"]
|
7
|
+
return ""
|
8
|
+
end
|
9
|
+
|
10
|
+
id = @props["id"].gsub("wistia_", "").gsub("Wistia_", "").gsub("wistia-", "").gsub("Wistia-", "")
|
11
|
+
class_name = @props["class"]
|
12
|
+
|
13
|
+
render = %Q[
|
14
|
+
<script src='https://fast.wistia.com/embed/medias/#{id}.jsonp' async></script>
|
15
|
+
<div class='wistia_responsive_padding #{class_name}' style='padding:56.25% 0 0 0;position:relative;'>
|
16
|
+
<div class='wistia_responsive_wrapper' style='height:100%;left:0;position:absolute;top:0;width:100%;'>
|
17
|
+
<div class='wistia_embed wistia_async_#{id} videoFoam=true' style='height:100%;width:100%'>
|
18
|
+
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Liquid::Template.register_tag('Wistia', Jekyll::WistiaComponent)
|
data/lib/jekyll/jelly/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-jelly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ItsJonQ
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.1.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jekyll-spark
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.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: 0.3.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: kramdown
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,19 +53,19 @@ dependencies:
|
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: rouge
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
61
|
+
version: '0'
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,7 +210,11 @@ files:
|
|
196
210
|
- jekyll-jelly.gemspec
|
197
211
|
- lib/jekyll-jelly.rb
|
198
212
|
- lib/jekyll/jelly.rb
|
213
|
+
- lib/jekyll/jelly/components/blocks/example.rb
|
214
|
+
- lib/jekyll/jelly/components/blocks/section.rb
|
215
|
+
- lib/jekyll/jelly/components/blocks/wistia_popover.rb
|
199
216
|
- lib/jekyll/jelly/components/tags/image.rb
|
217
|
+
- lib/jekyll/jelly/components/tags/wistia.rb
|
200
218
|
- lib/jekyll/jelly/version.rb
|
201
219
|
homepage: https://github.com/helpscout/jekyll-jelly
|
202
220
|
licenses:
|