wani 0.1.15 → 0.1.17

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: 7082411823ce9ed8947c371bc7e16d786fc39f6e90a2b6d3f7a9d184b256fdcb
4
- data.tar.gz: 3206f7bc05c39168c14007f5c958e07a4e04ddc4791ca05f7fc65e4dbd7969fc
3
+ metadata.gz: 5479c59b715d3dd55a496b727c6f6a8e7e40b4f0481408d965c56541b97d90ca
4
+ data.tar.gz: 2855dc7e7dff2e0466d8f78a9d28d20e7b334232ba44e6926cc26f0705667c4b
5
5
  SHA512:
6
- metadata.gz: cc53a8dbcc69c9f768f2af129f650d71263f8239ce0416b6c48420681f958a60feb5012402eea9f11478fa04a32a660c4f3fcec3c48111eb6ae19d9e81be5f70
7
- data.tar.gz: dd12aa99c08476117ed9e76c5dd2bab050680ba2e6d79d3ed8998c29c625e3353851d4d79206ed2f89906bf99eb4bff95c362e4f482a86a9869bcb7cf44ba9f1
6
+ metadata.gz: 95b4eefc19b1db40db28549a5769f48e477f7be42fb4275eaa0b43071b89b1839c75535b1f62f0f3356bfaaf7cbc411e7e6f630d2f94fa58c0afd28451c28cbf
7
+ data.tar.gz: 53463ed286abbe5cdaf7168cbcc36497ef4479aab26a9e2232f813b4241bd3ae9043ecac8442d4db1263a0b08306d5508fcf7b7cd21bfc768b4b46297cc3b956
data/README.md CHANGED
@@ -192,11 +192,11 @@ Ctrl+P でも印刷できます。
192
192
 
193
193
  ## 同梱フォント
194
194
 
195
- 日本語・英数字の標準書体は **IBM Plex Sans JP** です。
195
+ 日本語・英数字の標準書体は **Zen Kaku Gothic New** です。
196
196
  コードは **UDEV Gothic** を使い、日本語も半角1:全角2の等幅で表示します。
197
197
 
198
- フォントは SIL Open Font License 1.1 です。原文のライセンス・著作権表示と配布元・チェックサムは
199
- [third_party/ibm-plex-sans-jp](third_party/ibm-plex-sans-jp/README.md) と
198
+ フォントは SIL Open Font License 1.1 です。原文のライセンス・著作権表示と UDEV Gothic の配布元・チェックサムは
199
+ [Zen Kaku Gothic New のライセンス](assets/fonts/ZenKakuGothicNew-OFL.txt) と
200
200
  [third_party/udev-gothic](third_party/udev-gothic/README.md) に保持しています。
201
201
 
202
202
  ## フォントを変更する
data/assets/build.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.1.15",
3
- "source_sha256": "a9ec44f0f122168b5bdce3783ea9188f6955f1835f53ad67258bebcff1252aaf",
2
+ "version": "0.1.17",
3
+ "source_sha256": "84cea7b9da9df559fa9c204becc4a7a400af64907ff232f95e1744bf500ae669",
4
4
  "loader_commit": "dc6b0ffd5800ed9bfc49268ed8021d456f10ddf8",
5
- "wasm_sha256": "bad1062bd0f007e51f7278365f14537dd974666f8c6442c304c13223cb78f3e4"
5
+ "wasm_sha256": "d4200a9923f294b33f985bb84faa88c8f0e95093614507710506be36b2ac51f7"
6
6
  }
@@ -1,93 +1,93 @@
1
- Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
2
-
3
- This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
-
5
- This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
6
-
7
-
8
- -----------------------------------------------------------
9
- SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
- -----------------------------------------------------------
11
-
12
- PREAMBLE
13
- The goals of the Open Font License (OFL) are to stimulate worldwide
14
- development of collaborative font projects, to support the font creation
15
- efforts of academic and linguistic communities, and to provide a free and
16
- open framework in which fonts may be shared and improved in partnership
17
- with others.
18
-
19
- The OFL allows the licensed fonts to be used, studied, modified and
20
- redistributed freely as long as they are not sold by themselves. The
21
- fonts, including any derivative works, can be bundled, embedded,
22
- redistributed and/or sold with any software provided that any reserved
23
- names are not used by derivative works. The fonts and derivatives,
24
- however, cannot be released under any other type of license. The
25
- requirement for fonts to remain under this license does not apply
26
- to any document created using the fonts or their derivatives.
27
-
28
- DEFINITIONS
29
- "Font Software" refers to the set of files released by the Copyright
30
- Holder(s) under this license and clearly marked as such. This may
31
- include source files, build scripts and documentation.
32
-
33
- "Reserved Font Name" refers to any names specified as such after the
34
- copyright statement(s).
35
-
36
- "Original Version" refers to the collection of Font Software components as
37
- distributed by the Copyright Holder(s).
38
-
39
- "Modified Version" refers to any derivative made by adding to, deleting,
40
- or substituting -- in part or in whole -- any of the components of the
41
- Original Version, by changing formats or by porting the Font Software to a
42
- new environment.
43
-
44
- "Author" refers to any designer, engineer, programmer, technical
45
- writer or other person who contributed to the Font Software.
46
-
47
- PERMISSION & CONDITIONS
48
- Permission is hereby granted, free of charge, to any person obtaining
49
- a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
- redistribute, and sell modified and unmodified copies of the Font
51
- Software, subject to the following conditions:
52
-
53
- 1) Neither the Font Software nor any of its individual components,
54
- in Original or Modified Versions, may be sold by itself.
55
-
56
- 2) Original or Modified Versions of the Font Software may be bundled,
57
- redistributed and/or sold with any software, provided that each copy
58
- contains the above copyright notice and this license. These can be
59
- included either as stand-alone text files, human-readable headers or
60
- in the appropriate machine-readable metadata fields within text or
61
- binary files as long as those fields can be easily viewed by the user.
62
-
63
- 3) No Modified Version of the Font Software may use the Reserved Font
64
- Name(s) unless explicit written permission is granted by the corresponding
65
- Copyright Holder. This restriction only applies to the primary font name as
66
- presented to the users.
67
-
68
- 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
- Software shall not be used to promote, endorse or advertise any
70
- Modified Version, except to acknowledge the contribution(s) of the
71
- Copyright Holder(s) and the Author(s) or with their explicit written
72
- permission.
73
-
74
- 5) The Font Software, modified or unmodified, in part or in whole,
75
- must be distributed entirely under this license, and must not be
76
- distributed under any other license. The requirement for fonts to
77
- remain under this license does not apply to any document created
78
- using the Font Software.
79
-
80
- TERMINATION
81
- This license becomes null and void if any of the above conditions are
82
- not met.
83
-
84
- DISCLAIMER
85
- THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
- OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
- COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
- INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
- DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
- FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
- OTHER DEALINGS IN THE FONT SOFTWARE.
1
+ Copyright 2022 The Zen Kaku Gothic Project Authors (https://github.com/googlefonts/zen-kakugothic)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
data/assets/index.html CHANGED
@@ -30,7 +30,7 @@
30
30
  <output id="countdown" aria-live="off" aria-label="発表の残り時間" hidden></output>
31
31
  <section id="time-expired" role="dialog" aria-modal="true" aria-labelledby="time-expired-title" hidden>
32
32
  <h1 id="time-expired-title">時間切れです!</h1>
33
- <img id="time-expired-image" class="time-expired-image" src="/assets/time-expired.webp" width="1086" height="724" alt="兎柄フードをくわえるワニ(さめ)">
33
+ <img id="time-expired-image" class="time-expired-image" width="1200" height="900" alt="ウサギとサメのイラスト">
34
34
  <p>← または → キーで元のスライドに戻れます</p>
35
35
  <button id="resume-slides">スライドに戻る</button>
36
36
  </section>
data/assets/style.css CHANGED
@@ -1,32 +1,32 @@
1
1
  @font-face {
2
- font-family: "IBM Plex Sans JP";
3
- src: url("/assets/fonts/IBMPlexSansJP-Regular.woff2") format("woff2");
2
+ font-family: "UDEV Gothic";
3
+ src: url("/assets/fonts/UDEVGothic-Regular.ttf") format("truetype");
4
4
  font-weight: 400;
5
5
  font-style: normal;
6
6
  font-display: block;
7
7
  }
8
8
  @font-face {
9
- font-family: "IBM Plex Sans JP";
10
- src: url("/assets/fonts/IBMPlexSansJP-Bold.woff2") format("woff2");
9
+ font-family: "UDEV Gothic";
10
+ src: url("/assets/fonts/UDEVGothic-Bold.ttf") format("truetype");
11
11
  font-weight: 700;
12
12
  font-style: normal;
13
13
  font-display: block;
14
14
  }
15
15
  @font-face {
16
- font-family: "UDEV Gothic";
17
- src: url("/assets/fonts/UDEVGothic-Regular.ttf") format("truetype");
16
+ font-family: "Zen Kaku Gothic New";
17
+ src: url("/assets/fonts/ZenKakuGothicNew-Regular.ttf") format("truetype");
18
18
  font-weight: 400;
19
19
  font-style: normal;
20
20
  font-display: block;
21
21
  }
22
22
  @font-face {
23
- font-family: "UDEV Gothic";
24
- src: url("/assets/fonts/UDEVGothic-Bold.ttf") format("truetype");
23
+ font-family: "Zen Kaku Gothic New";
24
+ src: url("/assets/fonts/ZenKakuGothicNew-Bold.ttf") format("truetype");
25
25
  font-weight: 700;
26
26
  font-style: normal;
27
27
  font-display: block;
28
28
  }
29
- :root { font-family: "IBM Plex Sans JP", sans-serif; color: #20352e; background: #e9eee9; }
29
+ :root { font-family: "Zen Kaku Gothic New", sans-serif; color: #20352e; background: #e9eee9; }
30
30
  * { box-sizing: border-box; }
31
31
  body { margin: 0; }
32
32
  .presentation-view { height: 100dvh; display: flex; flex-direction: column; }
@@ -44,9 +44,9 @@ button:focus-visible, a:focus-visible { outline: 2px solid #557e64; outline-offs
44
44
  #status { font-size: 12px; margin: 0; padding: 8px 24px; color: #607569; min-height: 30px; }
45
45
  #viewport { width: 100%; flex: 1 1 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 20px; }
46
46
  #stage { flex: 0 0 1920px; transform-origin: center; box-shadow: 0 8px 48px #20352e18; }
47
- .slide { width: 1920px; height: 1080px; padding: 64px 80px 48px; display: flex; flex-direction: column; overflow: hidden; background: white; color: #172b24; }
48
- .title { margin: 0 0 36px; white-space: nowrap; flex: 0 0 160px; font-weight: 700; line-height: 1.12; overflow: hidden; letter-spacing: -.025em; }
49
- .body { flex: 1 1 0; min-height: 0; overflow: hidden; line-height: 1.3; }
47
+ .slide { position: relative; width: 1920px; height: 1080px; padding: 64px 80px 48px; display: flex; flex-direction: column; overflow: hidden; background: white; color: #172b24; }
48
+ .title { margin: 0 0 36px; white-space: nowrap; flex: 0 0 160px; font-family: "Zen Kaku Gothic New", sans-serif; color: #353535; font-weight: 700; line-height: 1.12; overflow: hidden; letter-spacing: -.025em; }
49
+ .body { flex: 1 1 0; min-height: 0; overflow: hidden; line-height: 1.3; font-family: "Zen Kaku Gothic New", sans-serif; color: #353535; }
50
50
  .body p { margin: 0 0 .35em; }
51
51
  .body p, .body li { word-break: auto-phrase; text-wrap: pretty; }
52
52
  .titleless .body { display: flex; flex-direction: column; justify-content: safe center; text-align: center; }
@@ -60,12 +60,23 @@ button:focus-visible, a:focus-visible { outline: 2px solid #557e64; outline-offs
60
60
  .body ul, .body ol { margin: .2em 0 .4em; padding-left: 1.35em; }
61
61
  .body pre { margin: .3em 0; padding: .4em .55em; background: #f3f6f2; white-space: pre-wrap; tab-size: 2; }
62
62
  .titleless .body pre { width: fit-content; max-width: 100%; margin-inline: auto; text-align: left; }
63
- .body code { font-family: "UDEV Gothic", "IBM Plex Sans JP", monospace; font-size: .8em; }
63
+ .body code { font-family: "UDEV Gothic", "Zen Kaku Gothic New", monospace; font-size: .8em; }
64
64
  .body blockquote { border-left: .08em solid #b6cbb9; margin: .4em 0; padding-left: .6em; }
65
65
  .body table { border-collapse: collapse; width: 100%; }
66
66
  .body th, .body td { border: 1px solid #bac8bd; padding: .15em .3em; }
67
67
  .body img { display: block; object-fit: contain; max-width: 100%; }
68
68
  .body a { color: #32634b; }
69
+ .body p:has(.youtube-video) { margin-bottom: 0; }
70
+ .body p.youtube-only { width: 100%; text-align: center; }
71
+ .youtube-video { display: inline-block; position: relative; vertical-align: top; max-width: 100%; }
72
+ .youtube-video img { aspect-ratio: 16 / 9; object-fit: cover; }
73
+ .youtube-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #e00; color: white; border: 0; border-radius: 14px; font-size: 48px; padding: 8px 32px; }
74
+ .youtube-play:hover { background: #b00; }
75
+ .youtube-overlay { position: absolute; inset: 0; z-index: 10; background: black; }
76
+ .youtube-frame { width: 100%; height: 100%; border: 0; }
77
+ .youtube-close { position: absolute; z-index: 1; top: 24px; right: 24px; padding: 12px 20px; font-size: 28px; background: #202020e8; color: white; border-color: white; }
78
+ .youtube-close:hover { background: #444; }
79
+ @media print { .youtube-overlay, .youtube-play { display: none !important; } }
69
80
  .slide-footer { flex: 0 0 128px; position: relative; display: flex; align-items: start; font-size: 24px; color: #71887e; padding-top: 12px; }
70
81
  .page-footnote { width: 100%; min-width: 0; height: 1.5em; line-height: 1.5; white-space: nowrap; overflow: hidden; }
71
82
  .decorations { position: absolute; left: 0; right: 132px; bottom: 0; height: 80px; }
@@ -118,7 +129,7 @@ button:focus-visible, a:focus-visible { outline: 2px solid #557e64; outline-offs
118
129
  #time-expired { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; background: white; color: #20352e; padding: 16px; overflow: auto; }
119
130
  #time-expired[hidden], #countdown[hidden] { display: none; }
120
131
  #time-expired h1 { margin: 0; font-size: clamp(24px, 4vw, 56px); }
121
- .time-expired-image { width: min(90vw, calc(65vh * 1086 / 724)); aspect-ratio: 1086 / 724; height: auto; flex-shrink: 0; }
132
+ .time-expired-image { width: min(90vw, calc(65vh * 4 / 3)); aspect-ratio: 4 / 3; height: auto; flex-shrink: 0; }
122
133
  #time-expired p { margin: 8px 0; text-align: center; }
123
134
  @media print { #countdown, #time-expired { display: none !important; } }
124
135
 
Binary file
Binary file
Binary file
Binary file
data/assets/wani.wasm CHANGED
Binary file
@@ -83,6 +83,14 @@ module Wani
83
83
  next if event[:ctrlKey] == JS::True || event[:altKey] == JS::True || event[:metaKey] == JS::True
84
84
  next if %w[INPUT TEXTAREA SELECT].include?(target[:tagName].to_s) || target[:isContentEditable] == JS::True
85
85
  next if @waiting_to_start && !%w[f F Escape n N].include?(event[:key].to_s)
86
+ if event[:key].to_s == "Escape"
87
+ close = @sections[@index].querySelector(".youtube-close")
88
+ unless close == JS::Null
89
+ close.click
90
+ event.preventDefault
91
+ next
92
+ end
93
+ end
86
94
  handled = true
87
95
  case event[:key].to_s
88
96
  when "ArrowRight", " ", "PageDown" then go(@index + 1)
@@ -117,6 +125,9 @@ module Wani
117
125
  end
118
126
  previous_number = @active_number || 0
119
127
  @index = index.clamp(0, @sections.length - 1)
128
+ if previous_number.positive? && previous_number != @index + 1
129
+ @sections[previous_number - 1].querySelectorAll(".youtube-overlay").to_a.each(&:remove)
130
+ end
120
131
  @renderer.transition(@sections[@index], previous_number)
121
132
  @sections.each_with_index { |section, number| section[:classList].toggle("active", number == @index) }
122
133
  @active_number = @index + 1
@@ -184,6 +195,7 @@ module Wani
184
195
  @presentation.slides.each_with_index do |slide, index|
185
196
  [false, *(notes ? [true] : [])].each do |is_note|
186
197
  section = is_note ? @renderer.slide(slide, notes: true) : @sections[index].cloneNode(true)
198
+ section.querySelectorAll(".youtube-overlay").to_a.each(&:remove)
187
199
  if is_note
188
200
  element("stage").appendChild(section)
189
201
  @layout.wait_assets(section)
@@ -49,7 +49,7 @@ module Wani
49
49
  end
50
50
  @document[:fonts][:ready].await
51
51
  style = @document.createElement("style")
52
- style[:textContent] = %(.slide .title, .slide .body { font-family: #{family}, "IBM Plex Sans JP", sans-serif; })
52
+ style[:textContent] = %(.slide .title, .slide .body { font-family: #{family}, "Zen Kaku Gothic New", sans-serif; })
53
53
  @document[:head].appendChild(style)
54
54
  rescue => error
55
55
  link.remove if link
@@ -164,13 +164,19 @@ module Wani
164
164
  def fit_images(body)
165
165
  images = body.querySelectorAll("img").to_a
166
166
  return if images.empty?
167
- mixed = !body[:textContent].to_s.strip.empty?
168
- budget = body[:clientHeight].to_f * (mixed ? 0.45 : 0.85) / images.length
167
+ content = body.cloneNode(true)
168
+ content.querySelectorAll(".youtube-video").to_a.each(&:remove)
169
+ mixed = !content[:textContent].to_s.strip.empty?
170
+ videos_only = images.all? { |image| image.closest(".youtube-video") != JS::Null }
171
+ fraction = mixed ? 0.45 : (videos_only ? 0.98 : 0.85)
172
+ budget = body[:clientHeight].to_f * fraction / images.length
169
173
  images.each do |image|
170
174
  next if image[:naturalWidth].to_i.zero? || image[:naturalHeight].to_i.zero?
171
- ratio = [body[:clientWidth].to_f / image[:naturalWidth].to_f, budget / image[:naturalHeight].to_f].min
172
- image[:style][:width] = "#{image[:naturalWidth].to_f * ratio}px"
173
- image[:style][:height] = "#{image[:naturalHeight].to_f * ratio}px"
175
+ width = image[:naturalWidth].to_f
176
+ height = image.closest(".youtube-video") == JS::Null ? image[:naturalHeight].to_f : width * 9 / 16
177
+ ratio = [body[:clientWidth].to_f / width, budget / height].min
178
+ image[:style][:width] = "#{width * ratio}px"
179
+ image[:style][:height] = "#{height * ratio}px"
174
180
  end
175
181
  end
176
182
  end
@@ -3,18 +3,29 @@ module Wani
3
3
  class Application
4
4
  private
5
5
 
6
- # Decode the actual displayed image before enabling presentation controls.
6
+ # Decode the candidates before enabling presentation controls.
7
7
  def prepare_timer_image
8
8
  return if @presentation.time_limit.zero?
9
9
 
10
- element("time-expired-image").decode.await
11
- rescue JS::Error
12
- warn("時間切れの画像を読み込めませんでした")
10
+ @timer_images = (1..4).map do |number|
11
+ image = @document.createElement("img")
12
+ image[:src] = "/assets/time-expired-#{number}.webp"
13
+ image
14
+ end
15
+ @timer_images.each do |image|
16
+ begin
17
+ image.decode.await
18
+ rescue JS::Error
19
+ warn("時間切れの画像を読み込めませんでした")
20
+ end
21
+ end
13
22
  end
14
23
 
15
24
  def start_timer
16
25
  return if @presentation.time_limit.zero?
17
26
 
27
+ selected = (JS.global[:Math].random.to_f * @timer_images.length).floor
28
+ element("time-expired-image")[:src] = @timer_images[selected][:src]
18
29
  @deadline = JS.global[:Date].now.to_f + @presentation.time_limit * 60_000
19
30
  element("resume-slides").addEventListener("click") { go(@index) }
20
31
  @timer_callback = -> { tick_timer }
@@ -21,6 +21,14 @@ module Wani
21
21
  body = child(section, "div", "body")
22
22
  body[:innerHTML] = notes ? slide.notes_html : slide.html
23
23
  resolve_links(body)
24
+ body.querySelectorAll("p").to_a.each do |paragraph|
25
+ children = paragraph[:children].to_a
26
+ next unless children.length == 1 && children.first[:classList].contains("youtube-video") == JS::True
27
+ copy = paragraph.cloneNode(true)
28
+ copy.querySelector(".youtube-video").remove
29
+ paragraph[:classList].add("youtube-only") if copy[:textContent].to_s.strip.empty?
30
+ end
31
+ prepare_videos(body)
24
32
  footer = child(section, "footer", "slide-footer")
25
33
  child(footer, "span", "page-footnote")[:textContent] = slide.page_footnote
26
34
  number = child(footer, "span", "slide-number")
@@ -64,6 +72,32 @@ module Wani
64
72
  end
65
73
  end
66
74
 
75
+ def prepare_videos(root)
76
+ root.querySelectorAll(".youtube-video").to_a.each do |video|
77
+ button = video.querySelector(".youtube-play")
78
+ button.addEventListener("click") do
79
+ section = video.closest(".slide")
80
+ next unless section.querySelector(".youtube-overlay") == JS::Null
81
+ overlay = child(section, "div", "youtube-overlay")
82
+ frame = child(overlay, "iframe", "youtube-frame")
83
+ url = video.getAttribute("data-youtube-src").to_s
84
+ frame[:src] = "#{url}#{url.include?("?") ? "&" : "?"}autoplay=1"
85
+ frame[:title] = button.getAttribute("aria-label")
86
+ frame.setAttribute("allow", "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share")
87
+ frame.setAttribute("allowfullscreen", "")
88
+ close = child(overlay, "button", "youtube-close")
89
+ close[:type] = "button"
90
+ close[:textContent] = "閉じる ×"
91
+ close.setAttribute("aria-label", "動画を閉じる")
92
+ close.addEventListener("click") do
93
+ overlay.remove
94
+ button.focus
95
+ end
96
+ close.focus
97
+ end
98
+ end
99
+ end
100
+
67
101
  def resolve_links(root)
68
102
  root.querySelectorAll("img, a").to_a.each do |node|
69
103
  attribute = node[:tagName].to_s == "IMG" ? "src" : "href"
@@ -16,6 +16,21 @@ module Wani
16
16
  !scheme || (image ? %w[http https] : %w[http https mailto]).include?(scheme.downcase)
17
17
  end
18
18
 
19
+ # Accept only an explicit, canonical YouTube video URL and numeric bounds.
20
+ def self.youtube(value)
21
+ return nil unless value.is_a?(String)
22
+ match = value.match(%r{\Ahttps://(?:www\.)?youtube\.com/watch\?([^#]+)\z})
23
+ return nil unless match
24
+ pairs = match[1].split("&", -1).map { |part| part.split("=", 2) }
25
+ return nil unless pairs.all? { |key, val| %w[v start end].include?(key) && val && !val.empty? }
26
+ return nil unless pairs.map(&:first).uniq.length == pairs.length
27
+ params = pairs.to_h
28
+ return nil unless params["v"]&.match?(/\A[A-Za-z0-9_-]{11}\z/)
29
+ return nil unless %w[start end].all? { |key| !params[key] || params[key].match?(/\A\d{1,8}\z/) }
30
+ return nil if params["end"] && params["end"].to_i <= (params["start"] || "0").to_i
31
+ params
32
+ end
33
+
19
34
  def initialize(&diagnostic)
20
35
  @diagnostic = diagnostic || ->(_message) {}
21
36
  end
@@ -37,7 +52,14 @@ module Wani
37
52
  body
38
53
  end
39
54
  when :img
40
- if self.class.safe_url?(node.attr["src"], image: true)
55
+ if (video = self.class.youtube(node.attr["src"]))
56
+ id = video.fetch("v")
57
+ query = %w[start end].filter_map { |key| "#{key}=#{video[key]}" if video[key] }.join("&")
58
+ url = "https://www.youtube.com/embed/#{id}"
59
+ url += "?#{query}" unless query.empty?
60
+ alt = self.class.escape(node.attr["alt"])
61
+ "<span class=\"youtube-video\" data-youtube-src=\"#{self.class.escape(url)}\"><img src=\"https://i.ytimg.com/vi/#{id}/hqdefault.jpg\" alt=\"#{alt}\"><button type=\"button\" class=\"youtube-play\" aria-label=\"#{alt.empty? ? 'YouTube動画を再生' : alt + 'を再生'}\">▶</button></span>"
62
+ elsif self.class.safe_url?(node.attr["src"], image: true)
41
63
  "<img src=\"#{self.class.escape(node.attr['src'])}\" alt=\"#{self.class.escape(node.attr['alt'])}\">"
42
64
  else
43
65
  @diagnostic.call("Unsafe image URL removed")
@@ -7,8 +7,8 @@ module Wani
7
7
  module Server
8
8
  # Only the selected Markdown, images below its directory and fixed gem assets are public.
9
9
  class Application
10
- ASSETS = %w[index.html style.css highlight.css rouge.LICENSE bootstrap.rb speaker.html rabbit.svg shark.svg time-expired.webp runtime.pr672.js wani.wasm runtime.LICENSE runtime.NOTICE build.json
11
- fonts/IBMPlexSansJP-Regular.woff2 fonts/IBMPlexSansJP-Bold.woff2
10
+ ASSETS = %w[index.html style.css highlight.css rouge.LICENSE bootstrap.rb speaker.html rabbit.svg shark.svg time-expired-1.webp time-expired-2.webp time-expired-3.webp time-expired-4.webp runtime.pr672.js wani.wasm runtime.LICENSE runtime.NOTICE build.json
11
+ fonts/ZenKakuGothicNew-Regular.ttf fonts/ZenKakuGothicNew-Bold.ttf
12
12
  fonts/UDEVGothic-Regular.ttf fonts/UDEVGothic-Bold.ttf].freeze
13
13
  TYPES = { ".html" => "text/html; charset=utf-8", ".css" => "text/css; charset=utf-8", ".rb" => "text/plain; charset=utf-8", ".js" => "text/javascript", ".wasm" => "application/wasm", ".md" => "text/plain; charset=utf-8", ".svg" => "image/svg+xml", ".png" => "image/png", ".jpg" => "image/jpeg", ".jpeg" => "image/jpeg", ".webp" => "image/webp", ".json" => "application/json", ".woff2" => "font/woff2", ".ttf" => "font/ttf" }.freeze
14
14
  IMAGES = %w[.png .jpg .jpeg .webp .svg].freeze
@@ -46,7 +46,7 @@ module Wani
46
46
  if type.start_with?("image/")
47
47
  headers["Content-Security-Policy"] = "sandbox; default-src 'none'; style-src 'unsafe-inline'"
48
48
  else
49
- headers["Content-Security-Policy"] = "default-src 'self'; script-src 'self' 'unsafe-eval' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' https: http:; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'"
49
+ headers["Content-Security-Policy"] = "default-src 'self'; script-src 'self' 'unsafe-eval' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' https: http:; connect-src 'self'; frame-src https://www.youtube.com; object-src 'none'; base-uri 'none'; frame-ancestors 'none'"
50
50
  end
51
51
  body = File.binread(file)
52
52
  report_font(body.dup.force_encoding(Encoding::UTF_8)) if path == "/talk/slides.md" && @diagnostics
data/lib/wani/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wani
2
- VERSION = "0.1.15"
2
+ VERSION = "0.1.17"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wani
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - ledsun
@@ -88,10 +88,11 @@ files:
88
88
  - README.md
89
89
  - assets/bootstrap.rb
90
90
  - assets/build.json
91
- - assets/fonts/IBMPlexSansJP-Bold.woff2
92
- - assets/fonts/IBMPlexSansJP-Regular.woff2
93
91
  - assets/fonts/UDEVGothic-Bold.ttf
94
92
  - assets/fonts/UDEVGothic-Regular.ttf
93
+ - assets/fonts/ZenKakuGothicNew-Bold.ttf
94
+ - assets/fonts/ZenKakuGothicNew-OFL.txt
95
+ - assets/fonts/ZenKakuGothicNew-Regular.ttf
95
96
  - assets/highlight.css
96
97
  - assets/index.html
97
98
  - assets/rabbit.svg
@@ -102,7 +103,10 @@ files:
102
103
  - assets/shark.svg
103
104
  - assets/speaker.html
104
105
  - assets/style.css
105
- - assets/time-expired.webp
106
+ - assets/time-expired-1.webp
107
+ - assets/time-expired-2.webp
108
+ - assets/time-expired-3.webp
109
+ - assets/time-expired-4.webp
106
110
  - assets/wani.wasm
107
111
  - exe/wani
108
112
  - lib/wani.rb
@@ -128,9 +132,6 @@ files:
128
132
  - third_party/gems/kramdown-LICENSE
129
133
  - third_party/gems/kramdown-parser-gfm-LICENSE
130
134
  - third_party/gems/rexml-LICENSE
131
- - third_party/ibm-plex-sans-jp/LICENSE.txt
132
- - third_party/ibm-plex-sans-jp/README.md
133
- - third_party/ibm-plex-sans-jp/provenance.json
134
135
  - third_party/ruby-wasm-loader/LICENSE
135
136
  - third_party/ruby-wasm-loader/NOTICE
136
137
  - third_party/ruby-wasm-loader/README.md
Binary file
Binary file
@@ -1,39 +0,0 @@
1
- # IBM Plex Sans JP
2
-
3
- IBM の公式 npm パッケージ [`@ibm/plex-sans-jp@3.0.0`](https://www.npmjs.com/package/@ibm/plex-sans-jp/v/3.0.0)
4
- から、以下の完成版 WOFF2 を変更せずに同梱する。
5
-
6
- - `assets/fonts/IBMPlexSansJP-Regular.woff2`(400 / 2,282,284 bytes)
7
- - `assets/fonts/IBMPlexSansJP-Bold.woff2`(700 / 2,352,756 bytes)
8
-
9
- 元ファイルは `fonts/complete/woff2/hinted/` にある。サブセット化・改名・フォントデータの加工はしていない。
10
- 出所・バージョン・配布アーカイブと各ファイルの SHA-256 は `provenance.json` に記録する。
11
-
12
- Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"。
13
- SIL Open Font License 1.1 により配布され、著作権表示とライセンス全文を `LICENSE.txt` に保持する。
14
- アプリの MIT ライセンスとは区別する。
15
-
16
- ## 取得の再現
17
-
18
- ```sh
19
- npm pack @ibm/plex-sans-jp@3.0.0 --pack-destination /tmp
20
- ```
21
-
22
- `provenance.json` のアーカイブ SHA-256 と照合して展開し、上記2ファイルとパッケージの `LICENSE.txt` を取り出す。
23
- Wani の通常利用・ビルド時にフォントのダウンロードや OS インストールは不要。
24
- 参照元: [IBM 公式リポジトリ](https://github.com/IBM/plex/tree/master/packages/plex-sans-jp)。
25
-
26
- ## PDF の文字抽出
27
-
28
- 検証した Chromium の PDF では、同じグリフに対応する文字が互換部首として抽出される場合がある
29
- (例: `日` → `⽇`)。表示の字形とフォント埋め込みは確認し、内容比較のテストでは NFKC 正規化する。
30
- PDF のテキストコピーが常に元のコードポイントと一致することまでは保証しない。
31
-
32
- ## 動作検証 (2026-10-26)
33
-
34
- Linux / Ruby 4.0.7 / Node.js 24.22.1 / Chrome 156.0.8078.47。
35
- Ruby は12件・85アサーション、ブラウザーは13件成功(35.8秒)。
36
- Chrome の実フォント情報で日本語の Regular / Bold と Web フォント使用を確認し、
37
- 日本語 PDF の文字内容・Regular / Bold と FontFile2 の埋め込みを検査した。
38
- 太字の取得先を壊すと実描画テストは失敗し、復元後はフォント検証3件が成功(9.2秒)。
39
- 隔離環境の gem インストールでも2フォントのハッシュ一致、ライセンス同梱、HTTP配信を確認した。
@@ -1,20 +0,0 @@
1
- {
2
- "package": "@ibm/plex-sans-jp",
3
- "version": "3.0.0",
4
- "repository": "https://github.com/IBM/plex/tree/master/packages/plex-sans-jp",
5
- "tarball": "https://registry.npmjs.org/@ibm/plex-sans-jp/-/plex-sans-jp-3.0.0.tgz",
6
- "tarball_sha256": "051484321fcffecc69c3d608b739c5fe0f558b0fd1de7958d96ca360d161de7f",
7
- "license": "OFL-1.1",
8
- "files": {
9
- "IBMPlexSansJP-Bold.woff2": {
10
- "sha256": "38336fbb169ae1b7b6ca2539332e1d59c9be222227659d23f8eb70ecda60337d",
11
- "bytes": 2352756,
12
- "source_path": "fonts/complete/woff2/hinted/IBMPlexSansJP-Bold.woff2"
13
- },
14
- "IBMPlexSansJP-Regular.woff2": {
15
- "sha256": "ec27e9b75cd90a6f7abe96ede49d00b151eb5b1c2c886bfe9b4fc845f40be1ff",
16
- "bytes": 2282284,
17
- "source_path": "fonts/complete/woff2/hinted/IBMPlexSansJP-Regular.woff2"
18
- }
19
- }
20
- }