moth/cmd/mothd/theme.go

37 lines
572 B
Go
Raw Normal View History

2019-09-02 18:42:27 -06:00
package main
import (
2019-12-05 22:25:03 -07:00
"github.com/spf13/afero"
"time"
2019-09-02 18:42:27 -06:00
)
type Theme struct {
afero.Fs
2019-09-02 18:42:27 -06:00
}
2019-12-05 22:25:03 -07:00
func NewTheme(fs afero.Fs) *Theme {
2019-09-02 18:42:27 -06:00
return &Theme{
Fs: fs,
2019-09-02 18:42:27 -06:00
}
}
// I don't understand why I need this. The type checking system is weird here.
2020-03-01 16:10:55 -07:00
func (t *Theme) Open(name string) (ReadSeekCloser, time.Time, error) {
f, err := t.Fs.Open(name)
if err != nil {
return nil, time.Time{}, err
}
fi, err := f.Stat()
if err != nil {
f.Close()
return nil, time.Time{}, err
2019-09-02 18:42:27 -06:00
}
2020-03-01 16:10:55 -07:00
return f, fi.ModTime(), nil
}
2019-09-02 18:42:27 -06:00
func (t *Theme) Update() {
// No periodic tasks for a theme
2019-09-02 18:42:27 -06:00
}