From 7ed06b19d27a96669751cb89b5286b82f93cb0c0 Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Tue, 3 Dec 2024 21:13:46 -0500 Subject: [PATCH 1/4] Adds redirects for other old embed routes --- .../[id]-[slug]/annotations/[note_id]/+page.ts | 16 ++++++++++++++++ .../documents/[id]-[slug]/pages/[page]/+page.ts | 13 +++++++++++++ .../documents/[id]/pages/[page]/+page.svelte | 8 ++++---- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 src/routes/(app)/documents/[id]-[slug]/annotations/[note_id]/+page.ts create mode 100644 src/routes/(app)/documents/[id]-[slug]/pages/[page]/+page.ts diff --git a/src/routes/(app)/documents/[id]-[slug]/annotations/[note_id]/+page.ts b/src/routes/(app)/documents/[id]-[slug]/annotations/[note_id]/+page.ts new file mode 100644 index 000000000..dbbf72015 --- /dev/null +++ b/src/routes/(app)/documents/[id]-[slug]/annotations/[note_id]/+page.ts @@ -0,0 +1,16 @@ +// this route was sometimes generated by old embeds and should redirect + +import { redirect } from "@sveltejs/kit"; +import { EMBED_URL } from "@/config/config.js"; + +export function load({ params }) { + const { id, note_id } = params; + + // the embed route can handle errors + const url = new URL( + `/documents/${id}/annotations/${note_id}/?embed=1`, + EMBED_URL, + ); + + return redirect(302, url); +} diff --git a/src/routes/(app)/documents/[id]-[slug]/pages/[page]/+page.ts b/src/routes/(app)/documents/[id]-[slug]/pages/[page]/+page.ts new file mode 100644 index 000000000..0c176df64 --- /dev/null +++ b/src/routes/(app)/documents/[id]-[slug]/pages/[page]/+page.ts @@ -0,0 +1,13 @@ +// this route was sometimes generated by old embeds and should redirect + +import { redirect } from "@sveltejs/kit"; +import { EMBED_URL } from "@/config/config.js"; + +export function load({ params }) { + const { id, page } = params; + + // if this is a 404, the embed route will handle it + const url = new URL(`/documents/${id}/pages/${page}/?embed=1`, EMBED_URL); + + return redirect(302, url); +} diff --git a/src/routes/embed/documents/[id]/pages/[page]/+page.svelte b/src/routes/embed/documents/[id]/pages/[page]/+page.svelte index 314e90710..cb38a9ca5 100644 --- a/src/routes/embed/documents/[id]/pages/[page]/+page.svelte +++ b/src/routes/embed/documents/[id]/pages/[page]/+page.svelte @@ -100,13 +100,13 @@
{$_("embedPage.pageOf", informSize(elem)} + on:load={() => informSize(elem)} /> @@ -138,7 +138,7 @@ note={active} {slugId} {page} - on:close={(e) => (active = null)} + on:close={() => (active = null)} /> {/if} @@ -169,7 +169,7 @@ or Date: Tue, 3 Dec 2024 21:27:16 -0500 Subject: [PATCH 2/4] Tighten hash routing --- src/lib/components/viewer/ViewerContext.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/components/viewer/ViewerContext.svelte b/src/lib/components/viewer/ViewerContext.svelte index 83b5136e2..f2db4c902 100644 --- a/src/lib/components/viewer/ViewerContext.svelte +++ b/src/lib/components/viewer/ViewerContext.svelte @@ -138,6 +138,8 @@ layouts, stories, and tests. $: noteMatchingPageHash = (note: Note) => note.id === noteFromHash($pageStore.url.hash); + $: console.log(`Page ${$currentPage}`); + function scrollToHash(hash?: string) { const page: Nullable = hash ? pageFromHash(hash) : null; let el: Maybe>; @@ -189,7 +191,7 @@ layouts, stories, and tests. } $currentMode = mode; $currentNote = $currentDoc.notes?.find(noteMatchingPageHash) ?? null; - if (shouldPaginate(mode) && $currentPage !== hashPage) { + if (shouldPaginate(mode) && (hashPage || 0) > 1) { scrollToHash(hash); } }); From 0c12d40e336118976de165ecc2efc0b7fb378bd6 Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Wed, 4 Dec 2024 09:36:19 -0500 Subject: [PATCH 3/4] add missing search mode to dropdown --- src/langs/json/en.json | 3 ++- src/lib/components/viewer/ReadingToolbar.svelte | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/langs/json/en.json b/src/langs/json/en.json index bccad5605..484fbec88 100644 --- a/src/langs/json/en.json +++ b/src/langs/json/en.json @@ -324,7 +324,8 @@ "grid": "Pages", "notes": "Notes", "annotating": "Annotate", - "redacting": "Redact" + "redacting": "Redact", + "search": "Search" }, "zoom": { "zoom": "Zoom", diff --git a/src/lib/components/viewer/ReadingToolbar.svelte b/src/lib/components/viewer/ReadingToolbar.svelte index 5e429f15e..6481e5453 100644 --- a/src/lib/components/viewer/ReadingToolbar.svelte +++ b/src/lib/components/viewer/ReadingToolbar.svelte @@ -59,6 +59,7 @@ Assumes it's a child of a ViewerContext ["text", $_("mode.text")], ["grid", $_("mode.grid")], ["notes", $_("mode.notes")], + ["search", $_("mode.search")], ]); const writeModes: Map = new Map([ From 6ff89218f933895ce540f53ec2f0f9e7a7fe8a2e Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Wed, 4 Dec 2024 10:00:10 -0500 Subject: [PATCH 4/4] logging Co-authored-by: Allan Lasser --- src/lib/components/viewer/ViewerContext.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib/components/viewer/ViewerContext.svelte b/src/lib/components/viewer/ViewerContext.svelte index f2db4c902..bf4ae6c84 100644 --- a/src/lib/components/viewer/ViewerContext.svelte +++ b/src/lib/components/viewer/ViewerContext.svelte @@ -138,8 +138,6 @@ layouts, stories, and tests. $: noteMatchingPageHash = (note: Note) => note.id === noteFromHash($pageStore.url.hash); - $: console.log(`Page ${$currentPage}`); - function scrollToHash(hash?: string) { const page: Nullable = hash ? pageFromHash(hash) : null; let el: Maybe>;