2019-09-02 18:42:27 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-12-05 22:25:03 -07:00
|
|
|
"github.com/spf13/afero"
|
2020-02-29 16:51:32 -07:00
|
|
|
"time"
|
2019-09-02 18:42:27 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
type Theme struct {
|
2020-02-29 16:51:32 -07:00
|
|
|
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{
|
2020-02-29 16:51:32 -07:00
|
|
|
Fs: fs,
|
2019-09-02 18:42:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-29 16:51:32 -07: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
|
2020-02-29 16:51:32 -07:00
|
|
|
}
|
2019-09-02 18:42:27 -06:00
|
|
|
|
2020-02-29 16:51:32 -07:00
|
|
|
func (t *Theme) Update() {
|
|
|
|
// No periodic tasks for a theme
|
2019-09-02 18:42:27 -06:00
|
|
|
}
|