From 64e9c9aa5349ea32a005e17ce15135418471da8e Mon Sep 17 00:00:00 2001 From: Thomas <27960254+thomiceli@users.noreply.github.com> Date: Fri, 3 Jul 2026 17:06:57 +0800 Subject: [PATCH] Fix actions db (#761) Signed-off-by: Thomas Miceli --- internal/actions/actions.go | 2 +- internal/db/action_lock.go | 2 +- public/ts/ipynb.ts | 7 +++++-- templates/pages/gist.html | 10 +++++++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/internal/actions/actions.go b/internal/actions/actions.go index a88cc1f..0606911 100644 --- a/internal/actions/actions.go +++ b/internal/actions/actions.go @@ -51,7 +51,7 @@ var registry = map[int]action{ ResetHooks: {run: resetHooks}, IndexGists: {run: indexGists}, SyncGistLanguages: {run: syncGistLanguages}, - DeleteExpiredGists: {run: deleteExpiredGists, spec: "@every 1m"}, + DeleteExpiredGists: {run: deleteExpiredGists, spec: "@every 12h"}, SyncSSHKeys: {run: syncSSHKeys, spec: "@every 72h"}, } diff --git a/internal/db/action_lock.go b/internal/db/action_lock.go index a86d537..c0e6692 100644 --- a/internal/db/action_lock.go +++ b/internal/db/action_lock.go @@ -11,7 +11,7 @@ import ( // keyed by Action (the action's identifier); LockedUntil holds the Unix // timestamp the current lease expires at (0 = free). type ActionLock struct { - Action int `gorm:"primaryKey"` + Action int `gorm:"primaryKey;autoIncrement:false"` LockedUntil int64 } diff --git a/public/ts/ipynb.ts b/public/ts/ipynb.ts index 8f3c054..7e6953b 100644 --- a/public/ts/ipynb.ts +++ b/public/ts/ipynb.ts @@ -9,6 +9,9 @@ import DOMPurify from 'dompurify'; // security advisory describing the original markdown-cell / output sinks). const sanitize = (html: string): string => DOMPurify.sanitize(html); +// nbformat allows `source`/`text` fields to be either a string or an array of strings. +const joinSource = (source: string | string[]): string => Array.isArray(source) ? source.join('') : source || ''; + class IPynb { private element: HTMLElement; private cells: HTMLElement[] = []; @@ -54,7 +57,7 @@ class IPynb { if (output.output_type === 'stream') { const textElement = document.createElement('pre'); textElement.classList.add('stream-output'); - textElement.textContent = output.text.join(''); + textElement.textContent = joinSource(output.text); outputElement.appendChild(textElement); } else if (output.output_type === 'display_data' || output.output_type === 'execute_result') { if (output.data['text/plain']) { @@ -82,7 +85,7 @@ class IPynb { private createCellElement(cell: any): HTMLElement { const cellElement = document.createElement('div'); - const source = cell.source.join(''); + const source = joinSource(cell.source); cellElement.classList.add('jupyter-cell'); switch (cell.cell_type) { diff --git a/templates/pages/gist.html b/templates/pages/gist.html index 7c94b72..2506927 100644 --- a/templates/pages/gist.html +++ b/templates/pages/gist.html @@ -85,7 +85,15 @@ {{ else if $file.MimeType.IsSVG }}
{{ $file.HTML | safe }}
{{ else if isJupyter $file.Filename }} -
{{ $file.Content }}
+
+
+ + + + +
+ +
{{ else }}
{{ $fileslug := slug $file.Filename }}