-
Notifications
You must be signed in to change notification settings - Fork 24
/
calendar_event.templ
125 lines (120 loc) · 3.55 KB
/
calendar_event.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
package main
import (
_ "embed"
"strings"
"html/template"
"github.com/nbd-wtf/go-nostr/nip19"
"github.com/nbd-wtf/go-nostr/nip52"
)
type CalendarPageParams struct {
BaseEventPageParams
OpenGraphParams
HeadParams
Details DetailsParams
TimeZone string
StartAtDate string
StartAtTime string
EndAtDate string
EndAtTime string
Content template.HTML
CalendarEvent Kind31922Or31923Metadata
Clients []ClientReference
}
func formatParticipants(participants []nip52.Participant) string {
var list = make([]string, 0)
for _, p := range participants {
nreplace, _ := nip19.EncodePublicKey(p.PubKey)
nreplace = replaceNostrURLsWithHTMLTags(nostrNpubNprofileMatcher, "nostr:"+nreplace)
if p.Role != "" {
nreplace = nreplace + " as " + strings.ToTitle(p.Role)
}
list = append(list, nreplace)
}
return strings.Join(list, ", ")
}
templ calendarEventInnerBlock(params CalendarPageParams) {
<h1 class="text-2xl">
{ params.CalendarEvent.Title }
</h1>
<div class="flex flex-col gap-4 sm:flex-row sm:flex-wrap xl:flex-nowrap">
if params.StartAtDate == params.EndAtDate {
<div class="sm:w-auto sm:grow xl:grow-0 xl:w-1/3">
<div class="font-semibold text-sm ml-2">Date</div>
<div class="py-2 px-4 bg-strongpink text-white rounded-md">
<div>{ params.StartAtDate }</div>
if params.StartAtTime != "" && params.EndAtTime != "" {
<div class="text-sm whitespace-nowrap">From { params.StartAtTime } to { params.EndAtTime } ({ params.TimeZone })</div>
}
</div>
</div>
} else {
<div class="sm:w-auto sm:grow xl:grow-0 xl:w-1/3">
<div class="font-semibold text-sm ml-2">Start date</div>
<div class="py-2 px-4 bg-strongpink text-white rounded-md">
<div class="whitespace-nowrap">{ params.StartAtDate }</div>
<div class="text-sm">{ params.StartAtTime } ({ params.TimeZone })</div>
</div>
</div>
if params.EndAtTime != "" {
<div class="sm:w-auto sm:grow xl:grow-0 xl:w-1/3">
<div class="font-semibold text-sm ml-2">End date</div>
<div class="py-2 px-4 bg-strongpink text-white rounded-md">
<div class="whitespace-nowrap">{ params.EndAtDate }</div>
<div class="text-sm">{ params.EndAtTime } ({ params.TimeZone })</div>
</div>
</div>
}
}
if params.CalendarEvent.Locations[0] != "" {
<div class="w-full">
<div class="font-semibold text-sm ml-2">Location</div>
<div class="py-2 px-4 bg-neutral-200 dark:bg-neutral-800 rounded-md">
{ params.CalendarEvent.Locations[0] }
</div>
</div>
}
</div>
<div class="mb-4 pt-6">
if len(params.CalendarEvent.Participants) != 0 {
<div class="pb-4">
<span class="font-medium">People</span>:
@templ.Raw(formatParticipants(params.CalendarEvent.Participants))
</div>
}
if params.CalendarEvent.Image != "" {
<img class="w-full mt-2" src={ params.CalendarEvent.Image }/>
}
@templ.Raw(params.Content)
</div>
<div class="mb-4">
for _, v := range params.CalendarEvent.Hashtags {
<span class="mr-2 whitespace-nowrap rounded bg-neutral-200 px-2 dark:bg-neutral-700 dark:text-white">
{ v }
</span>
}
</div>
}
templ calendarEventTemplate(params CalendarPageParams, isEmbed bool) {
<!DOCTYPE html>
if isEmbed {
@embeddedPageTemplate(
params.Event,
params.NeventNaked,
isEmbed,
) {
@calendarEventInnerBlock(params)
}
} else {
@eventPageTemplate(
"Calendar Event: "+params.CalendarEvent.Title,
params.OpenGraphParams,
params.HeadParams,
params.Clients,
params.Details,
params.Event,
isEmbed,
) {
@calendarEventInnerBlock(params)
}
}
}