mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 14:24:27 +01:00
fix nostrudel URL for rendering events and replace it with coracle for calendars.
This commit is contained in:
14
clients.go
14
clients.go
@@ -18,10 +18,10 @@ var (
|
|||||||
native = ClientReference{ID: "native", Name: "Your default app", Base: "nostr:{code}", Platform: "native"}
|
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"}
|
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"}
|
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"}
|
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"}
|
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"}
|
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"}
|
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"}
|
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
|
var clients []ClientReference
|
||||||
switch kind {
|
switch kind {
|
||||||
case -1: // relays
|
case -1: // relays
|
||||||
@@ -94,7 +98,7 @@ func generateClientList(kind int, code string, withModifiers ...func(string) str
|
|||||||
case 31922, 31923:
|
case 31922, 31923:
|
||||||
clients = []ClientReference{
|
clients = []ClientReference{
|
||||||
native,
|
native,
|
||||||
flockstr, nostrudel,
|
coracle, flockstr,
|
||||||
amethyst,
|
amethyst,
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -109,7 +113,7 @@ func generateClientList(kind int, code string, withModifiers ...func(string) str
|
|||||||
for i, c := range clients {
|
for i, c := range clients {
|
||||||
clients[i].URL = templ.SafeURL(strings.Replace(c.Base, "{code}", code, -1))
|
clients[i].URL = templ.SafeURL(strings.Replace(c.Base, "{code}", code, -1))
|
||||||
for _, modifier := range withModifiers {
|
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)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -398,8 +398,8 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
|
|||||||
Details: detailsData,
|
Details: detailsData,
|
||||||
LiveEvent: *data.kind30311Metadata,
|
LiveEvent: *data.kind30311Metadata,
|
||||||
Clients: generateClientList(data.event.Kind, data.naddr,
|
Clients: generateClientList(data.event.Kind, data.naddr,
|
||||||
func(s string) string {
|
func(c ClientReference, s string) string {
|
||||||
if strings.Contains(s, "nostrudel") {
|
if c == nostrudel {
|
||||||
s = strings.Replace(s, "/u/", "/streams/", 1)
|
s = strings.Replace(s, "/u/", "/streams/", 1)
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
|
|||||||
@@ -81,7 +81,14 @@ func renderProfile(w http.ResponseWriter, r *http.Request, code string) {
|
|||||||
Nprofile: data.nprofile,
|
Nprofile: data.nprofile,
|
||||||
AuthorRelays: data.authorRelays,
|
AuthorRelays: data.authorRelays,
|
||||||
LastNotes: data.renderableLastNotes,
|
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)
|
}).Render(r.Context(), w)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user