jekyll-webawesome 0.5.2 → 0.5.4
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/CHANGELOG.md +15 -0
- data/README.md +18 -19
- data/lib/jekyll/webawesome/plugin.rb +27 -0
- data/lib/jekyll/webawesome/transformer.rb +1 -1
- data/lib/jekyll/webawesome/transformers/dialog_transformer.rb +12 -9
- data/lib/jekyll/webawesome/transformers/image_dialog_transformer.rb +15 -6
- data/lib/jekyll/webawesome/version.rb +1 -1
- data/lib/jekyll/webawesome.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4151360850db59b840cd6c2fa516b04e34d35bbb801267a2db536fd7ef7220b0
|
|
4
|
+
data.tar.gz: a80f3fcdf769f017376b7efac94a94370efc8659124f4f06c44eefbae7a46596
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bfb4e8b772c1ccfb06a576689cb3fc6cdfd73039feffb6bd665df066f3d6b396ae39acb6d8239d25e82f6e414210e6b41c6982155d6001b1ea5dbbf075ef918e
|
|
7
|
+
data.tar.gz: d13ced83c839e51da9e6a4d20485d32301adba87ae5ade88371e3308d34b626af96f899a5ccfef4de0f7c960f6fc597a7ce967932250979b5289f457bc5efa1f
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
|
8
8
|
|
|
9
9
|
- Placeholder
|
|
10
10
|
|
|
11
|
+
## [0.5.4] - 2025-10-20
|
|
12
|
+
|
|
13
|
+
- Support for default width for the image_dialog like
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
webawesome:
|
|
17
|
+
image_dialog:
|
|
18
|
+
enabled: true
|
|
19
|
+
default_width: 90vh
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## [0.5.3] - 2025-10-20
|
|
23
|
+
|
|
24
|
+
- Always have a header with X button on the dialogs
|
|
25
|
+
|
|
11
26
|
## [0.5.2] - 2025-10-20
|
|
12
27
|
|
|
13
28
|
- Fix the image dialog auto-transformation feature protection again
|
data/README.md
CHANGED
|
@@ -69,7 +69,13 @@ webawesome:
|
|
|
69
69
|
transform_documents: true # Transform documents (like blog posts in _posts)
|
|
70
70
|
|
|
71
71
|
# Enable automatic image-to-dialog transformation (default: false)
|
|
72
|
+
# Can be a simple boolean
|
|
72
73
|
image_dialog: true # Makes all images clickable and open in dialogs
|
|
74
|
+
|
|
75
|
+
# Or a hash with options for more control
|
|
76
|
+
image_dialog:
|
|
77
|
+
enabled: true # Enable the feature
|
|
78
|
+
default_width: 90vh # Default width for dialogs (e.g., 90vh, 80%, 1200px)
|
|
73
79
|
```
|
|
74
80
|
|
|
75
81
|
And then execute:
|
|
@@ -387,16 +393,6 @@ Click outside to close this dialog.
|
|
|
387
393
|
???
|
|
388
394
|
```
|
|
389
395
|
|
|
390
|
-
**Without Header** - Remove the dialog header entirely:
|
|
391
|
-
|
|
392
|
-
```markdown
|
|
393
|
-
???without-header
|
|
394
|
-
Open Dialog
|
|
395
|
-
>>>
|
|
396
|
-
This dialog has no header.
|
|
397
|
-
???
|
|
398
|
-
```
|
|
399
|
-
|
|
400
396
|
**Custom Width** - Set a specific width using CSS units (px, em, rem, vw, vh, %):
|
|
401
397
|
|
|
402
398
|
```markdown
|
|
@@ -428,15 +424,9 @@ Open Dialog
|
|
|
428
424
|
# Custom Dialog
|
|
429
425
|
This dialog has light dismiss enabled and is 700px wide.
|
|
430
426
|
???
|
|
431
|
-
|
|
432
|
-
???without-header light-dismiss 45em
|
|
433
|
-
Open Simple Dialog
|
|
434
|
-
>>>
|
|
435
|
-
This dialog has no header, light dismiss, and is 45em wide.
|
|
436
|
-
???
|
|
437
427
|
```
|
|
438
428
|
|
|
439
|
-
> **Note**: The dialog uses Web Awesome's declarative `data-dialog` API, so no custom JavaScript is needed. Each dialog gets a unique ID automatically generated from its content, and a
|
|
429
|
+
> **Note**: The dialog uses Web Awesome's declarative `data-dialog` API, so no custom JavaScript is needed. Each dialog gets a unique ID automatically generated from its content. The header with X close button is always shown for accessibility, and a "Close" button is automatically added to the footer.
|
|
440
430
|
|
|
441
431
|
### Details/Summary (Collapsible Content)
|
|
442
432
|
|
|
@@ -621,12 +611,12 @@ Cards automatically parse content into these slots:
|
|
|
621
611
|
| Option | Description |
|
|
622
612
|
|--------|-------------|
|
|
623
613
|
| `light-dismiss` | Dialog closes when clicking outside/on overlay |
|
|
624
|
-
| `without-header` | Removes the dialog header entirely |
|
|
625
614
|
| Width (e.g., `500px`, `50vw`, `40em`) | Sets custom width using CSS units (px, em, rem, vw, vh, %) |
|
|
626
615
|
|
|
627
616
|
### Dialog Features
|
|
628
617
|
|
|
629
618
|
- **Automatic ID Generation**: Each dialog gets a unique ID based on MD5 hash of its content
|
|
619
|
+
- **Header with X Button**: The header with X close button is always shown for accessibility
|
|
630
620
|
- **Auto-close Button**: A "Close" button is automatically added to the footer
|
|
631
621
|
- **Declarative API**: Uses Web Awesome's `data-dialog` attributes - no custom JavaScript needed
|
|
632
622
|
- **Label Extraction**: First `#` heading becomes the dialog label, or button text is used as fallback
|
|
@@ -638,7 +628,13 @@ Enable automatic image-to-dialog transformation in your `_config.yml`:
|
|
|
638
628
|
|
|
639
629
|
```yaml
|
|
640
630
|
webawesome:
|
|
631
|
+
# Simple boolean to enable
|
|
641
632
|
image_dialog: true
|
|
633
|
+
|
|
634
|
+
# Or configure with options
|
|
635
|
+
image_dialog:
|
|
636
|
+
enabled: true
|
|
637
|
+
default_width: 90vh # Default width for all image dialogs
|
|
642
638
|
```
|
|
643
639
|
|
|
644
640
|
When enabled, all markdown images automatically become clickable and open in full-size dialogs:
|
|
@@ -647,7 +643,9 @@ When enabled, all markdown images automatically become clickable and open in ful
|
|
|
647
643
|

|
|
648
644
|
```
|
|
649
645
|
|
|
650
|
-
**
|
|
646
|
+
**Default Width**: Set a default width for all image dialogs in the configuration. Images will use this width unless overridden in the title.
|
|
647
|
+
|
|
648
|
+
**Control dialog width** by adding a width parameter to the title (overrides default):
|
|
651
649
|
|
|
652
650
|
```markdown
|
|
653
651
|
 # Dialog width: 50%
|
|
@@ -667,6 +665,7 @@ Supported width units: `px`, `em`, `rem`, `vw`, `vh`, `%`, `ch`
|
|
|
667
665
|
|
|
668
666
|
- Light-dismiss and headerless dialogs for clean UX
|
|
669
667
|
- Thumbnail displays at original size, dialog shows full-size
|
|
668
|
+
- Configurable default width for consistent sizing
|
|
670
669
|
|
|
671
670
|
### Tab Placements
|
|
672
671
|
|
|
@@ -52,6 +52,33 @@ module Jekyll
|
|
|
52
52
|
false
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
# Get image dialog configuration with default width support
|
|
56
|
+
def self.image_dialog_config(site)
|
|
57
|
+
config = {}
|
|
58
|
+
|
|
59
|
+
# First check if it's enabled
|
|
60
|
+
enabled_config = nil
|
|
61
|
+
if Jekyll::WebAwesome.configuration
|
|
62
|
+
enabled_config = Jekyll::WebAwesome.configuration.image_dialog
|
|
63
|
+
elsif site.config.dig('webawesome', 'image_dialog') != nil
|
|
64
|
+
enabled_config = site.config.dig('webawesome', 'image_dialog')
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# If disabled or not set, return empty config
|
|
68
|
+
return config unless enabled_config
|
|
69
|
+
|
|
70
|
+
# If it's a boolean true, set enabled
|
|
71
|
+
if enabled_config == true
|
|
72
|
+
config[:enabled] = true
|
|
73
|
+
# If it's a hash, merge it
|
|
74
|
+
elsif enabled_config.is_a?(Hash)
|
|
75
|
+
config = enabled_config.transform_keys(&:to_sym)
|
|
76
|
+
config[:enabled] = true unless config.key?(:enabled)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
config
|
|
80
|
+
end
|
|
81
|
+
|
|
55
82
|
# Check if a file is a markdown file
|
|
56
83
|
def self.markdown_file?(filepath)
|
|
57
84
|
filepath.to_s.match?(/\.md$/i)
|
|
@@ -18,7 +18,7 @@ module Jekyll
|
|
|
18
18
|
content = DetailsTransformer.transform(content)
|
|
19
19
|
|
|
20
20
|
# Apply image dialog transformer BEFORE dialog transformer so it can generate dialog syntax
|
|
21
|
-
content = ImageDialogTransformer.transform(content) if site && Plugin.image_dialog_enabled?(site)
|
|
21
|
+
content = ImageDialogTransformer.transform(content, site) if site && Plugin.image_dialog_enabled?(site)
|
|
22
22
|
|
|
23
23
|
content = DialogTransformer.transform(content)
|
|
24
24
|
content = IconTransformer.transform(content)
|
|
@@ -8,7 +8,8 @@ module Jekyll
|
|
|
8
8
|
# Transforms dialog syntax into wa-dialog elements with trigger buttons
|
|
9
9
|
# Primary syntax: ???params\nbutton text\n>>>\ncontent\n???
|
|
10
10
|
# Alternative syntax: :::wa-dialog params\nbutton text\n>>>\ncontent\n:::
|
|
11
|
-
# Params: light-dismiss
|
|
11
|
+
# Params: light-dismiss and optional width (e.g., 500px, 50vw, 40em)
|
|
12
|
+
# Note: Header with close X button is always enabled for accessibility
|
|
12
13
|
class DialogTransformer < BaseTransformer
|
|
13
14
|
def self.transform(content)
|
|
14
15
|
# Define both regex patterns - capture parameter string, button text, and content
|
|
@@ -24,7 +25,7 @@ module Jekyll
|
|
|
24
25
|
dialog_content = dialog_content.strip
|
|
25
26
|
|
|
26
27
|
# Parse parameters
|
|
27
|
-
light_dismiss,
|
|
28
|
+
light_dismiss, width = parse_parameters(params_string)
|
|
28
29
|
|
|
29
30
|
# Extract label from first heading or use button text
|
|
30
31
|
label, content_without_label = extract_label(dialog_content, button_text)
|
|
@@ -37,7 +38,7 @@ module Jekyll
|
|
|
37
38
|
|
|
38
39
|
# Build the dialog HTML
|
|
39
40
|
build_dialog_html(dialog_id, button_text, label, content_html,
|
|
40
|
-
light_dismiss,
|
|
41
|
+
light_dismiss, width)
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
# Apply both patterns
|
|
@@ -50,12 +51,11 @@ module Jekyll
|
|
|
50
51
|
|
|
51
52
|
# Parse parameters from the params string
|
|
52
53
|
def parse_parameters(params_string)
|
|
53
|
-
return [false,
|
|
54
|
+
return [false, nil] if params_string.nil? || params_string.strip.empty?
|
|
54
55
|
|
|
55
56
|
tokens = params_string.strip.split(/\s+/)
|
|
56
57
|
|
|
57
58
|
light_dismiss = tokens.include?('light-dismiss')
|
|
58
|
-
without_header = tokens.include?('without-header')
|
|
59
59
|
|
|
60
60
|
# Look for width parameter (last token with CSS units)
|
|
61
61
|
width = nil
|
|
@@ -66,10 +66,11 @@ module Jekyll
|
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
[light_dismiss,
|
|
69
|
+
[light_dismiss, width]
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
# Extract label from first heading in content
|
|
73
|
+
# Always returns a label - uses heading if available, otherwise default_label
|
|
73
74
|
def extract_label(content, default_label)
|
|
74
75
|
# Check if content starts with a heading
|
|
75
76
|
if content.match(/^#\s+(.+?)$/)
|
|
@@ -78,6 +79,7 @@ module Jekyll
|
|
|
78
79
|
content_without_label = content.sub(/^#\s+.+?\n/, '').strip
|
|
79
80
|
[label, content_without_label]
|
|
80
81
|
else
|
|
82
|
+
# Use default label (button text) to ensure header is always shown
|
|
81
83
|
[default_label, content]
|
|
82
84
|
end
|
|
83
85
|
end
|
|
@@ -90,13 +92,14 @@ module Jekyll
|
|
|
90
92
|
end
|
|
91
93
|
|
|
92
94
|
# Build the complete dialog HTML with trigger button
|
|
95
|
+
# Header with X close button is always enabled for accessibility
|
|
93
96
|
def build_dialog_html(dialog_id, button_text, label, content_html,
|
|
94
|
-
light_dismiss,
|
|
97
|
+
light_dismiss, width)
|
|
95
98
|
# Build dialog attributes
|
|
96
99
|
dialog_attrs = ["id='#{dialog_id}'"]
|
|
97
100
|
# Escape both HTML and attribute characters for label
|
|
98
|
-
|
|
99
|
-
dialog_attrs << '
|
|
101
|
+
# Header is always shown to provide the X close button
|
|
102
|
+
dialog_attrs << "label='#{escape_attribute(escape_html(label))}'"
|
|
100
103
|
dialog_attrs << 'light-dismiss' if light_dismiss
|
|
101
104
|
|
|
102
105
|
# Build style attribute for width if specified
|
|
@@ -9,7 +9,10 @@ module Jekyll
|
|
|
9
9
|
# Images can opt-out by adding "nodialog" to the title attribute
|
|
10
10
|
# Example: 
|
|
11
11
|
class ImageDialogTransformer < BaseTransformer
|
|
12
|
-
def self.transform(content)
|
|
12
|
+
def self.transform(content, site = nil)
|
|
13
|
+
# Get configuration including default width
|
|
14
|
+
config = site ? Plugin.image_dialog_config(site) : {}
|
|
15
|
+
|
|
13
16
|
# First, protect code blocks, inline code, and comparison blocks from transformation
|
|
14
17
|
protected_content, fenced_code_blocks = protect_fenced_code_blocks(content)
|
|
15
18
|
protected_content, inline_code_blocks = protect_inline_code(protected_content)
|
|
@@ -31,7 +34,7 @@ module Jekyll
|
|
|
31
34
|
match
|
|
32
35
|
else
|
|
33
36
|
# Transform to clickable image with dialog
|
|
34
|
-
transform_to_dialog(alt_text, image_url, title)
|
|
37
|
+
transform_to_dialog(alt_text, image_url, title, config)
|
|
35
38
|
end
|
|
36
39
|
end
|
|
37
40
|
|
|
@@ -115,12 +118,16 @@ module Jekyll
|
|
|
115
118
|
|
|
116
119
|
# Transform image into our custom dialog syntax
|
|
117
120
|
# This will be processed by DialogTransformer to create the actual wa-dialog
|
|
118
|
-
def transform_to_dialog(alt_text, image_url, title)
|
|
121
|
+
def transform_to_dialog(alt_text, image_url, title, config = {})
|
|
119
122
|
# Parse width from title if specified (e.g., "50%", "800px", "60vw")
|
|
120
123
|
width = extract_width_from_title(title)
|
|
124
|
+
|
|
125
|
+
# Use default width from config if no width specified in title
|
|
126
|
+
width ||= config[:default_width] if config[:default_width]
|
|
121
127
|
|
|
122
128
|
# Build dialog parameters
|
|
123
|
-
|
|
129
|
+
# Always include header with X close button for accessibility
|
|
130
|
+
params = ['light-dismiss']
|
|
124
131
|
params << width if width
|
|
125
132
|
params_string = params.join(' ')
|
|
126
133
|
|
|
@@ -129,8 +136,10 @@ module Jekyll
|
|
|
129
136
|
title_attr = title && !title.include?('nodialog') && !contains_width?(title) ? " title=\"#{title}\"" : ''
|
|
130
137
|
button_content = "<img src=\"#{image_url}\" alt=\"#{alt_text}\" style=\"cursor: zoom-in; display: block; width: 100%; height: auto;\"#{title_attr} />"
|
|
131
138
|
|
|
132
|
-
# Build the dialog content
|
|
133
|
-
|
|
139
|
+
# Build the dialog content with alt text as heading for the label
|
|
140
|
+
# Use alt text for the label, or "Image" as fallback if alt is empty
|
|
141
|
+
label_text = alt_text.empty? ? 'Image' : alt_text
|
|
142
|
+
dialog_content = "# #{label_text}\n\n<img src=\"#{image_url}\" alt=\"#{alt_text}\" style=\"max-width: 100%; height: auto; display: block; margin: 0 auto;\" />"
|
|
134
143
|
|
|
135
144
|
# Use our custom dialog syntax that will be processed by DialogTransformer
|
|
136
145
|
# Format: ???params\nbutton_content\n>>>\ndialog_content\n???
|
data/lib/jekyll/webawesome.rb
CHANGED
|
@@ -31,7 +31,7 @@ module Jekyll
|
|
|
31
31
|
@custom_components = {}
|
|
32
32
|
@transform_pages = true
|
|
33
33
|
@transform_documents = true
|
|
34
|
-
@image_dialog = false # Opt-in by default for safety
|
|
34
|
+
@image_dialog = false # Opt-in by default for safety, or can be a hash with options
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
private
|