bridgetown-cloudinary 1.0.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2a0a39fcc006a2b1293e4a18feddac2cbb2aa37d305c45830c3493a3b031543
4
- data.tar.gz: 6a3b8794b0151383dc4f331df4d9282a229681b315fa490c26791ca96fa04c92
3
+ metadata.gz: c832350f15549d90fda2675a21394484540b271aa4e27a6d2ddacfa1987b5c3c
4
+ data.tar.gz: 7766d51b45ffce0aeaaa9909846a4a07be7c9a351960513bd13f81f3ef59c010
5
5
  SHA512:
6
- metadata.gz: b1680c1d594c65fe4d1ffda7818c1bc46ffc2951a5d13569678e7054feab59442ae3f0fda80037d22bac46e7c39e04aa4c7a141d59070fc2b5cca7c25b914a42
7
- data.tar.gz: 62cc8410cd8248e69d61793b94b9c9ff91744c2cc4650d720f795789244c3fb067b6c60b0d558281c4a3a94e7986a423a5961b852a1b3ceeba9867baea5edbf7
6
+ metadata.gz: ff868191020b3b4dd248f8b35bc1e0a77a4904408798d1c0603e7524724c51e044650fe333fc8c5a42390a238df38f75b1f6db773ea69f7b2465452aee3f83ff
7
+ data.tar.gz: be185570e71ef19e4916668894f9e05de78899ec31189c8633516152689b54ed6c4634f845a6c8eb6c22f48d832d8d66136c17beb16d19fae02757f7b4b3f1ca
@@ -1,5 +1,9 @@
1
1
  # master
2
2
 
3
+ # 1.0.1 / 2020-05-21
4
+
5
+ * Support page/local variables in alt text for tag as well
6
+
3
7
  # 1.0.0 / 2020-05-18
4
8
 
5
9
  * First version of the Cloudinary plugin for Bridgetown, including defaults for
data/README.md CHANGED
@@ -9,6 +9,10 @@ This plugin wires the two up so you can use Cloudinary images in your blog posts
9
9
  articles, product pages, site templates, and anywhere else you might need to
10
10
  reference media optimized for mobile and responsive design.
11
11
 
12
+ (_Note: For users who may be familiar with the jekyll-cloudinary plugin, this is
13
+ unrelated and the usage is quite different. This plugin assumes you store your
14
+ images in Cloudinary directly, not your repo._)
15
+
12
16
  ## Installation
13
17
 
14
18
  Run this command to add this plugin to your site's Gemfile:
@@ -0,0 +1,15 @@
1
+ # Supporting the upcoming automation feature
2
+
3
+ say_status "Cloudinary", "Installing the bridgetown-cloudinary plugin..."
4
+
5
+ cloud_name = ask("What's your Cloudinary cloud name?")
6
+
7
+ add_bridgetown_plugin "bridgetown-cloudinary"
8
+
9
+ append_to_file "bridgetown.config.yml" do
10
+ <<~YAML
11
+
12
+ cloudinary:
13
+ cloud_name: #{cloud_name}
14
+ YAML
15
+ end
@@ -42,15 +42,8 @@ module Bridgetown
42
42
  # Define the "cloudinary_img" Liquid tag
43
43
  def img_tag(attributes, tag)
44
44
  alt, id, transformation = attributes.split(",").map(&:strip)
45
- alt.delete! '"'
46
- if id.include? '"'
47
- id.delete! '"'
48
- elsif id.include? "."
49
- obj, var = id.split(".")
50
- id = tag.context[obj][var]
51
- else
52
- id = tag.context[id]
53
- end
45
+ alt = variable_in_context(alt, tag.context)
46
+ id = variable_in_context(id, tag.context)
54
47
  transformation&.delete! '"'
55
48
 
56
49
  "<img alt=\"#{alt}\" src=\"#{url_filter(id, transformation)}\" />"
@@ -62,6 +55,20 @@ module Bridgetown
62
55
  config: config[:cloudinary], id: id, transformation: transformation
63
56
  )
64
57
  end
58
+
59
+ protected
60
+
61
+ def variable_in_context(variable, tag_context)
62
+ if variable.include? '"'
63
+ variable.delete! '"'
64
+ elsif variable.include? "."
65
+ obj, var = variable.split(".")
66
+ variable = tag_context[obj][var]
67
+ else
68
+ variable = tag_context[variable]
69
+ end
70
+ variable
71
+ end
65
72
  end
66
73
  end
67
74
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bridgetown
4
4
  module Cloudinary
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.1"
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.0.0
4
+ version: 1.0.1
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-05-18 00:00:00.000000000 Z
11
+ date: 2020-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bridgetown
@@ -129,6 +129,7 @@ files:
129
129
  - README.md
130
130
  - Rakefile
131
131
  - bridgetown-cloudinary.gemspec
132
+ - bridgetown.automation.rb
132
133
  - lib/bridgetown-cloudinary.rb
133
134
  - lib/bridgetown-cloudinary/builder.rb
134
135
  - lib/bridgetown-cloudinary/utils.rb