diff --git a/render.go b/render.go index 27bda56..0944073 100644 --- a/render.go +++ b/render.go @@ -17,6 +17,7 @@ import ( type Event struct { Npub string + NpubShort string Nevent string Content string CreatedAt string diff --git a/render_relay.go b/render_relay.go index 1f14563..f19877f 100644 --- a/render_relay.go +++ b/render_relay.go @@ -51,7 +51,8 @@ func renderRelayPage(w http.ResponseWriter, r *http.Request) { npub, _ := nip19.EncodePublicKey(n.PubKey) npubShort := npub[:8] + "…" + npub[len(npub)-4:] renderableLastNotes[i] = &Event{ - Npub: npubShort, + Npub: npub, + NpubShort: npubShort, Nevent: nevent, Content: n.Content, CreatedAt: time.Unix(int64(n.CreatedAt), 0).Format("2006-01-02 15:04:05"), diff --git a/templates/relay.html b/templates/relay.html index e646c33..51834a6 100644 --- a/templates/relay.html +++ b/templates/relay.html @@ -79,7 +79,7 @@ {{if not (eq .ParentNevent "")}}
- reply
{{end}} -
by {{.Npub}}
+
by {{.NpubShort}}
{{.Content | escapeString | previewNotesFormatting}}
diff --git a/templates/scripts.js b/templates/scripts.js index f6557ec..de60f38 100644 --- a/templates/scripts.js +++ b/templates/scripts.js @@ -146,10 +146,26 @@ if (desktop_name) { }); } +// Get all the npubs elements in last notes and link them +const headerDivs = document.querySelectorAll('div.header'); +headerDivs.forEach((headerDiv) => { + const spanElements = headerDiv.querySelectorAll('span'); + spanElements.forEach((span) => { + const href = span.getAttribute('href'); + if (href) { + span.addEventListener('click', () => { + event.preventDefault(); + window.location.href = href; + }); + } + }); +}); + + // Needed to apply proper print styles if ( navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1 ) { document.body.classList.add('safari') -} +} \ No newline at end of file