Cleanup prototype declarations.

This commit is contained in:
Benjamin A. Shelton 2026-09-25 15:38:13 -06:00
commit c2d25916a9
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01

View file

@ -3,7 +3,6 @@ package bible
import (
"bytes"
"encoding/json"
"os"
)
type Bible struct {
@ -37,6 +36,23 @@ type Chapter struct {
//Verses
}
func (c *Chapter) FilterVerses(start, stop int) []Content {
content := make([]Content, 0)
if start < 1 || (start > stop && stop != 0) {
return content
}
if start > c.NumVerses || stop > c.NumVerses {
return content
}
for _, v := range c.ChapterDecl.Content {
if v.IsVerse {
content = append(content, v)
}
}
return content
}
type ChapterDecl struct {
Number int `json:"number"`
Content []Content `json:"content"`
@ -126,76 +142,3 @@ func (c *Content) UnmarshalJSON(d []byte) error {
}
return nil
}
type HeadingSpec struct {
Type string `json:"type"`
Content []string `json:"content"`
}
type PoemSpec struct {
Text string `json:"text"`
Poem int `json:"poem"`
}
type VerseSpec struct {
Type string `json:"type"`
Number int `json:"number"`
Content []Content `json:"content"`
}
type ContentSpec struct {
Type string `json:"type"`
Number int `json:"number"`
}
type NoteSpec struct {
Id int `json:"noteId"`
Caller string `json:"caller"`
Text string `json:"text"`
Reference *RefSpec `json:"reference"`
}
type RefSpec struct {
Chapter int `json:"chapter"`
Verse int `json:"verse"`
}
type Scripture struct {
Verse string `json:"verse"`
Translation string `json:"translation"`
Content string `json:"content"`
}
type ScriptureStore struct {
Verses []*Scripture
Offset int `json:"offset"`
}
func (s *ScriptureStore) GetVerse() *Scripture {
defer func() {
if s.Offset+1 < len(s.Verses) {
s.Offset++
} else {
s.Offset = 0
}
}()
return s.Verses[s.Offset]
}
func OpenStore(name string) (*ScriptureStore, error) {
s := &ScriptureStore{}
buf, err := os.ReadFile(name)
if err != nil {
return nil, err
}
err = json.Unmarshal(buf, s)
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)
}