Fix missing code in 8ab0cfca

This commit is contained in:
Daniele Tonon
2023-09-20 12:53:53 +02:00
parent 0ffb7018d0
commit 3b828797b8
4 changed files with 21 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ import (
type Event struct {
Npub string
NpubShort string
Nevent string
Content string
CreatedAt string

View File

@@ -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"),

View File

@@ -79,7 +79,7 @@
{{if not (eq .ParentNevent "")}}
<div class="is_reply">- reply</div>
{{end}}
<div class="npub">by <span href="#">{{.Npub}}</span></div>
<div class="npub">by <span href="/{{.Npub}}">{{.NpubShort}}</span></div>
</div>
<div class="content">{{.Content | escapeString | previewNotesFormatting}}</div>
</a>

View File

@@ -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')
}
}