jekyll_pic_container 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +12 -0
- data/lib/jekyll_pic_container/version.rb +5 -0
- data/lib/jekyll_pic_container.rb +73 -0
- data/sig/jekyll_pic_container.rbs +4 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d259560f36cc149caf7e9c782b8eb06dd6e8619442a5b9d87de60243117f38b9
|
4
|
+
data.tar.gz: dcbfd7d5b108cf2929e97c89b7fb1d50bbf2ea705881a4dc0aec0f124c6de260
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6db2a209338cd80c84b7ade2c74fddf26ebac55dfb428bf57d5697d5326d1fdbe9ad347695470b5264e8c632d6691ea37d061469efa40ad98a2d109e5c4f3637
|
7
|
+
data.tar.gz: 5b2a1e09f900a8d1bb23cae11fa37616fd853032fc4cca5891fa9e239c27af3a415b91094d466d4065eba3d975273702273996873500a1eb69aaedd855dfcbf7
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.1
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Tejus Parikh
|
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,43 @@
|
|
1
|
+
# JekyllPicContainer
|
2
|
+
|
3
|
+
A simple wrapper around [Jekyll Picture Tag](https://github.com/rbuchberger/jekyll_picture_tag) to standardize my usage across
|
4
|
+
the different blogs that I manage. This gem is unlikely to be useful to anyone else.
|
5
|
+
|
6
|
+
The key benefits is that it adds some markup for easier formatting, will translate an `alt` argument into
|
7
|
+
a caption, and provides a standardized way of sharing attribution to 3rd party CC images.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
$ bundle add jekyll_pic_container
|
14
|
+
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
+
|
17
|
+
$ gem install jekyll_pic_container
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
This tag supports three arguments, `alt`, `attr_source`, and `attr_text`.
|
22
|
+
|
23
|
+
Example:
|
24
|
+
|
25
|
+
```
|
26
|
+
{% pic_container thumb --alt Alt Text --attr_source http://picture_site/picture_image.jpg --attr_text Original Author %}
|
27
|
+
```
|
28
|
+
|
29
|
+
This will render a caption with 'Alt Text' and a link to the picture image.
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
34
|
+
|
35
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/vi_jedi/jekyll_pic_container.
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "jekyll_pic_container/version"
|
4
|
+
require "liquid"
|
5
|
+
|
6
|
+
# Namespace for this class
|
7
|
+
module JekyllPicContainer
|
8
|
+
# Provices some markup around a picture tag. This tag will process the following arguments:
|
9
|
+
# --alt Alt text will be placed on the image tag as well as being provided as a caption to the image
|
10
|
+
# --attr_source A link to an original image that has been copied here.
|
11
|
+
# --attr_text The text to correctly credit the original source
|
12
|
+
class PicContainer < Liquid::Tag
|
13
|
+
attr_reader :markup, :tag_arguments
|
14
|
+
|
15
|
+
def initialize(_tag_name, markup, _tokens)
|
16
|
+
@markup = markup
|
17
|
+
@tag_arguments = markup.split(/--/)[1..].freeze
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def render(context)
|
22
|
+
tags = ['<div class="picture_container">']
|
23
|
+
tags.push(<<~HTML.strip)
|
24
|
+
{% picture #{markup} %}
|
25
|
+
HTML
|
26
|
+
|
27
|
+
alt = get_argument("alt")
|
28
|
+
tags.push(build_caption(alt)) unless alt.nil?
|
29
|
+
tags.push("</div>")
|
30
|
+
|
31
|
+
content = tags.join(" ")
|
32
|
+
Liquid::Template.parse(content).render(context)
|
33
|
+
end
|
34
|
+
|
35
|
+
# For a tag, the content is the markup of the tag, which means it
|
36
|
+
# has to be manually parsed. Picture tag 2 uses `--` to designate
|
37
|
+
# options after the first required ones
|
38
|
+
def get_argument(arg_name)
|
39
|
+
prefix = "#{arg_name} "
|
40
|
+
raw_value = tag_arguments.filter { |text| text.start_with?(prefix) }.first
|
41
|
+
return unless raw_value
|
42
|
+
|
43
|
+
arg_value = raw_value.dup
|
44
|
+
# Remove the arg prefix from the string
|
45
|
+
arg_value.slice!(prefix)
|
46
|
+
|
47
|
+
arg_value.strip
|
48
|
+
end
|
49
|
+
|
50
|
+
def build_caption(alt)
|
51
|
+
tags = ["<p>"]
|
52
|
+
tags.push(alt)
|
53
|
+
|
54
|
+
attr_source = get_argument("attr_source")
|
55
|
+
unless attr_source.nil?
|
56
|
+
tags.push(" ") # Add a space between the text and the tag
|
57
|
+
tags.push("<a target='_blank' rel='noreferrer' href='#{attr_source}'>")
|
58
|
+
attr_text = get_argument("attr_text")
|
59
|
+
if attr_text.nil?
|
60
|
+
tags.push("original source")
|
61
|
+
else
|
62
|
+
tags.push(attr_text)
|
63
|
+
end
|
64
|
+
tags.push("</a>")
|
65
|
+
end
|
66
|
+
|
67
|
+
tags.push("</p>")
|
68
|
+
tags.join("")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
Liquid::Template.register_tag("pic_container", JekyllPicContainer::PicContainer)
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll_pic_container
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tejus Parikh
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-07-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll_picture_tag
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- tejus@vijedi.net
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".rspec"
|
35
|
+
- ".rubocop.yml"
|
36
|
+
- ".ruby-version"
|
37
|
+
- CHANGELOG.md
|
38
|
+
- LICENSE.txt
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- lib/jekyll_pic_container.rb
|
42
|
+
- lib/jekyll_pic_container/version.rb
|
43
|
+
- sig/jekyll_pic_container.rbs
|
44
|
+
homepage: https://github.com/vijedi/jekyll_pic_container
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata:
|
48
|
+
homepage_uri: https://github.com/vijedi/jekyll_pic_container
|
49
|
+
source_code_uri: https://github.com/vijedi/jekyll_pic_container
|
50
|
+
changelog_uri: https://github.com/vijedi/jekyll_pic_container/CHANGELOG.md
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '2.6'
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '4.0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubygems_version: 3.4.6
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: Simple Liquid Tag to wrap a picture tag in a caption
|
73
|
+
test_files: []
|