plugins/caldav: edit event descriptions
This commit is contained in:
parent
7157627dcf
commit
4402a748f0
2 changed files with 15 additions and 0 deletions
|
@ -24,6 +24,10 @@
|
||||||
<input type="date" name="end" id="end" value="{{.Event.DateTimeEnd nil | ornow | formatinputdate}}"/>
|
<input type="date" name="end" id="end" value="{{.Event.DateTimeEnd nil | ornow | formatinputdate}}"/>
|
||||||
<br>
|
<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">
|
<input type="submit" value="Save">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,11 @@ package alpscaldav
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.sr.ht/~emersion/alps"
|
"git.sr.ht/~emersion/alps"
|
||||||
|
@ -179,6 +181,8 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
|
||||||
|
|
||||||
if ctx.Request().Method == "POST" {
|
if ctx.Request().Method == "POST" {
|
||||||
summary := ctx.FormValue("summary")
|
summary := ctx.FormValue("summary")
|
||||||
|
description := ctx.FormValue("description")
|
||||||
|
|
||||||
start, err := time.Parse("2006-01-02", ctx.FormValue("start"))
|
start, err := time.Parse("2006-01-02", ctx.FormValue("start"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("malformed start date: %v", err)
|
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.SetDateTime(ical.PropDateTimeEnd, end)
|
||||||
event.Props.Del(ical.PropDuration)
|
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()
|
newID := uuid.New()
|
||||||
if prop := event.Props.Get(ical.PropUID); prop == nil {
|
if prop := event.Props.Get(ical.PropUID); prop == nil {
|
||||||
event.Props.SetText(ical.PropUID, newID.String())
|
event.Props.SetText(ical.PropUID, newID.String())
|
||||||
|
|
Loading…
Reference in a new issue