jekyll_figure 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/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +2 -0
- data/jekyll_figure.gemspec +20 -0
- data/lib/jekyll_figure.rb +58 -0
- data/lib/jekyll_figure/version.rb +3 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eeda5a19bf522509d0c996e30ee0ca6b47572961
|
4
|
+
data.tar.gz: 71718baaa1f10f740ba3da7ed302f8e0f4a6676c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 84efb5c5871eed44bc147b0b6be0af396b47af7e2c03b64959c16e98ed6ac786d32c5df7f80deef5fa462d361ff9cb90b3c6075764a3a3b2e29bd61dcda71a0a
|
7
|
+
data.tar.gz: 57d5e8caf38d86216b151c804baf31b94245176ec7185b032f02f14f3bdae5682afe831f567f6a1e7dde1eba4537fecbd1e42948b04d51d53c79e7779d5e0fd8
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Lincoln Mullen
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# jekyll_figure
|
2
|
+
|
3
|
+
Adds a Liquid `figure` tag to a [Jekyll][] site
|
4
|
+
|
5
|
+
Lincoln A. Mullen | lincoln@lincolnmullen.com | http://lincolnmullen.com
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your Jekyll site's `Gemfile`:
|
10
|
+
|
11
|
+
gem 'jekyll_figure'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
bundle
|
16
|
+
|
17
|
+
In the Jekyll site's `_config.yml` file, add this line:
|
18
|
+
|
19
|
+
gems: [jekyll_figure]
|
20
|
+
|
21
|
+
If you have a directory where you keep your figures, add these lines to
|
22
|
+
`_config.yml`:
|
23
|
+
|
24
|
+
figures:
|
25
|
+
dir: /figures
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Creates a Liquid figure tag. The figure tag should take this form:
|
30
|
+
|
31
|
+
{% figure filename svg,png,pdf 'Your caption here' %}
|
32
|
+
|
33
|
+
The first value is the filename, which should be shared across every
|
34
|
+
format of the figure. The second value is a comma-separated list of
|
35
|
+
extensions for the filename. The third value is a quoted caption. The
|
36
|
+
tag will produce an img tag for the first file format in the list of
|
37
|
+
extensions. It will include a caption with links to all the figure
|
38
|
+
formats. If the figures directory is set in `_config.yml`, then the
|
39
|
+
image and the links will point there.
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
MIT License <http://lmullen.mit-license.org/>
|
44
|
+
|
45
|
+
[Jekyll]: http://jekyllrb.com/
|
46
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jekyll_figure/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jekyll_figure"
|
8
|
+
spec.version = JekyllFigure::VERSION
|
9
|
+
spec.authors = ["Lincoln Mullen"]
|
10
|
+
spec.email = ["lincoln@lincolnmullen.com"]
|
11
|
+
spec.summary = %q{Add a figure tag to output figures and captions in Jekyll}
|
12
|
+
spec.homepage = "https://github.com/lmullen/jekyll_figure"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler"
|
19
|
+
spec.add_development_dependency "rake"
|
20
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "jekyll_figure/version"
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
|
5
|
+
# Creates a Liquid figure tag. The figure tag should take this form:
|
6
|
+
#
|
7
|
+
# {% figure filename svg,png,pdf 'Your caption here' %}
|
8
|
+
#
|
9
|
+
# The first value is the filename, which should be shared across every
|
10
|
+
# format of the figure. The second value is a comma-separated list of
|
11
|
+
# extensions for the filename. The third value is a quoted caption. The tag
|
12
|
+
# will produce an img tag for the first file format in the list of
|
13
|
+
# extensions. It will include a caption with links to all the figure
|
14
|
+
# formats. If the figures directory is set in _config.yml, then the image
|
15
|
+
# and the links will point there.
|
16
|
+
class FigureTag < Liquid::Tag
|
17
|
+
|
18
|
+
require "shellwords"
|
19
|
+
|
20
|
+
def initialize(tag_name, text, tokens)
|
21
|
+
super
|
22
|
+
@text = text.shellsplit
|
23
|
+
end
|
24
|
+
|
25
|
+
def render(context)
|
26
|
+
# If the figures directory is not defined, set dir to site root
|
27
|
+
if defined? context.registers[:site].config["figures"]["dir"]
|
28
|
+
dir = context.registers[:site].config["figures"]["dir"]
|
29
|
+
else
|
30
|
+
dir = ""
|
31
|
+
end
|
32
|
+
|
33
|
+
filename = @text[0]
|
34
|
+
extensions = @text[1].split(",")
|
35
|
+
caption = @text[2]
|
36
|
+
img_src = "#{dir}/#{filename}.#{extensions.first}"
|
37
|
+
downloads = proc {
|
38
|
+
d = []
|
39
|
+
extensions.each do |ext|
|
40
|
+
d.push %Q{<a href="#{dir}/#{filename}.#{ext}">#{ext.upcase}</a>,}
|
41
|
+
end
|
42
|
+
d.join(" ")[0..-2]
|
43
|
+
}
|
44
|
+
|
45
|
+
"<figure>" +
|
46
|
+
"<a href='#{img_src}'><img src='#{img_src}' alt='#{caption}'></a>" +
|
47
|
+
"<figcaption>" +
|
48
|
+
"#{caption} (#{downloads.call})" +
|
49
|
+
"</figcaption>" +
|
50
|
+
"</figure>"
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
Liquid::Template.register_tag('figure', Jekyll::FigureTag)
|
58
|
+
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll_figure
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lincoln Mullen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '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: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- lincoln@lincolnmullen.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- Gemfile
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- jekyll_figure.gemspec
|
53
|
+
- lib/jekyll_figure.rb
|
54
|
+
- lib/jekyll_figure/version.rb
|
55
|
+
homepage: https://github.com/lmullen/jekyll_figure
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.2.2
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Add a figure tag to output figures and captions in Jekyll
|
79
|
+
test_files: []
|