mirror of
https://github.com/glanceapp/glance.git
synced 2024-12-25 16:39:02 +01:00
31 lines
606 B
Go
31 lines
606 B
Go
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)
|
|
}
|