@farberg/reveal-template 1.1.14 → 1.1.15

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.
@@ -22,6 +22,21 @@
22
22
 
23
23
  <body>
24
24
  <div class="reveal">
25
- <div class="slides"></div>
25
+ <div class="slides">
26
+ <section data-markdown>
27
+ <textarea data-template>
28
+ ## Gateway API
29
+
30
+ ```mermaid
31
+ graph LR
32
+ GWC[GatewayClass] -->|implemented by| Ctrl[Controller]
33
+ GW[Gateway] -->|references| GWC
34
+ Route[HTTPRoute] -->|attaches to| GW
35
+ Route -->|routes to| SvcA[Service A]
36
+ Route -->|routes to| SvcB[Service B]
37
+ ```
38
+ </textarea>
39
+ </section>
40
+ </div>
26
41
  </div>
27
42
  </body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farberg/reveal-template",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "homepage": "https://github.com/pfisterer/reveal-template",
5
5
  "description": "Reveal.js template for Dennis' lectures",
6
6
  "main": "index.js",
@@ -92,24 +92,39 @@ export default () => {
92
92
 
93
93
  //console.log(`language = ${language}, url = ${url}, beginMarker = ${beginMarker}, endMarker = ${endMarker}, showLink = ${showLink} `)
94
94
 
95
- if (url) {
96
- const response = await fetch(url, { "cache": "no-store", "credentials": "include" })
95
+ if (!url) {
96
+ showError(el, "No URL provided in elements innerText")
97
+ continue
98
+ }
99
+
100
+ try {
101
+ const sameOrigin = new URL(url, window.location.href).origin === window.location.origin
102
+ const response = await fetch(url, { "cache": "no-store", "credentials": sameOrigin ? "include" : "omit" })
97
103
  if (response.status === 401) {
98
104
  console.log("Authentication required (show-code-snippets), reloading page");
99
105
  window.location.reload();
100
106
  return;
101
107
  }
108
+ if (!response.ok) {
109
+ showError(el, `HTTP ${response.status} loading ${url}`)
110
+ continue
111
+ }
102
112
  const text = await response.text()
103
113
  let code = extractBeginEndSnippet(text, beginMarker, endMarker)
104
114
 
115
+ if (!code) {
116
+ showError(el, `No content extracted from ${url} (begin=${beginMarker}, end=${endMarker})`)
117
+ continue
118
+ }
119
+
105
120
  if (outdentCode)
106
121
  code = outdent(code)
107
122
 
108
123
  const newEl = showCode(el, language, code, showLink ? url : null, outdent)
109
124
  highlightPlugin.hljs.highlightElement(newEl)
110
-
111
- } else {
112
- showError(el, "No URL provided in elements innerText")
125
+ } catch (err) {
126
+ console.error(`show-code-snippets: failed to load ${url}:`, err)
127
+ showError(el, `Failed to load ${url}: ${err.message}`)
113
128
  }
114
129
  }
115
130