glance/internal/widget/calendar.go

31 lines
606 B
Go
Raw Permalink Normal View History

2024-04-27 21:10:24 +02:00
package widget
import (
"context"
"html/template"
"time"
"github.com/glanceapp/glance/internal/assets"
"github.com/glanceapp/glance/internal/feed"
)
type Calendar struct {
widgetBase `yaml:",inline"`
Calendar *feed.Calendar
}
func (widget *Calendar) Initialize() error {
widget.withTitle("Calendar").withCacheOnTheHour()
return nil
}
func (widget *Calendar) Update(ctx context.Context) {
widget.Calendar = feed.NewCalendar(time.Now())
widget.withError(nil).scheduleNextUpdate()
}
func (widget *Calendar) Render() template.HTML {
return widget.render(widget, assets.CalendarTemplate)
}