@farberg/reveal-template 1.1.10 → 1.1.13

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.
@@ -2,9 +2,11 @@
2
2
 
3
3
  <head>
4
4
  <meta charset="utf-8">
5
+ <meta name="mobile-web-app-capable" content="yes" />
5
6
  <meta name="apple-mobile-web-app-capable" content="yes" />
6
7
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
7
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes, minimal-ui">
8
+ <meta name="viewport"
9
+ content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes, minimal-ui">
8
10
 
9
11
  <script type="module">
10
12
  import { initReveal } from '../init-reveal.js'
package/init-reveal.js CHANGED
@@ -35,7 +35,7 @@ const externalJsLibs = [
35
35
 
36
36
  const extraStylesheets = [
37
37
  { href: 'node_modules/reveal.js/dist/reveal.css' },
38
- { href: 'node_modules/reveal.js/plugin/highlight/zenburn.css' },
38
+ { href: 'node_modules/reveal.js/dist/plugin/highlight/zenburn.css' },
39
39
  { href: 'node_modules/asciinema-player/dist/bundle/asciinema-player.css' },
40
40
  { href: 'node_modules/reveal.js-plugins/customcontrols/style.css' },
41
41
  { href: 'node_modules/reveal.js-plugins/chalkboard/style.css' },
@@ -126,19 +126,19 @@ function windowOnLoadPromise() {
126
126
  // Load reveal and its plugins
127
127
  function loadRevealAndPlugins(options) {
128
128
  const imports = [
129
- "dist/reveal.esm.js" /*must be the first one*/,
130
- "plugin/markdown/markdown.esm.js",
131
- "plugin/highlight/highlight.esm.js",
132
- "plugin/search/search.esm.js",
133
- "plugin/notes/notes.esm.js",
134
- "plugin/math/math.esm.js",
135
- "plugin/zoom/zoom.esm.js"
129
+ "dist/reveal.mjs" /*must be the first one*/,
130
+ "dist/plugin/markdown.mjs",
131
+ "dist/plugin/highlight.mjs",
132
+ "dist/plugin/search.mjs",
133
+ "dist/plugin/notes.mjs",
134
+ "dist/plugin/math.mjs",
135
+ "dist/plugin/zoom.mjs"
136
136
  ]
137
137
 
138
138
  if (options.verbose)
139
139
  console.log("Importing the following plugins: ", imports)
140
140
 
141
- return Promise.all(imports.map(i => import(options.revealPath + "/" + i)))
141
+ return Promise.all(imports.map(i => import(options.revealPath + i)))
142
142
  }
143
143
 
144
144
  // Add js tags to the header and resolve
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farberg/reveal-template",
3
- "version": "1.1.10",
3
+ "version": "1.1.13",
4
4
  "homepage": "https://github.com/pfisterer/reveal-template",
5
5
  "description": "Reveal.js template for Dennis' lectures",
6
6
  "main": "index.js",
@@ -15,17 +15,17 @@
15
15
  "author": "Dennis Pfisterer, http://dennis-pfisterer.de",
16
16
  "license": "Apache License 2.0",
17
17
  "dependencies": {
18
- "asciinema-player": "^3.9.0",
18
+ "asciinema-player": "^3.15.1",
19
19
  "connect": "^3.7.0",
20
20
  "easyqrcodejs": "^4.6.2",
21
21
  "file-saver": "^2.0.5",
22
22
  "jszip": "^3.10.1",
23
- "mermaid": "^11.6.0",
23
+ "mermaid": "^11.14.0",
24
24
  "pdf-merger-js": "^5.1.2",
25
- "puppeteer": "^24.6.0",
26
- "reveal.js": "^5.2.1",
27
- "serve-static": "^2.2.0",
28
- "@fortawesome/fontawesome-free": "^6.4.1",
25
+ "puppeteer": "^24.42.0",
26
+ "reveal.js": "^6.0.1",
27
+ "serve-static": "^2.2.1",
28
+ "@fortawesome/fontawesome-free": "^7.2.0",
29
29
  "reveal.js-plugins": "^4.6.0"
30
30
  }
31
31
  }
@@ -57,15 +57,24 @@ const dir_tree = {
57
57
  }
58
58
 
59
59
  function download(files, zipName) {
60
- Promise.all(files.map(file => fetch(file)))
61
- .then(promises => Promise.all(promises.map(p => p.text()))
62
- .then(values => {
63
- var zip = new JSZip();
64
- values.forEach((text, idx) => zip.file(files[idx], text))
65
- zip.generateAsync({ type: "blob" }).then(blob => {
66
- saveAs(blob, zipName);
60
+ Promise.all(files.map(file => fetch(file, { "credentials": "include" })))
61
+ .then(promises => {
62
+ // Check for 401 responses
63
+ const hasUnauthorized = promises.some(p => p.status === 401);
64
+ if (hasUnauthorized) {
65
+ console.log("Authentication required (dir-tree), reloading page");
66
+ window.location.reload();
67
+ return;
68
+ }
69
+ return Promise.all(promises.map(p => p.text()))
70
+ .then(values => {
71
+ var zip = new JSZip();
72
+ values.forEach((text, idx) => zip.file(files[idx], text))
73
+ zip.generateAsync({ type: "blob" }).then(blob => {
74
+ saveAs(blob, zipName);
75
+ })
67
76
  })
68
- }))
77
+ })
69
78
 
70
79
  }
71
80
 
@@ -1,8 +1,16 @@
1
- import mermaid from '../../../mermaid/dist/mermaid.esm.min.mjs';
1
+ // When installed as an npm package the plugin lives at node_modules/@farberg/reveal-template/plugins/
2
+ // and mermaid is 3 levels up. When running from the template root directly it is 1 level up.
3
+ const mermaidUrl = new URL(
4
+ new URL(import.meta.url).pathname.includes('/node_modules/')
5
+ ? '../../../mermaid/dist/mermaid.esm.min.mjs'
6
+ : '../node_modules/mermaid/dist/mermaid.esm.min.mjs',
7
+ import.meta.url
8
+ ).href;
2
9
 
3
10
  export default {
4
11
  id: 'mermaid',
5
- init: (deck) => {
12
+ init: async (deck) => {
13
+ const { default: mermaid } = await import(mermaidUrl);
6
14
  mermaid.initialize({
7
15
  'startOnLoad': false,
8
16
  'theme': 'base',
@@ -20,14 +28,41 @@ export default {
20
28
  'sequence': {
21
29
  'mirrorActors': false,
22
30
  'useMaxWidth': true
31
+ },
32
+ 'flowchart': {
33
+ 'useMaxWidth': true,
34
+ 'htmlLabels': true
23
35
  }
24
36
  });
25
37
 
38
+ function fixSvgScaling(el) {
39
+ el.querySelectorAll('pre.mermaid svg').forEach(svg => {
40
+ // mermaid v10+ sets style="max-width: Xpx" which constrains width —
41
+ // remove it and let the container CSS drive the size instead
42
+ svg.style.maxWidth = '100%';
43
+ svg.style.width = '100%';
44
+ svg.style.height = 'auto';
45
+ });
46
+ }
47
+
26
48
  function handle(el) {
27
- const mermaids = el.querySelectorAll('pre.mermaid')
28
- mermaid.run({
29
- nodes: mermaids,
49
+ // Convert ```mermaid code blocks into pre.mermaid elements.
50
+ // highlight.js processes them first (adding spans, encoding arrows as &gt;),
51
+ // so we read textContent to strip spans and decode HTML entities back to raw source.
52
+ el.querySelectorAll('code.mermaid').forEach(code => {
53
+ if (code.closest('pre.mermaid')) return; // already converted
54
+ const pre = code.parentElement;
55
+ pre.className = 'mermaid';
56
+ pre.textContent = code.textContent;
30
57
  });
58
+
59
+ const mermaids = el.querySelectorAll('pre.mermaid');
60
+ const result = mermaid.run({ nodes: mermaids });
61
+ if (result && typeof result.then === 'function') {
62
+ result.then(() => fixSvgScaling(el));
63
+ } else {
64
+ setTimeout(() => fixSvgScaling(el), 100);
65
+ }
31
66
  }
32
67
 
33
68
  deck.on('ready', event => {
@@ -40,12 +75,15 @@ export default {
40
75
  border: 1px solid #e0e0e0;
41
76
  box-shadow: none !important;
42
77
  text-align: center;
43
- }
78
+ overflow: visible;
79
+ }
80
+ pre.mermaid svg {
81
+ max-width: 100%;
82
+ height: auto;
83
+ }
44
84
  `;
45
85
  document.head.appendChild(style);
46
86
 
47
- //check if url contains print-pdf
48
-
49
87
  const print = window.location.search.match(/print-pdf/gi);
50
88
 
51
89
  if (print) {
@@ -55,7 +93,6 @@ export default {
55
93
  deck.addEventListener('slidechanged', e => handle(e.currentSlide));
56
94
  handle(event.currentSlide);
57
95
  }
58
-
59
96
  })
60
97
  }
61
98
  }
@@ -93,7 +93,12 @@ export default () => {
93
93
  //console.log(`language = ${language}, url = ${url}, beginMarker = ${beginMarker}, endMarker = ${endMarker}, showLink = ${showLink} `)
94
94
 
95
95
  if (url) {
96
- const response = await fetch(url, { "cache": "no-store" })
96
+ const response = await fetch(url, { "cache": "no-store", "credentials": "include" })
97
+ if (response.status === 401) {
98
+ console.log("Authentication required (show-code-snippets), reloading page");
99
+ window.location.reload();
100
+ return;
101
+ }
97
102
  const text = await response.text()
98
103
  let code = extractBeginEndSnippet(text, beginMarker, endMarker)
99
104
 
@@ -50,9 +50,18 @@ export default () => {
50
50
  deck.on('ready', () => {
51
51
  let info_json_url = (deck.getConfig().farberg_reveal_template || {}).info_json || new URL('package.json', window.location)
52
52
  if (info_json_url)
53
- fetch(info_json_url.href, { "cache": "no-store" })
54
- .then(res => res.json())
55
- .then(json => showLinkToSlidesAndQrCode(deck, json.homepage))
53
+ fetch(info_json_url.href, { "cache": "no-store", "credentials": "include" })
54
+ .then(res => {
55
+ if (res.status === 401) {
56
+ console.log("Authentication required, reloading page");
57
+ window.location.reload();
58
+ return;
59
+ }
60
+ return res.json();
61
+ })
62
+ .then(json => {
63
+ if (json) showLinkToSlidesAndQrCode(deck, json.homepage)
64
+ })
56
65
  .catch(err => console.log("Error fetching info json", err))
57
66
  else
58
67
  console.log("show_qr_code: no URL available @ farberg_reveal_template.info_json")
@@ -53,9 +53,18 @@ export default () => {
53
53
  deck.on('ready', () => {
54
54
  let info_json_url = (deck.getConfig().farberg_reveal_template || {}).info_json || new URL('package.json', window.location)
55
55
  if (info_json_url)
56
- fetch(info_json_url.href, { "cache": "no-store" })
57
- .then(response => response.json())
58
- .then(packageJson => showTitle(deck, packageJson));
56
+ fetch(info_json_url.href, { "cache": "no-store", "credentials": "include" })
57
+ .then(res => {
58
+ if (res.status === 401) {
59
+ console.log("Authentication required (show-title), reloading page");
60
+ window.location.reload();
61
+ return;
62
+ }
63
+ return res.json();
64
+ })
65
+ .then(packageJson => {
66
+ if (packageJson) showTitle(deck, packageJson)
67
+ });
59
68
  else
60
69
  console.log("show_title: no URL available @ farberg_reveal_template.info_json")
61
70
  })
@@ -14,9 +14,18 @@
14
14
  */
15
15
 
16
16
  function showToc(url, el) {
17
- fetch(url, { "cache": "no-store" })
18
- .then(res => res.text())
19
- .then(html => el.innerHTML = html)
17
+ fetch(url, { "cache": "no-store", "credentials": "include" })
18
+ .then(res => {
19
+ if (res.status === 401) {
20
+ console.log("Authentication required (show-toc), reloading page");
21
+ window.location.reload();
22
+ return;
23
+ }
24
+ return res.text();
25
+ })
26
+ .then(html => {
27
+ if (html) el.innerHTML = html
28
+ })
20
29
  .catch(e => console.log(`Unable to load TOC from ${url}`, e))
21
30
  }
22
31
 
@@ -2,12 +2,15 @@ const fs = require('fs');
2
2
 
3
3
  module.exports.combined_pdf = function (package_json) {
4
4
 
5
+ // Extract shortnames and join with " and "
5
6
  let authorBlock = package_json.authors.map(entry => {
6
7
  return entry.shortname || entry.name || "unknown"
7
8
  }).join(" and ")
8
9
 
9
- const combined_pdf_name = `${package_json.description} - ${authorBlock}`
10
- .replace(/[^\w- ]/gi, '') + ".pdf"
10
+ // Match the bash logic: Title - Shortnames.pdf
11
+ // Note: We avoid the regex replacement unless you specifically want
12
+ // to strip the " - " separator we just added.
13
+ const combined_pdf_name = `${package_json.title} - ${authorBlock}.pdf`
11
14
 
12
15
  return combined_pdf_name
13
16
  }