diff --git a/ROADMAP.md b/ROADMAP.md index 15da0967..2d6d6c49 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -2,10 +2,10 @@ - [ ] Move blog to nostr - [ ] Improve note rendering - - [ ] NIP 27 - [ ] Fix reactions and replies showing up - - [ ] Show all images in preview as slideshow or something + - [x] Show all images in preview as slideshow or something - [ ] Extract nostr: links and bech32 entities, hover + - [ ] Add nostr: links and bech32 entities in compose to tags - [ ] Linkify topics - [ ] Fix extra newlines when composing - [ ] Multiplexer diff --git a/src/App.svelte b/src/App.svelte index b4e627d1..70001e9c 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -266,7 +266,7 @@ {/key} {:else if $modal.type === "note/create"} - + {:else if $modal.type === "relay/add"} {:else if $modal.type === "onboarding"} diff --git a/src/app/index.ts b/src/app/index.ts index a3a6d163..942f0979 100644 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -1,15 +1,13 @@ import type {DisplayEvent} from "src/util/types" import {omit, sortBy} from "ramda" -import {createMap, ellipsize} from "hurdak/lib/hurdak" -import {renderContent} from "src/util/html" -import {displayPerson, findReplyId} from "src/util/nostr" +import {createMap} from "hurdak/lib/hurdak" +import {findReplyId} from "src/util/nostr" import {getUserFollows} from "src/agent/social" import {getUserReadRelays} from "src/agent/relays" -import {getPersonWithFallback} from "src/agent/tables" import network from "src/agent/network" import keys from "src/agent/keys" import listener from "src/app/listener" -import {routes, modal, toast} from "src/app/ui" +import {modal, toast} from "src/app/ui" export const loadAppData = async pubkey => { if (getUserReadRelays().length > 0) { @@ -28,32 +26,6 @@ export const login = (method, key) => { modal.set({type: "login/connect", noEscape: true}) } -export const renderNote = (note, {showEntire = false}) => { - let content - - // Ellipsize - content = note.content.length > 500 && !showEntire ? ellipsize(note.content, 500) : note.content - - // Escape html, replace urls - content = renderContent(content) - - // Mentions - content = content.replace(/#\[(\d+)\]/g, (tag, i) => { - if (!note.tags[parseInt(i)]) { - return tag - } - - const pubkey = note.tags[parseInt(i)][1] - const person = getPersonWithFallback(pubkey) - const name = displayPerson(person) - const path = routes.person(pubkey) - - return `@${name}` - }) - - return content -} - export const mergeParents = (notes: Array) => { const notesById = createMap("id", notes) as Record const childIds = [] diff --git a/src/partials/Carousel.svelte b/src/partials/Carousel.svelte index b59f7991..2844199f 100644 --- a/src/partials/Carousel.svelte +++ b/src/partials/Carousel.svelte @@ -1,6 +1,5 @@ {#if !hidden} -
- -
- +
+ + {#if annotated.length > 1} +

+ Show {annotated.length} link previews +

+ {/if}
- {#if annotated.length > 1} -

- Show all {annotated.length} link previews -

- {/if} -
{/if} {#if showModal} - - - {#each annotated as link} - - {/each} - - + + + {#each annotated as link} + + {/each} + + {/if} diff --git a/src/partials/CarouselItem.svelte b/src/partials/CarouselItem.svelte index bda43e89..4ff0502f 100644 --- a/src/partials/CarouselItem.svelte +++ b/src/partials/CarouselItem.svelte @@ -1,13 +1,14 @@ + +

+ {#each content as { type, value }} + {#if type === "br"} + {@html value} + {:else if type === "link"} + + {value.replace(/https?:\/\/(www\.)?/, "")} + + {:else if type.startsWith("nostr:")} + + {#if value.pubkey} + {displayPerson(getPersonWithFallback(value.pubkey))} + {:else if value.id} + event {value.id} + {:else} + {value.entity.slice(0, 10) + "..."} + {/if} + + {:else} + {value} + {/if} + {/each} +

diff --git a/src/partials/PersonInfo.svelte b/src/partials/PersonInfo.svelte index e8a3a033..fd173b5a 100644 --- a/src/partials/PersonInfo.svelte +++ b/src/partials/PersonInfo.svelte @@ -1,11 +1,11 @@
@@ -72,6 +103,16 @@ {value.replace(/https?:\/\/(www\.)?/, "")} + {:else if type.startsWith("nostr:")} + + {#if value.pubkey} + {displayPerson(getPersonWithFallback(value.pubkey))} + {:else if value.id} + event {value.id} + {:else} + {value.entity.slice(0, 10) + "..."} + {/if} + {:else if type === "mention"} {@const pubkey = getMentionPubkey(value)} {#if pubkey} @@ -87,8 +128,35 @@ {/each}

{#if user.getSetting("showMedia") && links.length > 0} - +
+ {/if} + {#if entities.length > 0} +
e.stopPropagation()}> + {#each entities as { value }} + openQuote(value.id)}> + {#await loadQuote(value)} + + {:then quote} + {@const person = getPersonWithFallback(quote.pubkey)} +
+ + navigate(routes.person(quote.pubkey))}> +

{displayPerson(person)}

+
+
+ + {:catch} +

+ Unable to load a preview for quoted event +

+ {/await} +
+ {/each} +
{/if}
diff --git a/src/views/notes/NoteCreate.svelte b/src/views/notes/NoteCreate.svelte index b4bb81f1..a83017fb 100644 --- a/src/views/notes/NoteCreate.svelte +++ b/src/views/notes/NoteCreate.svelte @@ -23,6 +23,7 @@ import {publishWithToast} from "src/app" export let pubkey = null + export let nevent = null let image = null let compose = null @@ -94,6 +95,10 @@ if (pubkey && pubkey !== user.getPubkey()) { compose.mention(getPersonWithFallback(pubkey)) } + + if (nevent) { + compose.nevent("nostr:" + nevent) + } }) diff --git a/src/views/person/PersonSummary.svelte b/src/views/person/PersonSummary.svelte index 22d37d4a..c2590f68 100644 --- a/src/views/person/PersonSummary.svelte +++ b/src/views/person/PersonSummary.svelte @@ -1,7 +1,6 @@