diff --git a/nostr.go b/nostr.go index 02ab96d..51e0ac2 100644 --- a/nostr.go +++ b/nostr.go @@ -127,11 +127,10 @@ func getEvent(ctx context.Context, code string) (*nostr.Event, error) { return nil, fmt.Errorf("couldn't find this %s", prefix) } -func getLastNotes(ctx context.Context, code string, options ...int) []*nostr.Event { +func getLastNotes(ctx context.Context, code string, limit int) []*nostr.Event { - events_num := 10 - if len(options) > 0 { - events_num = options[0] + if limit <= 0 { + limit = 10 } pp := sdk.InputToProfile(ctx, code) @@ -152,7 +151,7 @@ func getLastNotes(ctx context.Context, code string, options ...int) []*nostr.Eve { Kinds: []int{nostr.KindTextNote}, Authors: []string{pp.PublicKey}, - Limit: events_num, + Limit: limit, }, }) lastNotes := make([]*nostr.Event, 0, 20) diff --git a/render.go b/render.go index cdf7809..38955a5 100644 --- a/render.go +++ b/render.go @@ -54,11 +54,7 @@ func render(w http.ResponseWriter, r *http.Request) { // If the protocol is present strip it and redirect if strings.HasPrefix(code, "wss:/") || strings.HasPrefix(code, "ws:/") { - hostname := code - hostname = strings.TrimPrefix(hostname, "wss://") - hostname = strings.TrimPrefix(hostname, "ws://") - hostname = strings.TrimPrefix(hostname, "wss:/") // Some browsers replace upfront '//' with '/' - hostname = strings.TrimPrefix(hostname, "ws:/") // Some browsers replace upfront '//' with '/' + hostname := trimProtocol(code) http.Redirect(w, r, "/"+hostname, http.StatusFound) } @@ -85,6 +81,7 @@ func render(w http.ResponseWriter, r *http.Request) { author := event var renderableLastNotes []*Event parentNevent := "" + authorRelays := []string{} if event.Kind == 0 { key := "" @@ -97,6 +94,13 @@ func render(w http.ResponseWriter, r *http.Request) { key = "ln:" + event.PubKey } + ctx, cancel := context.WithTimeout(r.Context(), time.Second*4) + authorRelays = relaysForPubkey(ctx, event.PubKey) + cancel() + for i, n := range authorRelays { + authorRelays[i] = trimProtocol(n) + } + var lastNotes []*nostr.Event if ok := cache.GetJSON(key, &lastNotes); !ok { @@ -295,6 +299,7 @@ func render(w http.ResponseWriter, r *http.Request) { "kindNIP": kindNIP, "lastNotes": renderableLastNotes, "parentNevent": parentNevent, + "authorRelays": authorRelays, } // if a mapping is not found fallback to raw diff --git a/static/styles.css b/static/styles.css index f29489d..73799d1 100644 --- a/static/styles.css +++ b/static/styles.css @@ -366,6 +366,20 @@ iframe { .theme--dark .container .column_content .field a.nostr { background-color: #42091e; } +.container .column_content .field a.button { + border-bottom: 0; + border: 1px solid #c9c9c9; + border-radius: 8px; + padding: 2px 8px; + display: inline-block; + margin-top: 0.6em; + margin-right: 0.2em; +} +.container .column_content .field a.button:hover { + color: #ffffff; + background-color: #e32a6d; + border: 1px solid #e32a6d; +} .container .column_content .field .label { font-size: 0.8rem; } diff --git a/static/styles.scss b/static/styles.scss index d91a69f..9d4fe2c 100644 --- a/static/styles.scss +++ b/static/styles.scss @@ -376,6 +376,20 @@ iframe { } border-bottom: none; } + a.button { + border-bottom: 0; + border: 1px solid $color-base4; + border-radius: 8px; + padding: 2px 8px; + display: inline-block; + margin-top: 0.6em; + margin-right: 0.2em; + &:hover { + color: $color-base1; + background-color: $color-accent1; + border: 1px solid $color-accent1; + } + } .label { font-size: 0.8rem; @include themed() { diff --git a/templates/profile.html b/templates/profile.html index b073c42..e262c20 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -56,6 +56,13 @@ {{.metadata.LUD16 | escapeString}} +