Browse Source

Add auto-author functionality and move publish button

- 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 <noreply@anthropic.com>
master
limina1 7 months ago
parent
commit
088dc453bb
  1. 43
      src/lib/components/ZettelEditor.svelte
  2. 19
      src/lib/services/publisher.ts

43
src/lib/components/ZettelEditor.svelte

@ -185,8 +185,27 @@ Understanding the nature of knowledge itself... @@ -185,8 +185,27 @@ Understanding the nature of knowledge itself...
{/if}
</div>
<!-- Unified Publishing Button -->
<div class="flex space-x-2">
</div>
</div>
</div>
<div class="flex items-center justify-between">
<Button
color="light"
size="sm"
on:click={togglePreview}
class="flex items-center space-x-1"
>
{#if showPreview}
<EyeOutline class="w-4 h-4" />
<span>Hide Preview</span>
{:else}
<EyeOutline class="w-4 h-4" />
<span>Show Preview</span>
{/if}
</Button>
<!-- Smart Publishing Button -->
{#if generatedEvents && contentType !== 'none'}
<Button
color={contentType === 'article' ? 'blue' : 'green'}
@ -208,26 +227,6 @@ Understanding the nature of knowledge itself... @@ -208,26 +227,6 @@ Understanding the nature of knowledge itself...
</div>
{/if}
</div>
</div>
</div>
</div>
<div class="flex items-center justify-between">
<Button
color="light"
size="sm"
on:click={togglePreview}
class="flex items-center space-x-1"
>
{#if showPreview}
<EyeOutline class="w-4 h-4" />
<span>Hide Preview</span>
{:else}
<EyeOutline class="w-4 h-4" />
<span>Show Preview</span>
{/if}
</Button>
</div>
<div class="flex space-x-4 {showPreview ? 'h-96' : ''}">
<!-- Editor Panel -->

19
src/lib/services/publisher.ts

@ -143,11 +143,28 @@ export async function publishSingleEvent( @@ -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;

Loading…
Cancel
Save