소스 검색

plugins/caldav: edit event descriptions

master
Simon Ser 4 년 전
부모
커밋
4402a748f0
No known key found for this signature in database GPG 키 ID: FDE7BE0E88F5E48
2개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. +4
    -0
      plugins/caldav/public/update-event.html
  2. +11
    -0
      plugins/caldav/routes.go

+ 4
- 0
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>



+ 11
- 0
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())


불러오는 중...
취소
저장