aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/caldav/caldav.go16
-rw-r--r--plugins/caldav/public/calendar.html2
-rw-r--r--plugins/caldav/routes.go8
3 files changed, 21 insertions, 5 deletions
diff --git a/plugins/caldav/caldav.go b/plugins/caldav/caldav.go
index 906e747..377a40e 100644
--- a/plugins/caldav/caldav.go
+++ b/plugins/caldav/caldav.go
@@ -59,3 +59,19 @@ func getCalendar(u *url.URL, session *alps.Session) (*caldav.Client, *caldav.Cal
}
return c, &calendars[0], nil
}
+
+type CalendarObject struct {
+ *caldav.CalendarObject
+}
+
+func newCalendarObjectList(cos []caldav.CalendarObject) []CalendarObject {
+ l := make([]CalendarObject, len(cos))
+ for i := range cos {
+ l[i] = CalendarObject{&cos[i]}
+ }
+ return l
+}
+
+func (ao CalendarObject) URL() string {
+ return "/calendar/" + url.PathEscape(ao.Path)
+}
diff --git a/plugins/caldav/public/calendar.html b/plugins/caldav/public/calendar.html
index c23c555..1cae979 100644
--- a/plugins/caldav/public/calendar.html
+++ b/plugins/caldav/public/calendar.html
@@ -14,7 +14,7 @@
{{range .Events}}
{{$event := index .Data.Events 0}}
<li>
- <a href="/calendar/{{$event.Path | pathescape}}">{{$event.Props.Text "SUMMARY"}}</a>
+ <a href="{{$event.URL}}">{{$event.Props.Text "SUMMARY"}}</a>
({{$event.DateTimeStart nil | formatdate}} — {{$event.DateTimeEnd nil | formatdate}})
</li>
{{end}}
diff --git a/plugins/caldav/routes.go b/plugins/caldav/routes.go
index 9fb9db3..b9367b3 100644
--- a/plugins/caldav/routes.go
+++ b/plugins/caldav/routes.go
@@ -15,14 +15,14 @@ type CalendarRenderData struct {
alps.BaseRenderData
Time time.Time
Calendar *caldav.Calendar
- Events []caldav.CalendarObject
+ Events []CalendarObject
PrevPage, NextPage string
}
type EventRenderData struct {
alps.BaseRenderData
Calendar *caldav.Calendar
- Event *caldav.CalendarObject
+ Event CalendarObject
}
var monthPageLayout = "2006-01"
@@ -90,7 +90,7 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
BaseRenderData: *alps.NewBaseRenderData(ctx),
Time: start,
Calendar: calendar,
- Events: events,
+ Events: newCalendarObjectList(events),
PrevPage: start.AddDate(0, -1, 0).Format(monthPageLayout),
NextPage: start.AddDate(0, 1, 0).Format(monthPageLayout),
})
@@ -142,7 +142,7 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
return ctx.Render(http.StatusOK, "event.html", &EventRenderData{
BaseRenderData: *alps.NewBaseRenderData(ctx),
Calendar: calendar,
- Event: event,
+ Event: CalendarObject{event},
})
})
}