header.tmpl (5499B)
1 {{- /* 2 // GoToSocial 3 // Copyright (C) GoToSocial Authors admin@gotosocial.org 4 // SPDX-License-Identifier: AGPL-3.0-or-later 5 // 6 // This program is free software: you can redistribute it and/or modify 7 // it under the terms of the GNU Affero General Public License as published by 8 // the Free Software Foundation, either version 3 of the License, or 9 // (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU Affero General Public License for more details. 15 // 16 // You should have received a copy of the GNU Affero General Public License 17 // along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ -}} 19 20 21 {{- /* 22 NESTED TEMPLATE DECLARATIONS 23 If some if/else macro is used multiple times, declare it once here instead. 24 When invoking these nested templates, remember to pass in the values passed 25 to the executing template, ie., use '{{ template "example" . }}' not 26 '{{ template "example" }}', otherwise you'll end up with empty variables. 27 */ -}} 28 {{ define "thumbnailType" }}{{ if .instance.ThumbnailType }}{{ .instance.ThumbnailType }}{{ else }}image/png{{ end }}{{ end }} 29 {{ define "instanceTitle" }}{{ if .ogMeta }}{{ .ogMeta.Title }}{{ else }}{{ .instance.Title }} - GoToSocial{{ end }}{{ end }} 30 31 {{- /* 32 BOILERPLATE GOES HERE 33 */ -}} 34 <!DOCTYPE html> 35 <!-- header.tmpl --> 36 <html lang="en"> 37 <head> 38 <meta charset="UTF-8"> 39 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 40 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 41 42 {{- /* 43 ROBOTS META TAGS 44 If this template was provided with a specific robots meta policy, use that. 45 Otherwise, fall back to a default restrictive policy. 46 See: https://developers.google.com/search/docs/crawling-indexing/robots-meta-tag 47 */ -}} 48 <meta name="robots" content="{{ if .robotsMeta }}{{ .robotsMeta }}{{ else }}noindex, nofollow{{ end }}"> 49 50 {{- /* 51 OPEN GRAPH META TAGS 52 To enable fancy previews of links to GtS posts/profiles shared via instant 53 messaging, or other social media, parse out provided Open Graph meta tags. 54 */ -}} 55 {{ if .ogMeta -}} 56 {{ if .ogMeta.Locale }}<meta name="og:locale" content="{{ .ogMeta.Locale }}">{{ end }} 57 <meta property="og:type" content="{{ .ogMeta.Type }}"> 58 <meta property="og:title" content="{{ .ogMeta.Title }}"> 59 <meta property="og:url" content="{{ .ogMeta.URL }}"> 60 <meta property="og:site_name" content="{{ .ogMeta.SiteName }}"> 61 <meta property="og:description" {{ .ogMeta.Description | noescapeAttr }}> 62 {{ if .ogMeta.ArticlePublisher }} 63 <meta property="og:article:publisher" content="{{ .ogMeta.ArticlePublisher }}"> 64 <meta property="og:article:author" content="{{ .ogMeta.ArticleAuthor }}"> 65 <meta property="og:article:modified_time" content="{{ .ogMeta.ArticleModifiedTime }}"> 66 <meta property="og:article:published_time" content="{{ .ogMeta.ArticlePublishedTime }}"> 67 {{ end }} 68 {{ if .ogMeta.ProfileUsername }}<meta property="og:profile:username" content="{{ .ogMeta.ProfileUsername }}">{{ end }} 69 <meta property="og:image" content="{{ .ogMeta.Image }}"> 70 {{ if .ogMeta.ImageAlt }}<meta property="og:image:alt" content="{{ .ogMeta.ImageAlt }}">{{ end }} 71 {{ if .ogMeta.ImageWidth }} 72 <meta property="og:image:width" content="{{ .ogMeta.ImageWidth }}"> 73 <meta property="og:image:height" content="{{ .ogMeta.ImageHeight }}"> 74 {{ end }} 75 {{- end }} 76 77 {{- /* 78 ICON 79 For icon, provide a link to the instance thumbnail. If the instance admin has 80 set a custom thumbnail, use the type they uploaded, else assume image/png. 81 See: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel#icon 82 */ -}} 83 <link rel="icon" href="{{ .instance.Thumbnail }}" type="{{ template "thumbnailType" . }}"> 84 <link rel="apple-touch-icon" href="{{ .instance.Thumbnail }}" type="{{ template "thumbnailType" . }}"> 85 <link rel="apple-touch-startup-image" href="{{ .instance.Thumbnail }}" type="{{ template "thumbnailType" . }}"> 86 87 {{- /* 88 RSS FEED 89 To enable automatic rss feed discovery for feed readers, provide the 'alternate' 90 link only if rss is enabled. 91 See: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel#alternate 92 */ -}} 93 {{ if .rssFeed -}} 94 <link rel="alternate" type="application/rss+xml" href="{{ .rssFeed }}" title="{{ template "instanceTitle" . }}"> 95 {{- end }} 96 97 {{- /* 98 STYLESHEET STUFF 99 To try to speed up rendering a little bit, offer a preload for each stylesheet. 100 See: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload. 101 */ -}} 102 <link rel="preload" href="/assets/dist/_colors.css" as="style"> 103 <link rel="preload" href="/assets/dist/base.css" as="style"> 104 {{ range .stylesheets }}<link rel="preload" href="{{ . }}" as="style">{{ end }} 105 <link rel="stylesheet" href="/assets/dist/_colors.css"> 106 <link rel="stylesheet" href="/assets/dist/base.css"> 107 {{ range .stylesheets }}<link rel="stylesheet" href="{{ . }}">{{ end }} 108 <title>{{ template "instanceTitle" . }}</title> 109 </head> 110 111 <body> 112 <div class="page"> 113 <header> 114 <a aria-label="{{ .instance.Title }}. Go to instance homepage" href="/" class="nounderline header"> 115 <img src="{{ .instance.Thumbnail }}" 116 alt="{{ if .instance.ThumbnailDescription }}{{ .instance.ThumbnailDescription }}{{ else }}Instance Logo{{ end }}" /> 117 <h1> 118 {{ .instance.Title }} 119 </h1> 120 </a> 121 </header> 122 <div class="content">