mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 06:14:22 +01:00
use naked (no relay hints) nip19 codes for canonical URLs and move them to head_common.
This commit is contained in:
7
data.go
7
data.go
@@ -68,7 +68,9 @@ type Data struct {
|
||||
npubShort string
|
||||
nprofile string
|
||||
nevent string
|
||||
neventNaked string
|
||||
naddr string
|
||||
naddrNaked string
|
||||
createdAt string
|
||||
modifiedAt string
|
||||
parentLink template.HTML
|
||||
@@ -104,7 +106,9 @@ func grabData(ctx context.Context, code string, isProfileSitemap bool) (*Data, e
|
||||
npub, _ := nip19.EncodePublicKey(event.PubKey)
|
||||
nprofile := ""
|
||||
nevent, _ := nip19.EncodeEvent(event.ID, relaysForNip19, event.PubKey)
|
||||
neventNaked, _ := nip19.EncodeEvent(event.ID, nil, event.PubKey)
|
||||
naddr := ""
|
||||
naddrNaked := ""
|
||||
createdAt := time.Unix(int64(event.CreatedAt), 0).Format("2006-01-02 15:04:05")
|
||||
modifiedAt := time.Unix(int64(event.CreatedAt), 0).Format("2006-01-02T15:04:05Z07:00")
|
||||
|
||||
@@ -173,6 +177,7 @@ func grabData(ctx context.Context, code string, isProfileSitemap bool) (*Data, e
|
||||
templateId = Other
|
||||
if d := event.Tags.GetFirst([]string{"d", ""}); d != nil {
|
||||
naddr, _ = nip19.EncodeEntity(event.PubKey, event.Kind, d.Value(), relaysForNip19)
|
||||
naddrNaked, _ = nip19.EncodeEntity(event.PubKey, event.Kind, d.Value(), nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,7 +241,9 @@ func grabData(ctx context.Context, code string, isProfileSitemap bool) (*Data, e
|
||||
npubShort: npubShort,
|
||||
nprofile: nprofile,
|
||||
nevent: nevent,
|
||||
neventNaked: neventNaked,
|
||||
naddr: naddr,
|
||||
naddrNaked: naddrNaked,
|
||||
authorRelays: authorRelays,
|
||||
createdAt: createdAt,
|
||||
modifiedAt: modifiedAt,
|
||||
|
||||
4
pages.go
4
pages.go
@@ -30,6 +30,8 @@ var (
|
||||
type HeadCommonPartial struct {
|
||||
IsProfile bool
|
||||
TailwindDebugStuff template.HTML
|
||||
NaddrNaked string
|
||||
NeventNaked string
|
||||
}
|
||||
|
||||
func (*HeadCommonPartial) TemplateText() string { return tmplHeadCommon }
|
||||
@@ -164,7 +166,6 @@ type OtherPage struct {
|
||||
DetailsPartial `tmpl:"details"`
|
||||
FooterPartial `tmpl:"footer"`
|
||||
|
||||
IsParameterizedReplaceable bool
|
||||
Naddr string
|
||||
Kind int
|
||||
KindDescription string
|
||||
@@ -191,7 +192,6 @@ type NotePage struct {
|
||||
Description string
|
||||
Image string
|
||||
Metadata nostr.ProfileMetadata
|
||||
Nevent string
|
||||
Npub string
|
||||
NpubShort string
|
||||
Oembed string
|
||||
|
||||
@@ -243,7 +243,12 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
case Note:
|
||||
err = NoteTemplate.Render(w, &NotePage{
|
||||
HeadCommonPartial: HeadCommonPartial{IsProfile: false, TailwindDebugStuff: tailwindDebugStuff},
|
||||
HeadCommonPartial: HeadCommonPartial{
|
||||
IsProfile: false,
|
||||
TailwindDebugStuff: tailwindDebugStuff,
|
||||
NaddrNaked: data.naddrNaked,
|
||||
NeventNaked: data.neventNaked,
|
||||
},
|
||||
DetailsPartial: detailsData,
|
||||
ClientsPartial: ClientsPartial{
|
||||
Clients: generateClientList(code, data.event),
|
||||
@@ -255,7 +260,6 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
|
||||
Description: description,
|
||||
Image: data.image,
|
||||
Metadata: data.metadata,
|
||||
Nevent: data.nevent,
|
||||
Npub: data.npub,
|
||||
NpubShort: data.npubShort,
|
||||
Oembed: oembed,
|
||||
@@ -272,9 +276,13 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
case Other:
|
||||
err = OtherTemplate.Render(w, &OtherPage{
|
||||
HeadCommonPartial: HeadCommonPartial{IsProfile: false, TailwindDebugStuff: tailwindDebugStuff},
|
||||
HeadCommonPartial: HeadCommonPartial{
|
||||
IsProfile: false,
|
||||
TailwindDebugStuff: tailwindDebugStuff,
|
||||
NaddrNaked: data.naddrNaked,
|
||||
NeventNaked: data.neventNaked,
|
||||
},
|
||||
DetailsPartial: detailsData,
|
||||
IsParameterizedReplaceable: data.event.Kind >= 30000 && data.event.Kind < 40000,
|
||||
Naddr: data.naddr,
|
||||
Kind: data.event.Kind,
|
||||
KindDescription: data.kindDescription,
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
sizes="16x16"
|
||||
href="/njump/static/favicon/event/favicon-16x16.png?v=2"
|
||||
/>
|
||||
{{end}}
|
||||
<meta name="theme-color" content="#e42a6d" />
|
||||
<script src="https://unpkg.com/hyperscript.org@0.9.12"></script>
|
||||
{{ if not (eq "" .TailwindDebugStuff) }} {{ .TailwindDebugStuff }} {{ else }}
|
||||
<link
|
||||
@@ -53,7 +51,14 @@
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<meta name="theme-color" content="#e42a6d" />
|
||||
{{ if eq "" .NaddrNaked }}
|
||||
<link rel="canonical" href="https://njump.me/{{.NaddrNaked}}" />
|
||||
{{ else }}
|
||||
<link rel="canonical" href="https://njump.me/{{.NeventNaked}}" />
|
||||
{{ end }}
|
||||
<!---->
|
||||
{{ end }}
|
||||
<script type="text/hyperscript">
|
||||
on load get [navigator.userAgent.includes('Safari'), navigator.userAgent.includes('Chrome')] then if it[0] is true and it[1] is false add .safari to <body /> end
|
||||
</script>
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="theme--default text-lg sm:text-xl font-light print:text-base">
|
||||
<!doctype html>
|
||||
<html class="theme--default text-lg font-light print:text-base sm:text-xl">
|
||||
<meta charset="UTF-8" />
|
||||
<head>
|
||||
<title>{{.TitleizedContent}}</title>
|
||||
<title>{{.Nevent}} by {{.Metadata.Name}} is this note nostr ”nevent"</title>
|
||||
|
||||
<meta property="og:title" content="{{.Title}}" />
|
||||
{{ if eq .Style "twitter" }}
|
||||
@@ -33,7 +32,6 @@
|
||||
<meta name="twitter:description" content="{{.Description}}" />
|
||||
{{ end }}
|
||||
|
||||
<link rel="canonical" href="https://njump.me/{{.Nevent }}" />
|
||||
<!---->
|
||||
{{ if not (eq "" .Oembed) }}
|
||||
<link
|
||||
|
||||
Reference in New Issue
Block a user