forked from fiatjaf/njump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.templ
67 lines (62 loc) · 2.26 KB
/
error.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
package main
import (
"strings"
"html/template"
)
type ErrorPageParams struct {
HeadParams
Errors string
Message string
}
func (e *ErrorPageParams) MessageHTML() template.HTML {
if e.Message != "" {
return template.HTML(e.Message)
}
switch {
case strings.Contains(e.Errors, "invalid checksum"):
return "It looks like you entered an invalid event code.<br> Check if you copied it fully, a good idea is compare the first and the last characters."
case strings.Contains(e.Errors, "couldn't find this"):
return "Can't find the event in the relays. Try getting an `nevent1` code with relay hints."
case strings.Contains(e.Errors, "invalid bech32 string length"),
strings.Contains(e.Errors, "invalid separator"),
strings.Contains(e.Errors, "not part of charset"):
return "You have typed a wrong event code, we need a URL path that starts with /npub1, /nprofile1, /nevent1, /naddr1, or something like /name@domain.com (or maybe just /domain.com) or an event id as hex (like /aef8b32af...)"
case strings.Contains(e.Errors, "profile metadata not found"):
return "We couldn't find the metadata (name, picture etc) for the specified user. Please check back here in 6 hours."
default:
return "I can't give any suggestions to solve the problem.<br> Please tag <a href='/dtonon.com'>daniele</a> and <a href='/fiatjaf.com'>fiatjaf</a> and complain!"
}
}
templ errorTemplate(params ErrorPageParams) {
<!DOCTYPE html>
<html class="theme--default text-lg font-light print:text-base sm:text-xl">
<meta charset="UTF-8"/>
<head>
<title>Error</title>
@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 class="mx-auto mt-12 w-10/12 text-center lg:w-9/12">
<div class="mx-auto w-4/5 sm:w-3/5">
<div class="mt-4 text-2xl leading-6">
@templ.Raw(params.MessageHTML())
</div>
<div class="my-8 italic text-neutral-400 dark:text-neutral-500">
{ params.Errors }
</div>
<div>
Are you lost?
<a
href="/"
class="block leading-3 underline decoration-neutral-400 underline-offset-4"
>Go to the homepage</a>
</div>
</div>
</div>
@footerTemplate()
</body>
</html>
}