diff --git a/src/app.html b/src/app.html index da5c914..d025d7c 100644 --- a/src/app.html +++ b/src/app.html @@ -2,7 +2,7 @@ - + %sveltekit.head% diff --git a/src/lib/components/Publication.svelte b/src/lib/components/Publication.svelte index 0794cc9..e61cbb3 100644 --- a/src/lib/components/Publication.svelte +++ b/src/lib/components/Publication.svelte @@ -14,8 +14,14 @@ import Preview from "./Preview.svelte"; import { pharosInstance } from "$lib/parser"; import { page } from "$app/state"; + import { ndkInstance } from "$lib/ndk"; + import type { NDKEvent } from "@nostr-dev-kit/ndk"; - let { rootId, publicationType } = $props<{ rootId: string, publicationType: string }>(); + let { rootId, publicationType, indexEvent } = $props<{ + rootId: string, + publicationType: string, + indexEvent: NDKEvent + }>(); if (rootId !== $pharosInstance.getRootIndexId()) { console.error("Root ID does not match parser root index ID"); @@ -94,6 +100,7 @@ }); + {#if showTocButton && !showToc} +
+
+ + {node.title} + +
{node.type} ({node.kind})
-
- ID: {node.id} - {#if node.naddr} -
{node.naddr}
- {/if} - {#if node.nevent} -
{node.nevent}
- {/if} +
+ Author: {getAuthorTag(node)}
+ + {#if node.isContainer && getSummaryTag(node)} +
+ Summary: {truncateContent(getSummaryTag(node) || "", 200)} +
+ {/if} + {#if node.content}
- {node.content} + {truncateContent(node.content)}
{/if} {#if selected} diff --git a/src/lib/navigator/EventNetwork/index.svelte b/src/lib/navigator/EventNetwork/index.svelte index 9246df3..6a7fa61 100644 --- a/src/lib/navigator/EventNetwork/index.svelte +++ b/src/lib/navigator/EventNetwork/index.svelte @@ -8,6 +8,7 @@ import { createSimulation, setupDragHandlers, applyGlobalLogGravity, applyConnectedGravity } from "./utils/forceSimulation"; import Legend from "./Legend.svelte"; import NodeTooltip from "./NodeTooltip.svelte"; + import type { NetworkNode, NetworkLink } from "./types"; let { events = [] } = $props<{ events?: NDKEvent[] }>(); @@ -90,14 +91,14 @@ function updateGraph() { if (!svg || !events?.length || !svgGroup) return; - const { nodes, links } = generateGraph(events, currentLevels); + const { nodes, links } = generateGraph(events, Number(currentLevels)); if (!nodes.length) return; // Stop any existing simulation if (simulation) simulation.stop(); // Create new simulation - simulation = createSimulation(nodes, links, nodeRadius, linkDistance); + simulation = createSimulation(nodes, links, Number(nodeRadius), Number(linkDistance)); const dragHandler = setupDragHandlers(simulation); // Update links @@ -303,6 +304,11 @@ updateGraph(); } }); + + function handleTooltipClose() { + tooltipVisible = false; + selectedNodeId = null; + }
{/if}
- - \ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 0045d4c..4cac70e 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -2,15 +2,44 @@ import "../app.css"; import Navigation from "$lib/components/Navigation.svelte"; import { onMount } from "svelte"; + import { page } from "$app/stores"; // Compute viewport height. $: displayHeight = window.innerHeight; + // Get standard metadata for OpenGraph tags + let title = 'Library of Alexandria'; + let currentUrl = $page.url.href; + + // Get default image and summary for the Alexandria website + let image = '/screenshots/old_books.jpg'; + let summary = 'Alexandria is a digital library, utilizing Nostr events for curated publications and wiki pages.'; + onMount(() => { document.body.style.height = `${displayHeight}px`; }); + + + {title} + + + + + + + + + + + + + + + + +
diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelte index dd06bc4..6267348 100644 --- a/src/routes/about/+page.svelte +++ b/src/routes/about/+page.svelte @@ -9,12 +9,13 @@
- About + About the Library of Alexandria + Alexandria icon {#if isVersionKnown} Version: {appVersion} {/if}
- +

Alexandria is a reader and writer for curated publications (in Asciidoc), wiki pages (Asciidoc), and will eventually also support long-form articles (Markdown). It is produced by the GitCitadel project team.

diff --git a/src/routes/publication/+page.svelte b/src/routes/publication/+page.svelte index dbd673f..dff8ffb 100644 --- a/src/routes/publication/+page.svelte +++ b/src/routes/publication/+page.svelte @@ -3,16 +3,60 @@ import { TextPlaceholder } from "flowbite-svelte"; import type { PageData } from "./$types"; import { onDestroy } from "svelte"; + import type { NDKEvent } from "@nostr-dev-kit/ndk"; + import { pharosInstance } from "$lib/parser"; + import { page } from "$app/stores"; - let { data }: { data: PageData } = $props(); + // Extend the PageData type with the properties we need + interface ExtendedPageData extends PageData { + waitable: Promise; + publicationType: string; + indexEvent: NDKEvent; + parser: any; + } + + let { data } = $props<{ data: ExtendedPageData }>(); + + // Get publication metadata for OpenGraph tags + let title = $derived(data.indexEvent?.getMatchingTags('title')[0]?.[1] || data.parser?.getIndexTitle(data.parser?.getRootIndexId()) || 'Alexandria Publication'); + let currentUrl = $page.url.href; + + // Get image and summary from the event tags if available + // If image unavailable, use the Alexandria default pic. + let image = $derived(data.indexEvent?.getMatchingTags('image')[0]?.[1] || '/screenshots/old_books.jpg'); + let summary = $derived(data.indexEvent?.getMatchingTags('summary')[0]?.[1] || 'Alexandria is a digital library, utilizing Nostr events for curated publications and wiki pages.'); onDestroy(() => data.parser.reset()); + + + {title} + + + + + + + + + + + + + + + + +
{#await data.waitable} {:then} -
+
{/await}
diff --git a/src/routes/publication/+page.ts b/src/routes/publication/+page.ts index 286063a..56b7fd1 100644 --- a/src/routes/publication/+page.ts +++ b/src/routes/publication/+page.ts @@ -1,6 +1,6 @@ import { error } from '@sveltejs/kit'; +import type { Load } from '@sveltejs/kit'; import type { NDKEvent } from '@nostr-dev-kit/ndk'; -import type { PageLoad } from './$types'; import { nip19 } from 'nostr-tools'; import { getActiveRelays } from '$lib/ndk.ts'; @@ -82,7 +82,7 @@ async function fetchEventByDTag(ndk: any, dTag: string): Promise { } } -export const load: PageLoad = async ({ url, parent }: { url: URL; parent: () => Promise }) => { +export const load: Load = async ({ url, parent }: { url: URL; parent: () => Promise }) => { const id = url.searchParams.get('id'); const dTag = url.searchParams.get('d'); const { ndk, parser } = await parent(); @@ -102,5 +102,6 @@ export const load: PageLoad = async ({ url, parent }: { url: URL; parent: () => return { waitable: fetchPromise, publicationType, + indexEvent, }; }; diff --git a/src/routes/visualize/+page.svelte b/src/routes/visualize/+page.svelte index c74ac8d..f1f7d33 100644 --- a/src/routes/visualize/+page.svelte +++ b/src/routes/visualize/+page.svelte @@ -79,44 +79,45 @@
-

Publication Network

- - - - {#if !loading && !error} - +
+

Publication Network

+ + + {#if !loading && !error} + + {/if} +
+ {#if !loading && !error && showSettings} - {#if showSettings} -
-
-

- Visualization Settings -

+
+
+

+ Visualization Settings +

-
- - Showing {events.length} events from {$networkFetchLimit} headers - - - -
+
+ + Showing {events.length} events from {$networkFetchLimit} headers + + +
- {/if} +
{/if} + {#if loading}
@@ -155,6 +156,6 @@
{:else} -
+
{/if}
diff --git a/static/favicon.png b/static/favicon.png index 825b9e6..7418972 100644 Binary files a/static/favicon.png and b/static/favicon.png differ diff --git a/static/screenshots/old_books.jpg b/static/screenshots/old_books.jpg new file mode 100644 index 0000000..933a0be Binary files /dev/null and b/static/screenshots/old_books.jpg differ