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:
2026-08-20 06:43:56 +02:00
co-authored by Copilot
parent 37399d1ceb
commit ebbc7a2a2b
15 changed files with 618 additions and 163 deletions
+7 -4
View File
@@ -55,15 +55,15 @@ func (s *Server) resourceCards(username string) ([]templates.ResourceCard, error
if err != nil {
return nil, fmt.Errorf("listing calendars: %w", err)
}
for _, calName := range calNames {
card := templates.ResourceCard{Kind: "calendar", Name: calName}
shares, err := s.dbase.SharesOfCalendar(username, calName)
for _, cal := range calNames {
card := templates.ResourceCard{Kind: "calendar", Name: cal.Name, Color: cal.Color}
shares, err := s.dbase.SharesOfCalendar(username, cal.Name)
if err != nil {
s.logger.Warn("listing calendar shares", "error", err)
}
for _, sh := range shares {
card.Shares = append(card.Shares, templates.ShareRow{
ResourceName: calName,
ResourceName: cal.Name,
SharedWith: sh.SharedWith,
Permission: string(sh.Permission),
})
@@ -101,6 +101,9 @@ func (s *Server) resourceCardFor(username, kind, name string) (templates.Resourc
var shares []templates.ShareRow
if kind == "calendar" {
if color, err := s.dbase.GetCalendarColor(username, name); err == nil {
card.Color = color
}
rows, err := s.dbase.SharesOfCalendar(username, name)
if err != nil {
return card, err