diff --git a/main.go b/main.go index adf4aaa..3b3fefc 100644 --- a/main.go +++ b/main.go @@ -76,11 +76,11 @@ func main() { } funcMap := template.FuncMap{ - "basicFormatting": basicFormatting, - "basicNostrFormatting": basicNostrFormatting, - "escapeString": html.EscapeString, - "sanitizeXSS": sanitizeXSS, - "trimProtocol": trimProtocol, + "basicFormatting": basicFormatting, + "previewNotesFormatting": previewNotesFormatting, + "escapeString": html.EscapeString, + "sanitizeXSS": sanitizeXSS, + "trimProtocol": trimProtocol, } tmpl = template.Must( diff --git a/render.go b/render.go index 0e66c8e..27bda56 100644 --- a/render.go +++ b/render.go @@ -16,6 +16,7 @@ import ( ) type Event struct { + Npub string Nevent string Content string CreatedAt string diff --git a/render_relay.go b/render_relay.go index 816b997..1f14563 100644 --- a/render_relay.go +++ b/render_relay.go @@ -48,7 +48,10 @@ func renderRelayPage(w http.ResponseWriter, r *http.Request) { relay := []string{"wss://" + hostname} for i, n := range lastNotes { nevent, _ := nip19.EncodeEvent(n.ID, relay, n.PubKey) + npub, _ := nip19.EncodePublicKey(n.PubKey) + npubShort := npub[:8] + "…" + npub[len(npub)-4:] renderableLastNotes[i] = &Event{ + Npub: npubShort, Nevent: nevent, Content: n.Content, CreatedAt: time.Unix(int64(n.CreatedAt), 0).Format("2006-01-02 15:04:05"), diff --git a/static/styles.css b/static/styles.css index b04a5ef..5bbb2cb 100644 --- a/static/styles.css +++ b/static/styles.css @@ -638,12 +638,25 @@ iframe { border-bottom: none; } .container .column_content .field.last_notes a.note { + margin: 2rem 0; +} +.container .column_content .field.last_notes a.note .header { display: flex; flex-direction: row; flex-wrap: wrap; - margin-bottom: 1rem; + margin-left: -0.6rem; + margin-bottom: 0.4rem; + padding-left: 0.6rem; + padding-bottom: 0.2rem; } -.container .column_content .field.last_notes a.note .published_at { +.theme--default .container .column_content .field.last_notes a.note .header { + border-bottom: 6px solid #f3f3f3; +} +.theme--dark .container .column_content .field.last_notes a.note .header { + border-bottom: 6px solid #2d2d2d; +} +.container .column_content .field.last_notes a.note .header .published_at, +.container .column_content .field.last_notes a.note .header .npub { font-size: 0.8rem; } .theme--default @@ -651,20 +664,111 @@ iframe { .column_content .field.last_notes a.note - .published_at { + .header + .published_at, +.theme--default + .container + .column_content + .field.last_notes + a.note + .header + .npub { color: #e32a6d; } -.theme--dark .container .column_content .field.last_notes a.note .published_at { +.theme--dark + .container + .column_content + .field.last_notes + a.note + .header + .published_at, +.theme--dark .container .column_content .field.last_notes a.note .header .npub { color: #e32a6d; } -.container .column_content .field.last_notes a.note .is_reply { +.container .column_content .field.last_notes a.note .header .npub { + margin-left: auto; +} +.theme--default + .container + .column_content + .field.last_notes + a.note + .header + .npub { + color: #3d3d3d; +} +.theme--dark .container .column_content .field.last_notes a.note .header .npub { + color: #fafafa; +} +.container .column_content .field.last_notes a.note .header .npub span { + padding: 0 0.2rem; + border-radius: 4px; +} +.theme--default + .container + .column_content + .field.last_notes + a.note + .header + .npub + span { + background-color: #fdf0f5; +} +.theme--dark + .container + .column_content + .field.last_notes + a.note + .header + .npub + span { + background-color: #42091e; +} +.container .column_content .field.last_notes a.note .header .npub span:hover { + text-decoration: none; +} +.theme--default + .container + .column_content + .field.last_notes + a.note + .header + .npub + span:hover { + color: #ffffff; + background-color: #e32a6d; +} +.theme--dark + .container + .column_content + .field.last_notes + a.note + .header + .npub + span:hover { + color: #373737; + background-color: #e32a6d; +} +.container .column_content .field.last_notes a.note .header .is_reply { margin-left: 0.5em; font-size: 0.8rem; } -.theme--default .container .column_content .field.last_notes a.note .is_reply { +.theme--default + .container + .column_content + .field.last_notes + a.note + .header + .is_reply { color: #c9c9c9; } -.theme--dark .container .column_content .field.last_notes a.note .is_reply { +.theme--dark + .container + .column_content + .field.last_notes + a.note + .header + .is_reply { color: #969696; } .container .column_content .field.last_notes a.note .content { diff --git a/static/styles.scss b/static/styles.scss index 33ef3cd..21c57b3 100644 --- a/static/styles.scss +++ b/static/styles.scss @@ -597,21 +597,51 @@ iframe { text-decoration: none; border-bottom: none; &.note { - display: flex; - flex-direction: row; - flex-wrap: wrap; - margin-bottom: 1rem; - .published_at { - font-size: 0.8rem; + margin: 2rem 0; + .header { + display: flex; + flex-direction: row; + flex-wrap: wrap; + margin-left: -0.6rem; + margin-bottom: 0.4rem; + padding-left: 0.6rem; + padding-bottom: 0.2rem; @include themed() { - color: t($accent1); + border-bottom: 6px solid t($over-bg); } - } - .is_reply { - margin-left: 0.5em; - font-size: 0.8rem; - @include themed() { - color: t($base4); + .published_at, + .npub { + font-size: 0.8rem; + @include themed() { + color: t($accent1); + } + } + .npub { + margin-left: auto; + @include themed() { + color: t($base6); + } + span { + padding: 0 0.2rem; + border-radius: 4px; + @include themed() { + background-color: t($hrefbg); + } + &:hover { + text-decoration: none; + @include themed() { + color: t($base1); + background-color: t($accent1); + } + } + } + } + .is_reply { + margin-left: 0.5em; + font-size: 0.8rem; + @include themed() { + color: t($base4); + } } } .content { diff --git a/templates/profile.html b/templates/profile.html index 83d59e7..cfe1977 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -120,11 +120,13 @@

Last Notes

{{range .lastNotes}} -
{{.CreatedAt | escapeString}}
- {{if not (eq .ParentNevent "")}} -
- reply
- {{end}} -
{{.Content | escapeString | basicNostrFormatting}}
+
+
{{.CreatedAt | escapeString}}
+ {{if not (eq .ParentNevent "")}} +
- reply
+ {{end}} +
+
{{.Content | escapeString | previewNotesFormatting}}
{{end}} diff --git a/templates/relay.html b/templates/relay.html index 49662e2..e646c33 100644 --- a/templates/relay.html +++ b/templates/relay.html @@ -73,11 +73,15 @@

Last Notes

{{range .lastNotes}} -
{{.CreatedAt | escapeString}}
- {{if not (eq .ParentNevent "")}} -
- reply
- {{end}} -
{{.Content | escapeString | basicNostrFormatting}}
+ +
+
{{.CreatedAt | escapeString}}

+ {{if not (eq .ParentNevent "")}} +
- reply
+ {{end}} +
by {{.Npub}}
+
+
{{.Content | escapeString | previewNotesFormatting}}
{{end}} diff --git a/utils.go b/utils.go index 5deaf1c..777d01e 100644 --- a/utils.go +++ b/utils.go @@ -443,11 +443,14 @@ func basicFormatting(input string) string { return strings.Join(processedLines, "
") } -func basicNostrFormatting(input string) string { +func previewNotesFormatting(input string) string { lines := strings.Split(input, "\n") var processedLines []string for _, line := range lines { + if strings.TrimSpace(line) == "" { + continue + } processedLine := shortenNostrURLs(line) processedLines = append(processedLines, processedLine) }