Add Google Calendar link to event page

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-20 15:58:17 -04:00
parent cfa57cadc7
commit 9e14932dc6
3 changed files with 38 additions and 0 deletions
+20
View File
@@ -9,6 +9,7 @@ import (
"html/template"
"log"
"net/http"
"net/url"
"strconv"
"strings"
@@ -175,6 +176,7 @@ type EventPageData struct {
IsAdmin bool
BaseURL string
DescriptionHTML template.HTML
GCalURL string
User *db.User
AuthEnabled bool
CanEditRsvps bool
@@ -184,6 +186,23 @@ type EventPageData struct {
PlusOneMax int64
}
func buildGCalURL(event db.Event, baseURL string) string {
params := url.Values{}
params.Set("action", "TEMPLATE")
params.Set("text", event.Title)
if event.Location != "" {
params.Set("location", event.Location)
}
var details strings.Builder
if event.Description != "" {
details.WriteString(event.Description)
details.WriteString("\n\n")
}
details.WriteString(baseURL + "/e/" + event.Slug)
params.Set("details", details.String())
return "https://calendar.google.com/calendar/render?" + params.Encode()
}
func (s *Server) loadEventPage(r *http.Request, slug string, isAdmin bool) (*EventPageData, error) {
event, err := s.q.GetEventBySlug(r.Context(), slug)
if err != nil {
@@ -273,6 +292,7 @@ func (s *Server) loadEventPage(r *http.Request, slug string, isAdmin bool) (*Eve
IsAdmin: isAdmin,
BaseURL: s.baseURL,
DescriptionHTML: descHTML,
GCalURL: buildGCalURL(event, s.baseURL),
User: user,
AuthEnabled: s.features.Auth,
CanEditRsvps: isAdmin || !s.features.Auth || user != nil,
+3
View File
@@ -29,6 +29,9 @@
{{if .DescriptionHTML}}
<div class="event-description">{{.DescriptionHTML}}</div>
{{end}}
<div style="margin-top:14px">
<a href="{{.GCalURL}}" target="_blank" rel="noopener" class="gcal-link">&#128197; Add to Google Calendar &#8599;</a>
</div>
</div>
<div id="slots-container"
+15
View File
@@ -132,6 +132,21 @@
margin: 8px 0;
color: #555;
}
.gcal-link {
display: inline-block;
font-family: 'DM Mono', monospace;
font-size: 0.75rem;
color: var(--ink);
text-decoration: none;
border: 1.5px solid var(--ink);
padding: 5px 12px;
background: var(--cream);
transition: box-shadow 0.1s, transform 0.1s;
}
.gcal-link:hover {
box-shadow: 3px 3px 0 var(--ink);
transform: translate(-1px, -1px);
}
.section-label {
font-family: 'DM Mono', monospace;
font-size: 0.7rem;