mirror of
https://github.com/aljazceru/njump.git
synced 2026-01-31 11:44:34 +01:00
do not show blank fields and separators in profile.
This commit is contained in:
23
data.go
23
data.go
@@ -144,7 +144,6 @@ func grabData(ctx context.Context, code string, isProfileSitemap bool) (*Data, e
|
||||
data.createdAt = time.Unix(int64(event.CreatedAt), 0).Format("2006-01-02 15:04:05")
|
||||
data.modifiedAt = time.Unix(int64(event.CreatedAt), 0).Format("2006-01-02T15:04:05Z07:00")
|
||||
|
||||
author := event
|
||||
data.authorRelays = []string{}
|
||||
|
||||
eventRelays := []string{}
|
||||
@@ -254,13 +253,22 @@ func grabData(ctx context.Context, code string, isProfileSitemap bool) (*Data, e
|
||||
}
|
||||
}
|
||||
|
||||
if event.Kind != 0 {
|
||||
if event.Kind == 0 {
|
||||
data.nprofile, _ = nip19.EncodeProfile(event.PubKey, limitAt(relays, 2))
|
||||
json.Unmarshal([]byte(event.Content), &data.metadata)
|
||||
} else {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*3)
|
||||
author, relays, _ = getEvent(ctx, data.npub, relaysForNip19)
|
||||
defer cancel()
|
||||
author, relays, _ := getEvent(ctx, data.npub, relaysForNip19)
|
||||
if author != nil {
|
||||
if err := json.Unmarshal([]byte(author.Content), &data.metadata); err == nil {
|
||||
data.authorLong = fmt.Sprintf("%s (%s)", data.metadata.Name, data.npub)
|
||||
data.authorShort = fmt.Sprintf("%s (%s)", data.metadata.Name, data.npubShort)
|
||||
}
|
||||
}
|
||||
if len(relays) > 0 {
|
||||
data.nprofile, _ = nip19.EncodeProfile(event.PubKey, limitAt(relays, 2))
|
||||
}
|
||||
cancel()
|
||||
}
|
||||
|
||||
data.kindDescription = kindNames[event.Kind]
|
||||
@@ -303,12 +311,5 @@ func grabData(ctx context.Context, code string, isProfileSitemap bool) (*Data, e
|
||||
data.authorLong = data.npub
|
||||
data.authorShort = data.npubShort
|
||||
|
||||
if author != nil {
|
||||
if err := json.Unmarshal([]byte(author.Content), &data.metadata); err == nil {
|
||||
data.authorLong = fmt.Sprintf("%s (%s)", data.metadata.Name, data.npub)
|
||||
data.authorShort = fmt.Sprintf("%s (%s)", data.metadata.Name, data.npubShort)
|
||||
}
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@
|
||||
{{end}}
|
||||
</h1>
|
||||
</header>
|
||||
{{ if or (not (eq "" .Metadata.Website)) (not (eq ""
|
||||
.RenderedAuthorAboutText)) }}
|
||||
<div
|
||||
class="-ml-4 mb-6 h-1.5 w-1/2 bg-zinc-100 dark:bg-zinc-700 sm:-ml-2.5"
|
||||
></div>
|
||||
@@ -86,6 +88,7 @@
|
||||
>
|
||||
{{.RenderedAuthorAboutText}}
|
||||
</div>
|
||||
{{ end }}
|
||||
<div
|
||||
class="-ml-4 mb-6 h-1.5 w-1/3 bg-zinc-100 dark:bg-zinc-700 sm:-ml-2.5"
|
||||
></div>
|
||||
@@ -94,12 +97,14 @@
|
||||
{{.Npub}}
|
||||
</div>
|
||||
<div class="mb-6 leading-5">
|
||||
{{ if not (eq "" .Metadata.NIP05) }}
|
||||
<div class="text-sm text-strongpink">NIP-05 Address</div>
|
||||
{{.Metadata.NIP05}}
|
||||
{{.Metadata.NIP05}} {{ end }}
|
||||
</div>
|
||||
<div class="mb-6 leading-5">
|
||||
{{ if not (eq "" .Metadata.LUD16) }}
|
||||
<div class="text-sm text-strongpink">NIP-57 Address</div>
|
||||
{{.Metadata.LUD16}}
|
||||
{{.Metadata.LUD16}} {{ end }}
|
||||
</div>
|
||||
<div class="mb-6 leading-5">
|
||||
<div class="text-sm text-strongpink">Profile Code</div>
|
||||
|
||||
Reference in New Issue
Block a user