Skip to content

Commit b1e8d53

Browse files
committed
move templ params struct definitions for each page directly to their pages.
1 parent 4011528 commit b1e8d53

14 files changed

+199
-199
lines changed

about.templ

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package main
22

3+
type AboutParams struct {
4+
HeadParams
5+
}
6+
37
templ aboutTemplate(params AboutParams) {
48
<!DOCTYPE html>
59
<html class="theme--default font-light">

calendar_event.templ

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,26 @@ import (
44
_ "embed"
55
"strings"
66
"unicode"
7+
"html/template"
78
"github.com/nbd-wtf/go-nostr/nip19"
89
"github.com/nbd-wtf/go-nostr/nip52"
910
)
1011

12+
type CalendarPageParams struct {
13+
BaseEventPageParams
14+
OpenGraphParams
15+
HeadParams
16+
Details DetailsParams
17+
TimeZone string
18+
StartAtDate string
19+
StartAtTime string
20+
EndAtDate string
21+
EndAtTime string
22+
Content template.HTML
23+
CalendarEvent Kind31922Or31923Metadata
24+
Clients []ClientReference
25+
}
26+
1127
func formatParticipants(participants []nip52.Participant) string {
1228
var list = make([]string, 0)
1329
for _, p := range participants {

error.templ

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
package main
22

3+
import (
4+
"strings"
5+
"html/template"
6+
)
7+
8+
type ErrorPageParams struct {
9+
HeadParams
10+
Errors string
11+
Message string
12+
}
13+
14+
func (e *ErrorPageParams) MessageHTML() template.HTML {
15+
if e.Message != "" {
16+
return template.HTML(e.Message)
17+
}
18+
19+
switch {
20+
case strings.Contains(e.Errors, "invalid checksum"):
21+
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."
22+
case strings.Contains(e.Errors, "couldn't find this"):
23+
return "Can't find the event in the relays. Try getting an `nevent1` code with relay hints."
24+
case strings.Contains(e.Errors, "invalid bech32 string length"),
25+
strings.Contains(e.Errors, "invalid separator"),
26+
strings.Contains(e.Errors, "not part of charset"):
27+
return "You have typed a wrong event code, we need a URL path that starts with /npub1, /nprofile1, /nevent1, /naddr1, or something like /[email protected] (or maybe just /domain.com) or an event id as hex (like /aef8b32af...)"
28+
case strings.Contains(e.Errors, "profile metadata not found"):
29+
return "We couldn't find the metadata (name, picture etc) for the specified user. Please check back here in 6 hours."
30+
default:
31+
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!"
32+
}
33+
}
34+
335
templ errorTemplate(params ErrorPageParams) {
436
<!DOCTYPE html>
537
<html class="theme--default text-lg font-light print:text-base sm:text-xl">

file_metadata.templ

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
package main
22

3+
import "html/template"
4+
5+
type FileMetadataPageParams struct {
6+
BaseEventPageParams
7+
OpenGraphParams
8+
HeadParams
9+
10+
Details DetailsParams
11+
Content template.HTML
12+
13+
FileMetadata Kind1063Metadata
14+
IsImage bool
15+
IsVideo bool
16+
17+
Clients []ClientReference
18+
}
19+
320
templ fileMetadataTemplate(params FileMetadataPageParams) {
421
<!DOCTYPE html>
522
@eventPageTemplate(

homepage.templ

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package main
22

3+
type HomePageParams struct {
4+
HeadParams
5+
6+
Npubs []string
7+
LastNotes []string
8+
}
9+
310
templ homepageTemplate(params HomePageParams) {
411
<!DOCTYPE html>
512
<html class="theme--default font-light">

live_event.templ

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
package main
22

3+
import "html/template"
4+
5+
type LiveEventPageParams struct {
6+
BaseEventPageParams
7+
OpenGraphParams
8+
HeadParams
9+
10+
Details DetailsParams
11+
Content template.HTML
12+
13+
LiveEvent Kind30311Metadata
14+
Clients []ClientReference
15+
}
16+
317
templ liveEventTemplate(params LiveEventPageParams) {
418
<!DOCTYPE html>
519
@eventPageTemplate(

live_event_message.templ

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
package main
22

3+
import "html/template"
4+
5+
type LiveEventMessagePageParams struct {
6+
BaseEventPageParams
7+
OpenGraphParams
8+
HeadParams
9+
10+
Details DetailsParams
11+
Content template.HTML
12+
TitleizedContent string
13+
14+
Clients []ClientReference
15+
}
16+
317
templ liveEventMessageTemplate(params LiveEventMessagePageParams) {
418
<!DOCTYPE html>
519
@eventPageTemplate(

note.templ

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
package main
22

3+
import "html/template"
4+
5+
type NotePageParams struct {
6+
BaseEventPageParams
7+
OpenGraphParams
8+
HeadParams
9+
10+
Details DetailsParams
11+
Content template.HTML
12+
Cover string
13+
Subject string
14+
TitleizedContent string
15+
Clients []ClientReference
16+
}
17+
318
templ noteTemplate(params NotePageParams) {
419
<!DOCTYPE html>
520
@eventPageTemplate(

other.templ

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ package main
22

33
import "strconv"
44

5+
type OtherPageParams struct {
6+
BaseEventPageParams
7+
HeadParams
8+
9+
Details DetailsParams
10+
Kind int
11+
KindDescription string
12+
}
13+
514
templ otherTemplate(params OtherPageParams) {
615
<!DOCTYPE html>
716
<html class="theme--default text-lg font-light print:text-base sm:text-xl">

0 commit comments

Comments
 (0)