forked from fiatjaf/njump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.templ
240 lines (236 loc) · 8.87 KB
/
profile.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
package main
import (
"fmt"
"html/template"
"github.com/nbd-wtf/go-nostr/sdk"
)
type ProfilePageParams struct {
HeadParams
Details DetailsParams
AuthorRelays []string
Content string
CreatedAt string
Domain string
LastNotes []EnhancedEvent
Metadata sdk.ProfileMetadata
NormalizedAuthorWebsiteURL string
RenderedAuthorAboutText template.HTML
Nevent string
Nprofile string
Proxy string
Title string
Clients []ClientReference
}
templ profileTemplate(params ProfilePageParams) {
<!DOCTYPE html>
<html class="theme--default text-lg font-light print:text-base sm:text-xl">
<meta charset="UTF-8"/>
<head>
if params.Metadata.Name != "" && params.Metadata.DisplayName != "" {
<title>
{ params.Metadata.Name }
if params.Metadata.Name != "" && params.Metadata.DisplayName != "" {
/
}
{ params.Metadata.DisplayName } is on Nostr
</title>
}
<meta
name="description"
content={ fmt.Sprintf("%s is %s's public key on Nostr", params.Metadata.Npub(), params.Metadata.ShortName()) }
/>
<meta property="og:title" content={ params.Title }/>
<meta property="og:site_name" content={ params.Metadata.Npub() }/>
if params.Metadata.Picture != "" {
<meta property="og:image" content={ params.Metadata.Picture }/>
<meta property="twitter:image" content={ params.Proxy + params.Metadata.Picture }/>
}
if params.Metadata.About != "" {
<meta property="og:description" content={ params.Metadata.About }/>
}
<meta name="twitter:card" content="summary"/>
<link rel="canonical" href={ "https://njump.me/" + params.Metadata.Npub() }/>
<link
rel="sitemap"
type="application/xml"
title={ "Sitemap for " + params.Metadata.Npub() }
href={ "/" + params.Metadata.Npub() + ".xml" }
/>
<link
rel="alternate"
type="application/atom+xml"
title="RSS"
href={ "/" + params.Metadata.Npub() + ".rss" }
/>
@headCommonTemplate(params.HeadParams)
</head>
<body class="mb-16 bg-white text-gray-600 print:text-black dark:bg-neutral-900 dark:text-neutral-50">
@topTemplate(params.HeadParams)
<div
itemscope
itemtype="https://schema.org/Person"
class="mx-auto px-4 sm:flex sm:items-center sm:justify-center sm:px-0"
>
<div class="w-full max-w-screen-2xl justify-between gap-10 overflow-visible print:w-full sm:flex sm:w-11/12 sm:px-4 md:w-10/12 lg:w-9/12 lg:gap-48vw">
<header
class="relative top-auto flex basis-1/5 sm:max-w-[20%] items-center self-start sm:sticky sm:top-8 sm:mt-8 sm:block sm:items-start"
>
<div
class="hidden basis-[60%] pr-4 sm:pr-0 items-center overflow-hidden text-left break-words"
_="on load or scroll from window or resize from window get #profile_name then measure its top, height then if top is less than height / -2 or height is 0 remove .hidden otherwise add .hidden"
>
<div class="mb-3 sm:text-center">
<div class="text-2xl break-words" itemprop="name">{ params.Metadata.Name }</div>
if params.Metadata.Name != params.Metadata.DisplayName {
<div class="text-base text-stone-400 break-words" itemprop="alternateName">
{ params.Metadata.DisplayName }
</div>
}
</div>
</div>
<div
class="imgclip max-w-[40%] basis-2/5 overflow-hidden sm:max-w-full sm:basis-auto"
>
<img class="block h-auto w-full" src={ params.Metadata.Picture } itemprop="image"/>
</div>
</header>
<div class="w-full flex-1 break-words print:w-full sm:w-1/2">
<header class="mb-6 hidden leading-5 sm:flex sm:items-center">
<h1 class="sm:max-w-full">
<div id="profile_name" class="text-2xl break-words">
if params.Metadata.Event == nil {
<span class="text-stone-200 font-bold"><unnamed></span>
} else {
{ params.Metadata.Name }
}
</div>
if params.Metadata.Name != params.Metadata.DisplayName {
<div class="text-xl text-stone-400 break-words">
{ params.Metadata.DisplayName }
</div>
}
</h1>
</header>
<div class="-ml-4 mb-6 h-1.5 w-1/2 bg-zinc-100 sm:-ml-2.5 dark:bg-zinc-700"></div>
if params.Metadata.Website != "" {
<div class="mb-6 leading-5">
<a
itemprop="sameAs"
class="border-b-2 border-b-gray-300 pb-0.5 hover:text-strongpink"
href={ templ.URL(params.NormalizedAuthorWebsiteURL) }
>{ params.Metadata.Website }</a>
</div>
}
if params.RenderedAuthorAboutText != "" {
<div
class="prose mb-6 leading-5 dark:prose-invert prose-headings:font-light sm:prose-a:text-justify"
dir="auto"
itemprop="description"
>
@templ.Raw(params.RenderedAuthorAboutText)
</div>
}
if params.Metadata.Website != "" || params.RenderedAuthorAboutText != "" {
<div class="-ml-4 mb-6 h-1.5 w-1/3 bg-zinc-100 sm:-ml-2.5 dark:bg-zinc-700"></div>
}
<div class="mb-6 leading-5">
<div class="text-sm text-strongpink">Public Key</div>
<span itemprop="identifier">{ params.Metadata.Npub() }</span>
</div>
<div class="mb-6 leading-5">
if params.Metadata.NIP05 != "" {
<div class="text-sm text-strongpink">NIP-05 Address</div>
<span itemprop="alternateName">{ params.Metadata.NIP05 }</span>
}
</div>
<div class="mb-6 leading-5">
if params.Metadata.LUD16 != "" {
<div class="text-sm text-strongpink">NIP-57 Address</div>
{ params.Metadata.LUD16 }
}
</div>
<div class="mb-6 leading-5">
<div class="text-sm text-strongpink">Profile Code</div>
{ params.Nprofile }
</div>
if len(params.AuthorRelays) != 0 {
<div class="mb-6 leading-5">
<div class="text-sm text-strongpink">Publishing to</div>
for _, relay := range params.AuthorRelays {
<div
itemprop="affiliation"
itemscope
itemtype="https://schema.org/Organization"
>
<span class="hidden" itemprop="name identifier">{ relay }</span>
<a
itemprop="url"
href={ templ.URL("/r/" + relay) }
class="mr-1 mt-2 inline-block max-w-full rounded-lg border border-slate-300 px-2 py-0.5 hover:border hover:border-solid hover:border-strongpink hover:bg-strongpink hover:text-white"
>
{ relay }
</a>
</div>
}
</div>
}
if params.Metadata.Event != nil {
@detailsTemplate(params.Details)
}
if len(params.LastNotes) != 0 {
<aside>
<div class="-ml-4 mb-6 h-1.5 w-1/3 bg-zinc-100 sm:-ml-2.5 dark:bg-zinc-700"></div>
<nav 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="hidden" itemprop="author" itemscope itemtype="https://schema.org/Person">
<a href={ templ.SafeURL("/" + params.Metadata.Npub()) } itemprop="url"></a>
<span itemprop="identifier">{ params.Metadata.Npub() }</span>
<span itemprop="name">{ params.Metadata.ShortName() }</span>
</div>
<div class="-ml-2.5 mb-1.5 flex flex-row flex-wrap 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
itemprop="dateCreated"
datetime={ ee.CreatedAtStr() }
class="text-sm text-strongpink"
>
{ ee.CreatedAtStr() }
</span>
</a>
if ee.isReply() {
<div class="ml-2 text-sm text-gray-300 dark:text-gray-400">- reply</div>
}
</div>
<span
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())
</span>
</div>
}
</nav>
</aside>
}
<div class="-ml-4 mb-6 h-1.5 w-1/3 bg-zinc-100 sm:-ml-2.5 dark:bg-zinc-700"></div>
</div>
@clientsTemplate(params.Clients)
</div>
</div>
@footerTemplate()
</body>
</html>
}