display nprofile in profile pages and hidden in event details.

This commit is contained in:
fiatjaf
2023-10-26 08:25:53 -03:00
parent 92d8b6a6d1
commit e7d1b37ca7
7 changed files with 60 additions and 54 deletions

View File

@@ -60,6 +60,9 @@ type DetailsPartial struct {
CreatedAt string
EventJSON template.HTML
Nevent string
Nprofile string
Npub string
SeenOn []string
Kind int
KindNIP string
KindDescription string
@@ -178,7 +181,6 @@ type OtherPage struct {
IsParameterizedReplaceable bool
Naddr string
Npub string
Kind int
KindDescription string
}
@@ -250,6 +252,7 @@ type ProfilePage struct {
RenderedAuthorAboutText template.HTML
Nevent string
Npub string
Nprofile string
IsReply string
Proxy string
Title string

View File

@@ -211,7 +211,18 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Link", "<"+oembed+"&format=xml>; rel=\"alternate\"; type=\"text/xml+oembed\"")
}
// migrating to templ
detailsData := DetailsPartial{
HideDetails: true,
CreatedAt: data.createdAt,
KindDescription: data.kindDescription,
KindNIP: data.kindNIP,
EventJSON: eventToHTML(data.event),
Kind: data.event.Kind,
SeenOn: data.relays,
Npub: data.npub,
Nprofile: data.nprofile,
}
switch data.templateId {
case TelegramInstantView:
err = TelegramInstantViewTemplate.Render(w, &TelegramInstantViewPage{
@@ -229,14 +240,7 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
case Note:
err = NoteTemplate.Render(w, &NotePage{
HeadCommonPartial: HeadCommonPartial{IsProfile: false},
DetailsPartial: DetailsPartial{
HideDetails: true,
CreatedAt: data.createdAt,
KindDescription: data.kindDescription,
KindNIP: data.kindNIP,
EventJSON: eventToHTML(data.event),
Kind: data.event.Kind,
},
DetailsPartial: detailsData,
ClientsPartial: ClientsPartial{
Clients: generateClientList(code, data.event),
},
@@ -253,7 +257,6 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
Oembed: oembed,
ParentLink: data.parentLink,
Proxy: "https://" + host + "/njump/proxy?src=",
SeenOn: data.relays,
Style: style,
Subject: subject,
TextImageURL: textImageURL,
@@ -265,19 +268,10 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
})
case Other:
err = OtherTemplate.Render(w, &OtherPage{
HeadCommonPartial: HeadCommonPartial{IsProfile: false},
DetailsPartial: DetailsPartial{
HideDetails: false,
CreatedAt: data.createdAt,
KindDescription: data.kindDescription,
KindNIP: data.kindNIP,
EventJSON: eventToHTML(data.event),
Kind: data.event.Kind,
},
HeadCommonPartial: HeadCommonPartial{IsProfile: false},
DetailsPartial: detailsData,
IsParameterizedReplaceable: data.event.Kind >= 30000 && data.event.Kind < 40000,
Naddr: data.naddr,
Npub: data.npub,
Kind: data.event.Kind,
KindDescription: data.kindDescription,
})

View File

@@ -48,6 +48,7 @@ func renderProfile(w http.ResponseWriter, r *http.Request, code string) {
NormalizedAuthorWebsiteURL: normalizeWebsiteURL(data.metadata.Website),
RenderedAuthorAboutText: template.HTML(basicFormatting(html.EscapeString(data.metadata.About), false, false)),
Npub: data.npub,
Nprofile: data.nprofile,
AuthorRelays: data.authorRelays,
LastNotes: data.renderableLastNotes,
})

View File

@@ -1,3 +1,26 @@
<!-- always visible details -->
<div
class="h-1.5 mb-6 -ml-4 sm:-ml-2.5 bg-zinc-100 dark:bg-zinc-700 w-1/3"
></div>
{{ if not (eq "" .Npub) }}
<div class="leading-5 mb-6">
<div class="text-sm text-strongpink">Author Public Key</div>
{{.Npub}}
</div>
{{ end }}
<!---->
{{ if not (eq 0 (len .SeenOn)) }}
<div class="leading-5 mb-6">
<div class="text-sm text-strongpink">Seen on</div>
{{ range .SeenOn }}<a href="/r/{{.}}">{{.}}</a>
{{ end }}
</div>
{{ end }}
<!-- details hidden behind a toggle -->
{{ if .HideDetails }}
<div class="leading-5 mb-6 flex items-center print:hidden" _="">
<input
@@ -55,6 +78,8 @@
</div>
{{ end }}
<!---->
<div class="leading-5 mb-6 px-4 pb-4 -mx-4 bg-gray-100 dark:bg-gray-700">
<div
class="px-4 py-1 -mx-4 text-gray-100 dark:text-gray-400 bg-gray-300 dark:bg-gray-800"
@@ -65,4 +90,11 @@
{{- .EventJSON}}
</div>
</div>
{{ if not (eq "" .Nprofile) }}
<div class="leading-5 mb-6">
<div class="text-sm text-strongpink">Author Profile Code</div>
{{.Nprofile}}
</div>
{{ end }}
</div>

View File

@@ -112,26 +112,7 @@
{{ .Content }}
</article>
<div
class="h-1.5 mb-6 -ml-4 sm:-ml-2.5 bg-zinc-100 dark:bg-zinc-700 w-1/3"
></div>
<div class="leading-5 mb-6">
<div class="text-sm text-strongpink">Author Public key</div>
{{.Npub}}
</div>
{{ if not (eq 0 (len .SeenOn)) }}
<div class="leading-5 mb-6">
<div class="text-sm text-strongpink">Seen on</div>
{{ range .SeenOn }}<a href="/r/{{.}}">{{.}}</a>
{{ end }}
</div>
{{ end }}
<!---->
{{template "details" .}}
{{template "details" .DetailsPartial}}
<div
class="h-1.5 mb-6 -ml-4 sm:-ml-2.5 bg-zinc-100 dark:bg-zinc-700 w-1/3"

View File

@@ -28,15 +28,6 @@
<div class="text-2xl mb-4">{{.KindDescription}}</div>
</header>
<div
class="h-1.5 mb-6 -ml-4 sm:-ml-2.5 bg-zinc-100 dark:bg-zinc-700 w-1/3"
></div>
<div class="leading-5 mb-6">
<div class="text-sm text-strongpink">Author Public key</div>
<a href="/{{.Npub}}">{{.Npub}}</a>
</div>
{{template "details" .DetailsPartial}}
<div

View File

@@ -90,17 +90,21 @@
class="h-1.5 mb-6 -ml-4 sm:-ml-2.5 bg-zinc-100 dark:bg-zinc-700 w-1/3"
></div>
<div class="leading-5 mb-6">
<div class="text-sm text-strongpink">Public key</div>
<div class="text-sm text-strongpink">Public Key</div>
{{.Npub}}
</div>
<div class="leading-5 mb-6">
<div class="text-sm text-strongpink">NIP-05</div>
<div class="text-sm text-strongpink">NIP-05 Address</div>
{{.Metadata.NIP05}}
</div>
<div class="leading-5 mb-6">
<div class="text-sm text-strongpink">LN Address</div>
<div class="text-sm text-strongpink">NIP-57 Address</div>
{{.Metadata.LUD16}}
</div>
<div class="leading-5 mb-6">
<div class="text-sm text-strongpink">Profile Code</div>
{{.Nprofile}}
</div>
{{ if not (eq 0 (len .AuthorRelays)) }}
<div class="leading-5 mb-6">