jekyll-jelly 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +22 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/jekyll-jelly.gemspec +36 -0
- data/lib/jekyll-jelly.rb +1 -0
- data/lib/jekyll/jelly.rb +3 -0
- data/lib/jekyll/jelly/components/tags/image.rb +136 -0
- data/lib/jekyll/jelly/version.rb +5 -0
- metadata +225 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5e159b9522b437272e44425f8d5756e406f91f0d
|
4
|
+
data.tar.gz: 116efba0157d42e0a5652dc8e79963987ba1ab90
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 28c50a1ae8aedbc6f915a966e8705a19bb6bd64c3cc5e4da7fc42f3c7598aa1dc45617891f99795718925905fd927f22c00e67734586cc183f56050797a6b8a3
|
7
|
+
data.tar.gz: 7da4a81dd2b7c110ba2b8f0a8ac95b9b4c1ffa293dc2b8676c80a4d924a5ecf5dbe4492bccae4dfd280f915486e5b7ac1adfdc05ad7ba8f4cb74093ee4f95940
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Help Scout
|
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,22 @@
|
|
1
|
+
# Jelly 🍥 [![Build Status](https://travis-ci.org/helpscout/jekyll-jelly.svg?branch=master)](https://travis-ci.org/helpscout/jekyll-jelly)
|
2
|
+
|
3
|
+
Help Scout's Jekyll component library.
|
4
|
+
|
5
|
+
|
6
|
+
## Install
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'jekyll-jelly'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```
|
16
|
+
bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```
|
21
|
+
gem install jekyll-jelly
|
22
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "jekyll/jelly"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "jekyll/jelly/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jekyll-jelly"
|
8
|
+
spec.version = Jekyll::Jelly::VERSION
|
9
|
+
spec.authors = ["ItsJonQ"]
|
10
|
+
spec.email = ["itsjonq@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Help Scout's Jekyll component library"
|
13
|
+
spec.homepage = "https://github.com/helpscout/jekyll-jelly"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_runtime_dependency "jekyll", ">= 3.1.2"
|
24
|
+
spec.add_runtime_dependency "kramdown"
|
25
|
+
spec.add_runtime_dependency "jekyll-spark", "0.3.0"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "minitest-reporters"
|
30
|
+
spec.add_development_dependency "minitest-profile"
|
31
|
+
spec.add_development_dependency "minitest", "~> 5.8"
|
32
|
+
spec.add_development_dependency "kramdown"
|
33
|
+
spec.add_development_dependency "rspec-mocks"
|
34
|
+
spec.add_development_dependency "shoulda"
|
35
|
+
spec.add_development_dependency "jekyll-joule"
|
36
|
+
end
|
data/lib/jekyll-jelly.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "jekyll/jelly"
|
data/lib/jekyll/jelly.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
require "jekyll-spark"
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class ImageComponent < ComponentTag
|
5
|
+
DEFAULT_TAG_PROPS = [
|
6
|
+
"crossorigin",
|
7
|
+
"id",
|
8
|
+
"ismap",
|
9
|
+
"longdesc",
|
10
|
+
"style",
|
11
|
+
"usemap",
|
12
|
+
]
|
13
|
+
BLANK_IMG = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
|
14
|
+
|
15
|
+
def encode(string)
|
16
|
+
if (string)
|
17
|
+
string = string.gsub("'", "").gsub('"', '')
|
18
|
+
end
|
19
|
+
|
20
|
+
return string
|
21
|
+
end
|
22
|
+
|
23
|
+
def template(context)
|
24
|
+
prop = @props
|
25
|
+
|
26
|
+
alt = encode(prop["alt"])
|
27
|
+
blazy_class_name = "b-lazy"
|
28
|
+
class_name = prop["class"]
|
29
|
+
height = prop["height"]
|
30
|
+
data_src = BLANK_IMG
|
31
|
+
src = prop["src"]
|
32
|
+
srcset = prop["srcset"]
|
33
|
+
title = encode(prop["title"])
|
34
|
+
width = prop["width"]
|
35
|
+
responsive = ""
|
36
|
+
default_props = selector_props(DEFAULT_TAG_PROPS)
|
37
|
+
|
38
|
+
# Responsive
|
39
|
+
# Adds new responsive-based image attributes: srcset and sizes.
|
40
|
+
# The numbers are based on @attribute["width"].
|
41
|
+
# At the moment, this plugin only supports 1x and 2x pixel-density sizes.
|
42
|
+
#
|
43
|
+
# Learn more about srcset
|
44
|
+
# https://ericportis.com/posts/2014/srcset-sizes/
|
45
|
+
#
|
46
|
+
if srcset
|
47
|
+
srcset_2x = srcset.to_s.gsub(/\.(?=[^.]*$)/, "@2x.")
|
48
|
+
srcset_1x = srcset.to_s.gsub(/\.(?=[^.]*$)/, "@1x.")
|
49
|
+
# Width-based srcset (Recommended)
|
50
|
+
if (width)
|
51
|
+
# Ensure that width is just a number (just in case)
|
52
|
+
w = width.to_s.gsub("px", "").gsub("%", "").to_i
|
53
|
+
responsive = "
|
54
|
+
srcset='
|
55
|
+
#{srcset_1x} #{w}w,
|
56
|
+
#{srcset_2x} #{w*2}w
|
57
|
+
'
|
58
|
+
"
|
59
|
+
responsive += "
|
60
|
+
sizes='
|
61
|
+
(min-width: 40em) #{w}px,
|
62
|
+
100vw
|
63
|
+
'
|
64
|
+
"
|
65
|
+
# Fallback to pixel-density based (if width is not available)
|
66
|
+
else
|
67
|
+
responsive = "
|
68
|
+
srcset='
|
69
|
+
#{srcset_1x} 1x,
|
70
|
+
#{srcset_2x} 2x
|
71
|
+
'
|
72
|
+
"
|
73
|
+
end
|
74
|
+
src = srcset_1x
|
75
|
+
end
|
76
|
+
|
77
|
+
# Set the src for <noscript>. This is important since {% img %} uses
|
78
|
+
# JS lazy-loading by default.
|
79
|
+
noscript_src = src
|
80
|
+
|
81
|
+
# Non-lazy load
|
82
|
+
if (
|
83
|
+
prop["lazy"] === false or
|
84
|
+
prop["lazy"] === "false" or
|
85
|
+
prop["skip_lazy"] === true or
|
86
|
+
prop["skip_lazy"] === "true"
|
87
|
+
)
|
88
|
+
blazy_class_name = "b-skipped"
|
89
|
+
data_src = ""
|
90
|
+
src = src
|
91
|
+
else
|
92
|
+
data_src = src
|
93
|
+
src = BLANK_IMG
|
94
|
+
end
|
95
|
+
|
96
|
+
render = "
|
97
|
+
<img
|
98
|
+
alt='#{alt}'
|
99
|
+
class='#{blazy_class_name} #{class_name}'
|
100
|
+
data-src='#{data_src}'
|
101
|
+
height='#{height}'
|
102
|
+
src='#{src}'
|
103
|
+
width='#{width}'
|
104
|
+
title='#{title}'
|
105
|
+
#{responsive}
|
106
|
+
#{default_props}
|
107
|
+
/>
|
108
|
+
"
|
109
|
+
unless(prop["skip_noscript"])
|
110
|
+
# Add the <noscript> image for lazy-loaded images.
|
111
|
+
if (src === BLANK_IMG)
|
112
|
+
render += "
|
113
|
+
<noscript>
|
114
|
+
<img
|
115
|
+
alt='#{alt}'
|
116
|
+
class='#{class_name}'
|
117
|
+
height='#{height}'
|
118
|
+
src='#{noscript_src}'
|
119
|
+
title='#{title}'
|
120
|
+
width='#{width}'
|
121
|
+
#{responsive}
|
122
|
+
#{default_props}
|
123
|
+
/>
|
124
|
+
</noscript>
|
125
|
+
"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
return render
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
Liquid::Template.register_tag('Image', Jekyll::ImageComponent)
|
135
|
+
# Aliases
|
136
|
+
Liquid::Template.register_tag('img', Jekyll::ImageComponent)
|
metadata
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-jelly
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ItsJonQ
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-05 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.1.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.1.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: kramdown
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jekyll-spark
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.3.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.3.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.13'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.13'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest-reporters
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest-profile
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: minitest
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '5.8'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '5.8'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: kramdown
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec-mocks
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: shoulda
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: jekyll-joule
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description:
|
182
|
+
email:
|
183
|
+
- itsjonq@gmail.com
|
184
|
+
executables: []
|
185
|
+
extensions: []
|
186
|
+
extra_rdoc_files: []
|
187
|
+
files:
|
188
|
+
- ".gitignore"
|
189
|
+
- ".travis.yml"
|
190
|
+
- Gemfile
|
191
|
+
- LICENSE.txt
|
192
|
+
- README.md
|
193
|
+
- Rakefile
|
194
|
+
- bin/console
|
195
|
+
- bin/setup
|
196
|
+
- jekyll-jelly.gemspec
|
197
|
+
- lib/jekyll-jelly.rb
|
198
|
+
- lib/jekyll/jelly.rb
|
199
|
+
- lib/jekyll/jelly/components/tags/image.rb
|
200
|
+
- lib/jekyll/jelly/version.rb
|
201
|
+
homepage: https://github.com/helpscout/jekyll-jelly
|
202
|
+
licenses:
|
203
|
+
- MIT
|
204
|
+
metadata: {}
|
205
|
+
post_install_message:
|
206
|
+
rdoc_options: []
|
207
|
+
require_paths:
|
208
|
+
- lib
|
209
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
requirements: []
|
220
|
+
rubyforge_project:
|
221
|
+
rubygems_version: 2.5.2
|
222
|
+
signing_key:
|
223
|
+
specification_version: 4
|
224
|
+
summary: Help Scout's Jekyll component library
|
225
|
+
test_files: []
|