jekyll-page-asset 0.1.0 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e67fa350064b585c84d962a4752e3575c2a7f76b8794e3e24a41dbc5711195a
4
- data.tar.gz: 2475c4193837a426fafafd2c688c43f3702eeb8091f3346bd7bafe5c7d6177eb
3
+ metadata.gz: a4bc75d0d43f30ae672d870c5e0a6cf6f59c5d4c5e265defae10c1ecaca01d8c
4
+ data.tar.gz: a248414dec9ef31592ae271ee6648f6f50ed4d2deb98d1891dd43df1e680515e
5
5
  SHA512:
6
- metadata.gz: 537867e38701854bac6c6573ffa1f897992f3d6b12bee42014417cb41ec292e7879e2247ad00e16df7533956d222c32dcee621b5f17cb6049dc96ab026faf1ca
7
- data.tar.gz: a855b2886668c271a604446ae95fb35232d0b4f5405b26f855510f4ffc9b22f0818ee5e46a8436e7b7056bad89dedac00fa9347c1f0c8994b6b8e83df1a346bc
6
+ metadata.gz: 02ba586c38e6b1c12116b0b485d7c260fce71ee3d3eb3e8d270e8302fc70ca65990fab037f9f59a632eb602091dbcb7f5b6f2ab001729a2ac84ca35f2d18da70
7
+ data.tar.gz: 9a76aea336af968aef5452afde8f8dddd314d63b629cea171bae8f0f71fd4bf3d3827be0f7af8a7f70221570cdc5a6a66a7b75b8ce59b8d9dafd73b07ef42eab
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 `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.
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
- `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.
40
- `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.
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
 
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+
5
+ module Jekyll
6
+ module PageAsset
7
+ class AudioRenderer < Renderer
8
+ register_type "audio"
9
+
10
+ def render(context)
11
+ audio_path = @target_asset_path
12
+
13
+ <<~HTML
14
+ <audio controls preload="auto" class="page-asset-audio">
15
+ <source src="/#{html_escape(audio_path)}" type="#{html_escape(mime_type_for(audio_path))}">
16
+ Your browser does not support the audio tag.
17
+ </audio>
18
+ HTML
19
+ end
20
+
21
+ private
22
+
23
+ def mime_type_for(path)
24
+ case File.extname(path).downcase
25
+ when ".ogg"
26
+ "audio/ogg"
27
+ when ".wav"
28
+ "audio/wav"
29
+ when ".m4a"
30
+ "audio/mp4"
31
+ else
32
+ "audio/mpeg"
33
+ end
34
+ end
35
+
36
+ def html_escape(value)
37
+ CGI.escape_html(value.to_s)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -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">
@@ -199,6 +199,10 @@
199
199
  }
200
200
  }
201
201
 
202
+ .gallery-lightbox-desc {
203
+ margin-top: $spacing-md;
204
+ }
205
+
202
206
  .project-gallery-grid {
203
207
  column-count: 3;
204
208
  column-gap: $spacing-md;
@@ -282,6 +286,8 @@
282
286
  border-radius: $radius-md;
283
287
  border: 1px solid rgba(255, 255, 255, 0.2);
284
288
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.4);
289
+ flex-shrink: 1;
290
+ min-height: 0;
285
291
  }
286
292
 
287
293
  .gallery-lightbox-button {
@@ -307,3 +313,25 @@ body.gallery-lightbox-open {
307
313
  top: $spacing-sm;
308
314
  }
309
315
  }
316
+
317
+ // __ Video ___________________________________________________
318
+ .background-video {
319
+ width: 100%;
320
+ height: auto;
321
+ }
322
+
323
+ .foreground-video {
324
+ width: 100%;
325
+ height: auto;
326
+ display: block;
327
+ border: 1px solid $border-color;
328
+ border-radius: $radius-md;
329
+ background: $bg-card;
330
+ box-shadow: $shadow-card;
331
+ }
332
+
333
+ // __ Audio ___________________________________________________
334
+ .page-asset-audio {
335
+ width: 100%;
336
+ display: block;
337
+ }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllPageAsset
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-page-asset
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alastair King
@@ -62,6 +62,7 @@ files:
62
62
  - _includes/page_asset/fountain.html
63
63
  - _includes/page_asset/gallery.html
64
64
  - _includes/page_asset/scroll_scrub_video.html
65
+ - _lib/page_asset/audio_renderer.rb
65
66
  - _lib/page_asset/fountain_renderer.rb
66
67
  - _lib/page_asset/gallery_renderer.rb
67
68
  - _lib/page_asset/image_renderer.rb