Add calendar color support (DAVx5 calendar-color)
Calendars can now have a color (hex, e.g. #3b82f6) that DAVx5 and other
CalDAV clients pick up via the Apple/dav4jvm calendar-color property.
- db: add calendars.color column with migration for existing DBs;
CreateCalendarWithColor, SetCalendarColor, GetCalendarColor;
ListCalendars now returns []Calendar{Name, Color} instead of []string
- caldav: since go-webdav's caldav.Backend interface has no extension
point for vendor properties, wrap the handler with a response-rewriting
middleware that injects <calendar-color xmlns="http://apple.com/ns/ical/">
into PROPFIND responses for calendars that have a color set
- web: color picker on the "New calendar" form and an inline color swatch/
picker on each calendar card (calendars only, not address books)
- nidusctl: `calendar create --color` flag and a new `calendar color`
subcommand; `calendar list` now also prints the color if set
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+31
-8
@@ -80,7 +80,8 @@ Usage:
|
||||
nidusctl [-config config.yaml] user list
|
||||
nidusctl [-config config.yaml] user passwd <username> [--password PW]
|
||||
|
||||
nidusctl [-config config.yaml] calendar create <owner> <calendar>
|
||||
nidusctl [-config config.yaml] calendar create <owner> <calendar> [--color '#RRGGBB']
|
||||
nidusctl [-config config.yaml] calendar color <owner> <calendar> <hex-color>
|
||||
nidusctl [-config config.yaml] calendar delete <owner> <calendar>
|
||||
nidusctl [-config config.yaml] calendar list <owner>
|
||||
nidusctl [-config config.yaml] calendar share <owner> <calendar> <user> <read|write>
|
||||
@@ -117,12 +118,17 @@ func runCalendar(dbase *db.DB, st *store.Store, args []string) int {
|
||||
}
|
||||
switch args[0] {
|
||||
case "create":
|
||||
if len(args) != 3 {
|
||||
fmt.Fprintln(os.Stderr, "usage: nidusctl calendar create <owner> <calendar>")
|
||||
fs := newFlagSet("calendar create")
|
||||
color := fs.String("color", "", "hex color like #3b82f6 (optional)")
|
||||
if err := fs.Parse(args[1:]); err != nil {
|
||||
return 2
|
||||
}
|
||||
owner, calName := args[1], args[2]
|
||||
if err := dbase.CreateCalendar(owner, calName); err != nil {
|
||||
if fs.NArg() != 2 {
|
||||
fmt.Fprintln(os.Stderr, "usage: nidusctl calendar create <owner> <calendar> [--color '#RRGGBB']")
|
||||
return 2
|
||||
}
|
||||
owner, calName := fs.Arg(0), fs.Arg(1)
|
||||
if err := dbase.CreateCalendarWithColor(owner, calName, *color); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
@@ -132,6 +138,19 @@ func runCalendar(dbase *db.DB, st *store.Store, args []string) int {
|
||||
fmt.Printf("created calendar %q for %s\n", calName, owner)
|
||||
return 0
|
||||
|
||||
case "color":
|
||||
if len(args) != 4 {
|
||||
fmt.Fprintln(os.Stderr, "usage: nidusctl calendar color <owner> <calendar> <hex-color>")
|
||||
return 2
|
||||
}
|
||||
owner, calName, color := args[1], args[2], args[3]
|
||||
if err := dbase.SetCalendarColor(owner, calName, color); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
fmt.Printf("set color of calendar %q for %s to %s\n", calName, owner, color)
|
||||
return 0
|
||||
|
||||
case "delete":
|
||||
if len(args) != 3 {
|
||||
fmt.Fprintln(os.Stderr, "usage: nidusctl calendar delete <owner> <calendar>")
|
||||
@@ -154,13 +173,17 @@ func runCalendar(dbase *db.DB, st *store.Store, args []string) int {
|
||||
return 2
|
||||
}
|
||||
owner := args[1]
|
||||
names, err := dbase.ListCalendars(owner)
|
||||
cals, err := dbase.ListCalendars(owner)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
for _, n := range names {
|
||||
fmt.Println(n)
|
||||
for _, c := range cals {
|
||||
if c.Color != "" {
|
||||
fmt.Printf("%s\t%s\n", c.Name, c.Color)
|
||||
} else {
|
||||
fmt.Println(c.Name)
|
||||
}
|
||||
}
|
||||
return 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user