jekyll-img-prefix 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cfbf8fb14650f2ee1dc3ddf378c12de8baedf4f4
4
+ data.tar.gz: 4b1dba419f16ca7e16edc41737a0da38e44b78a2
5
+ SHA512:
6
+ metadata.gz: d84bbc31243ea92c9df09b44f0f7c6f08704f41676c80098cb51f25e7bbde4193c2b1ba4485b598b778afa3312ecdfd2345b5cb9aad8b06889ad7602c997beba
7
+ data.tar.gz: cb00462bd28a23bd85a45ce33511e47a22b1c8d5ef786afdf46373b7e1d1c93d4781d57d7d21c1aae4daf6c112174f0371a3ea5d1dc7ae23873369c020f22766
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 zhangshiyu
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,32 @@
1
+ # Jekyll Img Prefix Filter
2
+
3
+ ## Installation
4
+
5
+ Add this line to your Jekyll site's `Gemfile`:
6
+
7
+ ```ruby
8
+ gem "jekyll-img-prefix"
9
+ ```
10
+
11
+ Add `jekyll-img-prefix` to your Jekyll site's `_config.yml`:
12
+
13
+ ```yaml
14
+ plugins:
15
+ - jekyll-img-prefix
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install jekyll-img-prefix
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/erlzhang/jekyll-img-prefix. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
29
+
30
+ ## License
31
+
32
+ The theme is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "jekyll-img-prefix"
5
+ spec.version = "0.1.1"
6
+ spec.authors = ["Sharon Zhang"]
7
+ spec.email = ["zhangshiyu1992@hotmail.com"]
8
+
9
+ spec.summary = "Filter that add a remote url to your posts."
10
+ spec.homepage = "https://github.com/erlzhang/jekyll-img-prefix"
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files -z`.split("\x0")
14
+
15
+ spec.required_ruby_version = '>= 2.3'
16
+
17
+ spec.add_runtime_dependency "jekyll", "~> 3.5"
18
+ spec.add_runtime_dependency 'nokogiri', '~> 1.9'
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.16"
21
+ spec.add_development_dependency "rake", "~> 12.0"
22
+ end
@@ -0,0 +1,30 @@
1
+ module Jekyll
2
+ module AssetFilter
3
+ require 'jekyll'
4
+ require 'nokogiri'
5
+
6
+ def img_prefix(content)
7
+ img_url = @context.registers[:site].config['img_prefix']
8
+ return content unless img_url
9
+
10
+ doc = Nokogiri::HTML.fragment(content)
11
+ return content unless doc
12
+
13
+ doc.css('img').each do |img|
14
+ original_url = img.get_attribute("src")
15
+ next if original_url =~ /\Ahttp/i
16
+
17
+ new_url = img_url.to_s + relative_url(original_url)
18
+ img.set_attribute('src', new_url)
19
+ end
20
+ doc.to_s
21
+ end
22
+
23
+ def img_url_prefix(input)
24
+ img_url = @context.registers[:site].config['img_prefix']
25
+ img_url.to_s + relative_url(input)
26
+ end
27
+ end
28
+ end
29
+
30
+ Liquid::Template.register_filter(Jekyll::AssetFilter)
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-img-prefix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Sharon Zhang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-06-28 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.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '12.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '12.0'
69
+ description:
70
+ email:
71
+ - zhangshiyu1992@hotmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - jekyll-img-prefix.gemspec
81
+ - lib/jekyll-img-prefix.rb
82
+ homepage: https://github.com/erlzhang/jekyll-img-prefix
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '2.3'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.5.2.1
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Filter that add a remote url to your posts.
106
+ test_files: []