jekyll-linkpreview 0.5.0 → 0.6.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
2
  SHA256:
3
- metadata.gz: 6145c1a65dbaab48f8d1ce4b96e819ab91a1c9ccc17ee677a345c89cf5c3c15a
4
- data.tar.gz: 0b6dea42bd3b46a9b3a4d5dd0ff5a4a9eac69221bc6f810ebcddedfe80d6d133
3
+ metadata.gz: dd45369b38e2a2121de3c5a1b4af6c1096fe0649ad5d3e0c06fbc34ceb17634f
4
+ data.tar.gz: 2bfd854068e9ded58f9eb4dfbc22ac714608d99db457d1af78f0c741858f4b27
5
5
  SHA512:
6
- metadata.gz: 5155c52c70a23ae14be7b650b8bd04b64458c2a2e3ffb076b339701a0f7042ab36452bdc1a68f80bf4b8a116e377c3162522c86a69268ab1afb1a17c68e30265
7
- data.tar.gz: 4ee825fc487c1b0f98e9f8696210730972918db867b4a5065d533f68ae0b958d81f539e54edb013d7107cd03f788204d360de28450a763916341044bfdaffe25
6
+ metadata.gz: 444a4327a8c79d4a5847d74dba86dbda7dae27226e33c5831dda8f73ae4bb495964a8b8c2e0d1080904e0064c2c65483c95b14e746a38a061f7c8aa8df47371c
7
+ data.tar.gz: 9cd54f69288be12b24e395a6fc71b5ba637cca3f937c014e72dbb3f76defef256bc6c7ca167ba7b782a7f795b74f8469bd0373bfd47da5f73d4446fddef458e2
@@ -0,0 +1,59 @@
1
+ name: Release
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ jobs:
7
+ check-release:
8
+ container:
9
+ image: ruby:3.1
10
+ outputs:
11
+ release: ${{ steps.check-release.outputs.release }}
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v3
16
+ with:
17
+ fetch-depth: 2
18
+ # See https://github.com/actions/runner-images/issues/6775.
19
+ - name: Suppress 'detected dubious ownership' error.
20
+ run: git config --global --add safe.directory /__w/jekyll-linkpreview/jekyll-linkpreview
21
+ - id: check-release
22
+ name: Decide whether to release
23
+ run: |
24
+ set +e
25
+ git diff --exit-code --quiet HEAD~1 -- lib/jekyll-linkpreview/version.rb
26
+ if [ $? = 1 ]; then
27
+ echo release=true >> ${GITHUB_OUTPUT}
28
+ else
29
+ echo release=false >> ${GITHUB_OUTPUT}
30
+ fi
31
+ release:
32
+ container:
33
+ image: ruby:3.1
34
+ if: needs.check-release.outputs.release == 'true'
35
+ needs: check-release
36
+ runs-on: ubuntu-latest
37
+ steps:
38
+ - name: Checkout
39
+ uses: actions/checkout@v3
40
+ # See https://github.com/actions/runner-images/issues/6775.
41
+ - name: Suppress 'detected dubious ownership' error.
42
+ run: git config --global --add safe.directory /__w/jekyll-linkpreview/jekyll-linkpreview
43
+ - env:
44
+ RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
45
+ name: Set credentials for RubyGems
46
+ run: |
47
+ mkdir ~/.gem
48
+ echo :rubygems_api_key: ${RUBYGEMS_API_KEY} > ~/.gem/credentials
49
+ chmod 0600 ~/.gem/credentials
50
+ - name: Configure git
51
+ run: |
52
+ git config --global user.email "yusuke.nishioka.0713@gmail..com"
53
+ git config --global user.name "Yusuke Nishioka"
54
+ - name: Install dependencies
55
+ run: bundle install
56
+ - env:
57
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58
+ name: Make a new release
59
+ run: bundle exec rake release
@@ -1,5 +1,11 @@
1
1
  name: Test
2
- on: [push]
2
+ on:
3
+ pull_request:
4
+ branches:
5
+ - master
6
+ push:
7
+ branches:
8
+ - master
3
9
  jobs:
4
10
  test:
5
11
  container:
@@ -31,6 +37,15 @@ jobs:
31
37
  steps:
32
38
  - name: Checkout
33
39
  uses: actions/checkout@v3
40
+ - if: matrix.ruby == '2.7'
41
+ name: Update RubyGems version
42
+ # sass-embedded 1.57.1, which is one of dependencies of jekyll-sass-converter 3.0,
43
+ # requires rubygems version >= 3.3.22
44
+ # (see https://jekyllrb.com/news/2022/12/21/jekyll-sass-converter-3.0-released/
45
+ # for the jekyll-sass-converter 3.0 release).
46
+ # Just running `gem update --system` upgrades rubygems version to '>= 2.4',
47
+ # which appraisal 2.4.1 can't work with.
48
+ run: gem update --system 3.3.22
34
49
  - name: Install dependencies
35
50
  run: bundle install
36
51
  - name: Install dependencies for each appraisal
data/README.md CHANGED
@@ -56,6 +56,7 @@ You can override the default templates used for generating previews, both in cas
56
56
  2. Use built-in variables to extract data which you would like to render. Available variables are:
57
57
  * **link_url** i.e. `{{ link_url }}`
58
58
  * **link_title** i.e. `{{ link_title }}`
59
+ * **link_type** i.e. `{{ link_type }}`
59
60
  * **link_image** i.e. `{{ link_image }}`
60
61
  * **link_description** i.e. `{{ link_description }}`
61
62
  * **link_domain** i.e. `{{ link_domain }}`
@@ -20,10 +20,12 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency "jekyll", ">= 3.5", "< 5.0"
22
22
  spec.add_dependency "metainspector", "~> 5.9"
23
- spec.add_development_dependency "bundler", "~> 2.0"
23
+ # appraisal 2.4.1, which is the latest version as of Jan 2023, doesn't work with bundler >= 2.4.
24
+ # See https://github.com/thoughtbot/appraisal/issues/199 for details.
25
+ spec.add_development_dependency "bundler", ">= 2.0", "< 2.4"
24
26
  spec.add_development_dependency "rake", "~> 12.3.3"
25
27
  spec.add_development_dependency "rspec", "~> 3.0"
26
28
  spec.add_development_dependency "rspec-parameterized", "~> 0.5.2"
27
- spec.add_development_dependency "appraisal", "~> 2.2.0"
29
+ spec.add_development_dependency "appraisal", "~> 2.0"
28
30
  spec.add_development_dependency "wwtd", "~> 1.4.1"
29
31
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Linkpreview
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
@@ -10,8 +10,9 @@ module Jekyll
10
10
  class OpenGraphProperties
11
11
  @@template_file = 'linkpreview.html'
12
12
 
13
- def initialize(title, url, image, description, domain)
13
+ def initialize(title, type, url, image, description, domain)
14
14
  @title = title
15
+ @type = type
15
16
  @url = url
16
17
  @image = image
17
18
  @description = description
@@ -21,6 +22,7 @@ module Jekyll
21
22
  def to_hash()
22
23
  {
23
24
  'title' => @title,
25
+ 'type' => @type,
24
26
  'url' => @url,
25
27
  'image' => @image,
26
28
  'description' => @description,
@@ -31,6 +33,7 @@ module Jekyll
31
33
  def to_hash_for_custom_template()
32
34
  {
33
35
  'link_title' => @title,
36
+ 'link_type' => @type,
34
37
  'link_url' => @url,
35
38
  'link_image' => @image,
36
39
  'link_description' => @description,
@@ -48,16 +51,17 @@ module Jekyll
48
51
  og_properties = page.meta_tags['property']
49
52
  image_url = get_og_property(og_properties, 'og:image')
50
53
  title = get_og_property(og_properties, 'og:title')
54
+ type = get_og_property(og_properties, 'og:type')
51
55
  url = get_og_property(og_properties, 'og:url')
52
56
  image = convert_to_absolute_url(image_url, page.root_url)
53
57
  description = get_og_property(og_properties, 'og:description')
54
58
  domain = page.host
55
- OpenGraphProperties.new(title, url, image, description, domain)
59
+ OpenGraphProperties.new(title, type, url, image, description, domain)
56
60
  end
57
61
 
58
62
  def from_hash(hash)
59
63
  OpenGraphProperties.new(
60
- hash['title'], hash['url'], hash['image'], hash['description'], hash['domain'])
64
+ hash['title'], hash['type'], hash['url'], hash['image'], hash['description'], hash['domain'])
61
65
  end
62
66
 
63
67
  private
@@ -116,8 +120,7 @@ module Jekyll
116
120
 
117
121
  class NonOpenGraphPropertiesFactory
118
122
  def from_page(page)
119
- NonOpenGraphProperties.new(
120
- page.title, page.url, get_description(page), page.host)
123
+ NonOpenGraphProperties.new(page.best_title, page.url, get_description(page), page.host)
121
124
  end
122
125
 
123
126
  def from_hash(hash)
@@ -189,7 +192,9 @@ module Jekyll
189
192
 
190
193
  private
191
194
  def create_properties_from_page(page)
192
- if page.meta_tags['property'].empty? then
195
+ if !%w[og:title og:type og:url og:image].all? { |required_tag|
196
+ page.meta_tags['property'].include?(required_tag)
197
+ }
193
198
  factory = NonOpenGraphPropertiesFactory.new
194
199
  else
195
200
  factory = OpenGraphPropertiesFactory.new
@@ -239,16 +244,15 @@ module Jekyll
239
244
  image_html = ""
240
245
  if image then
241
246
  image_html = <<-EOS
242
- <div class="jekyll-linkpreview-image">
243
- <a href="#{url}" target="_blank">
244
- <img src="#{image}" />
245
- </a>
246
- </div>
247
+ <div class="jekyll-linkpreview-image">
248
+ <a href="#{url}" target="_blank">
249
+ <img src="#{image}" />
250
+ </a>
251
+ </div>
247
252
  EOS
248
253
  end
249
254
  html = <<-EOS
250
255
  <div class="jekyll-linkpreview-wrapper">
251
- <p><a href="#{url}" target="_blank">#{url}</a></p>
252
256
  <div class="jekyll-linkpreview-wrapper-inner">
253
257
  <div class="jekyll-linkpreview-content">
254
258
  #{image_html}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-linkpreview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.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: 2022-12-04 00:00:00.000000000 Z
11
+ date: 2023-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -48,16 +48,22 @@ dependencies:
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '2.0'
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '2.4'
54
57
  type: :development
55
58
  prerelease: false
56
59
  version_requirements: !ruby/object:Gem::Requirement
57
60
  requirements:
58
- - - "~>"
61
+ - - ">="
59
62
  - !ruby/object:Gem::Version
60
63
  version: '2.0'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '2.4'
61
67
  - !ruby/object:Gem::Dependency
62
68
  name: rake
63
69
  requirement: !ruby/object:Gem::Requirement
@@ -106,14 +112,14 @@ dependencies:
106
112
  requirements:
107
113
  - - "~>"
108
114
  - !ruby/object:Gem::Version
109
- version: 2.2.0
115
+ version: '2.0'
110
116
  type: :development
111
117
  prerelease: false
112
118
  version_requirements: !ruby/object:Gem::Requirement
113
119
  requirements:
114
120
  - - "~>"
115
121
  - !ruby/object:Gem::Version
116
- version: 2.2.0
122
+ version: '2.0'
117
123
  - !ruby/object:Gem::Dependency
118
124
  name: wwtd
119
125
  requirement: !ruby/object:Gem::Requirement
@@ -135,6 +141,7 @@ executables: []
135
141
  extensions: []
136
142
  extra_rdoc_files: []
137
143
  files:
144
+ - ".github/workflows/release.yaml"
138
145
  - ".github/workflows/test.yaml"
139
146
  - ".gitignore"
140
147
  - ".rspec"