Use new relay /r/... path in the archive

This commit is contained in:
Daniele Tonon
2023-07-27 22:49:02 +02:00
parent d23463dadf
commit fb046515cf
2 changed files with 15 additions and 11 deletions

View File

@@ -24,13 +24,16 @@ func renderArchive(w http.ResponseWriter, r *http.Request) {
}
prefix := ""
path_prefix := ""
title := ""
area := strings.Split(r.URL.Path[1:], "/")[0]
if area == "npubs-archive" {
prefix = "pa"
path_prefix = ""
title = "Nostr npubs archive"
} else {
prefix = "ra"
path_prefix = "r/"
title = "Nostr relays archive"
}
@@ -40,9 +43,9 @@ func renderArchive(w http.ResponseWriter, r *http.Request) {
if area == "npubs-archive" {
npub, _ := nip19.EncodePublicKey(keys[i])
data = append(data, npub)
} else {
} else {
data = append(data, keys[i])
}
}
}
prevPage := page - 1
@@ -53,11 +56,12 @@ func renderArchive(w http.ResponseWriter, r *http.Request) {
}
params := map[string]any{
"title": title,
"data": data,
"pagination_url": area ,
"nextPage": fmt.Sprint(nextPage),
"prevPage": fmt.Sprint(prevPage),
"title": title,
"pathPrefix": path_prefix,
"data": data,
"paginationUrl": area,
"nextPage": fmt.Sprint(nextPage),
"prevPage": fmt.Sprint(prevPage),
}
w.Header().Set("Cache-Control", "max-age=86400")

View File

@@ -31,19 +31,19 @@
<div class="field separator long"></div>
<div class="field last_notes">
{{range $index, $element := .data}}
<a href="/{{$element | escapeString}}" class="note">
{{range $index, $element := .data }}
<a href="/{{$.pathPrefix}}{{$element | escapeString}}" class="note">
<div class="content">{{$element | escapeString}}</div>
</a>
{{end}}
</div>
{{if not (eq .prevPage "0")}}
<a href="/{{.pagination_url}}/{{.prevPage | escapeString}}"><< Prev page</a>
<a href="/{{.paginationUrl}}/{{.prevPage | escapeString}}"><< Prev page</a>
{{end}}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{{if not (eq .nextPage "0")}}
<a href="/{{.pagination_url}}/{{.nextPage | escapeString}}">Next page >></a>
<a href="/{{.paginationUrl}}/{{.nextPage | escapeString}}">Next page >></a>
{{end}}
</div>