From 4a2640e0b42e86ae6d815dfc7273ad696b57edff Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sat, 5 Apr 2025 10:40:27 +0200 Subject: [PATCH 01/18] Pull the latest tag from git, on build, and display it top-right on the About page. --- src/routes/about/+page.svelte | 10 ++++++++-- vite.config.ts | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelte index 9e4ee80..00a14c8 100644 --- a/src/routes/about/+page.svelte +++ b/src/routes/about/+page.svelte @@ -1,10 +1,16 @@
- About +
+ About + Version: {gitTagVersion} +

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

Please submit support issues on the project repo page and follow us on GitHub and Geyserfund.

@@ -53,4 +59,4 @@

Documentation

-
\ No newline at end of file + diff --git a/vite.config.ts b/vite.config.ts index b9ba52c..7a6e207 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,9 +1,26 @@ import { sveltekit } from "@sveltejs/kit/vite"; import { defineConfig } from "vite"; +import { execSync } from "child_process"; + +// Function to get the latest git tag +function getLatestGitTag() { + try { + // Get the latest git tag + const tag = execSync('git describe --tags --abbrev=0').toString().trim(); + return tag; + } catch (error) { + console.error("Failed to get git tag:", error); + return "unknown"; + } +} export default defineConfig({ plugins: [sveltekit()], test: { include: ['./tests/unit/**/*.unit-test.js'] + }, + define: { + // Expose the git tag as a global variable + 'import.meta.env.GIT_TAG': JSON.stringify(getLatestGitTag()) } }); From b763ecd99f09373c69770717025e84e739a8df3b Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sat, 5 Apr 2025 11:47:23 +0200 Subject: [PATCH 02/18] Refactored a bit. Changed a tags to buttons that look like hyperlinks, to preserve normal button functionality. --- src/lib/components/Login.svelte | 2 +- src/lib/components/util/CardActions.svelte | 18 +++++++++--------- src/lib/components/util/CopyToClipboard.svelte | 4 ++-- src/lib/components/util/Profile.svelte | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/lib/components/Login.svelte b/src/lib/components/Login.svelte index 2d77763..1456149 100644 --- a/src/lib/components/Login.svelte +++ b/src/lib/components/Login.svelte @@ -50,7 +50,7 @@ @@ -157,7 +157,7 @@
{#if image}
- + Publication cover image for {title}
{/if}
diff --git a/src/lib/components/util/CopyToClipboard.svelte b/src/lib/components/util/CopyToClipboard.svelte index 9e72c79..63f1aa7 100644 --- a/src/lib/components/util/CopyToClipboard.svelte +++ b/src/lib/components/util/CopyToClipboard.svelte @@ -18,10 +18,10 @@ } - + diff --git a/src/lib/components/util/Profile.svelte b/src/lib/components/util/Profile.svelte index fd23c9f..a44cba1 100644 --- a/src/lib/components/util/Profile.svelte +++ b/src/lib/components/util/Profile.svelte @@ -46,10 +46,12 @@ function shortenNpub(long: string|undefined) { class='h-6 w-6 cursor-pointer' src={pfp} alt={username} + id="profile-avatar" /> {#key username || tag} @@ -70,15 +72,13 @@ function shortenNpub(long: string|undefined) { {#if isNav}
  • - Sign out - +
  • {:else} - - - {#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}
    From 52a353ebe18ac3168de58f6a7b4f36465aa13fee Mon Sep 17 00:00:00 2001 From: Silberengel Date: Wed, 9 Apr 2025 20:31:45 +0200 Subject: [PATCH 11/18] Changed logic to the sequence: package version git tag version development version -> hidden closes #162 --- src/routes/about/+page.svelte | 6 ++++-- vite.config.ts | 10 ++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelte index f9c81cf..b6c0f6c 100644 --- a/src/routes/about/+page.svelte +++ b/src/routes/about/+page.svelte @@ -3,13 +3,16 @@ // Get the git tag version from environment variables const appVersion = import.meta.env.APP_VERSION || 'development'; + const isVersionKnown = appVersion !== 'development';
    About - Version: {appVersion} + {#if isVersionKnown} + Version: {appVersion} + {/if}

    @@ -102,4 +105,3 @@

    - diff --git a/vite.config.ts b/vite.config.ts index 5d73bc3..4dc4254 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,18 +5,16 @@ import { execSync } from "child_process"; // Function to get the latest git tag function getAppVersionString() { // if running in ci context, we can assume the package has been properly versioned - if (process.env.ALEXANDIRA_IS_CI_BUILD) { - return process.env.npm_package_version; + if (process.env.ALEXANDIRA_IS_CI_BUILD && process.env.npm_package_version && process.env.npm_package_version.trim() !== '') { + return process.env.npm_package_version; } - + try { // Get the latest git tag, assuming git is installed and tagged branch is available const tag = execSync('git describe --tags --abbrev=0').toString().trim(); return tag; } catch (error) { - console.error("Failed to get git tag:", error); - // Fallback to package version - return process.env.npm_package_version; + return 'development'; } } From 94178e5dba63e317efde2e87561c480515a44851 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Thu, 10 Apr 2025 10:33:13 +0200 Subject: [PATCH 12/18] first step for issue #173 --- src/lib/consts.ts | 2 +- src/lib/navigator/EventNetwork/Legend.svelte | 2 +- .../navigator/EventNetwork/NodeTooltip.svelte | 4 ++-- src/lib/stores.ts | 2 +- src/routes/about/+page.svelte | 16 +++++++++++++--- src/routes/visualize/+page.svelte | 4 ++-- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/lib/consts.ts b/src/lib/consts.ts index 0df0ebf..17b8b87 100644 --- a/src/lib/consts.ts +++ b/src/lib/consts.ts @@ -1,6 +1,6 @@ export const wikiKind = 30818; export const indexKind = 30040; -export const zettelKinds = [ 30041 ]; +export const zettelKinds = [ 30041, 30818 ]; export const standardRelays = [ 'wss://thecitadel.nostr1.com', 'wss://relay.noswhere.com' ]; export const bootstrapRelays = [ 'wss://purplepag.es', 'wss://relay.noswhere.com' ]; diff --git a/src/lib/navigator/EventNetwork/Legend.svelte b/src/lib/navigator/EventNetwork/Legend.svelte index 7d27ffa..fe88aac 100644 --- a/src/lib/navigator/EventNetwork/Legend.svelte +++ b/src/lib/navigator/EventNetwork/Legend.svelte @@ -18,7 +18,7 @@ C
    - Content events (kind 30041) - Publication sections + Content events (kinds 30041, 30818) - Publication sections
  • diff --git a/src/lib/navigator/EventNetwork/NodeTooltip.svelte b/src/lib/navigator/EventNetwork/NodeTooltip.svelte index 9ebe042..545660d 100644 --- a/src/lib/navigator/EventNetwork/NodeTooltip.svelte +++ b/src/lib/navigator/EventNetwork/NodeTooltip.svelte @@ -15,7 +15,7 @@
    {node.title}
    - {node.type} ({node.isContainer ? "30040" : "30041"}) + {node.type} ({node.kind})
    {/if}
    -
    \ No newline at end of file +
  • diff --git a/src/lib/stores.ts b/src/lib/stores.ts index 04aa785..71f9fdc 100644 --- a/src/lib/stores.ts +++ b/src/lib/stores.ts @@ -3,6 +3,6 @@ import { FeedType } from "./consts"; export let idList = writable([]); -export let alexandriaKinds = readable([30040, 30041]); +export let alexandriaKinds = readable([30040, 30041, 30818]); export let feedType = writable(FeedType.StandardRelays); diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelte index 60d3738..9a2f461 100644 --- a/src/routes/about/+page.svelte +++ b/src/routes/about/+page.svelte @@ -7,7 +7,7 @@ About

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

    @@ -34,11 +34,11 @@

    - If you click on a card, which represents a 30040 index event, the associated reading view opens to the publication. The app then pulls all of the content events (30041s), in the order in which they are indexed, and displays them as a single document. + If you click on a card, which represents a 30040 index event, the associated reading view opens to the publication. The app then pulls all of the content events (30041s and 30818s for wiki pages), in the order in which they are indexed, and displays them as a single document.

    - Each 30041 section is also a level in the table of contents, which can be accessed from the floating icon top-left in the reading view. This allows for navigation within the publication. (This functionality has been temporarily disabled.) + Each content section (30041 or 30818) is also a level in the table of contents, which can be accessed from the floating icon top-left in the reading view. This allows for navigation within the publication. (This functionality has been temporarily disabled.)

    @@ -93,6 +93,16 @@
    Documentation
    + + For wiki pages + +

    + Alexandria now supports wiki pages (kind 30818), allowing for collaborative knowledge bases and documentation. Wiki pages use the same Asciidoc format as other publications but are specifically designed for interconnected, evolving content. +

    + +

    + Wiki pages can be linked to from other publications and can contain links to other wiki pages, creating a web of knowledge that can be navigated and explored. +

    diff --git a/src/routes/visualize/+page.svelte b/src/routes/visualize/+page.svelte index 35b837d..c74ac8d 100644 --- a/src/routes/visualize/+page.svelte +++ b/src/routes/visualize/+page.svelte @@ -49,7 +49,7 @@ // Fetch the referenced content events const contentEvents = await $ndkInstance.fetchEvents( { - kinds: [30041], + kinds: [30041, 30818], ids: Array.from(contentEventIds), }, { @@ -157,4 +157,4 @@
    {/if} -
    \ No newline at end of file +
    From f240083dac71fcb60d2958a4f7e88d8b8f31879a Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sat, 12 Apr 2025 18:50:26 +0200 Subject: [PATCH 13/18] implemen OpenGraph metadata --- src/lib/components/Publication.svelte | 48 ++++++++++++++++++++++++-- src/routes/publication/+page.svelte | 16 +++++++-- src/routes/publication/+page.ts | 5 +-- static/screenshots/old_books.jpg | Bin 0 -> 207556 bytes 4 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 static/screenshots/old_books.jpg diff --git a/src/lib/components/Publication.svelte b/src/lib/components/Publication.svelte index 0794cc9..9d79264 100644 --- a/src/lib/components/Publication.svelte +++ b/src/lib/components/Publication.svelte @@ -14,8 +14,28 @@ import Preview from "./Preview.svelte"; import { pharosInstance } from "$lib/parser"; import { page } from "$app/state"; - - let { rootId, publicationType } = $props<{ rootId: string, publicationType: string }>(); + import { ndkInstance } from "$lib/ndk"; + import type { NDKEvent } from "@nostr-dev-kit/ndk"; + + let { rootId, publicationType, indexEvent } = $props<{ + rootId: string, + publicationType: string, + indexEvent: NDKEvent + }>(); + + // Get publication metadata for OpenGraph tags + let title = $derived($pharosInstance.getIndexTitle(rootId) || '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(indexEvent?.getMatchingTags('image')[0]?.[1] || '/screenshots/old_books.jpg'); + let summary = $derived(indexEvent?.getMatchingTags('summary')[0]?.[1] || ``); + + // Debug: Log the event and its tags + console.log('indexEvent:', indexEvent); + console.log('image tag:', indexEvent?.getMatchingTags('image')); + console.log('summary tag:', indexEvent?.getMatchingTags('summary')); if (rootId !== $pharosInstance.getRootIndexId()) { console.error("Root ID does not match parser root index ID"); @@ -94,6 +114,30 @@ }); + + + {title} + + + + + + + + + {#if image} + + {/if} + + + + + + {#if image} + + {/if} + + {#if showTocButton && !showToc}