jekyll-flickr 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/jekyll-flickr.gemspec +3 -5
- data/lib/jekyll-flickr/flickr_tag.rb +40 -11
- data/lib/jekyll-flickr/version.rb +2 -2
- metadata +20 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb2f0ca419b0edf09cc93e3c122d8bf8c9325c9619951d3be4b35c5f18a0fd39
|
4
|
+
data.tar.gz: 78b24210551fd30062797d42460f94abc1a876c90731fe1dca938db93d2f8975
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d681c5b700606cf9547bd8215387f76cdc0cd65c7d51357d313eb474551e69c5e6f850e4807fa94f179aff18d98ecd8c50c0673f5cb6cfacb2641aacfe166b0d
|
7
|
+
data.tar.gz: 0f00350dabab634676e742fb53380565a882fbe0e920f4359b4091b40729c13c3fa384d3a84658e9295792ba70596a2790481525778ca168a05457d0028bc95d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
## HEAD
|
2
2
|
|
3
|
+
## 0.2.1 / 2024-01-01
|
4
|
+
|
5
|
+
* fix: change cache name according to recommendation from <https://jekyllrb.com/tutorials/cache-api/>
|
6
|
+
* feature: Add flexibility to searching for the right picture width and some minor issues (courtesy of <akarwande@coredigital.com>)
|
7
|
+
|
8
|
+
## 0.2.0 / 2021-02-25
|
9
|
+
|
10
|
+
* dependencies: require Jekyll 4.x and use gem flickr instead of flickraw
|
11
|
+
* use native Jekyll cache API (<https://jekyllrb.com/tutorials/cache-api/>) instead of jekyll-cache
|
12
|
+
|
13
|
+
## 0.1.3 / 2019-03-13
|
14
|
+
|
15
|
+
* refactor: use simpler API provided by gem flickraw 0.9.10
|
16
|
+
|
3
17
|
## 0.1.2 / 2019-03-06
|
4
18
|
|
5
19
|
* feature: reduce overhead due to class variables
|
data/jekyll-flickr.gemspec
CHANGED
@@ -7,7 +7,7 @@ require "jekyll-flickr/version"
|
|
7
7
|
|
8
8
|
Gem::Specification.new do |spec|
|
9
9
|
spec.name = "jekyll-flickr"
|
10
|
-
spec.version = Jekyll::
|
10
|
+
spec.version = Jekyll::Flickr::VERSION
|
11
11
|
spec.authors = ["Robert Riemann"]
|
12
12
|
spec.email = ["robert@riemann.cc"]
|
13
13
|
spec.summary = "Liquid tag for responsive Flickr images using HTML5 srcset."
|
@@ -21,10 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
# spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "
|
25
|
-
spec.add_dependency "flickraw-cached", ">= 20120701"
|
26
|
-
spec.add_dependency "flickraw", "~> 0.9.9"
|
24
|
+
spec.add_dependency "flickr", "~> 2.0"
|
27
25
|
spec.add_development_dependency "bundler", "~> 1.6"
|
28
|
-
spec.add_development_dependency "jekyll", "
|
26
|
+
spec.add_development_dependency "jekyll", "~>4.0", "< 5.0"
|
29
27
|
spec.add_development_dependency "rake"
|
30
28
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'jekyll-cache'
|
3
|
+
require 'flickr'
|
5
4
|
|
6
5
|
module Jekyll
|
7
6
|
module Flickr
|
8
7
|
class FlickrTag < Liquid::Tag
|
8
|
+
CACHE_NAME = "Jekyll::Flickr::FlickrTag"
|
9
9
|
|
10
10
|
# selection of sizes from those offered by Flickr API
|
11
11
|
DEFAULT_CONFIG = {
|
@@ -73,15 +73,13 @@ module Jekyll
|
|
73
73
|
|
74
74
|
def flickr
|
75
75
|
@@flickr ||= begin
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
@@flickr = FlickRaw::Flickr.new
|
76
|
+
# by default, Flickr uses ENV FLICKR_API_KEY and FLICKR_SHARED_SECRET, support here legacy name FLICKR_API_SECRET, too
|
77
|
+
@@flickr = ::Flickr.new(ENV['FLICKR_API_KEY'] || config['api_key'], ENV['FLICKR_SHARED_SECRET'] || ENV['FLICKR_API_SECRET'] || config['api_secret'])
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|
83
81
|
def cache
|
84
|
-
@@cache ||= Jekyll::Cache
|
82
|
+
@@cache ||= Jekyll::Cache.new(CACHE_NAME)
|
85
83
|
end
|
86
84
|
|
87
85
|
def config
|
@@ -90,13 +88,13 @@ module Jekyll
|
|
90
88
|
|
91
89
|
def render(context)
|
92
90
|
|
93
|
-
match = /(?<photo_id>\d+)(\s(\"(?<caption>[^"]
|
91
|
+
match = /(?<photo_id>\d+)(\s(\"(?<caption>[^"]*)\"))?(?<attr>.*)/.match @text
|
94
92
|
|
95
93
|
photo_id = match.named_captures['photo_id']
|
96
94
|
photo_caption = match.named_captures['caption']
|
97
95
|
photo_attr = match.named_captures['attr']
|
98
96
|
|
99
|
-
photo_data = cache.
|
97
|
+
photo_data = cache.getset photo_id do
|
100
98
|
{
|
101
99
|
info: flickr.photos.getInfo(photo_id: photo_id),
|
102
100
|
sizes: flickr.photos.getSizes(photo_id: photo_id)
|
@@ -107,6 +105,25 @@ module Jekyll
|
|
107
105
|
photo_sizes = photo_data[:sizes].select{ |photo| widths.include?(photo['width'].to_i) }
|
108
106
|
photo_legacy = photo_data[:sizes].find{ |photo| photo['width'].to_i == config['width_legacy']} || photo_data[:sizes].find{ |photo| photo['label'] == 'Original'}
|
109
107
|
|
108
|
+
# if these sizes are not found, pick the one closes to width_legacy
|
109
|
+
unless photo_legacy
|
110
|
+
candidate = nil
|
111
|
+
smallest_delta = nil
|
112
|
+
photo_data[:sizes].each do |photo|
|
113
|
+
current_delta = (photo['width'].to_i - config['width_legacy']).abs
|
114
|
+
if !smallest_delta || (current_delta < smallest_delta)
|
115
|
+
candidate = photo
|
116
|
+
smallest_delta = current_delta
|
117
|
+
end
|
118
|
+
end
|
119
|
+
photo_legacy = candidate
|
120
|
+
end
|
121
|
+
|
122
|
+
# if no photo is found return
|
123
|
+
unless photo_legacy
|
124
|
+
return ""
|
125
|
+
end
|
126
|
+
|
110
127
|
srcset = photo_sizes.map{|photo| "#{photo['source']} #{photo['width']}w"}.join(", ")
|
111
128
|
|
112
129
|
sizes = unless photo_attr.include?('sizes=') then
|
@@ -121,7 +138,7 @@ module Jekyll
|
|
121
138
|
|
122
139
|
img_tag = "<img class=\"flickr\" src=\"#{photo_legacy.source}\" srcset=\"#{srcset}\" sizes=\"#{sizes}\" #{photo_attr}>"
|
123
140
|
|
124
|
-
return img_tag if not config['figcaption']
|
141
|
+
return compute_html_tag(img_tag) if not config['figcaption']
|
125
142
|
|
126
143
|
photo_license = if config['license'] then
|
127
144
|
license = LICENSES[photo_data[:info].license.to_i]
|
@@ -144,12 +161,24 @@ module Jekyll
|
|
144
161
|
""
|
145
162
|
end
|
146
163
|
|
147
|
-
return img_tag if photo_license.empty? and photo_caption.empty?
|
164
|
+
return compute_html_tag(img_tag) if photo_license.empty? and photo_caption.empty?
|
148
165
|
|
149
166
|
return <<-HTML
|
150
167
|
<figure class="flickr">
|
151
168
|
#{img_tag}
|
152
169
|
<figcaption>#{photo_caption}#{photo_license}</figcaption>
|
170
|
+
</figure>
|
171
|
+
HTML
|
172
|
+
end
|
173
|
+
|
174
|
+
#######
|
175
|
+
private
|
176
|
+
#######
|
177
|
+
|
178
|
+
def compute_html_tag(img_tag)
|
179
|
+
return <<-HTML
|
180
|
+
<figure class="flickr">
|
181
|
+
#{img_tag}
|
153
182
|
</figure>
|
154
183
|
HTML
|
155
184
|
end
|
metadata
CHANGED
@@ -1,57 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-flickr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Riemann
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: flickr
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: flickraw-cached
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '20120701'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '20120701'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: flickraw
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.9.9
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.9.9
|
26
|
+
version: '2.0'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: bundler
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,16 +42,22 @@ dependencies:
|
|
70
42
|
name: jekyll
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
72
44
|
requirements:
|
73
|
-
- - "
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
- - "<"
|
74
49
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
50
|
+
version: '5.0'
|
76
51
|
type: :development
|
77
52
|
prerelease: false
|
78
53
|
version_requirements: !ruby/object:Gem::Requirement
|
79
54
|
requirements:
|
80
|
-
- - "
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '4.0'
|
58
|
+
- - "<"
|
81
59
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
60
|
+
version: '5.0'
|
83
61
|
- !ruby/object:Gem::Dependency
|
84
62
|
name: rake
|
85
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,7 +72,7 @@ dependencies:
|
|
94
72
|
- - ">="
|
95
73
|
- !ruby/object:Gem::Version
|
96
74
|
version: '0'
|
97
|
-
description:
|
75
|
+
description:
|
98
76
|
email:
|
99
77
|
- robert@riemann.cc
|
100
78
|
executables: []
|
@@ -115,7 +93,7 @@ homepage: https://github.com/rriemann/jekyll-flickr
|
|
115
93
|
licenses:
|
116
94
|
- MIT
|
117
95
|
metadata: {}
|
118
|
-
post_install_message:
|
96
|
+
post_install_message:
|
119
97
|
rdoc_options: []
|
120
98
|
require_paths:
|
121
99
|
- lib
|
@@ -130,9 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
108
|
- !ruby/object:Gem::Version
|
131
109
|
version: '0'
|
132
110
|
requirements: []
|
133
|
-
|
134
|
-
|
135
|
-
signing_key:
|
111
|
+
rubygems_version: 3.0.1
|
112
|
+
signing_key:
|
136
113
|
specification_version: 4
|
137
114
|
summary: Liquid tag for responsive Flickr images using HTML5 srcset.
|
138
115
|
test_files: []
|