Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterModelController(c ModelController)
- func RegisteredModelControllers() []string
- func Schedule(card *Card, answerDelay time.Duration, quality flashback.AnswerQuality) error
- type Card
- func (c *Card) Action(ctx context.Context, face *int, startTime time.Time, query interface{}) (done bool, err error)
- func (c *Card) Body(ctx context.Context, face int) (body string, err error)
- func (c *Card) Buttons(face int) (studyview.ButtonMap, error)
- func (c *Card) FieldValue(fieldName string) *fb.FieldValue
- func (c *Card) Fields() []string
- func (c *Card) MarshalJSON() ([]byte, error)
- type FlashbackDoc
- type FuncMapper
- type ModelController
- type Repo
- func (r *Repo) Auth(ctx context.Context, provider, token string) error
- func (r *Repo) BuryRelatedCards(ctx context.Context, card *fb.Card) error
- func (r *Repo) CurrentUser() (string, error)
- func (r *Repo) FetchAttachment(ctx context.Context, cardID, filename string) (*fb.Attachment, error)
- func (r *Repo) GetCardToStudy(ctx context.Context) (flashback.CardView, error)
- func (r *Repo) Import(ctx context.Context, f io.Reader) error
- func (r *Repo) ImportFile(ctx context.Context, f inputFile) error
- func (r *Repo) Logout(ctx context.Context) error
- func (r *Repo) SaveBundle(ctx context.Context, bundle *fb.Bundle) error
- func (r *Repo) Sync(ctx context.Context) error
Constants ¶
const ( // NewBuryTime sets the time to bury related new cards. NewBuryTime = 7 * fb.Day // MinBuryTime is the minimal burial time. MinBuryTime = 1 * fb.Day // MaxBuryTime is the maximal burial time. MaxBuryTime = 10 * fb.Day // MaxBuryRatio is the maximum burial-time / interval ratio. MaxBuryRatio = 0.20 )
const ( // Question is a card's first face Question = iota // Answer is a card's second face Answer )
Variables ¶
var ErrNotLoggedIn = errors.New("not logged in")
ErrNotLoggedIn is returned by CurrentUser if no user is logged in.
Functions ¶
func RegisterModelController ¶
func RegisterModelController(c ModelController)
RegisterModelController registers a model controller for use in the app. The passed controller's Type() must return a unique value.
func RegisteredModelControllers ¶
func RegisteredModelControllers() []string
RegisteredModelControllers returns a list of registered controller type
Types ¶
type Card ¶
Card wraps an *fb.Card and its dependencies.
func (*Card) Action ¶
func (c *Card) Action(ctx context.Context, face *int, startTime time.Time, query interface{}) (done bool, err error)
Action handles a card action produced by the user.
func (*Card) FieldValue ¶
func (c *Card) FieldValue(fieldName string) *fb.FieldValue
FieldValue returns the card's value for the requested field.
func (*Card) MarshalJSON ¶
MarshalJSON marshals a Card for the benefit of javascript context in HTML templates.
type FlashbackDoc ¶
type FlashbackDoc interface { DocID() string SetRev(string) ImportedTime() time.Time ModifiedTime() time.Time MergeImport(interface{}) (bool, error) json.Marshaler json.Unmarshaler }
FlashbackDoc is a generic interface for all types of FB docs
type FuncMapper ¶
type FuncMapper interface { // FuncMap is given the card and face, and is expected to return a // template.FuncMap which can be used when parsing the HTML templates for // this note type. If card is nil, the function is fine to return only // non-functional, placeholder methods. FuncMap(card *Card, face int) template.FuncMap }
FuncMapper is an optional interface that a ModelController may fulfill.
type ModelController ¶
type ModelController interface { // Type returns the Model Type identifier string. Type() string // IframeScript returns a blob of JavaScript, which is loaded inside the // iframe of each card associated with this model type. IframeScript() []byte // Buttons returns the attributes for the three available answer buttons' // initial state. Index 0 = left button, 1 = center, 2 = right Buttons(face int) (studyview.ButtonMap, error) // Action is called when the card submits the 'mainform' form. `query` is the // deserialized content of the form submission, which should include at minimum // `submit` key. If done is returned as true, the next card is selected. If // done is false, the same card will be displayed, with the current value // of face (possibly changed by the function) Action(card *Card, face *int, startTime time.Time, query interface{}) (done bool, err error) }
ModelController is an interface for the per-type model controllers.
func GetModelController ¶
func GetModelController(mType string) (ModelController, error)
GetModelController returns the ModelController for the registered model type, 'mType'.
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo represents an instance of the Couch/Pouch model.
func (*Repo) BuryRelatedCards ¶
BuryRelatedCards buries related cards.
The burial strategy involves the following:
- New cards (reviewCount = 0) are buried for NewBuryTime. This should help start of new card review to get off on the right foot.
- All related cards are buried for a minimum of 1 day (this is all Anki does)
- The target burial time is the current card's interval, divided by the number of related cards. NewBuryTime is used as the minimum target burial time.
- The maximum burial is MaxBuryRatio of the card's interval.
func (*Repo) CurrentUser ¶
CurrentUser returns the currently registered user.
func (*Repo) FetchAttachment ¶
func (r *Repo) FetchAttachment(ctx context.Context, cardID, filename string) (*fb.Attachment, error)
FetchAttachment fetches the requested attachment associated with the specified card.
func (*Repo) GetCardToStudy ¶
GetCardToStudy returns a CardView to display to the user to study, and buries related cards.
func (*Repo) ImportFile ¶
ImportFile imports a *.fbb file, as from an HTML form submission.
func (*Repo) SaveBundle ¶
SaveBundle saves the bundle.