From a8bf61ea2e01e61d4481b0071122fa6461c5e45b Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 11 Jan 2024 21:07:31 -0300 Subject: [PATCH] fix nostrudel URL for rendering events and replace it with coracle for calendars. --- clients.go | 14 +++++++++----- render_event.go | 4 ++-- render_profile.go | 9 ++++++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/clients.go b/clients.go index 1ea79f7..fb061dc 100644 --- a/clients.go +++ b/clients.go @@ -18,10 +18,10 @@ var ( native = ClientReference{ID: "native", Name: "Your default app", Base: "nostr:{code}", Platform: "native"} nosta = ClientReference{ID: "nosta", Name: "Nosta", Base: "https://nosta.me/{code}", Platform: "web"} - snort = ClientReference{ID: "snort", Name: "Snort", Base: "https://snort.social/p/{code}", Platform: "web"} + snort = ClientReference{ID: "snort", Name: "Snort", Base: "https://snort.social/{code}", Platform: "web"} satellite = ClientReference{ID: "satellite", Name: "Satellite", Base: "https://satellite.earth/@{code}", Platform: "web"} primalWeb = ClientReference{ID: "primal", Name: "Primal", Base: "https://primal.net/p/{code}", Platform: "web"} - nostrudel = ClientReference{ID: "nostrudel", Name: "Nostrudel", Base: "https://nostrudel.ninja/#/u/{code}", Platform: "web"} + nostrudel = ClientReference{ID: "nostrudel", Name: "Nostrudel", Base: "https://nostrudel.ninja/#/n/{code}", Platform: "web"} nostter = ClientReference{ID: "nostter", Name: "Nostter", Base: "https://nostter.app/{code}", Platform: "web"} iris = ClientReference{ID: "iris", Name: "Iris", Base: "https://iris.to/{code}", Platform: "web"} coracle = ClientReference{ID: "coracle", Name: "Coracle", Base: "https://coracle.social/{code}", Platform: "web"} @@ -50,7 +50,11 @@ var ( plebstrIOS = ClientReference{ID: "plebstr", Name: "Plebstr", Base: "plebstr:{code}", Platform: "ios"} ) -func generateClientList(kind int, code string, withModifiers ...func(string) string) []ClientReference { +func generateClientList( + kind int, + code string, + withModifiers ...func(ClientReference, string) string, +) []ClientReference { var clients []ClientReference switch kind { case -1: // relays @@ -94,7 +98,7 @@ func generateClientList(kind int, code string, withModifiers ...func(string) str case 31922, 31923: clients = []ClientReference{ native, - flockstr, nostrudel, + coracle, flockstr, amethyst, } default: @@ -109,7 +113,7 @@ func generateClientList(kind int, code string, withModifiers ...func(string) str for i, c := range clients { clients[i].URL = templ.SafeURL(strings.Replace(c.Base, "{code}", code, -1)) for _, modifier := range withModifiers { - clients[i].URL = templ.SafeURL(modifier(string(clients[i].URL))) + clients[i].URL = templ.SafeURL(modifier(c, string(clients[i].URL))) } } diff --git a/render_event.go b/render_event.go index 6117353..e2fec4a 100644 --- a/render_event.go +++ b/render_event.go @@ -398,8 +398,8 @@ func renderEvent(w http.ResponseWriter, r *http.Request) { Details: detailsData, LiveEvent: *data.kind30311Metadata, Clients: generateClientList(data.event.Kind, data.naddr, - func(s string) string { - if strings.Contains(s, "nostrudel") { + func(c ClientReference, s string) string { + if c == nostrudel { s = strings.Replace(s, "/u/", "/streams/", 1) } return s diff --git a/render_profile.go b/render_profile.go index ae8949d..64f5b01 100644 --- a/render_profile.go +++ b/render_profile.go @@ -81,7 +81,14 @@ func renderProfile(w http.ResponseWriter, r *http.Request, code string) { Nprofile: data.nprofile, AuthorRelays: data.authorRelays, LastNotes: data.renderableLastNotes, - Clients: generateClientList(data.event.Kind, data.metadata.Npub()), + Clients: generateClientList(data.event.Kind, data.metadata.Npub(), + func(c ClientReference, s string) string { + if c == nostrudel { + s = strings.Replace(s, "/n/", "/u/", 1) + } + return s + }, + ), }).Render(r.Context(), w) }