jekyll-uj-powertools 1.6.11 → 1.6.12

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: 19f624e2812b54ffff77ac6e5b5ab0d9198454555c9d331ccf109c6d32f0d724
4
+ data.tar.gz: beebdaa32f7008d4427cbf030226157c9f691ee9e66e30612ead0d2c6f6b8518
5
5
  SHA512:
6
- metadata.gz: 83364951d73755ddaf57a0ffde41e0e917945366f9aaed67f238ea967d8ee89600ef140b39b32e04b80cc926a694a3e5f2d9ad905202fbbf3db82c62801eef14
7
- data.tar.gz: 42543e04159f00a31c7316b620a6d5cc426a4ebd0a2739cdc3fcda96615a57fa1d7a106a045fee49f96ee95a17e84b24c537ad8b00e11d49b9fd077130685fcc
6
+ metadata.gz: 0e3a7b208d8acbdbb4a3fd634283a09acddcd4f2728f4b1275d03b28888cfa76730c9054942e3ac83b1031374ff8d1e8be65655f07db40f20fb01e5d33c5a006
7
+ data.tar.gz: 15882e59423be03df44691a14bcf04ae2953a834caf7e2ce8c2b84bf8da487cd3cd210c5022d1815f50291ef0c9dc403e03e105664e03b6cf92a31a856a7b54e
@@ -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.12"
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,173 @@
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 = "<video\n"
54
+
55
+ # Add common video attributes
56
+ css_class = options['class'] || ''
57
+ style = options['style'] || ''
58
+ width = options['width'] || ''
59
+ height = options['height'] || ''
60
+ autoplay = options['autoplay'] || ''
61
+ loop = options['loop'] || ''
62
+ muted = options['muted'] || ''
63
+ controls = options['controls'] || 'true'
64
+ playsinline = options['playsinline'] || ''
65
+ preload = options['preload'] || 'metadata'
66
+ poster = options['poster'] || ''
67
+
68
+ html += "class=\"#{css_class}\"\n" unless css_class.empty?
69
+ html += "style=\"#{style}\"\n" unless style.empty?
70
+ html += "width=\"#{width}\"\n" unless width.empty?
71
+ html += "height=\"#{height}\"\n" unless height.empty?
72
+ html += "autoplay\n" unless autoplay.empty? || autoplay == 'false'
73
+ html += "loop\n" unless loop.empty? || loop == 'false'
74
+ html += "muted\n" unless muted.empty? || muted == 'false'
75
+ html += "controls\n" unless controls == 'false'
76
+ html += "playsinline\n" unless playsinline.empty? || playsinline == 'false'
77
+ html += "preload=\"#{preload}\"\n"
78
+ html += "poster=\"#{poster}\"\n" unless poster.empty?
79
+ html += ">\n"
80
+
81
+ # Add sources based on max_width
82
+ html += build_video_sources(src_path, extension, max_width, src)
83
+
84
+ # Fallback text
85
+ html += "Your browser does not support the video tag.\n"
86
+ html += "</video>"
87
+
88
+ html
89
+ end
90
+
91
+ def build_video_sources(src_path, extension, max_width, src)
92
+ html = ""
93
+
94
+ case max_width
95
+ when "320"
96
+ html += "<source data-lazy=\"@src #{src_path}-320px#{extension}\" type=\"video/#{get_mime_type(extension)}\">\n"
97
+ when "640"
98
+ html += "<source data-lazy=\"@src #{src_path}-320px#{extension}\" media=\"(max-width: 320px)\" type=\"video/#{get_mime_type(extension)}\">\n"
99
+ html += "<source data-lazy=\"@src #{src_path}-640px#{extension}\" type=\"video/#{get_mime_type(extension)}\">\n"
100
+ when "1024"
101
+ html += "<source data-lazy=\"@src #{src_path}-320px#{extension}\" media=\"(max-width: 320px)\" type=\"video/#{get_mime_type(extension)}\">\n"
102
+ html += "<source data-lazy=\"@src #{src_path}-640px#{extension}\" media=\"(max-width: 640px)\" type=\"video/#{get_mime_type(extension)}\">\n"
103
+ html += "<source data-lazy=\"@src #{src_path}-1024px#{extension}\" type=\"video/#{get_mime_type(extension)}\">\n"
104
+ else
105
+ html += "<source data-lazy=\"@src #{src_path}-320px#{extension}\" media=\"(max-width: 320px)\" type=\"video/#{get_mime_type(extension)}\">\n"
106
+ html += "<source data-lazy=\"@src #{src_path}-640px#{extension}\" media=\"(max-width: 640px)\" type=\"video/#{get_mime_type(extension)}\">\n"
107
+ html += "<source data-lazy=\"@src #{src_path}-1024px#{extension}\" media=\"(max-width: 1024px)\" type=\"video/#{get_mime_type(extension)}\">\n"
108
+ html += "<source data-lazy=\"@src #{src}\" media=\"(min-width: 1025px)\" type=\"video/#{get_mime_type(extension)}\">\n"
109
+ end
110
+
111
+ html
112
+ end
113
+
114
+ def build_external_video(src, options)
115
+ # Build responsive video tag for external URLs
116
+ css_class = options['class'] || ''
117
+ style = options['style'] || ''
118
+ width = options['width'] || ''
119
+ height = options['height'] || ''
120
+ autoplay = options['autoplay'] || ''
121
+ loop = options['loop'] || ''
122
+ muted = options['muted'] || ''
123
+ controls = options['controls'] || 'true'
124
+ playsinline = options['playsinline'] || ''
125
+ preload = options['preload'] || 'metadata'
126
+ poster = options['poster'] || ''
127
+
128
+ # Build video tag on a single line to prevent markdown parsing issues
129
+ html = "<video"
130
+ html += " class=\"#{css_class}\"" unless css_class.empty?
131
+ html += " style=\"#{style}\"" unless style.empty?
132
+ html += " width=\"#{width}\"" unless width.empty?
133
+ html += " height=\"#{height}\"" unless height.empty?
134
+ html += " autoplay" unless autoplay.empty? || autoplay == 'false'
135
+ html += " loop" unless loop.empty? || loop == 'false'
136
+ html += " muted" unless muted.empty? || muted == 'false'
137
+ html += " controls" unless controls == 'false'
138
+ html += " playsinline" unless playsinline.empty? || playsinline == 'false'
139
+ html += " preload=\"#{preload}\""
140
+ html += " poster=\"#{poster}\"" unless poster.empty?
141
+ html += ">"
142
+
143
+ # Determine MIME type from file extension
144
+ extension = File.extname(src)
145
+ mime_type = get_mime_type(extension)
146
+
147
+ html += "<source data-lazy=\"@src #{src}\" type=\"video/#{mime_type}\">"
148
+ html += "Your browser does not support the video tag."
149
+ html += "</video>"
150
+
151
+ html
152
+ end
153
+
154
+ def get_mime_type(extension)
155
+ case extension.downcase
156
+ when '.mp4'
157
+ 'mp4'
158
+ when '.webm'
159
+ 'webm'
160
+ when '.ogg', '.ogv'
161
+ 'ogg'
162
+ when '.mov'
163
+ 'quicktime'
164
+ when '.avi'
165
+ 'x-msvideo'
166
+ else
167
+ 'mp4' # Default to mp4
168
+ end
169
+ end
170
+ end
171
+ end
172
+
173
+ 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.12
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-16 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