jekyll-uj-powertools 1.6.11 → 1.6.13

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: 11df894ba3e6ec90b19f3cfce9ee7696dc1ae2a399dd709ebc3894ed75292fa8
4
- data.tar.gz: 3ad318e32bd86a8718a2c4a20daaa201a0a555c776b4ae37d084000831f53fc8
3
+ metadata.gz: '02549cb967cbd7824079ec66c7b3efc58bfbd8900541807199e4999472e4f637'
4
+ data.tar.gz: 4b8f38b4f5a17787d3edd32b00f3a011682b2fd276dc561e9a1fb37349e2ddde
5
5
  SHA512:
6
- metadata.gz: 83364951d73755ddaf57a0ffde41e0e917945366f9aaed67f238ea967d8ee89600ef140b39b32e04b80cc926a694a3e5f2d9ad905202fbbf3db82c62801eef14
7
- data.tar.gz: 42543e04159f00a31c7316b620a6d5cc426a4ebd0a2739cdc3fcda96615a57fa1d7a106a045fee49f96ee95a17e84b24c537ad8b00e11d49b9fd077130685fcc
6
+ metadata.gz: 572aee2b9a5c50dc70061d1d4b6b49773b0297a9e786c6e897fb767166600de697285570a245ee10e1b40f1a24dad018fff7adcf2ac3efa03380a07b8fd4fb0d
7
+ data.tar.gz: bdc0de0cb663b2f4de284ceefa13c094384b4d6cea72e90a7fd05fc48e3d1d3d56be2a29d6bf413aeb89295a448c7f4102397a742a99c0bed32fa4157fd71572
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  Gem::Specification.new do |spec|
6
6
  # Gem info
7
7
  spec.name = "jekyll-uj-powertools"
8
- spec.version = "1.6.11"
8
+ spec.version = "1.6.13"
9
9
 
10
10
  # Author info
11
11
  spec.authors = ["ITW Creative Works"]
@@ -28,4 +28,5 @@ module Jekyll
28
28
  require_relative "tags/social"
29
29
  require_relative "tags/translation_url"
30
30
  require_relative "tags/urlmatches"
31
+ require_relative "tags/video"
31
32
  end
data/lib/tags/video.rb ADDED
@@ -0,0 +1,177 @@
1
+ # Libraries
2
+ require "jekyll"
3
+ require_relative '../helpers/variable_resolver'
4
+
5
+ module Jekyll
6
+ class UJVideoTag < Liquid::Tag
7
+ include UJPowertools::VariableResolver
8
+
9
+ PLACEHOLDER = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
10
+
11
+ def initialize(tag_name, markup, tokens)
12
+ super
13
+ @markup = markup.strip
14
+ end
15
+
16
+ def render(context)
17
+ # Parse arguments
18
+ args = parse_arguments(@markup)
19
+ src_input = args[0]
20
+
21
+ # Parse options and resolve their values
22
+ options = parse_options(args[1..-1], context)
23
+
24
+ # Resolve source path (treat unquoted strings as literals)
25
+ src = resolve_input(context, src_input, true)
26
+ return '' unless src
27
+
28
+ # Check if this is an external URL
29
+ is_external = !!(src =~ /^https?:\/\//)
30
+
31
+ if is_external
32
+ # For external URLs, just create a simple responsive video tag
33
+ build_external_video(src, options)
34
+ else
35
+ # Extract file extension
36
+ extension = File.extname(src)
37
+ src_path = src.chomp(extension)
38
+
39
+ # Determine max width
40
+ max_width = options['max_width'] || options['max-width'] || false
41
+ max_width = max_width.to_s if max_width
42
+
43
+ # Build video element for local videos
44
+ build_video_element(src, src_path, extension, max_width, options)
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ # parse_arguments and parse_options methods are now provided by VariableResolver module
51
+
52
+ def build_video_element(src, src_path, extension, max_width, options)
53
+ html = "<div class=\"lazy-loading\" data-lazy-load-container>\n"
54
+ html += "<video\n"
55
+
56
+ # Add common video attributes
57
+ css_class = options['class'] || ''
58
+ style = options['style'] || ''
59
+ width = options['width'] || ''
60
+ height = options['height'] || ''
61
+ autoplay = options['autoplay'] || ''
62
+ loop = options['loop'] || ''
63
+ muted = options['muted'] || ''
64
+ controls = options['controls'] || 'true'
65
+ playsinline = options['playsinline'] || ''
66
+ preload = options['preload'] || 'metadata'
67
+ poster = options['poster'] || ''
68
+
69
+ html += "class=\"#{css_class}\"\n" unless css_class.empty?
70
+ html += "style=\"#{style}\"\n" unless style.empty?
71
+ html += "width=\"#{width}\"\n" unless width.empty?
72
+ html += "height=\"#{height}\"\n" unless height.empty?
73
+ html += "autoplay\n" unless autoplay.empty? || autoplay == 'false'
74
+ html += "loop\n" unless loop.empty? || loop == 'false'
75
+ html += "muted\n" unless muted.empty? || muted == 'false'
76
+ html += "controls\n" unless controls == 'false'
77
+ html += "playsinline\n" unless playsinline.empty? || playsinline == 'false'
78
+ html += "preload=\"#{preload}\"\n"
79
+ html += "poster=\"#{poster}\"\n" unless poster.empty?
80
+ html += ">\n"
81
+
82
+ # Add sources based on max_width
83
+ html += build_video_sources(src_path, extension, max_width, src)
84
+
85
+ # Fallback text
86
+ html += "Your browser does not support the video tag.\n"
87
+ html += "</video>\n"
88
+ html += "</div>"
89
+
90
+ html
91
+ end
92
+
93
+ def build_video_sources(src_path, extension, max_width, src)
94
+ html = ""
95
+
96
+ case max_width
97
+ when "320"
98
+ html += "<source data-lazy=\"@src #{src_path}-320px#{extension}\" type=\"video/#{get_mime_type(extension)}\">\n"
99
+ when "640"
100
+ html += "<source data-lazy=\"@src #{src_path}-320px#{extension}\" media=\"(max-width: 320px)\" type=\"video/#{get_mime_type(extension)}\">\n"
101
+ html += "<source data-lazy=\"@src #{src_path}-640px#{extension}\" type=\"video/#{get_mime_type(extension)}\">\n"
102
+ when "1024"
103
+ html += "<source data-lazy=\"@src #{src_path}-320px#{extension}\" media=\"(max-width: 320px)\" type=\"video/#{get_mime_type(extension)}\">\n"
104
+ html += "<source data-lazy=\"@src #{src_path}-640px#{extension}\" media=\"(max-width: 640px)\" type=\"video/#{get_mime_type(extension)}\">\n"
105
+ html += "<source data-lazy=\"@src #{src_path}-1024px#{extension}\" type=\"video/#{get_mime_type(extension)}\">\n"
106
+ else
107
+ html += "<source data-lazy=\"@src #{src_path}-320px#{extension}\" media=\"(max-width: 320px)\" type=\"video/#{get_mime_type(extension)}\">\n"
108
+ html += "<source data-lazy=\"@src #{src_path}-640px#{extension}\" media=\"(max-width: 640px)\" type=\"video/#{get_mime_type(extension)}\">\n"
109
+ html += "<source data-lazy=\"@src #{src_path}-1024px#{extension}\" media=\"(max-width: 1024px)\" type=\"video/#{get_mime_type(extension)}\">\n"
110
+ html += "<source data-lazy=\"@src #{src}\" media=\"(min-width: 1025px)\" type=\"video/#{get_mime_type(extension)}\">\n"
111
+ end
112
+
113
+ html
114
+ end
115
+
116
+ def build_external_video(src, options)
117
+ # Build responsive video tag for external URLs
118
+ css_class = options['class'] || ''
119
+ style = options['style'] || ''
120
+ width = options['width'] || ''
121
+ height = options['height'] || ''
122
+ autoplay = options['autoplay'] || ''
123
+ loop = options['loop'] || ''
124
+ muted = options['muted'] || ''
125
+ controls = options['controls'] || 'true'
126
+ playsinline = options['playsinline'] || ''
127
+ preload = options['preload'] || 'metadata'
128
+ poster = options['poster'] || ''
129
+
130
+ # Build video tag on a single line to prevent markdown parsing issues
131
+ html = "<div class=\"lazy-loading\" data-lazy-load-container>"
132
+ html += "<video"
133
+ html += " class=\"#{css_class}\"" unless css_class.empty?
134
+ html += " style=\"#{style}\"" unless style.empty?
135
+ html += " width=\"#{width}\"" unless width.empty?
136
+ html += " height=\"#{height}\"" unless height.empty?
137
+ html += " autoplay" unless autoplay.empty? || autoplay == 'false'
138
+ html += " loop" unless loop.empty? || loop == 'false'
139
+ html += " muted" unless muted.empty? || muted == 'false'
140
+ html += " controls" unless controls == 'false'
141
+ html += " playsinline" unless playsinline.empty? || playsinline == 'false'
142
+ html += " preload=\"#{preload}\""
143
+ html += " poster=\"#{poster}\"" unless poster.empty?
144
+ html += ">"
145
+
146
+ # Determine MIME type from file extension
147
+ extension = File.extname(src)
148
+ mime_type = get_mime_type(extension)
149
+
150
+ html += "<source data-lazy=\"@src #{src}\" type=\"video/#{mime_type}\">"
151
+ html += "Your browser does not support the video tag."
152
+ html += "</video>"
153
+ html += "</div>"
154
+
155
+ html
156
+ end
157
+
158
+ def get_mime_type(extension)
159
+ case extension.downcase
160
+ when '.mp4'
161
+ 'mp4'
162
+ when '.webm'
163
+ 'webm'
164
+ when '.ogg', '.ogv'
165
+ 'ogg'
166
+ when '.mov'
167
+ 'quicktime'
168
+ when '.avi'
169
+ 'x-msvideo'
170
+ else
171
+ 'mp4' # Default to mp4
172
+ end
173
+ end
174
+ end
175
+ end
176
+
177
+ Liquid::Template.register_tag('uj_video', Jekyll::UJVideoTag)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-uj-powertools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.11
4
+ version: 1.6.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITW Creative Works
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-29 00:00:00.000000000 Z
11
+ date: 2025-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -134,6 +134,7 @@ files:
134
134
  - lib/tags/social.rb
135
135
  - lib/tags/translation_url.rb
136
136
  - lib/tags/urlmatches.rb
137
+ - lib/tags/video.rb
137
138
  homepage: https://github.com/itw-creative-works/jekyll-uj-powertools
138
139
  licenses:
139
140
  - MIT