jekyll-linkpreview 0.1.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e553cbd1585c7303612cb32a21651039f3ebba2f
4
- data.tar.gz: 58bf7022cf2eb09e8661292b5143bd8b8750d201
2
+ SHA256:
3
+ metadata.gz: d55e7758cdacbdcbd976a0669efd3f4210a77e02f3ac6fa5e1518d8d1ee863e7
4
+ data.tar.gz: 6ca1a338b6bdc68e3a769b5c6c071a91a1dbaa909fdf86f4e1a41707b2edf043
5
5
  SHA512:
6
- metadata.gz: d41da5f3352c0fee0e9fcdb5c5d91f8b3f75d3943d2fe00f41593ed00b78f0d94e55d8d5bb8474022a815dcbf532622b6afc8a8df62d84bfde0cb0e39ae2075e
7
- data.tar.gz: e6a23a9bb9c3170780aadd984af4977034055eaa4d53fc6ef008ce4bb92818057877894cb1bd43d2927b04e09c389d36af1572f6e054151272b74851d2b171aa
6
+ metadata.gz: 8390070dc663f7f5a07d5e13c8b6e804a6e6649f1de07bf1443f054048858a8ccad6a6eff970a706c87a71baf3e2a9efc57e750bb82d596defaadc310fbd2719
7
+ data.tar.gz: ae3b069df61e1b9d151a56d20054ab67b910a3965c76265f7f8f3626e0b7c8a88b91bf56db20cd7d0468a5b46d77c52c28bf51a5860dd2e756355354167f571c
data/.gitignore CHANGED
@@ -9,3 +9,8 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ # Appraisal
14
+ *.gemfile.lock
15
+ Gemfile.lock
16
+ vendor/
@@ -4,4 +4,19 @@ language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
6
  - 2.4.2
7
+ - 2.7.0
7
8
  before_install: gem install bundler -v 2.0.1
9
+ gemfile:
10
+ - gemfiles/jekyll_35.gemfile
11
+ - gemfiles/jekyll_36.gemfile
12
+ - gemfiles/jekyll_37.gemfile
13
+ - gemfiles/jekyll_38.gemfile
14
+ - gemfiles/jekyll_40.gemfile
15
+ - gemfiles/jekyll_41.gemfile
16
+ script: "bundle exec rake test"
17
+ matrix:
18
+ exclude:
19
+ - rvm: 2.4.2
20
+ gemfile: gemfiles/jekyll_40.gemfile
21
+ - rvm: 2.4.2
22
+ gemfile: gemfiles/jekyll_41.gemfile
@@ -0,0 +1,23 @@
1
+ appraise "jekyll-35" do
2
+ gem "jekyll", "3.5.2"
3
+ end
4
+
5
+ appraise "jekyll-36" do
6
+ gem "jekyll", "3.6.3"
7
+ end
8
+
9
+ appraise "jekyll-37" do
10
+ gem "jekyll", "3.7.4"
11
+ end
12
+
13
+ appraise "jekyll-38" do
14
+ gem "jekyll", "3.8.7"
15
+ end
16
+
17
+ appraise "jekyll-40" do
18
+ gem "jekyll", "4.0.1"
19
+ end
20
+
21
+ appraise "jekyll-41" do
22
+ gem "jekyll", "4.1.0"
23
+ end
@@ -0,0 +1,14 @@
1
+ FROM ruby:2.6.5
2
+
3
+ RUN apt update \
4
+ && apt install -y \
5
+ vim \
6
+ && rm -rf /var/lib/apt/lists/*
7
+ RUN gem install \
8
+ bundler \
9
+ jekyll
10
+ RUN mkdir /jekyll-linkpreview
11
+ ADD Gemfile /jekyll-linkpreview
12
+ ADD jekyll-linkpreview.gemspec /jekyll-linkpreview
13
+ ADD lib/jekyll-linkpreview/version.rb /jekyll-linkpreview/lib/jekyll-linkpreview/version.rb
14
+ RUN cd /jekyll-linkpreview && bundle install
data/README.md CHANGED
@@ -1,36 +1,31 @@
1
1
  # Jekyll::Linkpreview
2
2
 
3
- Jekyll plugin to generate link preview by `{% linkpreview %}` tag. The plugin fetches [Open Graph protocols](http://ogp.me/) of the designated page to generate preview. The og properties are saved as JSON for caching and it is used when rebuilding the site.
4
-
5
- For example, `{% linkpreview https://github.com %}` tag generates following HTML when you run `jekyll build`,
6
-
7
- ```html
8
- <div class="jekyll-linkpreview-wrapper">
9
- <p><a href="https://github.com" target="_blank">https://github.com</a></p>
10
- <div class="jekyll-linkpreview-wrapper-inner">
11
- <div class="jekyll-linkpreview-content">
12
- <div class="jekyll-linkpreview-image">
13
- <a href="https://github.com" target="_blank">
14
- <img src="https://github.githubassets.com/images/modules/open_graph/github-logo.png" />
15
- </a>
16
- </div>
17
- <div class="jekyll-linkpreview-body">
18
- <h2 class="jekyll-linkpreview-title">
19
- <a href="https://github.com" target="_blank">Build software better, together</a>
20
- </h2>
21
- <div class="jekyll-linkpreview-description">GitHub is where people build software. More than 31 million people use GitHub to discover, fork, and contribute to over 100 million projects.</div>
22
- </div>
23
- </div>
24
- <div class="jekyll-linkpreview-footer">
25
- <a href="https://github.com" target="_blank">github.com</a>
26
- </div>
27
- </div>
28
- </div>
29
- ```
30
-
31
- Applying appropriate CSS, the link preview will be like this.
32
-
33
- <img width="613" alt="スクリーンショット 2019-04-03 20 52 50" src="https://user-images.githubusercontent.com/3449164/55479970-35baf100-565a-11e9-8c5d-709213917f74.png">
3
+ [![Build Status](https://travis-ci.com/ysk24ok/jekyll-linkpreview.svg?branch=master)](https://travis-ci.com/ysk24ok/jekyll-linkpreview)
4
+
5
+ Jekyll plugin to generate link preview by `{% linkpreview %}` tag. The plugin fetches [Open Graph protocol](http://ogp.me/) metadata of the designated page to generate preview. The og properties are saved as JSON for caching and it is used when rebuilding the site.
6
+
7
+ You can pass url directly to the tag,
8
+
9
+ ```
10
+ {% linkpreview "https://github.com/ysk24ok/jekyll-linkpreview" %}
11
+ ```
12
+
13
+ or, can pass a url variable.
14
+
15
+ ```
16
+ {% assign jekyll_linkpreview_page = "https://github.com/ysk24ok/jekyll-linkpreview" %}
17
+ {% linkpreview jekyll_linkpreview_page %}
18
+ ```
19
+
20
+ By applying [linkpreview.css](assets/css/linkpreview.css), the link preview will be like this.
21
+
22
+ <img width="613" alt="スクリーンショット 2020-10-26 19 10 26" src="https://user-images.githubusercontent.com/3449164/97160548-db472f80-17bf-11eb-9cc2-383a076fb14d.png">
23
+
24
+ When the page does not have Open Graph protocol metadata, the preview will be like this.
25
+
26
+ <img width="613" alt="スクリーンショット 2020-10-26 19 10 35" src="https://user-images.githubusercontent.com/3449164/97160564-e00be380-17bf-11eb-8adb-55c2a07520f1.png">
27
+
28
+ You can override the default templates, see [Custom templates](#user-content-custom-templates).
34
29
 
35
30
  ## Installation
36
31
 
@@ -38,7 +33,7 @@ See https://jekyllrb.com/docs/plugins/installation/ .
38
33
 
39
34
  ## Usage
40
35
 
41
- 1. Create `_cache` directory in the same hierarchy as `_site` directory.
36
+ 1. Create `_cache` directory.
42
37
 
43
38
  1. Embed [linkpreview.css](assets/css/linkpreview.css) into your Website.
44
39
 
@@ -46,12 +41,71 @@ See https://jekyllrb.com/docs/plugins/installation/ .
46
41
 
47
42
  1. Run `jekyll build` or `jekyll serve`.
48
43
 
44
+
45
+ ## Custom templates
46
+
47
+ You can override the default templates used for generating previews, both in case Open Graph protocol metadata exists or does not exist for a given page.
48
+
49
+ ### Template for pages where Open Graph protocol metadata exists
50
+
51
+ 1. Place `linkpreview.html` file inside `_includes/` folder of your Jekyll site (`_includes/linkpreview.html`)
52
+
53
+ 2. Use built-in variables to extract data which you would like to render. Available variables are:
54
+ * **link_url** i.e. `{{ link_url }}`
55
+ * **link_title** i.e. `{{ link_title }}`
56
+ * **link_image** i.e. `{{ link_image }}`
57
+ * **link_description** i.e. `{{ link_description }}`
58
+ * **link_domain** i.e. `{{ link_domain }}`
59
+
60
+ ### Template for pages where Open Graph protocol metadata does not exist
61
+
62
+ 1. Place `linkpreview_nog.html` file inside `_includes/` folder of your Jekyll site (`_includes/linkpreview_nog.html`)
63
+
64
+ 2. Use built-in variables to extract data which you would like to render. Available variables are:
65
+ * **link_url** i.e. `{{ link_url }}`
66
+ * **link_title** i.e. `{{ link_title }}`
67
+ * **link_description** i.e. `{{ link_description }}`
68
+ * **link_domain** i.e. `{{ link_domain }}`
69
+
49
70
  ## Development
50
71
 
51
72
  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.
52
73
 
53
74
  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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
54
75
 
76
+ ### Test with Jekyll site
77
+
78
+ First, build a Docker image and run a container.
79
+
80
+ ```console
81
+ $ docker build --no-cache -t jekyll_linkpreview_dev .
82
+ $ docker run --rm -it -w /jekyll-linkpreview -p 4000:4000 jekyll_linkpreview_dev /bin/bash
83
+ ```
84
+
85
+ Create a new Jekyll site and move into the new directory.
86
+
87
+ ```console
88
+ # bundle exec jekyll new testsite && cd testsite
89
+ ```
90
+
91
+ Add this line to `:jekyll_plugins` group of Gemfile.
92
+
93
+ ```console
94
+ gem "jekyll-linkpreview", git: "https://github.com/YOUR_ACCOUNT/jekyll-linkpreview", branch: "YOUR_BRANCH"
95
+ ```
96
+
97
+ Install the dependecies to your new site.
98
+
99
+ ```console
100
+ # bundle install
101
+ ```
102
+
103
+ Add a tag such as `{% linkpreview "https://github.com/ysk24ok/jekyll-linkpreview" %}` to `index.markdown` , then start a Jekyll server.
104
+
105
+ ```console
106
+ # bundle exec jekyll serve --host 0.0.0.0
107
+ ```
108
+
55
109
  ## Contributing
56
110
 
57
111
  Bug reports and pull requests are welcome on GitHub at https://github.com/ysk24ok/jekyll-linkpreview.
data/Rakefile CHANGED
@@ -4,3 +4,4 @@ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task :default => :spec
7
+ task :test => :spec
@@ -30,6 +30,10 @@
30
30
  margin-right: 110px;
31
31
  }
32
32
 
33
+ .jekyll-linkpreview-body-nog {
34
+ margin-right: 10px;
35
+ }
36
+
33
37
  .jekyll-linkpreview-title {
34
38
  font-size: 17px;
35
39
  margin: 0 0 2px;
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_RETRY: "1"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "jekyll", "3.5.2"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "jekyll", "3.6.3"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "jekyll", "3.7.4"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "jekyll", "3.8.7"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "jekyll", "4.0.1"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "jekyll", "4.1.0"
6
+
7
+ gemspec path: "../"
@@ -18,9 +18,11 @@ Gem::Specification.new do |spec|
18
18
  end
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "jekyll", "~> 3.5"
22
- spec.add_dependency "metainspector"
21
+ spec.add_dependency "jekyll", ">= 3.5", "< 5.0"
22
+ spec.add_dependency "metainspector", "~> 5.9"
23
23
  spec.add_development_dependency "bundler", "~> 2.0"
24
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rake", "~> 12.3.3"
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "appraisal", "~> 2.2.0"
27
+ spec.add_development_dependency "wwtd", "~> 1.4.1"
26
28
  end
@@ -1,106 +1,271 @@
1
1
  require "digest"
2
2
  require "json"
3
+ require 'uri'
3
4
 
4
5
  require "metainspector"
5
6
  require "jekyll-linkpreview/version"
6
7
 
7
8
  module Jekyll
8
9
  module Linkpreview
10
+ class OpenGraphProperties
11
+ @@template_file = 'linkpreview.html'
12
+
13
+ def initialize(title, url, image, description, domain)
14
+ @title = title
15
+ @url = url
16
+ @image = image
17
+ @description = description
18
+ @domain = domain
19
+ end
20
+
21
+ def to_hash()
22
+ {
23
+ 'title' => @title,
24
+ 'url' => @url,
25
+ 'image' => @image,
26
+ 'description' => @description,
27
+ 'domain' => @domain,
28
+ }
29
+ end
30
+
31
+ def to_hash_for_custom_template()
32
+ {
33
+ 'link_title' => @title,
34
+ 'link_url' => @url,
35
+ 'link_image' => @image,
36
+ 'link_description' => @description,
37
+ 'link_domain' => @domain
38
+ }
39
+ end
40
+
41
+ def template_file()
42
+ @@template_file
43
+ end
44
+ end
45
+
46
+ class OpenGraphPropertiesFactory
47
+ def from_page(page)
48
+ og_properties = page.meta_tags['property']
49
+ image_url = get_og_property(og_properties, 'og:image')
50
+ title = get_og_property(og_properties, 'og:title')
51
+ url = get_og_property(og_properties, 'og:url')
52
+ image = convert_to_absolute_url(image_url, page.root_url)
53
+ description = get_og_property(og_properties, 'og:description')
54
+ domain = page.host
55
+ OpenGraphProperties.new(title, url, image, description, domain)
56
+ end
57
+
58
+ def from_hash(hash)
59
+ OpenGraphProperties.new(
60
+ hash['title'], hash['url'], hash['image'], hash['description'], hash['domain'])
61
+ end
62
+
63
+ private
64
+ def get_og_property(properties, key)
65
+ if !properties.key? key then
66
+ return nil
67
+ end
68
+ properties[key].first
69
+ end
70
+
71
+ private
72
+ def convert_to_absolute_url(url, domain)
73
+ if url.nil? then
74
+ return nil
75
+ end
76
+ # root relative url
77
+ if url[0] == '/' then
78
+ return URI.join(domain, url).to_s
79
+ end
80
+ url
81
+ end
82
+ end
83
+
84
+ class NonOpenGraphProperties
85
+ @@template_file = 'linkpreview_nog.html'
86
+
87
+ def initialize(title, url, description, domain)
88
+ @title = title
89
+ @url = url
90
+ @description = description
91
+ @domain = domain
92
+ end
93
+
94
+ def to_hash()
95
+ {
96
+ 'title' => @title,
97
+ 'url' => @url,
98
+ 'description' => @description,
99
+ 'domain' => @domain,
100
+ }
101
+ end
102
+
103
+ def to_hash_for_custom_template()
104
+ {
105
+ 'link_title' => @title,
106
+ 'link_url' => @url,
107
+ 'link_description' => @description,
108
+ 'link_domain' => @domain
109
+ }
110
+ end
111
+
112
+ def template_file()
113
+ @@template_file
114
+ end
115
+ end
116
+
117
+ class NonOpenGraphPropertiesFactory
118
+ def from_page(page)
119
+ NonOpenGraphProperties.new(
120
+ page.title, page.url, get_description(page), page.host)
121
+ end
122
+
123
+ def from_hash(hash)
124
+ NonOpenGraphProperties.new(
125
+ hash['title'], hash['url'], hash['description'], hash['domain'])
126
+ end
127
+
128
+ private
129
+ def get_description(page)
130
+ if !page.parsed.xpath('//p[normalize-space()]').empty? then
131
+ return page.parsed.xpath('//p[normalize-space()]').map(&:text).first[0..180] + "..."
132
+ else
133
+ return "..."
134
+ end
135
+ end
136
+ end
137
+
9
138
  class LinkpreviewTag < Liquid::Tag
139
+ @@cache_dir = '_cache'
140
+ @@template_dir = '_includes'
141
+
10
142
  def initialize(tag_name, markup, parse_context)
11
143
  super
12
- @markup = markup.rstrip()
13
- @cache_filepath = "_cache/%s.json" % Digest::MD5.hexdigest(@markup)
144
+ @markup = markup.strip()
14
145
  end
15
146
 
16
147
  def render(context)
17
- properties = get_properties()
18
- title = properties['title']
19
- url = properties['url']
20
- image = properties['image']
21
- description = properties['description']
22
- domain = properties['domain']
23
- if title.nil? || url.nil? || image.nil? then
24
- html = <<-EOS
25
- <div class="jekyll-linkpreview-wrapper">
26
- <p><a href="#{@markup}" target="_blank">#{@markup}</a></p>
27
- </div>
28
- EOS
29
- return html
30
- end
31
- html = <<-EOS
32
- <div class="jekyll-linkpreview-wrapper">
33
- <p><a href="#{@markup}" target="_blank">#{@markup}</a></p>
34
- <div class="jekyll-linkpreview-wrapper-inner">
35
- <div class="jekyll-linkpreview-content">
36
- <div class="jekyll-linkpreview-image">
37
- <a href="#{url}" target="_blank">
38
- <img src="#{image}" />
39
- </a>
40
- </div>
41
- <div class="jekyll-linkpreview-body">
42
- <h2 class="jekyll-linkpreview-title">
43
- <a href="#{url}" target="_blank">#{title}</a>
44
- </h2>
45
- <div class="jekyll-linkpreview-description">#{description}</div>
46
- </div>
47
- </div>
48
- <div class="jekyll-linkpreview-footer">
49
- <a href="#{url}" target="_blank">#{domain}</a>
50
- </div>
51
- </div>
52
- </div>
53
- EOS
54
- html
148
+ url = get_url_from(context)
149
+ properties = get_properties(url)
150
+ render_linkpreview properties
55
151
  end
56
152
 
57
- def get_properties()
58
- if File.exist?(@cache_filepath) then
59
- return load_cache_file
153
+ def get_properties(url)
154
+ cache_filepath = "#{@@cache_dir}/%s.json" % Digest::MD5.hexdigest(url)
155
+ if File.exist?(cache_filepath) then
156
+ hash = load_cache_file(cache_filepath)
157
+ return create_properties_from_hash(hash)
158
+ end
159
+ page = fetch(url)
160
+ properties = create_properties_from_page(page)
161
+ if Dir.exists?(@@cache_dir) then
162
+ save_cache_file(cache_filepath, properties)
60
163
  else
61
- og_properties = fetch_og_properties()
62
- url = get_og_property(og_properties, 'og:url')
63
- properties = {
64
- 'title' => get_og_property(og_properties, 'og:title'),
65
- 'url' => url,
66
- 'image' => get_og_property(og_properties, 'og:image'),
67
- 'description' => get_og_property(og_properties, 'og:description'),
68
- 'domain' => extract_domain(url)
69
- }
70
- save_cache_file(properties)
71
- return properties
164
+ # TODO: This message will be shown at all linkprevew tag
165
+ warn "'#{@@cache_dir}' directory does not exist. Create it for caching."
72
166
  end
167
+ properties
73
168
  end
74
169
 
75
170
  private
76
- def fetch_og_properties()
77
- MetaInspector.new(@markup).meta_tags['property']
171
+ def get_url_from(context)
172
+ context[@markup]
78
173
  end
79
174
 
80
175
  private
81
- def get_og_property(properties, key)
82
- if !properties.key? key then
83
- return nil
176
+ def fetch(url)
177
+ MetaInspector.new(url)
178
+ end
179
+
180
+ private
181
+ def load_cache_file(filepath)
182
+ JSON.parse(File.open(filepath).read)
183
+ end
184
+
185
+ protected
186
+ def save_cache_file(filepath, properties)
187
+ File.open(filepath, 'w') { |f| f.write JSON.generate(properties.to_hash) }
188
+ end
189
+
190
+ private
191
+ def create_properties_from_page(page)
192
+ if page.meta_tags['property'].empty? then
193
+ factory = NonOpenGraphPropertiesFactory.new
194
+ else
195
+ factory = OpenGraphPropertiesFactory.new
84
196
  end
85
- properties[key][0]
197
+ factory.from_page(page)
86
198
  end
87
199
 
88
200
  private
89
- def extract_domain(url)
90
- if url.nil? then
91
- return nil
201
+ def create_properties_from_hash(hash)
202
+ if hash['image'] then
203
+ factory = OpenGraphPropertiesFactory.new
204
+ else
205
+ factory = NonOpenGraphPropertiesFactory.new
206
+ end
207
+ factory.from_hash(hash)
208
+ end
209
+
210
+ private
211
+ def render_linkpreview(properties)
212
+ template_path = get_custom_template_path properties
213
+ if File.exist?(template_path)
214
+ hash = properties.to_hash_for_custom_template
215
+ gen_custom_template template_path, hash
216
+ else
217
+ gen_default_template properties.to_hash
92
218
  end
93
- url.match(%r{(http|https)://([^/]+).*})[-1]
94
219
  end
95
220
 
96
221
  private
97
- def load_cache_file()
98
- JSON.parse(File.open(@cache_filepath).read)
222
+ def get_custom_template_path(properties)
223
+ File.join Dir.pwd, @@template_dir, properties.template_file
224
+ end
225
+
226
+ private
227
+ def gen_default_template(hash)
228
+ title = hash['title']
229
+ url = hash['url']
230
+ description = hash['description']
231
+ domain = hash['domain']
232
+ image = hash['image']
233
+ image_html = ""
234
+ if image then
235
+ image_html = <<-EOS
236
+ <div class="jekyll-linkpreview-image">
237
+ <a href="#{url}" target="_blank">
238
+ <img src="#{image}" />
239
+ </a>
240
+ </div>
241
+ EOS
242
+ end
243
+ html = <<-EOS
244
+ <div class="jekyll-linkpreview-wrapper">
245
+ <p><a href="#{url}" target="_blank">#{url}</a></p>
246
+ <div class="jekyll-linkpreview-wrapper-inner">
247
+ <div class="jekyll-linkpreview-content">
248
+ #{image_html}
249
+ <div class="jekyll-linkpreview-body">
250
+ <h2 class="jekyll-linkpreview-title">
251
+ <a href="#{url}" target="_blank">#{title}</a>
252
+ </h2>
253
+ <div class="jekyll-linkpreview-description">#{description}</div>
254
+ </div>
255
+ </div>
256
+ <div class="jekyll-linkpreview-footer">
257
+ <a href="#{domain}" target="_blank">#{domain}</a>
258
+ </div>
259
+ </div>
260
+ </div>
261
+ EOS
262
+ html
99
263
  end
100
264
 
101
265
  private
102
- def save_cache_file(properties)
103
- File.open(@cache_filepath, 'w').write(JSON.generate(properties))
266
+ def gen_custom_template(template_path, hash)
267
+ template = File.read template_path
268
+ Liquid::Template.parse(template).render!(hash)
104
269
  end
105
270
  end
106
271
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Linkpreview
3
- VERSION = "0.1.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-linkpreview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Nishioka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-04 00:00:00.000000000 Z
11
+ date: 2020-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.5'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '3.5'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: metainspector
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ">="
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '0'
39
+ version: '5.9'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ">="
44
+ - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: '0'
46
+ version: '5.9'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +64,14 @@ dependencies:
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '10.0'
67
+ version: 12.3.3
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '10.0'
74
+ version: 12.3.3
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: rspec
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +86,34 @@ dependencies:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
88
  version: '3.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: appraisal
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 2.2.0
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 2.2.0
103
+ - !ruby/object:Gem::Dependency
104
+ name: wwtd
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 1.4.1
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 1.4.1
83
117
  description:
84
118
  email:
85
119
  - yusuke.nishioka.0713@gmail.com
@@ -90,6 +124,8 @@ files:
90
124
  - ".gitignore"
91
125
  - ".rspec"
92
126
  - ".travis.yml"
127
+ - Appraisals
128
+ - Dockerfile
93
129
  - Gemfile
94
130
  - LICENSE.txt
95
131
  - README.md
@@ -97,6 +133,13 @@ files:
97
133
  - assets/css/linkpreview.css
98
134
  - bin/console
99
135
  - bin/setup
136
+ - gemfiles/.bundle/config
137
+ - gemfiles/jekyll_35.gemfile
138
+ - gemfiles/jekyll_36.gemfile
139
+ - gemfiles/jekyll_37.gemfile
140
+ - gemfiles/jekyll_38.gemfile
141
+ - gemfiles/jekyll_40.gemfile
142
+ - gemfiles/jekyll_41.gemfile
100
143
  - jekyll-linkpreview.gemspec
101
144
  - lib/jekyll-linkpreview.rb
102
145
  - lib/jekyll-linkpreview/version.rb
@@ -119,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
162
  - !ruby/object:Gem::Version
120
163
  version: '0'
121
164
  requirements: []
122
- rubyforge_project:
123
- rubygems_version: 2.6.13
165
+ rubygems_version: 3.0.3
124
166
  signing_key:
125
167
  specification_version: 4
126
168
  summary: Jekyll tag plugin to generate link preview