Skip to content

Commit 55aa3c6

Browse files
committed
deps: h5p-author 0.15.0, and the build page saves the source it built (#84)
1 parent e30afa5 commit 55aa3c6

6 files changed

Lines changed: 38 additions & 13 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@codemirror/state": "6.7.6",
2929
"@codemirror/view": "6.43.15",
3030
"@lezer/highlight": "1.2.5",
31-
"@missing-elements/h5p-author": "0.14.0",
31+
"@missing-elements/h5p-author": "0.15.0",
3232
"@missing-elements/h5p-libraries": "1.1.1",
3333
"@missing-elements/h5p-offline-player": "1.7.0",
3434
"@missing-elements/h5p-runtime": "1.0.2",

‎pnpm-lock.yaml‎

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/assets/site.css‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,8 @@ pre.prompt { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.9375re
10511051
.build .file-list li[data-chosen="true"]::before { border: 0; border-radius: 0; background: var(--accent); mask: var(--icon-check) center / contain no-repeat; }
10521052
.build .file-list li[data-chosen="false"] { color: var(--muted); }
10531053
.build .hint { color: var(--muted); font-size: 0.875rem; }
1054+
/* The package and its source, side by side, and one under the other where they do not fit. */
1055+
.build .downloads { display: flex; flex-wrap: wrap; gap: 0.6rem; }
10541056
/* H5P content draws on white, whatever the page's theme. */
10551057
/* H5P content draws on white, whatever the page's theme. Clipped to the box's corners. */
10561058
.player-box { margin: 1rem 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: clip; background: #ffffff; }

‎src/h5p/build/build-page.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const notesBox = $('notes-box')
6060
const notesList = $<HTMLUListElement>('notes')
6161
const playStep = $('play-step')
6262
const download = $<HTMLAnchorElement>('download')
63+
const downloadSource = $<HTMLAnchorElement>('download-source')
6364
const player = $('player') as HTMLElementTagNameMap['h5p-player']
6465
const sample = $('sample') as HTMLElementTagNameMap['h5p-player']
6566
const sampleFigure = $('sample-figure')
@@ -97,6 +98,8 @@ let typeFilesArriving: Promise<void> | null = null
9798
let shows = 0
9899
/** The address of the package last built, given back when the next one replaces it. */
99100
let packageUrl: string | null = null
101+
/** The address of its source, as the build took it, given back likewise. */
102+
let sourceUrl: string | null = null
100103
/** Counts builds, so that one overtaken by a newer one shows nothing. */
101104
let builds = 0
102105
/** Whether the address carries a source, which it then keeps in step with the source as it changes. */
@@ -304,6 +307,14 @@ async function build(): Promise<void> {
304307
download.href = packageUrl
305308
download.download = name
306309
download.textContent = `Download ${name}`
310+
// The source as the build took it, naming what it was built with, under the package's name:
311+
// the file the command line writes beside a package, and the one "Or open a file" takes.
312+
const sourceName = name.replace(/\.h5p$/, '.source.json')
313+
if (sourceUrl) URL.revokeObjectURL(sourceUrl)
314+
sourceUrl = URL.createObjectURL(new Blob([`${JSON.stringify(result.source, null, 2)}\n`], { type: 'application/json' }))
315+
downloadSource.href = sourceUrl
316+
downloadSource.download = sourceName
317+
downloadSource.textContent = `Download ${sourceName}`
307318
showNotes([...result.notes, ...translationNotes(String(result.manifest.language ?? ''), result.translations)])
308319
const media = result.media.length ? `, ${result.media.length} media file${result.media.length === 1 ? '' : 's'}` : ''
309320
setStatus(`Built “${title}”: ${String(result.manifest.mainLibrary)}, ${result.libraries.length} libraries${media}, ${sized(result.blob.size)}. Starting it below…`, 'building')

‎src/h5p/build/index.njk‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ csp: "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' da
103103
<li class="feature">
104104
<span class="feature-icon icon-browser" aria-hidden="true"></span>
105105
<h3>Privacy first, no server of ours</h3>
106-
<p>Your chat builds the activity in its own sandbox, or this page builds and plays it on your computer: nothing you make is sent to us. It is free and <a href="https://github.com/missing-elements/missing-elements.github.io/tree/main/src/h5p/build">open source</a>, and needs no account.</p>
106+
<p>Your chat builds the activity in its own sandbox, or this page builds and plays it on your computer: nothing you make is sent to us. Where your source names a picture or a video by web address, the page asks that address's site for it, and YouTube or Vimeo whether the video is there. It is free and <a href="https://github.com/missing-elements/missing-elements.github.io/tree/main/src/h5p/build">open source</a>, and needs no account.</p>
107107
</li>
108108
<li class="feature">
109109
<span class="feature-icon icon-school" aria-hidden="true"></span>
@@ -239,7 +239,19 @@ csp: "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' da
239239
Work through all of it, wrong answers included, and check the answers and feedback against
240240
your material. The build checks the structure, not whether the content is right.
241241
</p>
242-
<p><a class="button button-solid button-large" id="download" download>Download the .h5p</a></p>
242+
{#- The source goes with the package, as the command line writes it beside one (author
243+
0.15.0, h5p-toolkit#219): as the build took it, naming the version of its content type
244+
it was built with, so that a later build with newer libraries can say the type has
245+
moved. It is the build's, not the box's text, which stays as the person wrote it. -#}
246+
<p class="downloads">
247+
<a class="button button-solid button-large" id="download" download>Download the .h5p</a>
248+
<a class="button button-large" id="download-source" download>Download its source</a>
249+
</p>
250+
<p class="hint">
251+
Keep the source with the file. To change the activity later, open the source here and
252+
build it again: it names the version of its content type it was built with, and a build
253+
with newer libraries says if that has moved.
254+
</p>
243255
<div class="player-box">
244256
<h5p-player id="player"></h5p-player>
245257
</div>

‎src/h5p/create-with-ai/index.njk‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ csp: "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self'; o
165165
</ul>
166166
<p>
167167
From the source, the build page builds it in your browser, plays it, and saves the file
168-
with Download the .h5p. A chat that built the file gives its source file too: open it on the
168+
with Download the .h5p, and its source with the button beside it. A chat that built the file gives its source file too: open it on the
169169
build page to play the activity before you use it.
170170
</p>
171171
{#- The whole of the archive is here, under a heading of its own, where a reader has just

0 commit comments

Comments
 (0)