jekyll-flickr 0.2.0 → 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 +6 -1
- data/lib/jekyll-flickr/flickr_tag.rb +36 -4
- data/lib/jekyll-flickr/version.rb +1 -1
- metadata +2 -2
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,6 +1,11 @@
|
|
1
1
|
## HEAD
|
2
2
|
|
3
|
-
##
|
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
|
4
9
|
|
5
10
|
* dependencies: require Jekyll 4.x and use gem flickr instead of flickraw
|
6
11
|
* use native Jekyll cache API (<https://jekyllrb.com/tutorials/cache-api/>) instead of jekyll-cache
|
@@ -5,6 +5,7 @@ require 'flickr'
|
|
5
5
|
module Jekyll
|
6
6
|
module Flickr
|
7
7
|
class FlickrTag < Liquid::Tag
|
8
|
+
CACHE_NAME = "Jekyll::Flickr::FlickrTag"
|
8
9
|
|
9
10
|
# selection of sizes from those offered by Flickr API
|
10
11
|
DEFAULT_CONFIG = {
|
@@ -78,7 +79,7 @@ module Jekyll
|
|
78
79
|
end
|
79
80
|
|
80
81
|
def cache
|
81
|
-
@@cache ||= Jekyll::Cache.new(
|
82
|
+
@@cache ||= Jekyll::Cache.new(CACHE_NAME)
|
82
83
|
end
|
83
84
|
|
84
85
|
def config
|
@@ -87,7 +88,7 @@ module Jekyll
|
|
87
88
|
|
88
89
|
def render(context)
|
89
90
|
|
90
|
-
match = /(?<photo_id>\d+)(\s(\"(?<caption>[^"]
|
91
|
+
match = /(?<photo_id>\d+)(\s(\"(?<caption>[^"]*)\"))?(?<attr>.*)/.match @text
|
91
92
|
|
92
93
|
photo_id = match.named_captures['photo_id']
|
93
94
|
photo_caption = match.named_captures['caption']
|
@@ -104,6 +105,25 @@ module Jekyll
|
|
104
105
|
photo_sizes = photo_data[:sizes].select{ |photo| widths.include?(photo['width'].to_i) }
|
105
106
|
photo_legacy = photo_data[:sizes].find{ |photo| photo['width'].to_i == config['width_legacy']} || photo_data[:sizes].find{ |photo| photo['label'] == 'Original'}
|
106
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
|
+
|
107
127
|
srcset = photo_sizes.map{|photo| "#{photo['source']} #{photo['width']}w"}.join(", ")
|
108
128
|
|
109
129
|
sizes = unless photo_attr.include?('sizes=') then
|
@@ -118,7 +138,7 @@ module Jekyll
|
|
118
138
|
|
119
139
|
img_tag = "<img class=\"flickr\" src=\"#{photo_legacy.source}\" srcset=\"#{srcset}\" sizes=\"#{sizes}\" #{photo_attr}>"
|
120
140
|
|
121
|
-
return img_tag if not config['figcaption']
|
141
|
+
return compute_html_tag(img_tag) if not config['figcaption']
|
122
142
|
|
123
143
|
photo_license = if config['license'] then
|
124
144
|
license = LICENSES[photo_data[:info].license.to_i]
|
@@ -141,12 +161,24 @@ module Jekyll
|
|
141
161
|
""
|
142
162
|
end
|
143
163
|
|
144
|
-
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?
|
145
165
|
|
146
166
|
return <<-HTML
|
147
167
|
<figure class="flickr">
|
148
168
|
#{img_tag}
|
149
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}
|
150
182
|
</figure>
|
151
183
|
HTML
|
152
184
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-flickr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Riemann
|
8
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
14
|
name: flickr
|