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