2026-09-09 16:19:41 -06:00
|
|
|
package bible
|
|
|
|
|
|
2026-09-10 22:31:23 -06:00
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"os"
|
|
|
|
|
)
|
2026-09-09 16:19:41 -06:00
|
|
|
|
2026-09-10 22:31:23 -06:00
|
|
|
type Bible struct {
|
2026-09-09 16:19:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Metadata struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Book struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Chapter struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type VerseSpec struct {
|
2026-09-10 22:31:23 -06:00
|
|
|
}
|
2026-09-09 16:19:41 -06:00
|
|
|
|
2026-09-10 22:31:23 -06:00
|
|
|
type Scripture struct {
|
2026-09-11 15:23:47 -06:00
|
|
|
Verse string `json:"verse"`
|
|
|
|
|
Translation string `json:"translation"`
|
|
|
|
|
Content string `json:"content"`
|
2026-09-10 22:31:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ScriptureStore struct {
|
|
|
|
|
Verses []*Scripture
|
2026-09-11 15:23:47 -06:00
|
|
|
Offset int `json:"offset"`
|
2026-09-10 22:31:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *ScriptureStore) GetVerse() *Scripture {
|
2026-09-12 08:54:23 -06:00
|
|
|
defer func() {
|
|
|
|
|
if s.Offset+1 < len(s.Verses) {
|
|
|
|
|
s.Offset++
|
|
|
|
|
} else {
|
|
|
|
|
s.Offset = 0
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
return s.Verses[s.Offset]
|
2026-09-10 22:31:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func OpenStore(name string) (*ScriptureStore, error) {
|
|
|
|
|
s := &ScriptureStore{}
|
|
|
|
|
buf, err := os.ReadFile(name)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
2026-09-11 15:20:13 -06:00
|
|
|
err = json.Unmarshal(buf, s)
|
2026-09-10 22:31:23 -06:00
|
|
|
return s, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func SaveStore(name string, s *ScriptureStore) error {
|
|
|
|
|
buf, err := json.Marshal(s)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return os.WriteFile(name, buf, 0o644)
|
|
|
|
|
}
|