From 088dc453bbaafd245557a9a219fa90eee7cbc635 Mon Sep 17 00:00:00 2001 From: limina1 Date: Tue, 5 Aug 2025 17:14:29 -0400 Subject: [PATCH] Add auto-author functionality and move publish button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Auto-add author identity when not publishing on behalf of others - Check for existing :author: and :p: tags, only add if missing - Add ["author", displayName] and ["p", pubkey] tags automatically - Move publish button from top gradient to underneath text area - Preserve smart color functionality: blue for articles, green for notes - Position publish button next to preview button for better UX 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/lib/components/ZettelEditor.svelte | 45 +++++++++++++------------- src/lib/services/publisher.ts | 19 ++++++++++- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/lib/components/ZettelEditor.svelte b/src/lib/components/ZettelEditor.svelte index 5bac793..fe545cd 100644 --- a/src/lib/components/ZettelEditor.svelte +++ b/src/lib/components/ZettelEditor.svelte @@ -185,29 +185,6 @@ Understanding the nature of knowledge itself... {/if} - -
- {#if generatedEvents && contentType !== 'none'} - - {:else} -
- Add content to enable publishing -
- {/if} -
@@ -227,6 +204,28 @@ Understanding the nature of knowledge itself... Show Preview {/if} + + + {#if generatedEvents && contentType !== 'none'} + + {:else} +
+ Add content to enable publishing +
+ {/if}
diff --git a/src/lib/services/publisher.ts b/src/lib/services/publisher.ts index ad2831a..5d58923 100644 --- a/src/lib/services/publisher.ts +++ b/src/lib/services/publisher.ts @@ -143,11 +143,28 @@ export async function publishSingleEvent( return tag; }); + // Auto-add author identity if not publishing on behalf of others + const hasAuthorTag = fixedTags.some(tag => tag[0] === 'author'); + const hasPTag = fixedTags.some(tag => tag[0] === 'p'); + + const finalTags = [...fixedTags]; + + if (!hasAuthorTag && ndk.activeUser) { + // Add display name as author + const displayName = ndk.activeUser.profile?.displayName || ndk.activeUser.profile?.name || 'Anonymous'; + finalTags.push(['author', displayName]); + } + + if (!hasPTag && ndk.activeUser) { + // Add pubkey as p-tag + finalTags.push(['p', ndk.activeUser.pubkey]); + } + // Create and sign NDK event const ndkEvent = new NDKEvent(ndk); ndkEvent.kind = kind; ndkEvent.created_at = Math.floor(Date.now() / 1000); - ndkEvent.tags = fixedTags; + ndkEvent.tags = finalTags; ndkEvent.content = content; ndkEvent.pubkey = ndk.activeUser.pubkey;