data

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDeckFromDir

func CreateDeckFromDir(dirPath string) (*model.Deck, error)

CreateDeckFromDir creates a new deck from a directory of markdown files

func GetDummyDecks

func GetDummyDecks() []model.Deck

addDummyData adds sample decks and cards

func ImportMarkdownToDeck

func ImportMarkdownToDeck(dirPath string, deck *model.Deck) error

ImportMarkdownToDeck imports markdown files into an existing deck

func SanitizeFilename

func SanitizeFilename(name string) string

SanitizeFilename converts a string to a Unix-friendly filename

func ScanDirForMarkdown

func ScanDirForMarkdown(dirPath string) ([]string, error)

ScanDirForMarkdown scans a directory for markdown files

func UpdateCardFile

func UpdateCardFile(card model.Card) error

UpdateCardFile updates an existing markdown file with modified card data

func WriteCard

func WriteCard(card model.Card, path string) error

WriteCard writes a model.Card to a markdown file

func WriteDeckToMarkdown

func WriteDeckToMarkdown(deck *model.Deck, dirPath string) error

WriteDeckToMarkdown writes all cards in a deck to markdown files

func WriteMarkdownCard

func WriteMarkdownCard(mc *MarkdownCard, path string) error

WriteMarkdownCard writes a MarkdownCard to a file

func WriteNewDeck

func WriteNewDeck(deck *model.Deck) error

WriteNewDeck creates a new deck directory and writes all cards as markdown files

Types

type FrontMatter

type FrontMatter struct {
	Tags           []string  `yaml:"tags"`
	Created        time.Time `yaml:"created"`
	LastReviewed   time.Time `yaml:"last_reviewed"`
	ReviewInterval int       `yaml:"review_interval"`
	Difficulty     float64   `yaml:"difficulty"`
}

FrontMatter represents the YAML frontmatter in a markdown file

type MarkdownCard

type MarkdownCard struct {
	Path        string
	FrontMatter FrontMatter
	Question    string
	Answer      string
}

MarkdownCard represents a card in markdown format

func CardToMarkdown

func CardToMarkdown(card model.Card) *MarkdownCard

CardToMarkdown converts a model.Card to a MarkdownCard

func ParseMarkdownFile

func ParseMarkdownFile(path string) (*MarkdownCard, error)

ParseMarkdownFile parses a markdown file into a MarkdownCard

func (*MarkdownCard) ToModelCard

func (mc *MarkdownCard) ToModelCard(deckID string) model.Card

ToModelCard converts a MarkdownCard to a model.Card

type Store

type Store struct {
	Decks []model.Deck
}

Store manages all data for the application

func NewStore

func NewStore() *Store

NewStore creates a new data store with dummy data

func NewStoreFromDir

func NewStoreFromDir(dirPath string) (*Store, error)

NewStoreFromDir creates a new data store with decks from the specified directory

func (*Store) GetDeck

func (s *Store) GetDeck(id string) (model.Deck, bool)

GetDeck returns a deck by ID

func (*Store) GetDecks

func (s *Store) GetDecks() []model.Deck

GetDecks returns all decks

func (*Store) GetDueCards

func (s *Store) GetDueCards() []model.Card

GetDueCards returns cards due for review

func (*Store) GetDueCardsForDeck

func (s *Store) GetDueCardsForDeck(deckID string) []model.Card

GetDueCardsForDeck returns cards due for review in a specific deck

func (*Store) SaveCardReview

func (s *Store) SaveCardReview(card model.Card, rating int) bool

SaveCardReview updates a card with its new review data and updates the parent deck's LastStudied timestamp

func (*Store) SaveDeckToMarkdown

func (s *Store) SaveDeckToMarkdown(deckID string) error

SaveDeckToMarkdown saves SRS metadata for all cards in a deck back to their markdown files

func (*Store) UpdateCard

func (s *Store) UpdateCard(updatedCard model.Card) bool

UpdateCard updates a card in the store and returns whether it was found

func (*Store) UpdateDeckLastStudied

func (s *Store) UpdateDeckLastStudied(deckID string) bool

UpdateDeckLastStudied updates the LastStudied timestamp for a deck

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL