mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-18 06:44:22 +01:00
Add support for summary field and cut description if too long
This commit is contained in:
10
render.go
10
render.go
@@ -149,10 +149,13 @@ func render(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var subject string
|
var subject string
|
||||||
|
var summary string
|
||||||
for _, tag := range event.Tags {
|
for _, tag := range event.Tags {
|
||||||
if tag[0] == "subject" || tag[0] == "title" {
|
if tag[0] == "subject" || tag[0] == "title" {
|
||||||
subject = tag[1]
|
subject = tag[1]
|
||||||
break
|
}
|
||||||
|
if tag[0] == "summary" {
|
||||||
|
summary = tag[1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,8 +206,13 @@ func render(w http.ResponseWriter, r *http.Request) {
|
|||||||
} else {
|
} else {
|
||||||
description = seenOnRelays
|
description = seenOnRelays
|
||||||
}
|
}
|
||||||
|
} else if summary != "" {
|
||||||
|
description = summary
|
||||||
} else {
|
} else {
|
||||||
description = prettyJsonOrRaw(event.Content)
|
description = prettyJsonOrRaw(event.Content)
|
||||||
|
if len(description) > 240 {
|
||||||
|
description = description[:240]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manage not NIP-27 content replacing #[..] note/npub occurrences
|
// Manage not NIP-27 content replacing #[..] note/npub occurrences
|
||||||
|
|||||||
Reference in New Issue
Block a user