hswaw/site: wip new layout
Change-Id: I4da3a668429dee42c7292accb9e24b93703f1538
diff --git a/hswaw/site/calendar/event.go b/hswaw/site/calendar/event.go
index 19a916b..141e4a6 100644
--- a/hswaw/site/calendar/event.go
+++ b/hswaw/site/calendar/event.go
@@ -19,6 +19,8 @@
UID string
// Summary is the 'title' of the event, usually a short one-liner.
Summary string
+ // Full description of event. Might contain multiple lines of test.
+ Description string
// Start and End of the events, potentially whole-day dates. See EventTime
// for more information.
// If Start is WholeDay then so is End, and vice-versa.
diff --git a/hswaw/site/calendar/load.go b/hswaw/site/calendar/load.go
index 5b36b9c..f9ae146 100644
--- a/hswaw/site/calendar/load.go
+++ b/hswaw/site/calendar/load.go
@@ -6,6 +6,7 @@
"io"
"net/http"
"sort"
+ "strings"
"time"
_ "time/tzdata"
@@ -57,6 +58,13 @@
}
summary := summaryProp.Value
+ var description string
+ descriptionProp := event.GetProperty(ics.ComponentPropertyDescription)
+ if descriptionProp != nil && descriptionProp.Value != "" {
+ // The ICS/iCal description has escaped newlines. Undo that.
+ description = strings.ReplaceAll(descriptionProp.Value, `\n`, "\n")
+ }
+
status := event.GetProperty(ics.ComponentPropertyStatus)
tentative := false
if status != nil {
@@ -87,11 +95,12 @@
}
u := &UpcomingEvent{
- UID: uid,
- Summary: summary,
- Start: start,
- End: end,
- Tentative: tentative,
+ UID: uid,
+ Summary: summary,
+ Description: description,
+ Start: start,
+ End: end,
+ Tentative: tentative,
}
if u.Elapsed(now) {
continue
diff --git a/hswaw/site/calendar/load_test.go b/hswaw/site/calendar/load_test.go
index a07f134..1b2945a 100644
--- a/hswaw/site/calendar/load_test.go
+++ b/hswaw/site/calendar/load_test.go
@@ -22,8 +22,9 @@
want := []*UpcomingEvent{
{
- UID: "65cd51ba-2fd7-475e-a274-61d19c186b66",
- Summary: "test event please ignore",
+ UID: "65cd51ba-2fd7-475e-a274-61d19c186b66",
+ Summary: "test event please ignore",
+ Description: "I am a description",
Start: &EventTime{
Time: time.Unix(1626091200, 0),
},
@@ -32,8 +33,9 @@
},
},
{
- UID: "2f874784-1e09-4cdc-8ae6-185c9ee36be0",
- Summary: "many days",
+ UID: "2f874784-1e09-4cdc-8ae6-185c9ee36be0",
+ Summary: "many days",
+ Description: "I am a multiline\n\ndescription\n\nwith a link: https://example.com/foo\n\nbarfoo",
Start: &EventTime{
Time: time.Unix(1626134400, 0),
WholeDay: true,