bridgetown-cloudinary 1.1.0 → 1.2.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: 366f2d5d3354c186045ea89968b96df7bce677b391990e864ba355f1181e9386
4
- data.tar.gz: 72de912532f48ede11a53676cb3b0f333a88cf7025f8d163a88501b91b827788
3
+ metadata.gz: c23d1b1e19337f21322c361f43b32ddec90c719a7f5eaa6b4ddfe546a9eec2cf
4
+ data.tar.gz: 306c64264ae0abda2a73616cc5491b230748c112a7ca304c9470b4c1729c30a6
5
5
  SHA512:
6
- metadata.gz: 870607b637392b2d753fa705eba71808e6965acb032854c24b4d3beb47c606f88d1edaee07aa335c013ccc63b384835344a1707e527beb7f47a17fec0998bf80
7
- data.tar.gz: 1f7515d6c563cf488d47f55ae18effdfb781c60fd62f568bb377cd22b84ff6723d8290162a6c36e95c1ff839813bf17cb3b635a5c7a46f02a9d0051c79f2c6e4
6
+ metadata.gz: 89728ff5a1473d45b7e166cc37b9ad641cc572d132ff65ed44529afb35273979d84ddc93acca8e587c9933c4a36a019b1382f80db5f357d45f54355841e34e96
7
+ data.tar.gz: 9dc6ce8d8a3ba7c17da917d10a294c413ca9e2e5ed3d4dc63f3664a10ccfc0875375ddae2e116dc1b335c968aedf3ff555b031053369cba7004a4bc53d1e45ba
data/CHANGELOG.md CHANGED
@@ -1,18 +1,33 @@
1
- # master
1
+ # Changelog
2
2
 
3
- # 1.1.0 / 2020-09-19
3
+ All notable changes to this project will be documented in this file.
4
4
 
5
- * Add helper support for Ruby-based templates (requires Bridgetown 0.17)
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
7
 
7
- # 1.0.2 / 2020-05-21
8
+ ## 1.2.0 - 2021-07-11
8
9
 
9
- * Escape tag attributes with `xml_escape`
10
+ ### Added
10
11
 
11
- # 1.0.1 / 2020-05-21
12
+ - Support for the Resource content engine
12
13
 
13
- * Support page/local variables in alt text for tag as well
14
+ ### Changed
14
15
 
15
- # 1.0.0 / 2020-05-18
16
+ - This changelog format! :)
16
17
 
17
- * First version of the Cloudinary plugin for Bridgetown, including defaults for
18
+ ## 1.1.0 - 2020-09-19
19
+
20
+ - Add helper support for Ruby-based templates (requires Bridgetown 0.17)
21
+
22
+ ## 1.0.2 - 2020-05-21
23
+
24
+ - Escape tag attributes with `xml_escape`
25
+
26
+ ## 1.0.1 - 2020-05-21
27
+
28
+ - Support page/local variables in alt text for tag as well
29
+
30
+ ## 1.0.0 - 2020-05-18
31
+
32
+ - First version of the Cloudinary plugin for Bridgetown, including defaults for
18
33
  various image sizes.
data/README.md CHANGED
@@ -15,7 +15,7 @@ images in Cloudinary directly, not your repo._)
15
15
 
16
16
  ## Installation
17
17
 
18
- If you're running Bridgetown v0.15 or later, you can install this plugin via an automation to guide you through the configuration:
18
+ You can install this plugin via an automation to guide you through the configuration:
19
19
 
20
20
  ```shell
21
21
  bundle exec bridgetown apply https://github.com/bridgetownrb/bridgetown-cloudinary
@@ -38,7 +38,7 @@ cloudinary:
38
38
  ## Usage
39
39
 
40
40
  The simplest usage of the Bridgetown Cloudinary plugin is to add a `cloudinary_id` to
41
- the front matter of a page or document. For example:
41
+ the front matter of a resource. For example:
42
42
 
43
43
  ```yaml
44
44
  ---
@@ -63,7 +63,7 @@ You can use `image.path` in a template:
63
63
  Since `image.path` is also referenced by the Bridgetown [Feed](https://github.com/bridgetownrb/bridgetown-feed) and [SEO](https://github.com/bridgetownrb/bridgetown-seo-tag) plugins,
64
64
  your Cloudinary images will be picked up in those contexts automatically.
65
65
 
66
- To reference other available sizes, you can use either a Liquid tag or filter,
66
+ To reference other available sizes, you can use either a Liquid tag or filter, or Ruby helper,
67
67
  depending on your needs. Using a tag:
68
68
 
69
69
  `{% cloudinary_img "Alt text goes here", post.cloudinary_id, "large" %}`
@@ -72,6 +72,11 @@ Or a filter:
72
72
 
73
73
  `<img alt="Alt text" src="{{ post.cloudinary_id | cloudinary_url: "medium" }}" />`
74
74
 
75
+ Or helpers in ERB and other Ruby templates:
76
+
77
+ `<%= cloudinary_img "Alt text goes here", post.data.cloudinary_id %>`
78
+
79
+ `<img alt="Alt text" src="<%= cloudinary_url post.data.cloudinary_id, :medium %>" />`
75
80
 
76
81
  ### Default Sizes Included
77
82
 
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.required_ruby_version = ">= 2.5.0"
19
19
 
20
- spec.add_dependency "bridgetown", ">= 0.14", "< 2.0"
20
+ spec.add_dependency "bridgetown", ">= 0.21", "< 2.0"
21
21
  spec.add_dependency "cloudinary", ">= 0.13"
22
22
 
23
23
  spec.add_development_dependency "bundler"
@@ -29,18 +29,16 @@ module Bridgetown
29
29
  "secure" => true,
30
30
  })
31
31
 
32
- generator :add_image_urls_to_documents
32
+ generator :add_image_urls_to_resources
33
33
  liquid_tag "cloudinary_img", :img_tag
34
34
  liquid_filter "cloudinary_url", :url_filter
35
- if respond_to? :helper
36
- helper "cloudinary_img", :img_helper
37
- helper "cloudinary_url", :url_filter
38
- end
35
+ helper "cloudinary_img", :img_helper
36
+ helper "cloudinary_url", :url_filter
39
37
  end
40
38
 
41
39
  # Populate front matter
42
- def add_image_urls_to_documents
43
- Bridgetown::Cloudinary::Utils.add_image_urls_to_documents(
40
+ def add_image_urls_to_resources
41
+ Bridgetown::Cloudinary::Utils.add_image_urls_to_resources(
44
42
  site, config[:cloudinary]
45
43
  )
46
44
  end
@@ -18,23 +18,24 @@ module Bridgetown
18
18
  cloudinary_url&.sub("/image/upload", "/image/upload#{transformation}")
19
19
  end
20
20
 
21
- def self.add_image_urls_to_documents(site, config)
22
- (site.documents + site.pages).each do |page|
23
- next unless page.data[:cloudinary_id] && !page.data[:image]
21
+ def self.add_image_urls_to_resources(site, config)
22
+ site.contents.each do |resource|
23
+ next unless resource.data[:cloudinary_id] && !resource.data[:image]
24
+ next if resource.respond_to?(:collection) && resource.collection.data?
24
25
 
25
- page.data[:image] = {
26
+ resource.data[:image] = {
26
27
  path: url(
27
28
  config: config,
28
- id: page.data[:cloudinary_id],
29
+ id: resource.data[:cloudinary_id],
29
30
  transformation: nil
30
31
  ),
31
32
  }
32
33
  next unless config[:add_transformed_urls_to_image_front_matter]
33
34
 
34
35
  config[:transformations].each_key do |transformation|
35
- page.data[:image][transformation] = url(
36
+ resource.data[:image][transformation] = url(
36
37
  config: config,
37
- id: page.data[:cloudinary_id],
38
+ id: resource.data[:cloudinary_id],
38
39
  transformation: transformation
39
40
  )
40
41
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bridgetown
4
4
  module Cloudinary
5
- VERSION = "1.1.0"
5
+ VERSION = "1.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-cloudinary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-19 00:00:00.000000000 Z
11
+ date: 2021-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bridgetown
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.14'
19
+ version: '0.21'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '2.0'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '0.14'
29
+ version: '0.21'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2.0'
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  requirements: []
157
- rubygems_version: 3.0.8
157
+ rubygems_version: 3.1.4
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Embed or access images with transformations using Cloudinary