-
Notifications
You must be signed in to change notification settings - Fork 24
/
relay.templ
184 lines (180 loc) · 6.48 KB
/
relay.templ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package main
import "github.com/nbd-wtf/go-nostr/nip11"
type RelayPageParams struct {
HeadParams
Info nip11.RelayInformationDocument
Hostname string
Proxy string
LastNotes []EnhancedEvent
ModifiedAt string
Clients []ClientReference
}
templ relayTemplate(params RelayPageParams) {
<!DOCTYPE html>
<html class="theme--default text-lg font-light print:text-base sm:text-xl">
<meta charset="UTF-8"/>
<head>
<title>Nostr Relay { params.Hostname } - { params.Info.Name }</title>
<meta property="og:title" content={ params.Hostname + " - Nostr Relay" }/>
<meta name="twitter:title" content={ params.Hostname + " - Nostr Relay" }/>
<meta property="og:site_name" content={ params.Hostname + " - Nostr Relay" }/>
if params.Info.Icon != "" {
<meta property="og:image" content={ params.Info.Icon }/>
<meta name="twitter:image" content={ params.Proxy + params.Info.Icon }/>
}
if params.Info.Description != "" {
<meta property="og:description" content={ params.Info.Description }/>
<meta name="twitter:description" content={ params.Info.Description }/>
}
<meta name="twitter:card" content="summary"/>
<link
rel="sitemap"
type="application/xml"
title={ "Sitemap for " + params.Hostname }
href={ "/r/" + params.Hostname + ".xml" }
/>
<link
rel="alternate"
type="application/atom+xml"
title="RSS"
href={ "/r/" + params.Hostname + ".rss" }
/>
@headCommonTemplate(params.HeadParams)
</head>
<body
class="mb-16 bg-white text-gray-600 dark:bg-neutral-900 dark:text-neutral-50 print:text-black"
>
@topTemplate(params.HeadParams)
<div
itemscope
itemtype="https://schema.org/Organization"
class="mx-auto px-4 sm:flex sm:items-center sm:justify-center sm:px-0"
>
<span class="hidden" itemprop="identifier name">{ params.Hostname }</span>
<div
class="w-full max-w-screen-2xl justify-between gap-10 overflow-visible px-4 print:w-full sm:flex md:w-10/12 lg:w-9/12 lg:gap-48vw"
>
<div
class="relative top-auto flex flex-row sm:flex-col basis-1/4 items-center self-start sm:sticky sm:top-8 sm:mt-8 sm:items-start"
>
<div
class="hidden items-center overflow-hidden text-left text-2xl sm:break-word sm:text-center sm:basis-full"
_="on load or scroll from window or resize from window get #relay_name then measure its top, height then if top is less than height / -2 or height is 0 add .flex then remove .hidden otherwise remove .flex then add .hidden"
itemprop="alternateName"
>
{ params.Info.Name }
</div>
<div
class="imgclip max-w-full basis-2/5 overflow-hidden sm:basis-full"
itemprop="image logo"
>
<img class="block h-auto w-full" src={ params.Info.Icon }/>
</div>
</div>
<div class="w-full break-words print:w-full sm:w-1/2">
<header class="mb-6 hidden leading-5 sm:flex sm:items-center">
<h1>
<div id="relay_name" class="text-2xl">{ params.Info.Name }</div>
</h1>
</header>
<div
class="-ml-4 mb-6 h-1.5 w-1/2 bg-zinc-100 dark:bg-zinc-700 sm:-ml-2.5"
></div>
<div class="mb-6 leading-5">
<a
class="border-b-2 border-b-gray-300 pb-0.5 hover:text-strongpink"
itemprop="url"
href={ templ.URL("https://" + params.Hostname) }
target="_blank"
_="on mouseenter set my innerText to my.innerText.replace('wss://', 'https://')
on mouseleave set my innerText to my.innerText.replace('https://', 'wss://')"
>{ "wss://" + params.Hostname }</a>
</div>
<div
class="prose mb-6 leading-5 dark:prose-invert prose-headings:font-light sm:prose-a:text-justify"
dir="auto"
itemprop="description"
>
{ params.Info.Description }
</div>
<div
class="-ml-4 mb-6 h-1.5 w-1/2 bg-zinc-100 dark:bg-zinc-700 sm:-ml-2.5"
></div>
if params.Info.PubKey != "" {
<div class="mb-6 leading-5">
<div class="text-sm text-strongpink">Public Key</div>
{ params.Info.PubKey }
</div>
}
<!---->
if params.Info.Contact != "" {
<div class="mb-6 leading-5">
<div class="text-sm text-strongpink">Contact</div>
<a href={ templ.URL(params.Info.Contact) }>{ params.Info.Contact }</a>
</div>
}
<div
class="-ml-4 mb-6 h-1.5 w-1/3 bg-zinc-100 dark:bg-zinc-700 sm:-ml-2.5"
></div>
<aside>
<div class="mb-6 leading-5">
<h2 class="text-2xl text-strongpink">Last Notes</h2>
for _, ee := range params.LastNotes {
<div
itemscope
itemtype="https://schema.org/Article"
class="my-8 block no-underline hover:-ml-6 hover:border-l-05rem hover:border-solid hover:border-l-gray-100 hover:pl-4 dark:hover:border-l-zinc-700"
>
<div class="-ml-2.5 mb-1.5 flex flex-row border-b-4 border-solid border-b-gray-100 pb-1 pl-2.5 dark:border-b-neutral-800">
<a
itemprop="url"
href={ templ.URL("/" + ee.Nevent()) }
>
<span class="text-sm text-strongpink" itemprop="dateCreated">
{ ee.CreatedAtStr() }
</span>
</a>
if ee.isReply() {
<div class="ml-2 text-xs text-gray-300 dark:text-gray-400">
- reply
</div>
}
<span
class="ml-auto text-xs text-zinc-700 dark:text-neutral-50"
itemprop="author"
itemscope
itemtype="https://schema.org/Person"
>
<span class="hidden" itemprop="identifier">{ ee.Npub() }</span>
by
<a
itemprop="url"
class="rounded bg-lavender px-1 hover:bg-strongpink hover:text-white dark:bg-garnet dark:hover:bg-strongpink"
href={ templ.SafeURL("/" + ee.Npub()) }
>
{ ee.NpubShort() }
</a>
</span>
</div>
<div
class="mt-0.5 max-h-40 basis-full overflow-hidden hover:text-strongpink cursor-pointer"
_="on load if my scrollHeight > my offsetHeight add .gradient end
on click halt the event then set the window's location to @loc"
loc={ "/" + ee.Nevent() }
dir="auto"
itemprop="articleBody"
>
@templ.Raw(ee.Preview())
</div>
</div>
}
</div>
</aside>
</div>
@clientsTemplate(params.Clients)
</div>
</div>
@footerTemplate()
</body>
</html>
}