Add reply reference in RSS

This commit is contained in:
Daniele Tonon
2023-11-16 23:43:14 +01:00
parent b8345f9176
commit e4c61edde5
2 changed files with 20 additions and 3 deletions

11
data.go
View File

@@ -26,6 +26,10 @@ func (ee EnhancedEvent) IsReply() bool {
return nip10.GetImmediateReply(ee.event.Tags) != nil return nip10.GetImmediateReply(ee.event.Tags) != nil
} }
func (ee EnhancedEvent) Reply() *nostr.Tag {
return nip10.GetImmediateReply(ee.event.Tags)
}
func (ee EnhancedEvent) Preview() template.HTML { func (ee EnhancedEvent) Preview() template.HTML {
lines := strings.Split(html.EscapeString(ee.event.Content), "\n") lines := strings.Split(html.EscapeString(ee.event.Content), "\n")
var processedLines []string var processedLines []string
@@ -72,7 +76,12 @@ func (ee EnhancedEvent) RssTitle() string {
} }
func (ee EnhancedEvent) RssContent() string { func (ee EnhancedEvent) RssContent() string {
content := basicFormatting(html.EscapeString(ee.event.Content), true, false) content := ee.event.Content
if ee.IsReply() {
nevent, _ := nip19.EncodeEvent(ee.Reply().Value(), ee.relays, ee.event.PubKey)
content = "In reply to nostr:" + nevent + "\n_________________________\n\n" + content
}
content = basicFormatting(html.EscapeString(content), true, false)
// content = renderQuotesAsHTML(context.Background(), content, false) // content = renderQuotesAsHTML(context.Background(), content, false)
content = linkQuotes(content) content = linkQuotes(content)
return content return content

View File

@@ -8,12 +8,20 @@
{{if not (eq "" .Npub)}} {{if not (eq "" .Npub)}}
<title>Nostr notes by {{.Metadata.Name}}</title> <title>Nostr notes by {{.Metadata.Name}}</title>
<link>https://{{.Host}}/{{.Npub}}</link> <link>https://{{.Host}}/{{.Npub}}</link>
<image>{{.Metadata.Picture}}</image> <image>
<url>{{.Metadata.Picture}}</url>
<link>https://{{.Host}}/{{.Npub}}</link>
<title>Nostr notes by {{.Metadata.Name}}</title>
</image>
{{end}} {{end}}
{{if not (eq "" .RelayHostname)}} {{if not (eq "" .RelayHostname)}}
<title>Nostr notes on {{.RelayHostname}}</title> <title>Nostr notes on {{.RelayHostname}}</title>
<link>https://{{.Host}}/r/{{.RelayHostname}}</link> <link>https://{{.Host}}/r/{{.RelayHostname}}</link>
<image>{{.Info.Icon}}</image> <image>
<url>{{.Info.Icon}}</url>
<title>Nostr notes on {{.RelayHostname}}</title>
<link>https://{{.Host}}/r/{{.RelayHostname}}</link>
</image>
{{end}} {{end}}
{{range $i, $ee := .LastNotes}} {{range $i, $ee := .LastNotes}}