jekyll-uj-powertools 1.6.22 → 1.6.24
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/jekyll-uj-powertools.gemspec +1 -1
- data/lib/tags/logo.rb +59 -18
- 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: 8e244425c0a57091b17d74eeb82b585314a5892bc4d2185e6dc50b5d66d7d16c
|
|
4
|
+
data.tar.gz: e999ee1ea01bee859c675e451c3d8323c984b225a7ae2438f3d06f1f43158848
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4042544bbfb0c7e818b9d56ab22adb617c0e5ab74f5284e03eaab1c2a5fed114b77e3d7860759cdef9d0ba9d057b542e5e916f690bda237defbf7426056fcff7
|
|
7
|
+
data.tar.gz: cd588783c0bd5b02069eb47363352d6200d03de8b4208004a34a23db7372a123dffc47b2138174e7969f4380cf39f649ac977c06a41e6dfbedd7469592732a5f
|
data/lib/tags/logo.rb
CHANGED
|
@@ -5,12 +5,15 @@ require_relative '../helpers/variable_resolver'
|
|
|
5
5
|
module Jekyll
|
|
6
6
|
class UJLogoTag < Liquid::Tag
|
|
7
7
|
include UJPowertools::VariableResolver
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
# Default logo to show when requested logo is not found
|
|
10
10
|
DEFAULT_LOGO = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Free v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 64C334.7 64 348.2 72.1 355.2 85L571.2 485C577.9 497.4 577.6 512.4 570.4 524.5C563.2 536.6 550.1 544 536 544L104 544C89.9 544 76.9 536.6 69.6 524.5C62.3 512.4 62.1 497.4 68.8 485L284.8 85C291.8 72.1 305.3 64 320 64zM320 232C306.7 232 296 242.7 296 256L296 368C296 381.3 306.7 392 320 392C333.3 392 344 381.3 344 368L344 256C344 242.7 333.3 232 320 232zM346.7 448C347.3 438.1 342.4 428.7 333.9 423.5C325.4 418.4 314.7 418.4 306.2 423.5C297.7 428.7 292.8 438.1 293.4 448C292.8 457.9 297.7 467.3 306.2 472.5C314.7 477.6 325.4 477.6 333.9 472.5C342.4 467.3 347.3 457.9 346.7 448z"/></svg>'
|
|
11
|
-
|
|
12
|
-
# Cache for loaded logos to improve performance
|
|
11
|
+
|
|
12
|
+
# Cache for loaded logos (raw SVG content) to improve performance
|
|
13
13
|
@@logo_cache = {}
|
|
14
|
+
|
|
15
|
+
# Counter for generating unique prefixes per logo instance
|
|
16
|
+
@@instance_counter = 0
|
|
14
17
|
|
|
15
18
|
def initialize(tag_name, markup, tokens)
|
|
16
19
|
super
|
|
@@ -63,38 +66,76 @@ module Jekyll
|
|
|
63
66
|
# Get site from context
|
|
64
67
|
site = context.registers[:site]
|
|
65
68
|
return '' unless site
|
|
66
|
-
|
|
67
|
-
# Load the logo SVG from file
|
|
68
|
-
|
|
69
|
-
return '' unless
|
|
70
|
-
|
|
71
|
-
#
|
|
72
|
-
|
|
69
|
+
|
|
70
|
+
# Load the raw logo SVG from file (cached)
|
|
71
|
+
raw_svg = load_logo_from_file(logo_name.to_s, type, color)
|
|
72
|
+
return '' unless raw_svg
|
|
73
|
+
|
|
74
|
+
# Generate unique prefix for this instance to prevent ID conflicts
|
|
75
|
+
# when the same logo is used multiple times on a page
|
|
76
|
+
@@instance_counter += 1
|
|
77
|
+
unique_prefix = "#{logo_name}-#{@@instance_counter}"
|
|
78
|
+
|
|
79
|
+
# Prefix all IDs with unique prefix
|
|
80
|
+
prefix_svg_ids(raw_svg, unique_prefix)
|
|
73
81
|
end
|
|
74
|
-
|
|
82
|
+
|
|
75
83
|
private
|
|
76
|
-
|
|
84
|
+
|
|
77
85
|
def load_logo_from_file(logo_name, type, color)
|
|
78
86
|
# Create cache key
|
|
79
87
|
cache_key = "#{type}/#{color}/#{logo_name}"
|
|
80
|
-
|
|
81
|
-
# Return cached version if available
|
|
88
|
+
|
|
89
|
+
# Return cached version if available (raw SVG without prefixing)
|
|
82
90
|
return @@logo_cache[cache_key] if @@logo_cache.key?(cache_key)
|
|
83
|
-
|
|
91
|
+
|
|
84
92
|
# Build file path
|
|
85
93
|
logo_path = File.join(Dir.pwd, 'node_modules', 'ultimate-jekyll-manager', 'assets', 'logos', type, color, "#{logo_name}.svg")
|
|
86
|
-
|
|
94
|
+
|
|
87
95
|
# Try to load the logo
|
|
88
96
|
logo_svg = if File.exist?(logo_path)
|
|
89
97
|
File.read(logo_path)
|
|
90
98
|
else
|
|
91
99
|
DEFAULT_LOGO
|
|
92
100
|
end
|
|
93
|
-
|
|
94
|
-
# Cache the result
|
|
101
|
+
|
|
102
|
+
# Cache the raw result (before prefixing)
|
|
95
103
|
@@logo_cache[cache_key] = logo_svg
|
|
96
104
|
return logo_svg
|
|
97
105
|
end
|
|
106
|
+
|
|
107
|
+
# Prefix all IDs in an SVG with the logo name to prevent conflicts
|
|
108
|
+
# when multiple SVGs are inlined on the same page
|
|
109
|
+
def prefix_svg_ids(svg_content, prefix)
|
|
110
|
+
# Find all id attributes in the SVG
|
|
111
|
+
ids = svg_content.scan(/\bid=["']([^"']+)["']/).flatten.uniq
|
|
112
|
+
|
|
113
|
+
return svg_content if ids.empty?
|
|
114
|
+
|
|
115
|
+
result = svg_content.dup
|
|
116
|
+
|
|
117
|
+
ids.each do |id|
|
|
118
|
+
new_id = "#{prefix}-#{id}"
|
|
119
|
+
|
|
120
|
+
# Replace id definitions: id="X" and id='X'
|
|
121
|
+
result.gsub!(/\bid=(["'])#{Regexp.escape(id)}\1/, "id=\"#{new_id}\"")
|
|
122
|
+
|
|
123
|
+
# Replace url() references: url(#X) and url('#X') and url("#X")
|
|
124
|
+
result.gsub!(/url\(\s*##{Regexp.escape(id)}\s*\)/, "url(##{new_id})")
|
|
125
|
+
result.gsub!(/url\(\s*["']##{Regexp.escape(id)}["']\s*\)/, "url(##{new_id})")
|
|
126
|
+
|
|
127
|
+
# Replace xlink:href references: xlink:href="#X"
|
|
128
|
+
result.gsub!(/xlink:href=["']##{Regexp.escape(id)}["']/, "xlink:href=\"##{new_id}\"")
|
|
129
|
+
|
|
130
|
+
# Replace x:href references (custom namespace, convert to standard href): x:href="#X"
|
|
131
|
+
result.gsub!(/x:href=["']##{Regexp.escape(id)}["']/, "href=\"##{new_id}\"")
|
|
132
|
+
|
|
133
|
+
# Replace href references (modern SVG): href="#X"
|
|
134
|
+
result.gsub!(/\bhref=["']##{Regexp.escape(id)}["']/, "href=\"##{new_id}\"")
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
result
|
|
138
|
+
end
|
|
98
139
|
end
|
|
99
140
|
end
|
|
100
141
|
|
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.
|
|
4
|
+
version: 1.6.24
|
|
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-12-
|
|
11
|
+
date: 2025-12-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jekyll
|