mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 14:24:27 +01:00
Update last notes design + add npub to relays list
This commit is contained in:
2
main.go
2
main.go
@@ -77,7 +77,7 @@ func main() {
|
||||
|
||||
funcMap := template.FuncMap{
|
||||
"basicFormatting": basicFormatting,
|
||||
"basicNostrFormatting": basicNostrFormatting,
|
||||
"previewNotesFormatting": previewNotesFormatting,
|
||||
"escapeString": html.EscapeString,
|
||||
"sanitizeXSS": sanitizeXSS,
|
||||
"trimProtocol": trimProtocol,
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
)
|
||||
|
||||
type Event struct {
|
||||
Npub string
|
||||
Nevent string
|
||||
Content string
|
||||
CreatedAt string
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -597,16 +597,45 @@ iframe {
|
||||
text-decoration: none;
|
||||
border-bottom: none;
|
||||
&.note {
|
||||
margin: 2rem 0;
|
||||
.header {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 1rem;
|
||||
.published_at {
|
||||
margin-left: -0.6rem;
|
||||
margin-bottom: 0.4rem;
|
||||
padding-left: 0.6rem;
|
||||
padding-bottom: 0.2rem;
|
||||
@include themed() {
|
||||
border-bottom: 6px solid t($over-bg);
|
||||
}
|
||||
.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;
|
||||
@@ -614,6 +643,7 @@ iframe {
|
||||
color: t($base4);
|
||||
}
|
||||
}
|
||||
}
|
||||
.content {
|
||||
flex-basis: 100%;
|
||||
margin-top: 0.2rem;
|
||||
|
||||
@@ -120,11 +120,13 @@
|
||||
<h2>Last Notes</h2>
|
||||
{{range .lastNotes}}
|
||||
<a href="/{{.Nevent | escapeString}}" class="note">
|
||||
<div class="header">
|
||||
<div class="published_at">{{.CreatedAt | escapeString}}</div>
|
||||
{{if not (eq .ParentNevent "")}}
|
||||
<div class="is_reply">- reply</div>
|
||||
{{end}}
|
||||
<div class="content">{{.Content | escapeString | basicNostrFormatting}}</div>
|
||||
</div>
|
||||
<div class="content">{{.Content | escapeString | previewNotesFormatting}}</div>
|
||||
</a>
|
||||
{{end}}
|
||||
</nav>
|
||||
|
||||
@@ -73,11 +73,15 @@
|
||||
<h2>Last Notes</h2>
|
||||
{{range .lastNotes}}
|
||||
<a href="/{{.Nevent | escapeString}}" class="note">
|
||||
<div class="published_at">{{.CreatedAt | escapeString}}</div>
|
||||
|
||||
<div class="header">
|
||||
<div class="published_at">{{.CreatedAt | escapeString}}</div><br/>
|
||||
{{if not (eq .ParentNevent "")}}
|
||||
<div class="is_reply">- reply</div>
|
||||
{{end}}
|
||||
<div class="content">{{.Content | escapeString | basicNostrFormatting}}</div>
|
||||
<div class="npub">by <span href="#">{{.Npub}}</span></div>
|
||||
</div>
|
||||
<div class="content">{{.Content | escapeString | previewNotesFormatting}}</div>
|
||||
</a>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
5
utils.go
5
utils.go
@@ -443,11 +443,14 @@ func basicFormatting(input string) string {
|
||||
return strings.Join(processedLines, "<br/>")
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user