+
@templ.Raw(ee.Preview())
diff --git a/data.go b/data.go
index e219ba8..f7c40e5 100644
--- a/data.go
+++ b/data.go
@@ -4,12 +4,12 @@ import (
"context"
"fmt"
"html/template"
- "strconv"
"strings"
"time"
"github.com/nbd-wtf/go-nostr/nip19"
"github.com/nbd-wtf/go-nostr/nip31"
+ "github.com/nbd-wtf/go-nostr/nip52"
"github.com/nbd-wtf/go-nostr/nip53"
"github.com/nbd-wtf/go-nostr/nip94"
sdk "github.com/nbd-wtf/nostr-sdk"
@@ -122,9 +122,6 @@ func grabData(ctx context.Context, code string, isProfileSitemap bool) (*Data, e
case 1, 7, 30023, 30024:
data.templateId = Note
data.content = event.Content
- if parentNevent := getParentNevent(event); parentNevent != "" {
- data.parentLink = template.HTML(replaceNostrURLsWithTags(nostrNoteNeventMatcher, "nostr:"+parentNevent))
- }
case 6:
data.templateId = Note
if reposted := event.Tags.GetFirst([]string{"e", ""}); reposted != nil {
@@ -145,12 +142,9 @@ func grabData(ctx context.Context, code string, isProfileSitemap bool) (*Data, e
case 1311:
data.templateId = LiveEventMessage
data.content = event.Content
- if atag := event.Tags.GetFirst([]string{"a", ""}); atag != nil {
- parts := strings.Split((*atag)[1], ":")
- kind, _ := strconv.Atoi(parts[0])
- parentNevent, _ := nip19.EncodeEntity(parts[1], kind, parts[2], data.event.relays)
- data.parentLink = template.HTML(replaceNostrURLsWithTags(nostrEveryMatcher, "nostr:"+parentNevent))
- }
+ case 31922, 31923:
+ data.templateId = CalendarEvent
+ data.kind31922Or31923Metadata = &Kind31922Or31923Metadata{CalendarEvent: nip52.ParseCalendarEvent(*event)}
default:
data.templateId = Other
}
diff --git a/details.templ b/details.templ
index d5f2b3b..dc3ddc1 100644
--- a/details.templ
+++ b/details.templ
@@ -4,44 +4,22 @@ import (
"strconv"
)
-templ detailsTemplate(params DetailsParams) {
+templ detailsTemplate(details DetailsParams) {
- if params.Metadata.Npub() != "" {
+ if details.Metadata.Npub() != "" {
Author Public Key
-
{ params.Metadata.Npub() }
+
{ details.Metadata.Npub() }
}
- if params.FileMetadata != nil {
- if params.FileMetadata.Summary != "" {
-
-
Summary
-
{ params.FileMetadata.Summary }
-
- }
- if params.FileMetadata.Dim != "" {
-
-
Dimension
-
{ params.FileMetadata.Dim }
-
- }
- if params.FileMetadata.Size != "" {
-
-
Size
-
{ params.FileMetadata.Size } bytes
-
- }
- if params.FileMetadata.Magnet != "" {
-
-
Magnet URL
-
{ params.FileMetadata.Magnet }
-
- }
+ if details.Extra != nil {
+ @details.Extra
}
- if len(params.SeenOn) != 0 {
+
+ if len(details.SeenOn) != 0 {
Seen on
- for _, v := range params.SeenOn {
+ for _, v := range details.SeenOn {
}
- if params.HideDetails {
+ if details.HideDetails {
Show more details
}
-
+
Published at
-
{ params.CreatedAt }
+
{ details.CreatedAt }
Kind type
-
{ strconv.Itoa(params.Kind) }
- if params.KindNIP != "" {
+
{ strconv.Itoa(details.Kind) }
+ if details.KindNIP != "" {
{ params.KindDescription }
+ >{ details.KindDescription }
}
- if params.Nevent != "" {
+ if details.Nevent != "" {
Address Code
-
{ params.Nevent }
+
{ details.Nevent }
}
@@ -109,13 +87,13 @@ templ detailsTemplate(params DetailsParams) {
Event JSON
- @templ.Raw(params.EventJSON)
+ @templ.Raw(details.EventJSON)
- if params.Nprofile != "" {
+ if details.Nprofile != "" {
Author Profile Code
-
{ params.Nprofile }
+
{ details.Nprofile }
}
diff --git a/event_page.templ b/event_page.templ
new file mode 100644
index 0000000..700dfe7
--- /dev/null
+++ b/event_page.templ
@@ -0,0 +1,49 @@
+package main
+
+templ eventPageTemplate(
+ title string,
+ og OpenGraphParams,
+ head HeadParams,
+ author Metadata,
+ clients []ClientReference,
+ details DetailsParams,
+ event EnhancedEvent,
+) {
+
+
+
+ { title }
+ @openGraphTemplate(og)
+ @headCommonTemplate(head)
+
+
+ @topTemplate()
+
+
+
+ @authorHeaderTemplate(author)
+
+ { event.CreatedAtStr() }
+
+
+ if nevent := event.getParentNevent(); nevent != "" {
+ in reply to
+
+ @templ.Raw(replaceNostrURLsWithHTMLTags(nostrNoteNeventMatcher, "nostr:" + nevent))
+
+ }
+
+
+
+ { children... }
+
+ @detailsTemplate(details)
+
+
+ @clientsTemplate(clients)
+
+
+ @footerTemplate()
+
+
+}
diff --git a/file_metadata.templ b/file_metadata.templ
index 7a6e3c9..fc719b7 100644
--- a/file_metadata.templ
+++ b/file_metadata.templ
@@ -2,72 +2,59 @@ package main
templ fileMetadataTemplate(params FileMetadataPageParams) {
-
-
-
- File Metadata
- @openGraphTemplate(params.OpenGraphParams)
- @headCommonTemplate(params.HeadParams)
-
-
- @topTemplate()
-
-
-
- @authorHeaderTemplate(params.Metadata)
-
- { params.CreatedAt }
-
-
- if params.ParentLink != "" {
- in reply to
-
- @templ.Raw(params.ParentLink)
-
- }
-
-
-
- if params.Subject != "" {
- { params.Subject }
- } else {
-
- { params.Metadata.ShortName() } on Nostr: { params.TitleizedContent }
-
- }
-
- if params.FileMetadata.Image != "" {
-
- } else if params.IsImage {
-
- } else if params.IsVideo {
-
- }
- Download file
-
- @detailsTemplate(params.DetailsParams)
-
-
- @clientsTemplate(params.Clients)
-
-
- @footerTemplate()
-
-
+ @eventPageTemplate(
+ "File Metadata",
+ params.OpenGraphParams,
+ params.HeadParams,
+ params.Metadata,
+ params.Clients,
+ params.Details,
+ params.Event,
+ ) {
+ if params.FileMetadata.Image != "" {
+
+ } else if params.IsImage {
+
+ } else if params.IsVideo {
+
+ }
+ Download file
+ }
+}
+
+templ fileMetadataDetails(params FileMetadataPageParams) {
+ if params.FileMetadata.Summary != "" {
+
+
Summary
+
{ params.FileMetadata.Summary }
+
+ }
+ if params.FileMetadata.Dim != "" {
+
+
Dimension
+
{ params.FileMetadata.Dim }
+
+ }
+ if params.FileMetadata.Size != "" {
+
+
Size
+
{ params.FileMetadata.Size } bytes
+
+ }
+ if params.FileMetadata.Magnet != "" {
+
+
Magnet URL
+
{ params.FileMetadata.Magnet }
+
+ }
}
diff --git a/head_common.templ b/head_common.templ
deleted file mode 100644
index 308e170..0000000
--- a/head_common.templ
+++ /dev/null
@@ -1,70 +0,0 @@
-package main
-
-templ headCommonTemplate(params HeadParams) {
-
- if params.Oembed != "" {
-
-
- }
- if params.IsProfile {
-
-
-
- } else {
-
-
-
- }
-
- if tailwindDebugStuff != "" {
- @templ.Raw(tailwindDebugStuff)
- } else {
-
- }
-
-
- if params.NaddrNaked != "" {
-
- } else {
-
- }
-
-}
diff --git a/live_event.templ b/live_event.templ
index ae9e9ec..03a977d 100644
--- a/live_event.templ
+++ b/live_event.templ
@@ -2,75 +2,49 @@ package main
templ liveEventTemplate(params LiveEventPageParams) {
-
-
-
-
Stream: { params.LiveEvent.Title } by { params.LiveEvent.Host.Name }
- @openGraphTemplate(params.OpenGraphParams)
- @headCommonTemplate(params.HeadParams)
-
-
- @topTemplate()
-
-
-
- @authorHeaderTemplate(params.Metadata)
-
- { params.CreatedAt }
-
-
- if params.ParentLink != "" {
- in reply to
-
- @templ.Raw(params.ParentLink)
-
- }
-
-
-
-
- { params.LiveEvent.Title }
- switch params.LiveEvent.Status {
- case "ended":
- Ended
- case "live":
- Live now!
- }
-
-
-
-
- for _, v := range params.LiveEvent.Hashtags {
-
- { v }
-
- }
-
- if params.LiveEvent.Summary != "" {
- { params.LiveEvent.Summary }
- }
- if params.LiveEvent.Image != "" {
-
- }
-
- @detailsTemplate(params.DetailsParams)
-
-
- @clientsTemplate(params.Clients)
-
-
- @footerTemplate()
-
-
+ @eventPageTemplate(
+ params.LiveEvent.title(),
+ params.OpenGraphParams,
+ params.HeadParams,
+ params.Metadata,
+ params.Clients,
+ params.Details,
+ params.Event,
+ ) {
+
+ { params.LiveEvent.Title }
+ switch params.LiveEvent.Status {
+ case "ended":
+ Ended
+ case "live":
+ Live now!
+ }
+
+
+
+
+ for _, v := range params.LiveEvent.Hashtags {
+
+ { v }
+
+ }
+
+ if params.LiveEvent.Summary != "" {
+
{ params.LiveEvent.Summary }
+ }
+ if params.LiveEvent.Image != "" {
+

+ }
+ }
}
diff --git a/live_event_message.templ b/live_event_message.templ
index ca2bbae..4a52415 100644
--- a/live_event_message.templ
+++ b/live_event_message.templ
@@ -2,51 +2,15 @@ package main
templ liveEventMessageTemplate(params LiveEventMessagePageParams) {
-
-
-
-
{ params.TitleizedContent }
- @openGraphTemplate(params.OpenGraphParams)
- @headCommonTemplate(params.HeadParams)
-
-
- @topTemplate()
-
-
-
- @authorHeaderTemplate(params.Metadata)
-
- { params.CreatedAt }
-
-
- if params.ParentLink != "" {
- messaging during the live event
-
- @templ.Raw(params.ParentLink)
-
- }
-
-
-
- if params.Subject != "" {
- { params.Subject }
- } else {
-
- { params.Metadata.ShortName() } on Nostr: { params.TitleizedContent }
-
- }
-
- @templ.Raw(params.Content)
-
- @detailsTemplate(params.DetailsParams)
-
-
- @clientsTemplate(params.Clients)
-
-
- @footerTemplate()
-
-
+ @eventPageTemplate(
+ params.TitleizedContent,
+ params.OpenGraphParams,
+ params.HeadParams,
+ params.Metadata,
+ params.Clients,
+ params.Details,
+ params.Event,
+ ) {
+ @templ.Raw(params.Content)
+ }
}
diff --git a/markdown.go b/markdown.go
index e174443..35f9c08 100644
--- a/markdown.go
+++ b/markdown.go
@@ -52,7 +52,7 @@ var tgivmdrenderer = html.NewRenderer(html.RendererOptions{
func mdToHTML(md string, usingTelegramInstantView bool, skipLinks bool) string {
md = strings.ReplaceAll(md, "\u00A0", " ")
- md = replaceNostrURLsWithTags(nostrEveryMatcher, md)
+ md = replaceNostrURLsWithHTMLTags(nostrEveryMatcher, md)
// create markdown parser with extensions
// this parser is stateful so it must be reinitialized every time
diff --git a/note.templ b/note.templ
index cbb140e..9e40afe 100644
--- a/note.templ
+++ b/note.templ
@@ -2,51 +2,25 @@ package main
templ noteTemplate(params NotePageParams) {
-
-
-
-
{ params.TitleizedContent }
- @openGraphTemplate(params.OpenGraphParams)
- @headCommonTemplate(params.HeadParams)
-
-
- @topTemplate()
-
-
-
- @authorHeaderTemplate(params.Metadata)
-
- { params.CreatedAt }
-
-
- if params.ParentLink != "" {
- in reply to
-
- @templ.Raw(params.ParentLink)
-
- }
-
-
-
- if params.Subject != "" {
- { params.Subject }
- } else {
-
- { params.Metadata.ShortName() } on Nostr: { params.TitleizedContent }
-
- }
-
-
- @templ.Raw(params.Content)
-
-
- @detailsTemplate(params.DetailsParams)
-
-
- @clientsTemplate(params.Clients)
-
-
- @footerTemplate()
-
-
+ @eventPageTemplate(
+ params.TitleizedContent,
+ params.OpenGraphParams,
+ params.HeadParams,
+ params.Metadata,
+ params.Clients,
+ params.Details,
+ params.Event,
+ ) {
+ if params.Subject != "" {
+
{ params.Subject }
+ } else {
+
+ { params.Metadata.ShortName() } on Nostr: { params.TitleizedContent }
+
+ }
+
+
+ @templ.Raw(params.Content)
+
+ }
}
diff --git a/other.templ b/other.templ
index 4414037..1f44529 100644
--- a/other.templ
+++ b/other.templ
@@ -26,7 +26,7 @@ templ otherTemplate(params OtherPageParams) {
{ params.Alt }
}
- @detailsTemplate(params .DetailsParams)
+ @detailsTemplate(params.Details)
diff --git a/pages.go b/pages.go
index e24b1a3..230bee4 100644
--- a/pages.go
+++ b/pages.go
@@ -7,6 +7,7 @@ import (
"html/template"
"strings"
+ "github.com/a-h/templ"
"github.com/nbd-wtf/go-nostr/nip11"
)
@@ -20,6 +21,7 @@ const (
FileMetadata
LiveEvent
LiveEventMessage
+ CalendarEvent
Other
)
@@ -51,10 +53,7 @@ type DetailsParams struct {
Kind int
KindNIP string
KindDescription string
-
- // kind-specific stuff
- FileMetadata *Kind1063Metadata
- LiveEvent *Kind30311Metadata
+ Extra templ.Component
}
type HeadParams struct {
@@ -65,17 +64,17 @@ type HeadParams struct {
}
type TelegramInstantViewParams struct {
- Video string
- VideoType string
- Image string
- Summary template.HTML
- Content template.HTML
- Description string
- Subject string
- Metadata Metadata
- AuthorLong string
- CreatedAt string
- ParentLink template.HTML
+ Video string
+ VideoType string
+ Image string
+ Summary template.HTML
+ Content template.HTML
+ Description string
+ Subject string
+ Metadata Metadata
+ AuthorLong string
+ CreatedAt string
+ ParentNevent string
}
type HomePageParams struct {
@@ -97,30 +96,6 @@ type ArchivePageParams struct {
PrevPage int
}
-type OtherPageParams struct {
- HeadParams
- DetailsParams
-
- Kind int
- KindDescription string
- Alt string
-}
-
-type NotePageParams struct {
- OpenGraphParams
- HeadParams
- DetailsParams
-
- Content template.HTML
- CreatedAt string
- Metadata Metadata
- ParentLink template.HTML
- SeenOn []string
- Subject string
- TitleizedContent string
- Clients []ClientReference
-}
-
type EmbeddedNoteParams struct {
Content template.HTML
CreatedAt string
@@ -132,8 +107,8 @@ type EmbeddedNoteParams struct {
type ProfilePageParams struct {
HeadParams
- DetailsParams
+ Details DetailsParams
AuthorRelays []string
Content string
CreatedAt string
@@ -144,7 +119,6 @@ type ProfilePageParams struct {
RenderedAuthorAboutText template.HTML
Nevent string
Nprofile string
- IsReply string
Proxy string
Title string
Clients []ClientReference
@@ -164,66 +138,6 @@ type EmbeddedProfileParams struct {
Title string
}
-type FileMetadataPageParams struct {
- OpenGraphParams
- HeadParams
- DetailsParams
-
- Content template.HTML
- CreatedAt string
- Metadata Metadata
- ParentLink template.HTML
- SeenOn []string
- Style Style
- Subject string
- TitleizedContent string
- Alt string
-
- FileMetadata Kind1063Metadata
- IsImage bool
- IsVideo bool
-
- Clients []ClientReference
-}
-
-type LiveEventPageParams struct {
- OpenGraphParams
- HeadParams
- DetailsParams
-
- Content template.HTML
- CreatedAt string
- Metadata Metadata
- ParentLink template.HTML
- SeenOn []string
- Style Style
- Subject string
- TitleizedContent string
- Alt string
-
- LiveEvent Kind30311Metadata
-
- Clients []ClientReference
-}
-
-type LiveEventMessagePageParams struct {
- OpenGraphParams
- HeadParams
- DetailsParams
-
- Content template.HTML
- CreatedAt string
- Metadata Metadata
- ParentLink template.HTML
- SeenOn []string
- Style Style
- Subject string
- TitleizedContent string
- Alt string
-
- Clients []ClientReference
-}
-
type RelayPageParams struct {
HeadParams
@@ -259,3 +173,83 @@ func (e *ErrorPageParams) MessageHTML() template.HTML {
return "I can't give any suggestions to solve the problem.