aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-05-20 17:08:24 +0200
committerSimon Ser <contact@emersion.fr>2020-05-20 17:08:24 +0200
commit4402a748f05a8495a1ca88b637a3531e9564c11b (patch)
tree384eac9e1a98140a46174bce49b6b57a62632d3c
parent7157627dcfdec4c2f0da5e497f9a1988cd3c60cc (diff)
downloadalps-4402a748f05a8495a1ca88b637a3531e9564c11b.tar.gz
alps-4402a748f05a8495a1ca88b637a3531e9564c11b.zip
plugins/caldav: edit event descriptions
-rw-r--r--plugins/caldav/public/update-event.html4
-rw-r--r--plugins/caldav/routes.go11
2 files changed, 15 insertions, 0 deletions
diff --git a/plugins/caldav/public/update-event.html b/plugins/caldav/public/update-event.html
index 1a4abcc..0decb5a 100644
--- a/plugins/caldav/public/update-event.html
+++ b/plugins/caldav/public/update-event.html
@@ -24,6 +24,10 @@
<input type="date" name="end" id="end" value="{{.Event.DateTimeEnd nil | ornow | formatinputdate}}"/>
<br>
+ <label for="description">Description:</label><br>
+ <textarea name="description" id="description" cols="80" rows="15">{{.Event.Props.Text "DESCRIPTION"}}</textarea>
+ <br><br>
+
<input type="submit" value="Save">
</form>
diff --git a/plugins/caldav/routes.go b/plugins/caldav/routes.go
index 52f8d31..4610330 100644
--- a/plugins/caldav/routes.go
+++ b/plugins/caldav/routes.go
@@ -2,9 +2,11 @@ package alpscaldav
import (
"fmt"
+ "log"
"net/http"
"net/url"
"path"
+ "strings"
"time"
"git.sr.ht/~emersion/alps"
@@ -179,6 +181,8 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
if ctx.Request().Method == "POST" {
summary := ctx.FormValue("summary")
+ description := ctx.FormValue("description")
+
start, err := time.Parse("2006-01-02", ctx.FormValue("start"))
if err != nil {
err = fmt.Errorf("malformed start date: %v", err)
@@ -203,6 +207,13 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
event.Props.SetDateTime(ical.PropDateTimeEnd, end)
event.Props.Del(ical.PropDuration)
+ if description != "" {
+ description = strings.ReplaceAll(description, "\r", "")
+ event.Props.SetText(ical.PropDescription, description)
+ } else {
+ event.Props.Del(ical.PropDescription)
+ }
+
newID := uuid.New()
if prop := event.Props.Get(ical.PropUID); prop == nil {
event.Props.SetText(ical.PropUID, newID.String())