jekyll-page-asset 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8db9a6281095ce4e99b4c0d3b8ddec55c5ce371fb6164c721ca9568a18068e05
4
- data.tar.gz: 7e98af8cb08d9ac9e4aa714fdd8a2aea07b570e407e9537bbaf037fbd5985e7c
3
+ metadata.gz: 4d6d2997cebfa6648d100a3335cf78425358a609ad5d524eb38d5ee4671d0b32
4
+ data.tar.gz: 70559d1c925bc506b6f037b4fdd1d2fc5e8989e359f9755fdc85e9b97e0cabb7
5
5
  SHA512:
6
- metadata.gz: 75bad5045e80cf194478a525e9d7fb681cde348b8a67a8962c4eabc207cc9df001fb47f6bd1fdcb38c89f225ff2dc9bdd6f1b42a6ed2e32ef6075eb5298e7bdf
7
- data.tar.gz: bd98568459c9efb1495fc564bb51aba5fbd4f8159afc071c8bd01447797fdbff7b9d6ab1ee6fc61817f29906fa685e2f486237da4356b6d120cfce2f6134800b
6
+ metadata.gz: 2b56178cd9e58f14ce07230045a85528fdf11a0189095ae75fcd242711859170f78dd4a983daad8db5d6ab3d29c951353ae2daf628127214d4e57a4460943dfa
7
+ data.tar.gz: '0890f071dd316148b87d3f470a9ce88c160f094b8936c2aba6f1fdda19f5a2e273b9e383efaef08fbe622fa45524d287a3c2dfed19abaee60950cdcb7962ba21'
data/README.md CHANGED
@@ -38,10 +38,13 @@ Pass a folder name in the media asset directory and all images in that folder wi
38
38
 
39
39
  The generated html and script for this will also write tags to two target mount points in the site, if found.
40
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.
41
+ * `page-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. This is optional, but if not included, the gallery will only display as thumbnails and cannot be expanded.
42
+
43
+ * `page-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. Optional, if not included, the controls will be rendered at the top of the lightbox.
44
+
45
+ Gallery can take optional `title` and `description` arguments to provide a heading and descriptive text for the gallery.
46
+ `{% page_asset gallery <gallery-folder-name> [title="<title-text>"] [description="<description-text>"] %}`
42
47
 
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.
44
- `{% page_asset gallery <gallery-folder-name> %}`
45
48
 
46
49
 
47
50
  ### fountain script reader
@@ -21,6 +21,16 @@
21
21
  lightboxMount.setAttribute(MOUNTED_ATTR, "true");
22
22
  }
23
23
 
24
+ if (!controlsMount) {
25
+ var fallbackControlsDiv = document.createElement("div");
26
+ fallbackControlsDiv.id = "page-asset-gallery-controls-fallback";
27
+ fallbackControlsDiv.className = "gallery-controls-fallback";
28
+ if (lightboxMount) {
29
+ lightboxMount.insertBefore(fallbackControlsDiv, lightboxMount.firstChild);
30
+ }
31
+ controlsMount = fallbackControlsDiv;
32
+ }
33
+
24
34
  if (controlsMount) {
25
35
  controlsMount.innerHTML =
26
36
  '<div class="gallery-controls" id="gallery-controls" hidden aria-label="Gallery controls">' +
@@ -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
@@ -45,9 +45,12 @@ module Jekyll
45
45
  HTML
46
46
  end
47
47
 
48
+ title_html = render_title(@params["title"])
49
+ description_html = render_description(@params["description"])
50
+
48
51
  <<~HTML + gallery_template
49
52
  <section class="project-gallery" data-gallery="#{html_escape(@asset_path_arg)}" aria-label="Image gallery">
50
- <div class="project-gallery-grid">
53
+ #{title_html}#{description_html}<div class="project-gallery-grid">
51
54
  #{thumbnails.join("\n")}
52
55
  </div>
53
56
  </section>
@@ -108,6 +111,16 @@ module Jekyll
108
111
  HTML
109
112
  end
110
113
 
114
+ def render_title(title)
115
+ return "" if title.nil? || title.to_s.strip.empty?
116
+ "<h2 class=\"project-gallery-title\">#{html_escape(title)}</h2>\n"
117
+ end
118
+
119
+ def render_description(description)
120
+ return "" if description.nil? || description.to_s.strip.empty?
121
+ "<p class=\"project-gallery-description\">#{html_escape(description)}</p>\n"
122
+ end
123
+
111
124
  def html_escape(value)
112
125
  CGI.escape_html(value.to_s)
113
126
  end
@@ -171,6 +171,7 @@
171
171
  width: 100%;
172
172
  height: 100%;
173
173
  position: absolute;
174
+ pointer-events: none;
174
175
  }
175
176
 
176
177
  #page-asset-gallery-controls {
@@ -199,6 +200,15 @@
199
200
  }
200
201
  }
201
202
 
203
+ .gallery-controls-fallback {
204
+ position: relative;
205
+ width: 100%;
206
+ padding: $spacing-sm 0;
207
+ background: transparent;
208
+ pointer-events: all;
209
+ z-index: 221;
210
+ }
211
+
202
212
  .gallery-lightbox-desc {
203
213
  margin-top: $spacing-md;
204
214
  }
@@ -286,6 +296,8 @@
286
296
  border-radius: $radius-md;
287
297
  border: 1px solid rgba(255, 255, 255, 0.2);
288
298
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.4);
299
+ flex-shrink: 1;
300
+ min-height: 0;
289
301
  }
290
302
 
291
303
  .gallery-lightbox-button {
@@ -311,3 +323,25 @@ body.gallery-lightbox-open {
311
323
  top: $spacing-sm;
312
324
  }
313
325
  }
326
+
327
+ // __ Video ___________________________________________________
328
+ .background-video {
329
+ width: 100%;
330
+ height: auto;
331
+ }
332
+
333
+ .foreground-video {
334
+ width: 100%;
335
+ height: auto;
336
+ display: block;
337
+ border: 1px solid $border-color;
338
+ border-radius: $radius-md;
339
+ background: $bg-card;
340
+ box-shadow: $shadow-card;
341
+ }
342
+
343
+ // __ Audio ___________________________________________________
344
+ .page-asset-audio {
345
+ width: 100%;
346
+ display: block;
347
+ }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllPageAsset
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
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.2
4
+ version: 0.1.4
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