jekyll-linkpreview 0.2.0 → 0.4.1

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: 597a9685dd537f7fddef541e75b596cdcda260cc
4
- data.tar.gz: f4a9201088c0881410bf7e87d3963f04e9942de5
2
+ SHA256:
3
+ metadata.gz: adf9461d95ca27356364fab24299596d9dbfe50148c84055920275c87c98b975
4
+ data.tar.gz: b5e364944e5f919276035478795d21ddd1172f070739a8d513ea2e6c056edd77
5
5
  SHA512:
6
- metadata.gz: e9affa10e185284257a77d68d44736f8c3f0f0d9a324aa4578fdb7fc454504dad883f69b0b2875ef5cdbd0766768709dc0c81a140b219c88bd607714cd1bbe9e
7
- data.tar.gz: bd20c259e0becb55c2976f384f1e220b835e53778b7edc1a0382e37ccf49e00d6eb0aac38b77a453d9281f3cb11802925ac5095b1aa3a9d14c61e072afecf7db
6
+ metadata.gz: 03a80ba47f3b838a9f6ea6c383d3822d091caf210c9e3038405e2b1558d385643d2b8de2c4abe3c8353ef1688322ad808716cea53fe663c348255bd75952aa68
7
+ data.tar.gz: 6576980e12bf8816b8b16f336f5d1fd106ee0005f151f4cf621613ee743b17e487cf7d84ce5d683ce6375e4a9261315453a78192b8a7aed7b294bcd0b6d5e281
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/
data/.travis.yml CHANGED
@@ -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
data/Appraisals ADDED
@@ -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
data/Dockerfile ADDED
@@ -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,49 +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.
3
+ [![Build Status](https://travis-ci.com/ysk24ok/jekyll-linkpreview.svg?branch=master)](https://travis-ci.com/ysk24ok/jekyll-linkpreview)
4
4
 
5
- You can pass url directly to the tag,
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,
6
8
 
7
9
  ```
8
- {% linkpreview https://github.com %}
10
+ {% linkpreview "https://github.com/ysk24ok/jekyll-linkpreview" %}
9
11
  ```
10
12
 
11
13
  or, can pass a url variable.
12
14
 
13
15
  ```
14
- {% assign github_toppage = 'https://github.com'%}
15
- {% linkpreview github_toppage %}
16
+ {% assign jekyll_linkpreview_page = "https://github.com/ysk24ok/jekyll-linkpreview" %}
17
+ {% linkpreview jekyll_linkpreview_page %}
16
18
  ```
17
19
 
18
- The tag above generates following HTML when you run `jekyll build`,
19
-
20
- ```html
21
- <div class="jekyll-linkpreview-wrapper">
22
- <p><a href="https://github.com" target="_blank">https://github.com</a></p>
23
- <div class="jekyll-linkpreview-wrapper-inner">
24
- <div class="jekyll-linkpreview-content">
25
- <div class="jekyll-linkpreview-image">
26
- <a href="https://github.com" target="_blank">
27
- <img src="https://github.githubassets.com/images/modules/open_graph/github-logo.png" />
28
- </a>
29
- </div>
30
- <div class="jekyll-linkpreview-body">
31
- <h2 class="jekyll-linkpreview-title">
32
- <a href="https://github.com" target="_blank">Build software better, together</a>
33
- </h2>
34
- <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>
35
- </div>
36
- </div>
37
- <div class="jekyll-linkpreview-footer">
38
- <a href="https://github.com" target="_blank">github.com</a>
39
- </div>
40
- </div>
41
- </div>
42
- ```
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.
43
25
 
44
- Applying appropriate CSS, the link preview will be like this.
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">
45
27
 
46
- <img width="613" alt="スクリーンショット 2019-04-03 20 52 50" src="https://user-images.githubusercontent.com/3449164/55479970-35baf100-565a-11e9-8c5d-709213917f74.png">
28
+ You can override the default templates, see [Custom templates](#user-content-custom-templates).
47
29
 
48
30
  ## Installation
49
31
 
@@ -51,7 +33,7 @@ See https://jekyllrb.com/docs/plugins/installation/ .
51
33
 
52
34
  ## Usage
53
35
 
54
- 1. Create `_cache` directory where you run `jekyll build` or `jekyll serve`.
36
+ 1. Create `_cache` directory.
55
37
 
56
38
  1. Embed [linkpreview.css](assets/css/linkpreview.css) into your Website.
57
39
 
@@ -59,12 +41,71 @@ See https://jekyllrb.com/docs/plugins/installation/ .
59
41
 
60
42
  1. Run `jekyll build` or `jekyll serve`.
61
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
+
62
70
  ## Development
63
71
 
64
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.
65
73
 
66
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).
67
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
+
68
109
  ## Contributing
69
110
 
70
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,5 +1,6 @@
1
1
  require "digest"
2
2
  require "json"
3
+ require 'uri'
3
4
 
4
5
  require "metainspector"
5
6
  require "jekyll-linkpreview/version"
@@ -7,31 +8,64 @@ require "jekyll-linkpreview/version"
7
8
  module Jekyll
8
9
  module Linkpreview
9
10
  class OpenGraphProperties
10
- def get(url)
11
- og_properties = fetch(url)
12
- og_url = get_og_property(og_properties, 'og:url')
13
- domain = extract_domain(og_url)
14
- image_url = get_og_property(og_properties, 'og:image')
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()
15
32
  {
16
- 'title' => get_og_property(og_properties, 'og:title'),
17
- 'url' => og_url,
18
- 'image' => convert_to_absolute_url(image_url, domain),
19
- 'description' => get_og_property(og_properties, 'og:description'),
20
- 'domain' => domain
33
+ 'link_title' => @title,
34
+ 'link_url' => @url,
35
+ 'link_image' => @image,
36
+ 'link_description' => @description,
37
+ 'link_domain' => @domain
21
38
  }
22
39
  end
23
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
+
24
63
  private
25
64
  def get_og_property(properties, key)
26
65
  if !properties.key? key then
27
66
  return nil
28
67
  end
29
- properties[key][0]
30
- end
31
-
32
- private
33
- def fetch(url)
34
- MetaInspector.new(url).meta_tags['property']
68
+ properties[key].first
35
69
  end
36
70
 
37
71
  private
@@ -41,76 +75,89 @@ module Jekyll
41
75
  end
42
76
  # root relative url
43
77
  if url[0] == '/' then
44
- return "//#{domain}#{url}"
78
+ return URI.join(domain, url).to_s
45
79
  end
46
80
  url
47
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
48
127
 
49
128
  private
50
- def extract_domain(url)
51
- if url.nil? then
52
- return nil
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 "..."
53
134
  end
54
- url.match(%r{(http|https)://([^/]+).*})[-1]
55
135
  end
56
136
  end
57
137
 
58
138
  class LinkpreviewTag < Liquid::Tag
59
139
  @@cache_dir = '_cache'
140
+ @@template_dir = '_includes'
60
141
 
61
142
  def initialize(tag_name, markup, parse_context)
62
143
  super
63
- @markup = markup.rstrip()
64
- @og_properties = OpenGraphProperties.new
144
+ @markup = markup.strip()
65
145
  end
66
146
 
67
147
  def render(context)
68
148
  url = get_url_from(context)
69
149
  properties = get_properties(url)
70
- title = properties['title']
71
- image = properties['image']
72
- description = properties['description']
73
- domain = properties['domain']
74
- if title.nil? || image.nil? || description.nil? || domain.nil? then
75
- html = <<-EOS
76
- <div class="jekyll-linkpreview-wrapper">
77
- <p><a href="#{url}" target="_blank">#{url}</a></p>
78
- </div>
79
- EOS
80
- return html
81
- end
82
- html = <<-EOS
83
- <div class="jekyll-linkpreview-wrapper">
84
- <p><a href="#{url}" target="_blank">#{url}</a></p>
85
- <div class="jekyll-linkpreview-wrapper-inner">
86
- <div class="jekyll-linkpreview-content">
87
- <div class="jekyll-linkpreview-image">
88
- <a href="#{url}" target="_blank">
89
- <img src="#{image}" />
90
- </a>
91
- </div>
92
- <div class="jekyll-linkpreview-body">
93
- <h2 class="jekyll-linkpreview-title">
94
- <a href="#{url}" target="_blank">#{title}</a>
95
- </h2>
96
- <div class="jekyll-linkpreview-description">#{description}</div>
97
- </div>
98
- </div>
99
- <div class="jekyll-linkpreview-footer">
100
- <a href="//#{domain}" target="_blank">#{domain}</a>
101
- </div>
102
- </div>
103
- </div>
104
- EOS
105
- html
150
+ render_linkpreview properties
106
151
  end
107
152
 
108
153
  def get_properties(url)
109
154
  cache_filepath = "#{@@cache_dir}/%s.json" % Digest::MD5.hexdigest(url)
110
155
  if File.exist?(cache_filepath) then
111
- return load_cache_file(cache_filepath)
156
+ hash = load_cache_file(cache_filepath)
157
+ return create_properties_from_hash(hash)
112
158
  end
113
- properties = @og_properties.get(url)
159
+ page = fetch(url)
160
+ properties = create_properties_from_page(page)
114
161
  if Dir.exists?(@@cache_dir) then
115
162
  save_cache_file(cache_filepath, properties)
116
163
  else
@@ -122,7 +169,12 @@ module Jekyll
122
169
 
123
170
  private
124
171
  def get_url_from(context)
125
- context.scopes[0].key?(@markup) ? context.scopes[0][@markup] : @markup
172
+ context[@markup]
173
+ end
174
+
175
+ private
176
+ def fetch(url)
177
+ MetaInspector.new(url)
126
178
  end
127
179
 
128
180
  private
@@ -132,7 +184,88 @@ module Jekyll
132
184
 
133
185
  protected
134
186
  def save_cache_file(filepath, properties)
135
- File.open(filepath, 'w').write(JSON.generate(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
196
+ end
197
+ factory.from_page(page)
198
+ end
199
+
200
+ private
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
218
+ end
219
+ end
220
+
221
+ private
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
263
+ end
264
+
265
+ private
266
+ def gen_custom_template(template_path, hash)
267
+ template = File.read template_path
268
+ Liquid::Template.parse(template).render!(hash)
136
269
  end
137
270
  end
138
271
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Linkpreview
3
- VERSION = "0.2.0"
3
+ VERSION = "0.4.1"
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.2.0
4
+ version: 0.4.1
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-08-21 00:00:00.000000000 Z
11
+ date: 2021-05-18 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.5.2.3
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