mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 06:14:22 +01:00
make "s" (Settings) a global template function so we don't have to pass it around everywhere.
This commit is contained in:
1
main.go
1
main.go
@@ -77,6 +77,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
funcMap := template.FuncMap{
|
funcMap := template.FuncMap{
|
||||||
|
"s": func() Settings { return s },
|
||||||
"basicFormatting": func(input string) string { return basicFormatting(input, false, false) },
|
"basicFormatting": func(input string) string { return basicFormatting(input, false, false) },
|
||||||
"previewNotesFormatting": previewNotesFormatting,
|
"previewNotesFormatting": previewNotesFormatting,
|
||||||
"escapeString": html.EscapeString,
|
"escapeString": html.EscapeString,
|
||||||
|
|||||||
@@ -262,7 +262,6 @@ func render(w http.ResponseWriter, r *http.Request) {
|
|||||||
"parentNevent": data.parentNevent,
|
"parentNevent": data.parentNevent,
|
||||||
"authorRelays": data.authorRelays,
|
"authorRelays": data.authorRelays,
|
||||||
"oembed": oembed,
|
"oembed": oembed,
|
||||||
"s": s,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if a mapping is not found fallback to raw
|
// if a mapping is not found fallback to raw
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ func renderArchive(w http.ResponseWriter, r *http.Request) {
|
|||||||
"paginationUrl": area,
|
"paginationUrl": area,
|
||||||
"nextPage": fmt.Sprint(nextPage),
|
"nextPage": fmt.Sprint(nextPage),
|
||||||
"prevPage": fmt.Sprint(prevPage),
|
"prevPage": fmt.Sprint(prevPage),
|
||||||
"s": s,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(data) != 0 {
|
if len(data) != 0 {
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ func renderHomepage(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
params := map[string]any{
|
params := map[string]any{
|
||||||
"s": s,
|
|
||||||
"npubs": npubs,
|
"npubs": npubs,
|
||||||
"lastNotes": lastNotes,
|
"lastNotes": lastNotes,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ func renderRelayPage(w http.ResponseWriter, r *http.Request) {
|
|||||||
"proxy": "https://" + hostname + "/njump/proxy?src=",
|
"proxy": "https://" + hostname + "/njump/proxy?src=",
|
||||||
"lastNotes": renderableLastNotes,
|
"lastNotes": renderableLastNotes,
|
||||||
"modifiedAt": lastEventAt.Format("2006-01-02T15:04:05Z07:00"),
|
"modifiedAt": lastEventAt.Format("2006-01-02T15:04:05Z07:00"),
|
||||||
"s": s,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(renderableLastNotes) != 0 {
|
if len(renderableLastNotes) != 0 {
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ func renderRobots(w http.ResponseWriter, r *http.Request) {
|
|||||||
typ := "robots"
|
typ := "robots"
|
||||||
w.Header().Set("Cache-Control", "max-age=3600")
|
w.Header().Set("Cache-Control", "max-age=3600")
|
||||||
|
|
||||||
params := map[string]any{
|
params := map[string]any{}
|
||||||
"s": s,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := tmpl.ExecuteTemplate(w, templateMapping[typ], params); err != nil {
|
if err := tmpl.ExecuteTemplate(w, templateMapping[typ], params); err != nil {
|
||||||
log.Error().Err(err).Msg("error rendering")
|
log.Error().Err(err).Msg("error rendering")
|
||||||
|
|||||||
@@ -26,14 +26,14 @@
|
|||||||
(yet) working.
|
(yet) working.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<i>njump</i> currently lives under {{ .s.CanonicalHost }}, you can
|
<i>njump</i> currently lives under {{ s.CanonicalHost }}, you can
|
||||||
reach it appending a Nostr (<a
|
reach it appending a Nostr (<a
|
||||||
href="https://github.com/nostr-protocol/nips/blob/master/19.md"
|
href="https://github.com/nostr-protocol/nips/blob/master/19.md"
|
||||||
>NIP-19</a
|
>NIP-19</a
|
||||||
>) entity (<code>npub</code>, <code>nevent</code>,
|
>) entity (<code>npub</code>, <code>nevent</code>,
|
||||||
<code>naddr</code>, etc) after the domain:
|
<code>naddr</code>, etc) after the domain:
|
||||||
<span class="exampleUrl"
|
<span class="exampleUrl"
|
||||||
>{{ .s.CanonicalHost }}/<nip-19-entity></span
|
>{{ s.CanonicalHost }}/<nip-19-entity></span
|
||||||
>.
|
>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
<div class="try">
|
<div class="try">
|
||||||
<form action="/try" method="POST">
|
<form action="/try" method="POST">
|
||||||
<div class="tryForm">
|
<div class="tryForm">
|
||||||
<div>{{ .s.CanonicalHost }}/</div>
|
<div>{{ s.CanonicalHost }}/</div>
|
||||||
<input
|
<input
|
||||||
id="nip19entity"
|
id="nip19entity"
|
||||||
name="nip19entity"
|
name="nip19entity"
|
||||||
@@ -140,11 +140,11 @@
|
|||||||
>NIP-05</a
|
>NIP-05</a
|
||||||
>
|
>
|
||||||
inspired permalink:
|
inspired permalink:
|
||||||
<span class="exampleUrl">{{ .s.CanonicalHost }}/<nip-5></span
|
<span class="exampleUrl">{{ s.CanonicalHost }}/<nip-5></span
|
||||||
>, for example:
|
>, for example:
|
||||||
<a href="/nvk.org">https://{{ .s.CanonicalHost }}/nvk.org</a> or
|
<a href="/nvk.org">https://{{ s.CanonicalHost }}/nvk.org</a> or
|
||||||
<a href="/mike@mikedilger.com"
|
<a href="/mike@mikedilger.com"
|
||||||
>https://{{ .s.CanonicalHost }}/mike@mikedilger.com</a
|
>https://{{ s.CanonicalHost }}/mike@mikedilger.com</a
|
||||||
>.
|
>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@@ -156,10 +156,10 @@
|
|||||||
<p>
|
<p>
|
||||||
You can have a view of the last content posted to a relay using
|
You can have a view of the last content posted to a relay using
|
||||||
<span class="exampleUrl"
|
<span class="exampleUrl"
|
||||||
>{{ .s.CanonicalHost }}/r/<relay-host></span
|
>{{ s.CanonicalHost }}/r/<relay-host></span
|
||||||
>, for example:
|
>, for example:
|
||||||
<a href="/r/nostr.wine"
|
<a href="/r/nostr.wine"
|
||||||
>https://{{ .s.CanonicalHost }}/r/nostr.wine</a
|
>https://{{ s.CanonicalHost }}/r/nostr.wine</a
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
<link
|
<link
|
||||||
rel="canonical"
|
rel="canonical"
|
||||||
href="https://{{.s.CanonicalHost}}/{{.nevent | escapeString }}"
|
href="https://{{s.CanonicalHost}}/{{.nevent | escapeString }}"
|
||||||
/>
|
/>
|
||||||
<!---->
|
<!---->
|
||||||
{{ if .oembed }}
|
{{ if .oembed }}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<link
|
<link
|
||||||
rel="canonical"
|
rel="canonical"
|
||||||
href="https://{{.s.CanonicalHost}}/{{.npub | escapeString }}"
|
href="https://{{s.CanonicalHost}}/{{.npub | escapeString }}"
|
||||||
/>
|
/>
|
||||||
<link
|
<link
|
||||||
rel="sitemap"
|
rel="sitemap"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
User-agent: *
|
User-agent: *
|
||||||
Allow: /
|
Allow: /
|
||||||
|
|
||||||
Sitemap: https://{{.s.CanonicalHost}}/npubs-archive.xml
|
Sitemap: https://{{s.CanonicalHost}}/npubs-archive.xml
|
||||||
Sitemap: https://{{.s.CanonicalHost}}/relays-archive.xml
|
Sitemap: https://{{s.CanonicalHost}}/relays-archive.xml
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
{{if .npub}}
|
{{if .npub}}
|
||||||
<url>
|
<url>
|
||||||
<loc>https://{{.s.CanonicalHost}}/{{.npub | escapeString}}</loc>
|
<loc>https://{{s.CanonicalHost}}/{{.npub | escapeString}}</loc>
|
||||||
<lastmod>{{.modifiedAt | escapeString}}</lastmod>
|
<lastmod>{{.modifiedAt | escapeString}}</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
<priority>0.8</priority>
|
<priority>0.8</priority>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
{{if .hostname}}
|
{{if .hostname}}
|
||||||
<url>
|
<url>
|
||||||
<loc>https://{{.s.CanonicalHost}}/r/{{.hostname | escapeString}}</loc>
|
<loc>https://{{s.CanonicalHost}}/r/{{.hostname | escapeString}}</loc>
|
||||||
<lastmod>{{.modifiedAt | escapeString}}</lastmod>
|
<lastmod>{{.modifiedAt | escapeString}}</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
<priority>0.8</priority>
|
<priority>0.8</priority>
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
{{if .lastNotes}}
|
{{if .lastNotes}}
|
||||||
{{range .lastNotes}}
|
{{range .lastNotes}}
|
||||||
<url>
|
<url>
|
||||||
<loc>https://{{.s.CanonicalHost}}/{{.Nevent | escapeString}}</loc>
|
<loc>https://{{s.CanonicalHost}}/{{.Nevent | escapeString}}</loc>
|
||||||
<lastmod>{{.ModifiedAt | escapeString}}</lastmod>
|
<lastmod>{{.ModifiedAt | escapeString}}</lastmod>
|
||||||
<changefreq>never</changefreq>
|
<changefreq>never</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
{{if .data}}
|
{{if .data}}
|
||||||
{{range $element := .data }}
|
{{range $element := .data }}
|
||||||
<url>
|
<url>
|
||||||
<loc>https://{{.s.CanonicalHost}}/{{$.pathPrefix}}{{$element | trimProtocol | escapeString}}</loc>
|
<loc>https://{{s.CanonicalHost}}/{{$.pathPrefix}}{{$element | trimProtocol | escapeString}}</loc>
|
||||||
<lastmod>{{$.modifiedAt | escapeString}}</lastmod>
|
<lastmod>{{$.modifiedAt | escapeString}}</lastmod>
|
||||||
<changefreq>daily</changefreq>
|
<changefreq>daily</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
|
|||||||
Reference in New Issue
Block a user