jekyll-image-links 0.1.1 → 0.1.2
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 +12 -35
- data/lib/jekyll/image_links/hooks.rb +16 -2
- data/lib/jekyll/image_links/version.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: 19b54b99566ef68cb4781a9ac97bbf0244aecdc8df97de25842b379916d5ffb6
|
|
4
|
+
data.tar.gz: f8398c0bbfabd847e30639200b95b11bccee7e205938f440eb0d96a1b6da83ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 67dc7db67ce397dd3c9df03c8c84681a7fb60731a717520e5d30d6b5c57ab3a8f3be1fbdddcd564ccecad632941982d4d7311e79a67487b4f72020b9fa7025d2
|
|
7
|
+
data.tar.gz: 84f6ddb951f954fcf32d8af81fcef097104c16d987824abc95766654e64d9895f4728669c321cfb2f9de250d601b3ff86d1e1e9f8c87a18dc5753fc9b23d6559
|
data/README.md
CHANGED
|
@@ -2,17 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
A Jekyll plugin for [Just the Docs](https://github.com/just-the-docs/just-the-docs) sites that adds clickable polygon regions on images.
|
|
4
4
|
|
|
5
|
-
Inspired by the Dynamic Map Viewer in [5etools](https://github.com/5etools/5etools-src)
|
|
5
|
+
Inspired by the Dynamic Map Viewer in [5etools](https://github.com/5etools/5etools-src).
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
- Define polygon click regions in Markdown using a Liquid tag
|
|
9
|
+
- Define polygon click regions in Markdown using a Liquid tag inline or using an external YAML file
|
|
10
10
|
- Click a region to navigate to an internal or external link
|
|
11
|
+
- Automatic point rescaling for variable image dimensions (i.e. `width: 50%`)
|
|
11
12
|
- Hold **Shift** while clicking to open the link in a new tab
|
|
12
|
-
- Integrates with [jekyll-hover-popup](https://github.com/directsun/jekyll-hover-popup) when both plugins are enabled: region clicks open pinned hover-popup windows (no page darkening), and the map viewer opens inside a hover-popup window too
|
|
13
13
|
- Optional **Dynamic Map Viewer** button with zoom, pan, and region highlighting
|
|
14
14
|
- Optional region labels overlaid on the image
|
|
15
|
-
-
|
|
15
|
+
- Integrates with [jekyll-hover-popup](https://github.com/sunflowermans/hover-popup) when both plugins are enabled:
|
|
16
|
+
- Map viewer opens inside a hover-popup window
|
|
17
|
+
- Region clicks open pinned hover-popup windows
|
|
18
|
+
|
|
19
|
+
https://github.com/user-attachments/assets/9b2f123b-56a4-43f4-984f-2dbfa7b844f9
|
|
16
20
|
|
|
17
21
|
## Install
|
|
18
22
|
|
|
@@ -95,13 +99,6 @@ When `width` and `height` are in the YAML file, you can omit them from the tag a
|
|
|
95
99
|
{% endimage_map %}
|
|
96
100
|
```
|
|
97
101
|
|
|
98
|
-
Legacy form still works — numeric `width`/`height` on the tag or `<img>` define the native coordinate system when the YAML file does not include them:
|
|
99
|
-
|
|
100
|
-
```liquid
|
|
101
|
-
{% image_map src="/assets/maps/example.webp" width="1200" height="800" file="assets/maps/example-map.yml" %}
|
|
102
|
-
{% endimage_map %}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
102
|
### Tag options
|
|
106
103
|
|
|
107
104
|
| Attribute | Description |
|
|
@@ -119,7 +116,7 @@ Legacy form still works — numeric `width`/`height` on the tag or `<img>` defin
|
|
|
119
116
|
|
|
120
117
|
### Manual HTML (portable markup)
|
|
121
118
|
|
|
122
|
-
You can also write image maps directly in Markdown using `{::nomarkdown}` blocks. Only an `<img>` tag is required
|
|
119
|
+
You can also write image maps directly in Markdown using `{::nomarkdown}` blocks. Only an `<img>` tag is required. Put configuration on the image itself using `data-jil-*` attributes.
|
|
123
120
|
|
|
124
121
|
Store the **native** image dimensions in the YAML file. Region `points` use that coordinate system. Use CSS on the `<img>` for **display** size (percentages, max width/height, and so on). At build time those display styles are moved to the surrounding `.jil-map-host` wrapper so percentage sizes resolve against the page layout correctly.
|
|
125
122
|
|
|
@@ -153,16 +150,7 @@ regions:
|
|
|
153
150
|
points: [[120, 80], [420, 80], [420, 320], [120, 320]]
|
|
154
151
|
```
|
|
155
152
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
| Attribute | Example | Description |
|
|
159
|
-
|-----------|---------|-------------|
|
|
160
|
-
| `style` | `width:100%;max-width:900px;height:auto` | Full CSS control (recommended) |
|
|
161
|
-
| `width` / `height` | `width="100%"` or `width="800"` | Display size when YAML provides native dimensions |
|
|
162
|
-
| `data-jil-max-width` | `900px` or `80%` | Shorthand for `max-width` |
|
|
163
|
-
| `data-jil-max-height` | `600px` | Shorthand for `max-height` |
|
|
164
|
-
|
|
165
|
-
Portable images are detected by `class="jil-map-image"` together with region data (`data-jil-regions`, an adjacent `<script class="jil-regions-data">` block, or legacy `data-jil-map="true"`). Legacy `<figure data-jil-map="true">` markup is still supported.
|
|
153
|
+
Qualified images are detected by `class="jil-map-image"` together with region data (`data-jil-regions`)
|
|
166
154
|
|
|
167
155
|
| Attribute | Description |
|
|
168
156
|
|-----------|-------------|
|
|
@@ -175,21 +163,10 @@ Portable images are detected by `class="jil-map-image"` together with region dat
|
|
|
175
163
|
|
|
176
164
|
## Coordinate system
|
|
177
165
|
|
|
178
|
-
Region `points` use the image's native pixel coordinates
|
|
166
|
+
Region `points` use the image's native pixel coordinates. Define the native size once in the YAML file (`width` and `height`) or on the tag/image when not using YAML dimensions. For example, a 4937×3439 map uses coordinates in that range.
|
|
179
167
|
|
|
180
168
|
The plugin scales clicks from whatever size the image is displayed at back into that native coordinate system. Changing display size with CSS, percentages, or max width/height does not require editing region points.
|
|
181
169
|
|
|
182
|
-
## How this relates to 5etools
|
|
183
|
-
|
|
184
|
-
5etools stores regions as `mapRegions` on image entries in JSON data, then renders them with a custom `RenderMap` class (`js/render-map.js`) that:
|
|
185
|
-
|
|
186
|
-
- draws the image on a `<canvas>`
|
|
187
|
-
- overlays clickable polygons
|
|
188
|
-
- uses a ray-casting algorithm for hit detection
|
|
189
|
-
- opens linked adventure content in hover windows
|
|
190
|
-
|
|
191
|
-
This plugin uses the same polygon coordinate model and the same hit-detection approach, adapted for Jekyll pages with normal `href` links instead of 5etools' internal book area IDs.
|
|
192
|
-
|
|
193
170
|
## License
|
|
194
171
|
|
|
195
|
-
MIT
|
|
172
|
+
[MIT](LICENSE)
|
|
@@ -11,8 +11,7 @@ module Jekyll
|
|
|
11
11
|
html = doc.output.to_s
|
|
12
12
|
next unless html.include?('data-jil-image-map="true"') || MapRenderer.portable_markup?(html)
|
|
13
13
|
|
|
14
|
-
assets_path = cfg
|
|
15
|
-
assets_path = "/#{assets_path}" unless assets_path.start_with?("/")
|
|
14
|
+
assets_path = resolve_assets_path(site, cfg)
|
|
16
15
|
|
|
17
16
|
begin
|
|
18
17
|
html = MapRenderer.enhance_html(html, site: site, page: doc, cfg: cfg)
|
|
@@ -23,6 +22,21 @@ module Jekyll
|
|
|
23
22
|
end
|
|
24
23
|
end
|
|
25
24
|
|
|
25
|
+
# Site-root path (e.g. "/assets/jekyll-image-links"), with site.baseurl prepended.
|
|
26
|
+
def self.resolve_assets_path(site, cfg)
|
|
27
|
+
assets_path = cfg["assets_path"] || "/assets/jekyll-image-links"
|
|
28
|
+
assets_path = "/#{assets_path}" unless assets_path.start_with?("/")
|
|
29
|
+
|
|
30
|
+
baseurl = site.config["baseurl"].to_s
|
|
31
|
+
baseurl = "" if baseurl == "/"
|
|
32
|
+
baseurl = baseurl.chomp("/")
|
|
33
|
+
|
|
34
|
+
return assets_path if baseurl.empty?
|
|
35
|
+
return assets_path if assets_path == baseurl || assets_path.start_with?("#{baseurl}/")
|
|
36
|
+
|
|
37
|
+
"#{baseurl}#{assets_path}"
|
|
38
|
+
end
|
|
39
|
+
|
|
26
40
|
def self.build_jil_config(site, cfg)
|
|
27
41
|
return { useHoverPopup: false } if cfg["use_hover_popup"] == false
|
|
28
42
|
return { useHoverPopup: true } if cfg["use_hover_popup"] == true
|