jekyll-uj-powertools 1.5.2 → 1.6.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 +4 -4
- data/README.md +113 -4
- data/jekyll-uj-powertools.gemspec +2 -1
- data/lib/filters/main.rb +37 -19
- data/lib/generators/inject-properties.rb +29 -7
- data/lib/hooks/inject-properties.rb +10 -0
- data/lib/hooks/markdown-images.rb +40 -0
- data/lib/jekyll-uj-powertools.rb +12 -1
- data/lib/tags/fake_comments.rb +72 -0
- data/lib/tags/icon.rb +262 -0
- data/lib/tags/iffalsy.rb +38 -0
- data/lib/tags/iftruthy.rb +38 -0
- data/lib/tags/image.rb +208 -0
- data/lib/tags/language.rb +301 -0
- data/lib/tags/member.rb +204 -0
- data/lib/tags/post.rb +258 -0
- data/lib/tags/readtime.rb +73 -0
- data/lib/tags/social.rb +84 -0
- data/lib/tags/translation_url.rb +154 -0
- metadata +28 -3
- data/lib/tags/ifistruthy.rb +0 -161
@@ -0,0 +1,301 @@
|
|
1
|
+
# Libraries
|
2
|
+
require "jekyll"
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
class UJLanguageTag < Liquid::Tag
|
6
|
+
# Language mappings: ISO code => [English name, Native name]
|
7
|
+
LANGUAGE_MAPPINGS = {
|
8
|
+
'aa' => ['Afar', 'Afaraf'],
|
9
|
+
'ab' => ['Abkhazian', 'аҧсуа бызшәа'],
|
10
|
+
'ae' => ['Avestan', 'avesta'],
|
11
|
+
'af' => ['Afrikaans', 'Afrikaans'],
|
12
|
+
'ak' => ['Akan', 'Akan'],
|
13
|
+
'am' => ['Amharic', 'አማርኛ'],
|
14
|
+
'an' => ['Aragonese', 'aragonés'],
|
15
|
+
'ar' => ['Arabic', 'العربية'],
|
16
|
+
'as' => ['Assamese', 'অসমীয়া'],
|
17
|
+
'av' => ['Avaric', 'авар мацӀ'],
|
18
|
+
'ay' => ['Aymara', 'aymar aru'],
|
19
|
+
'az' => ['Azerbaijani', 'azərbaycan dili'],
|
20
|
+
'ba' => ['Bashkir', 'башҡорт теле'],
|
21
|
+
'be' => ['Belarusian', 'беларуская мова'],
|
22
|
+
'bg' => ['Bulgarian', 'български език'],
|
23
|
+
'bh' => ['Bihari languages', 'भोजपुरी'],
|
24
|
+
'bi' => ['Bislama', 'Bislama'],
|
25
|
+
'bm' => ['Bambara', 'bamanankan'],
|
26
|
+
'bn' => ['Bengali', 'বাংলা'],
|
27
|
+
'bo' => ['Tibetan', 'བོད་ཡིག'],
|
28
|
+
'br' => ['Breton', 'brezhoneg'],
|
29
|
+
'bs' => ['Bosnian', 'bosanski jezik'],
|
30
|
+
'ca' => ['Catalan', 'català'],
|
31
|
+
'ce' => ['Chechen', 'нохчийн мотт'],
|
32
|
+
'ch' => ['Chamorro', 'Chamoru'],
|
33
|
+
'co' => ['Corsican', 'corsu'],
|
34
|
+
'cr' => ['Cree', 'ᓀᐦᐃᔭᐍᐏᐣ'],
|
35
|
+
'cs' => ['Czech', 'čeština'],
|
36
|
+
'cu' => ['Church Slavic', 'ѩзыкъ словѣньскъ'],
|
37
|
+
'cv' => ['Chuvash', 'чӑваш чӗлхи'],
|
38
|
+
'cy' => ['Welsh', 'Cymraeg'],
|
39
|
+
'da' => ['Danish', 'dansk'],
|
40
|
+
'de' => ['German', 'Deutsch'],
|
41
|
+
'dv' => ['Divehi', 'ދިވެހި'],
|
42
|
+
'dz' => ['Dzongkha', 'རྫོང་ཁ'],
|
43
|
+
'ee' => ['Ewe', 'Eʋegbe'],
|
44
|
+
'el' => ['Greek', 'ελληνικά'],
|
45
|
+
'en' => ['English', 'English'],
|
46
|
+
'eo' => ['Esperanto', 'Esperanto'],
|
47
|
+
'es' => ['Spanish', 'español'],
|
48
|
+
'et' => ['Estonian', 'eesti'],
|
49
|
+
'eu' => ['Basque', 'euskera'],
|
50
|
+
'fa' => ['Persian', 'فارسی'],
|
51
|
+
'ff' => ['Fulah', 'Fulfulde'],
|
52
|
+
'fi' => ['Finnish', 'suomi'],
|
53
|
+
'fj' => ['Fijian', 'vosa Vakaviti'],
|
54
|
+
'fo' => ['Faroese', 'føroyskt'],
|
55
|
+
'fr' => ['French', 'français'],
|
56
|
+
'fy' => ['Western Frisian', 'Frysk'],
|
57
|
+
'ga' => ['Irish', 'Gaeilge'],
|
58
|
+
'gd' => ['Gaelic', 'Gàidhlig'],
|
59
|
+
'gl' => ['Galician', 'galego'],
|
60
|
+
'gn' => ['Guarani', 'Avañe\'ẽ'],
|
61
|
+
'gu' => ['Gujarati', 'ગુજરાતી'],
|
62
|
+
'gv' => ['Manx', 'Gaelg'],
|
63
|
+
'ha' => ['Hausa', 'هَوُسَ'],
|
64
|
+
'he' => ['Hebrew', 'עברית'],
|
65
|
+
'hi' => ['Hindi', 'हिन्दी'],
|
66
|
+
'ho' => ['Hiri Motu', 'Hiri Motu'],
|
67
|
+
'hr' => ['Croatian', 'hrvatski jezik'],
|
68
|
+
'ht' => ['Haitian', 'Kreyòl ayisyen'],
|
69
|
+
'hu' => ['Hungarian', 'magyar'],
|
70
|
+
'hy' => ['Armenian', 'Հայերեն'],
|
71
|
+
'hz' => ['Herero', 'Otjiherero'],
|
72
|
+
'ia' => ['Interlingua', 'Interlingua'],
|
73
|
+
'id' => ['Indonesian', 'Bahasa Indonesia'],
|
74
|
+
'ie' => ['Interlingue', 'Interlingue'],
|
75
|
+
'ig' => ['Igbo', 'Asụsụ Igbo'],
|
76
|
+
'ii' => ['Nuosu', 'ꆈꌠ꒿ Nuosuhxop'],
|
77
|
+
'ik' => ['Inupiaq', 'Iñupiaq'],
|
78
|
+
'io' => ['Ido', 'Ido'],
|
79
|
+
'is' => ['Icelandic', 'Íslenska'],
|
80
|
+
'it' => ['Italian', 'italiano'],
|
81
|
+
'iu' => ['Inuktitut', 'ᐃᓄᒃᑎᑐᑦ'],
|
82
|
+
'ja' => ['Japanese', '日本語'],
|
83
|
+
'jv' => ['Javanese', 'basa Jawa'],
|
84
|
+
'ka' => ['Georgian', 'ქართული'],
|
85
|
+
'kg' => ['Kongo', 'Kikongo'],
|
86
|
+
'ki' => ['Kikuyu', 'Gĩkũyũ'],
|
87
|
+
'kj' => ['Kwanyama', 'Kuanyama'],
|
88
|
+
'kk' => ['Kazakh', 'қазақ тілі'],
|
89
|
+
'kl' => ['Kalaallisut', 'kalaallisut'],
|
90
|
+
'km' => ['Khmer', 'ខ្មែរ'],
|
91
|
+
'kn' => ['Kannada', 'ಕನ್ನಡ'],
|
92
|
+
'ko' => ['Korean', '한국어'],
|
93
|
+
'kr' => ['Kanuri', 'Kanuri'],
|
94
|
+
'ks' => ['Kashmiri', 'कश्मीरी'],
|
95
|
+
'ku' => ['Kurdish', 'Kurdî'],
|
96
|
+
'kv' => ['Komi', 'коми кыв'],
|
97
|
+
'kw' => ['Cornish', 'Kernewek'],
|
98
|
+
'ky' => ['Kirghiz', 'Кыргызча'],
|
99
|
+
'la' => ['Latin', 'latine'],
|
100
|
+
'lb' => ['Luxembourgish', 'Lëtzebuergesch'],
|
101
|
+
'lg' => ['Ganda', 'Luganda'],
|
102
|
+
'li' => ['Limburgish', 'Limburgs'],
|
103
|
+
'ln' => ['Lingala', 'Lingála'],
|
104
|
+
'lo' => ['Lao', 'ພາສາລາວ'],
|
105
|
+
'lt' => ['Lithuanian', 'lietuvių kalba'],
|
106
|
+
'lu' => ['Luba-Katanga', 'Tshiluba'],
|
107
|
+
'lv' => ['Latvian', 'latviešu valoda'],
|
108
|
+
'mg' => ['Malagasy', 'fiteny malagasy'],
|
109
|
+
'mh' => ['Marshallese', 'Kajin M̧ajeļ'],
|
110
|
+
'mi' => ['Māori', 'te reo Māori'],
|
111
|
+
'mk' => ['Macedonian', 'македонски јазик'],
|
112
|
+
'ml' => ['Malayalam', 'മലയാളം'],
|
113
|
+
'mn' => ['Mongolian', 'Монгол хэл'],
|
114
|
+
'mr' => ['Marathi', 'मराठी'],
|
115
|
+
'ms' => ['Malay', 'bahasa Melayu'],
|
116
|
+
'mt' => ['Maltese', 'Malti'],
|
117
|
+
'my' => ['Burmese', 'ဗမာစာ'],
|
118
|
+
'na' => ['Nauru', 'Dorerin Naoero'],
|
119
|
+
'nb' => ['Norwegian Bokmål', 'Norsk bokmål'],
|
120
|
+
'nd' => ['North Ndebele', 'isiNdebele'],
|
121
|
+
'ne' => ['Nepali', 'नेपाली'],
|
122
|
+
'ng' => ['Ndonga', 'Owambo'],
|
123
|
+
'nl' => ['Dutch', 'Nederlands'],
|
124
|
+
'nn' => ['Norwegian Nynorsk', 'Norsk nynorsk'],
|
125
|
+
'no' => ['Norwegian', 'Norsk'],
|
126
|
+
'nr' => ['South Ndebele', 'isiNdebele'],
|
127
|
+
'nv' => ['Navajo', 'Diné bizaad'],
|
128
|
+
'ny' => ['Chichewa', 'chiCheŵa'],
|
129
|
+
'oc' => ['Occitan', 'occitan'],
|
130
|
+
'oj' => ['Ojibwa', 'ᐊᓂᔑᓈᐯᒧᐎᓐ'],
|
131
|
+
'om' => ['Oromo', 'Afaan Oromoo'],
|
132
|
+
'or' => ['Oriya', 'ଓଡ଼ିଆ'],
|
133
|
+
'os' => ['Ossetian', 'ирон æвзаг'],
|
134
|
+
'pa' => ['Panjabi', 'ਪੰਜਾਬੀ'],
|
135
|
+
'pi' => ['Pāli', 'पाऴि'],
|
136
|
+
'pl' => ['Polish', 'język polski'],
|
137
|
+
'ps' => ['Pashto', 'پښتو'],
|
138
|
+
'pt' => ['Portuguese', 'português'],
|
139
|
+
'qu' => ['Quechua', 'Runa Simi'],
|
140
|
+
'rm' => ['Romansh', 'rumantsch grischun'],
|
141
|
+
'rn' => ['Kirundi', 'Ikirundi'],
|
142
|
+
'ro' => ['Romanian', 'română'],
|
143
|
+
'ru' => ['Russian', 'русский'],
|
144
|
+
'rw' => ['Kinyarwanda', 'Ikinyarwanda'],
|
145
|
+
'sa' => ['Sanskrit', 'संस्कृतम्'],
|
146
|
+
'sc' => ['Sardinian', 'sardu'],
|
147
|
+
'sd' => ['Sindhi', 'सिन्धी'],
|
148
|
+
'se' => ['Northern Sami', 'Davvisámegiella'],
|
149
|
+
'sg' => ['Sango', 'yângâ tî sängö'],
|
150
|
+
'si' => ['Sinhala', 'සිංහල'],
|
151
|
+
'sk' => ['Slovak', 'slovenčina'],
|
152
|
+
'sl' => ['Slovene', 'slovenski jezik'],
|
153
|
+
'sm' => ['Samoan', 'gagana fa\'a Samoa'],
|
154
|
+
'sn' => ['Shona', 'chiShona'],
|
155
|
+
'so' => ['Somali', 'Soomaaliga'],
|
156
|
+
'sq' => ['Albanian', 'gjuha shqipe'],
|
157
|
+
'sr' => ['Serbian', 'српски језик'],
|
158
|
+
'ss' => ['Swati', 'SiSwati'],
|
159
|
+
'st' => ['Southern Sotho', 'Sesotho'],
|
160
|
+
'su' => ['Sundanese', 'Basa Sunda'],
|
161
|
+
'sv' => ['Swedish', 'svenska'],
|
162
|
+
'sw' => ['Swahili', 'Kiswahili'],
|
163
|
+
'ta' => ['Tamil', 'தமிழ்'],
|
164
|
+
'te' => ['Telugu', 'తెలుగు'],
|
165
|
+
'tg' => ['Tajik', 'тоҷикӣ'],
|
166
|
+
'th' => ['Thai', 'ไทย'],
|
167
|
+
'ti' => ['Tigrinya', 'ትግርኛ'],
|
168
|
+
'tk' => ['Turkmen', 'Türkmen'],
|
169
|
+
'tl' => ['Tagalog', 'Wikang Tagalog'],
|
170
|
+
'tn' => ['Tswana', 'Setswana'],
|
171
|
+
'to' => ['Tonga', 'faka Tonga'],
|
172
|
+
'tr' => ['Turkish', 'Türkçe'],
|
173
|
+
'ts' => ['Tsonga', 'Xitsonga'],
|
174
|
+
'tt' => ['Tatar', 'татар теле'],
|
175
|
+
'tw' => ['Twi', 'Twi'],
|
176
|
+
'ty' => ['Tahitian', 'Reo Tahiti'],
|
177
|
+
'ug' => ['Uighur', 'ئۇيغۇرچە'],
|
178
|
+
'uk' => ['Ukrainian', 'українська мова'],
|
179
|
+
'ur' => ['Urdu', 'اردو'],
|
180
|
+
'uz' => ['Uzbek', 'Oʻzbek'],
|
181
|
+
've' => ['Venda', 'Tshivenḓa'],
|
182
|
+
'vi' => ['Vietnamese', 'Tiếng Việt'],
|
183
|
+
'vo' => ['Volapük', 'Volapük'],
|
184
|
+
'wa' => ['Walloon', 'walon'],
|
185
|
+
'wo' => ['Wolof', 'Wollof'],
|
186
|
+
'xh' => ['Xhosa', 'isiXhosa'],
|
187
|
+
'yi' => ['Yiddish', 'ייִדיש'],
|
188
|
+
'yo' => ['Yoruba', 'Yorùbá'],
|
189
|
+
'za' => ['Zhuang', 'Saɯ cueŋƅ'],
|
190
|
+
'zh' => ['Chinese', '中文'],
|
191
|
+
'zu' => ['Zulu', 'isiZulu']
|
192
|
+
}
|
193
|
+
|
194
|
+
def initialize(tag_name, markup, tokens)
|
195
|
+
super
|
196
|
+
@markup = markup.strip
|
197
|
+
end
|
198
|
+
|
199
|
+
def render(context)
|
200
|
+
# Parse arguments that can be quoted or unquoted
|
201
|
+
parts = parse_arguments(@markup)
|
202
|
+
iso_code_input = parts[0]
|
203
|
+
output_type = parts[1] || 'english' # default to english
|
204
|
+
|
205
|
+
# Check if the input was originally quoted (literal string)
|
206
|
+
is_quoted = @markup.strip.match(/^['"]/)
|
207
|
+
|
208
|
+
# If quoted, use as literal. Otherwise, try to resolve as variable
|
209
|
+
if is_quoted
|
210
|
+
iso_code = iso_code_input
|
211
|
+
else
|
212
|
+
# Try to resolve as a variable
|
213
|
+
iso_code = resolve_variable(context, iso_code_input)
|
214
|
+
# If it didn't resolve to a string, use the input as literal
|
215
|
+
iso_code = iso_code_input if iso_code.nil? || !iso_code.is_a?(String)
|
216
|
+
end
|
217
|
+
|
218
|
+
# Strip quotes from resolved iso code if present
|
219
|
+
if iso_code.is_a?(String) && iso_code.match(/^['"].*['"]$/)
|
220
|
+
iso_code = iso_code[1..-2]
|
221
|
+
end
|
222
|
+
|
223
|
+
# Strip quotes from output type if present
|
224
|
+
if output_type.is_a?(String) && output_type.match(/^['"].*['"]$/)
|
225
|
+
output_type = output_type[1..-2]
|
226
|
+
end
|
227
|
+
|
228
|
+
# Convert to lowercase for lookup
|
229
|
+
iso_code = iso_code.to_s.downcase
|
230
|
+
output_type = output_type.to_s.downcase
|
231
|
+
|
232
|
+
# Look up the language
|
233
|
+
language_data = LANGUAGE_MAPPINGS[iso_code]
|
234
|
+
return iso_code if language_data.nil? # Return original code if not found
|
235
|
+
|
236
|
+
# Return appropriate language name based on output type
|
237
|
+
case output_type
|
238
|
+
when 'native'
|
239
|
+
language_data[1] # Native name
|
240
|
+
else
|
241
|
+
language_data[0] # English name (default)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
private
|
246
|
+
|
247
|
+
def parse_arguments(markup)
|
248
|
+
# Parse arguments that can be quoted or unquoted
|
249
|
+
# Examples: de, english OR 'de', 'english' OR myVar, "native"
|
250
|
+
args = []
|
251
|
+
current_arg = ''
|
252
|
+
in_quotes = false
|
253
|
+
quote_char = nil
|
254
|
+
|
255
|
+
markup.each_char.with_index do |char, i|
|
256
|
+
if !in_quotes && (char == '"' || char == "'")
|
257
|
+
# Start of quoted string
|
258
|
+
in_quotes = true
|
259
|
+
quote_char = char
|
260
|
+
elsif in_quotes && char == quote_char
|
261
|
+
# End of quoted string
|
262
|
+
in_quotes = false
|
263
|
+
quote_char = nil
|
264
|
+
elsif !in_quotes && char == ','
|
265
|
+
# Argument separator
|
266
|
+
args << current_arg.strip
|
267
|
+
current_arg = ''
|
268
|
+
else
|
269
|
+
# Regular character
|
270
|
+
current_arg += char
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
# Add the last argument
|
275
|
+
args << current_arg.strip if current_arg.strip.length > 0
|
276
|
+
|
277
|
+
args
|
278
|
+
end
|
279
|
+
|
280
|
+
def resolve_variable(context, variable_name)
|
281
|
+
# Handle nested variable access like page.language
|
282
|
+
parts = variable_name.split('.')
|
283
|
+
current = context
|
284
|
+
|
285
|
+
parts.each do |part|
|
286
|
+
if current.respond_to?(:[])
|
287
|
+
current = current[part]
|
288
|
+
elsif current.respond_to?(:key?) && current.key?(part)
|
289
|
+
current = current[part]
|
290
|
+
else
|
291
|
+
return nil
|
292
|
+
end
|
293
|
+
return nil if current.nil?
|
294
|
+
end
|
295
|
+
|
296
|
+
current
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
Liquid::Template.register_tag('uj_language', Jekyll::UJLanguageTag)
|
data/lib/tags/member.rb
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
# Libraries
|
2
|
+
require "jekyll"
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
class UJMemberTag < Liquid::Tag
|
6
|
+
def initialize(tag_name, markup, tokens)
|
7
|
+
super
|
8
|
+
@markup = markup.strip
|
9
|
+
end
|
10
|
+
|
11
|
+
def render(context)
|
12
|
+
# Parse arguments preserving quotes
|
13
|
+
args = parse_arguments_with_quotes(@markup)
|
14
|
+
member_input = args[0]
|
15
|
+
property_input = args[1] || "'name'" # Default to name if no property specified
|
16
|
+
|
17
|
+
# Strip quotes from property if present
|
18
|
+
property = property_input.gsub(/^['"]|['"]$/, '')
|
19
|
+
|
20
|
+
# Check if the member input was originally quoted
|
21
|
+
is_quoted = member_input && member_input.match(/^['"]/)
|
22
|
+
|
23
|
+
# Resolve member ID
|
24
|
+
if is_quoted
|
25
|
+
# If quoted, strip quotes and use as literal
|
26
|
+
member_id = member_input.gsub(/^['"]|['"]$/, '')
|
27
|
+
else
|
28
|
+
# Otherwise resolve as variable
|
29
|
+
member_id = resolve_member_id(context, member_input)
|
30
|
+
end
|
31
|
+
return '' unless member_id
|
32
|
+
|
33
|
+
# Find member in site.team collection
|
34
|
+
site = context.registers[:site]
|
35
|
+
member = find_member(site, member_id)
|
36
|
+
return '' unless member
|
37
|
+
|
38
|
+
# Return the requested property
|
39
|
+
case property
|
40
|
+
when 'name'
|
41
|
+
(member.data['member'] && member.data['member']['name']) || ''
|
42
|
+
when 'url'
|
43
|
+
site_url = site.config['url'] || ''
|
44
|
+
site_url + member.url
|
45
|
+
when 'path'
|
46
|
+
member.url
|
47
|
+
when 'image'
|
48
|
+
member_id_clean = member.id.gsub('/team/', '')
|
49
|
+
"/assets/images/team/#{member_id_clean}/profile.jpg"
|
50
|
+
when 'image-tag'
|
51
|
+
# Generate image path
|
52
|
+
member_id_clean = member.id.gsub('/team/', '')
|
53
|
+
image_path = "/assets/images/team/#{member_id_clean}/profile.jpg"
|
54
|
+
|
55
|
+
# Parse additional options for the image tag
|
56
|
+
image_options = parse_image_options(args[2..-1])
|
57
|
+
|
58
|
+
# Set default alt text if not provided
|
59
|
+
if !image_options['alt'] && member.data['member'] && member.data['member']['name']
|
60
|
+
image_options['alt'] = member.data['member']['name']
|
61
|
+
end
|
62
|
+
|
63
|
+
# Build the markup string for uj_image tag
|
64
|
+
image_markup = build_image_markup(image_path, image_options)
|
65
|
+
|
66
|
+
# Parse and render the uj_image tag using Liquid template
|
67
|
+
template_content = "{% uj_image #{image_markup} %}"
|
68
|
+
template = Liquid::Template.parse(template_content)
|
69
|
+
template.render!(context)
|
70
|
+
else
|
71
|
+
# Try to access any other property dynamically
|
72
|
+
(member.data['member'] && member.data['member'][property]) || member.data[property] || ''
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def parse_arguments_with_quotes(markup)
|
79
|
+
# Parse arguments preserving quotes for detection
|
80
|
+
args = []
|
81
|
+
current_arg = ''
|
82
|
+
in_quotes = false
|
83
|
+
quote_char = nil
|
84
|
+
|
85
|
+
markup.each_char.with_index do |char, i|
|
86
|
+
if !in_quotes && (char == '"' || char == "'")
|
87
|
+
in_quotes = true
|
88
|
+
quote_char = char
|
89
|
+
current_arg += char
|
90
|
+
elsif in_quotes && char == quote_char
|
91
|
+
in_quotes = false
|
92
|
+
current_arg += char
|
93
|
+
quote_char = nil
|
94
|
+
elsif !in_quotes && char == ','
|
95
|
+
args << current_arg.strip
|
96
|
+
current_arg = ''
|
97
|
+
else
|
98
|
+
current_arg += char
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
args << current_arg.strip if current_arg.strip.length > 0
|
103
|
+
args
|
104
|
+
end
|
105
|
+
|
106
|
+
def parse_arguments(markup)
|
107
|
+
# Parse arguments that can be quoted or unquoted
|
108
|
+
args = []
|
109
|
+
current_arg = ''
|
110
|
+
in_quotes = false
|
111
|
+
quote_char = nil
|
112
|
+
|
113
|
+
markup.each_char.with_index do |char, i|
|
114
|
+
if !in_quotes && (char == '"' || char == "'")
|
115
|
+
in_quotes = true
|
116
|
+
quote_char = char
|
117
|
+
elsif in_quotes && char == quote_char
|
118
|
+
in_quotes = false
|
119
|
+
quote_char = nil
|
120
|
+
elsif !in_quotes && char == ','
|
121
|
+
args << current_arg.strip
|
122
|
+
current_arg = ''
|
123
|
+
else
|
124
|
+
current_arg += char
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
args << current_arg.strip if current_arg.strip.length > 0
|
129
|
+
args
|
130
|
+
end
|
131
|
+
|
132
|
+
def resolve_member_id(context, member_input)
|
133
|
+
if member_input.nil? || member_input.empty?
|
134
|
+
# No input, try default sources
|
135
|
+
page = context['page']
|
136
|
+
return nil unless page
|
137
|
+
|
138
|
+
if page['post'] && page['post']['member']
|
139
|
+
page['post']['member']
|
140
|
+
elsif page['member'] && page['member']['name']
|
141
|
+
page['id']
|
142
|
+
else
|
143
|
+
nil
|
144
|
+
end
|
145
|
+
else
|
146
|
+
# Resolve the variable
|
147
|
+
resolve_variable(context, member_input)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def resolve_variable(context, variable_name)
|
152
|
+
# Handle nested variable access
|
153
|
+
parts = variable_name.split('.')
|
154
|
+
current = context
|
155
|
+
|
156
|
+
parts.each do |part|
|
157
|
+
return nil unless current.respond_to?(:[]) || current.is_a?(Hash)
|
158
|
+
current = current[part]
|
159
|
+
return nil if current.nil?
|
160
|
+
end
|
161
|
+
|
162
|
+
current
|
163
|
+
end
|
164
|
+
|
165
|
+
def find_member(site, member_id)
|
166
|
+
return nil unless site.collections['team']
|
167
|
+
|
168
|
+
site.collections['team'].docs.find do |member|
|
169
|
+
member.id.include?(member_id.to_s)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def parse_image_options(option_args)
|
174
|
+
options = {}
|
175
|
+
|
176
|
+
option_args.each do |arg|
|
177
|
+
# Strip quotes if present
|
178
|
+
arg_clean = arg.gsub(/^['"]|['"]$/, '')
|
179
|
+
|
180
|
+
if arg_clean.include?('=')
|
181
|
+
key, value = arg_clean.split('=', 2)
|
182
|
+
key = key.strip
|
183
|
+
value = value.strip.gsub(/^['"]|['"]$/, '')
|
184
|
+
options[key] = value
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
options
|
189
|
+
end
|
190
|
+
|
191
|
+
def build_image_markup(image_path, options)
|
192
|
+
# Build markup string in the format expected by uj_image tag
|
193
|
+
markup_parts = ["\"#{image_path}\""]
|
194
|
+
|
195
|
+
options.each do |key, value|
|
196
|
+
markup_parts << "#{key}=\"#{value}\""
|
197
|
+
end
|
198
|
+
|
199
|
+
markup_parts.join(', ')
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
Liquid::Template.register_tag('uj_member', Jekyll::UJMemberTag)
|