jekyll-page-asset 0.1.0 → 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 +11 -5
- data/_includes/page_asset/gallery.html +5 -1
- data/_lib/page_asset/gallery_renderer.rb +31 -1
- data/_sass/_page-asset.scss +4 -0
- data/lib/jekyll-page-asset/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: 8db9a6281095ce4e99b4c0d3b8ddec55c5ce371fb6164c721ca9568a18068e05
|
|
4
|
+
data.tar.gz: 7e98af8cb08d9ac9e4aa714fdd8a2aea07b570e407e9537bbaf037fbd5985e7c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75bad5045e80cf194478a525e9d7fb681cde348b8a67a8962c4eabc207cc9df001fb47f6bd1fdcb38c89f225ff2dc9bdd6f1b42a6ed2e32ef6075eb5298e7bdf
|
|
7
|
+
data.tar.gz: bd98568459c9efb1495fc564bb51aba5fbd4f8159afc071c8bd01447797fdbff7b9d6ab1ee6fc61817f29906fa685e2f486237da4356b6d120cfce2f6134800b
|
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@ bundle exec jekyll serve --livereload
|
|
|
5
5
|
```
|
|
6
6
|
# jekyll-page-asset
|
|
7
7
|
|
|
8
|
-
The `page_asset` plugin designed for a project portfolio style ( although it might well work with blog/post style layouts) to make it easy to put assets that relate to a page, onto that page.
|
|
8
|
+
The `page_asset` extensible plugin designed for a project portfolio style ( although it might well work with blog/post style layouts) to make it easy to put assets that relate to a page, onto that page.
|
|
9
9
|
|
|
10
10
|
It's essentially a convenience tag for adding components that reference media files into project pages. The media files are stored in the `assets/project_media/<project-slug>/` folder and can be referenced by just a relative path to that folder.
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ The intent is to make it easy to add media components into project pages by defi
|
|
|
14
14
|
|
|
15
15
|
## Supported components
|
|
16
16
|
### image
|
|
17
|
-
Standard image. This delegates to the
|
|
17
|
+
Standard image. This delegates to the [jekyll_picture_tag](https://github.com/rbuchberger/jekyll_picture_tag) plugin which handles responsive images. Any args past the filename are passed through to that plugin, so you can use any of the options it supports.
|
|
18
18
|
|
|
19
19
|
`{% page_asset image <image-filename> [alt="<alt-text>"] %}`
|
|
20
20
|
|
|
@@ -34,12 +34,16 @@ Video that loads muted and advances as the user scrolls the page.
|
|
|
34
34
|
`{% page_asset scroll_scrub_video <video-filename> %}`
|
|
35
35
|
|
|
36
36
|
### gallery
|
|
37
|
-
Pass a folder name in the media asset directory and all images in that folder will be displayed in a gallery.
|
|
37
|
+
Pass a folder name in the media asset directory and all images in that folder will be displayed in a gallery. Image files in the gallery can also have a 'support file' - a markdown file with the same name as the image. Support files can give a custom `alt` value in frontmatter, and markdown body is displayed as an image description in the lightbox view.
|
|
38
|
+
|
|
38
39
|
The generated html and script for this will also write tags to two target mount points in the site, if found.
|
|
39
|
-
|
|
40
|
-
`project-asset-gallery-
|
|
40
|
+
|
|
41
|
+
* `project-asset-gallery-lightbox` is the target for the lightbox html. By default this is styled to fill the viewport area of the component that it is mounted in to act as a full area takeover.
|
|
42
|
+
|
|
43
|
+
* `project-asset-gallery-controls` is the target for the gallery controls - to move to next/previous images and close the lightbox. This appears when the lightbox is open.
|
|
41
44
|
`{% page_asset gallery <gallery-folder-name> %}`
|
|
42
45
|
|
|
46
|
+
|
|
43
47
|
### fountain script reader
|
|
44
48
|
Simple scrollable script reader for [fountain](https://fountain.io/) formatted scripts.
|
|
45
49
|
|
|
@@ -101,6 +105,8 @@ end
|
|
|
101
105
|
```
|
|
102
106
|
and has the following variables available:
|
|
103
107
|
|
|
108
|
+
| Argument | Description |
|
|
109
|
+
| :--- | :--- |
|
|
104
110
|
| @type | component type string |
|
|
105
111
|
| @asset_path_arg | requested path argument from the tag |
|
|
106
112
|
| @rest | all the rest of the args from the tag (useful for passing through) |
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
'<div class="gallery-lightbox" id="gallery-lightbox" role="dialog" aria-modal="true" aria-label="Image viewer" hidden>' +
|
|
16
16
|
'<div class="gallery-lightbox-inner" tabindex="-1">' +
|
|
17
17
|
'<img class="gallery-lightbox-image" id="gallery-lightbox-image" src="" alt="">' +
|
|
18
|
+
'<div class="gallery-lightbox-desc" id="gallery-lightbox-desc">' +
|
|
18
19
|
'</div>' +
|
|
19
20
|
'</div>';
|
|
20
21
|
lightboxMount.setAttribute(MOUNTED_ATTR, "true");
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
function initLightbox() {
|
|
38
39
|
var lightbox = document.getElementById("gallery-lightbox");
|
|
39
40
|
var lightboxImage = document.getElementById("gallery-lightbox-image");
|
|
41
|
+
var lightboxDesc = document.getElementById("gallery-lightbox-desc");
|
|
40
42
|
var lightboxMount = document.getElementById("page-asset-gallery-lightbox");
|
|
41
43
|
var focusableSelector = ".gallery-controls .gallery-control-button";
|
|
42
44
|
|
|
@@ -86,7 +88,8 @@
|
|
|
86
88
|
.map(function (thumb) {
|
|
87
89
|
return {
|
|
88
90
|
src: thumb.getAttribute("data-gallery-src"),
|
|
89
|
-
alt: thumb.getAttribute("data-gallery-alt") || "Gallery image"
|
|
91
|
+
alt: thumb.getAttribute("data-gallery-alt") || "Gallery image",
|
|
92
|
+
desc: thumb.getAttribute("data-gallery-desc")
|
|
90
93
|
};
|
|
91
94
|
});
|
|
92
95
|
}
|
|
@@ -110,6 +113,7 @@
|
|
|
110
113
|
var current = state.items[state.index];
|
|
111
114
|
lightboxImage.src = current.src;
|
|
112
115
|
lightboxImage.alt = current.alt;
|
|
116
|
+
lightboxDesc.innerHTML = current.desc;
|
|
113
117
|
emitState();
|
|
114
118
|
}
|
|
115
119
|
|
|
@@ -22,8 +22,11 @@ module Jekyll
|
|
|
22
22
|
|
|
23
23
|
thumbnails = images.each_with_index.map do |filename, index|
|
|
24
24
|
asset_path = File.join(gallery_asset_root, filename)
|
|
25
|
+
supporting_text = get_supporting_text(context, asset_path)
|
|
26
|
+
|
|
25
27
|
src = "/#{asset_path}"
|
|
26
|
-
alt = alt_text_for(filename, index)
|
|
28
|
+
alt = supporting_text.dig(:args, 'alt') || alt_text_for(filename, index)
|
|
29
|
+
description = supporting_text.dig(:body)
|
|
27
30
|
picture_tag = render_thumbnail(context, asset_path)
|
|
28
31
|
|
|
29
32
|
<<~HTML
|
|
@@ -35,6 +38,7 @@ module Jekyll
|
|
|
35
38
|
data-gallery-index="#{index}"
|
|
36
39
|
data-gallery-src="#{html_escape(src)}"
|
|
37
40
|
data-gallery-alt="#{html_escape(alt)}"
|
|
41
|
+
data-gallery-desc="#{html_escape(description)}"
|
|
38
42
|
aria-label="Open image #{index + 1}">
|
|
39
43
|
#{picture_tag}
|
|
40
44
|
</button>
|
|
@@ -70,6 +74,32 @@ module Jekyll
|
|
|
70
74
|
stem.gsub(/\s+/, " ")
|
|
71
75
|
end
|
|
72
76
|
|
|
77
|
+
def get_supporting_text(context, path)
|
|
78
|
+
# find supporting md file if it exists
|
|
79
|
+
supporting_md = File.join(File.dirname(path) , File.basename(path, ".*") + ".md")
|
|
80
|
+
if File.exist?(supporting_md)
|
|
81
|
+
file_contents = File.read(supporting_md)
|
|
82
|
+
site = context.registers[:site]
|
|
83
|
+
|
|
84
|
+
if file_contents =~ Jekyll::Document::YAML_FRONT_MATTER_REGEXP
|
|
85
|
+
front_matter_string = $1
|
|
86
|
+
body_content = $POSTMATCH # Captures everything after the front matter block
|
|
87
|
+
|
|
88
|
+
# Parse the front matter string using Jekyll's internal parser
|
|
89
|
+
front_matter = SafeYAML.load(front_matter_string)
|
|
90
|
+
else
|
|
91
|
+
body_content = file_contents
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
args: front_matter,
|
|
96
|
+
body: site.find_converter_instance(Jekyll::Converters::Markdown)
|
|
97
|
+
.convert(body_content)
|
|
98
|
+
}
|
|
99
|
+
end
|
|
100
|
+
{}
|
|
101
|
+
end
|
|
102
|
+
|
|
73
103
|
def empty_state_html(gallery_id)
|
|
74
104
|
<<~HTML
|
|
75
105
|
<section class="project-gallery" data-gallery="#{html_escape(gallery_id)}" aria-label="Image gallery">
|
data/_sass/_page-asset.scss
CHANGED