Documentation
¶
Index ¶
- Constants
- Variables
- func ChangeTitle(db Storager, ns NotestoreClient, old, new string) error
- func CreateNotebook(ns NotestoreClient, notebook *Notebook, defaultNotebook bool) error
- func DeleteNote(db Storager, ns NotestoreClient, title, notebook string) error
- func MoveNote(db Storager, ns NotestoreClient, noteTitle, notebookName string) error
- func SaveChanges(ns NotestoreClient, n *Note, useRawContent bool) error
- func SaveNewNote(ns NotestoreClient, n *Note, raw bool) error
- func UpdateNotebook(db Storager, ns NotestoreClient, name string, notebook *Notebook) error
- type APIClient
- type Configuration
- type DefaultConfig
- type Note
- type NoteFilter
- type Notebook
- type NotebookCacheList
- type NotestoreClient
- type Settings
- type Storager
Constants ¶
const ( // XMLHeader is the header that needs to added to the note content. XMLHeader string = `<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">` )
Variables ¶
var ( // NoteFilterOrderCreated sorts the notes by create time. NoteFilterOrderCreated = int32(1) // NoteFilterOrderUpdated sorts the notes by update time. NoteFilterOrderUpdated = int32(2) // NoteFilterOrderRelevance sorts the notes by relevance. NoteFilterOrderRelevance = int32(3) // NoteFilterOrderSequenceNumber sorts the notes by sequence number. NoteFilterOrderSequenceNumber = int32(4) // NoteFilterOrderTitle sorts the notes by title. NoteFilterOrderTitle = int32(5) )
var ( // ErrNoNotebookFound is returned if no matching notebook was found. ErrNoNotebookFound = errors.New("no notebook found") // ErrNoNotebookCached is returned when trying to update a notebook // that hasn't been pulled from the server. ErrNoNotebookCached = errors.New("no notebook found") )
var ( // DefaultNotebookCacheTime is the default time limit for when the // list is considered outdated. DefaultNotebookCacheTime = 24 * time.Hour )
var ( // ErrNoNoteFound is returned if search resulted in no notes found. ErrNoNoteFound = errors.New("no note found") )
Functions ¶
func ChangeTitle ¶
func ChangeTitle(db Storager, ns NotestoreClient, old, new string) error
ChangeTitle changes the note's title.
func CreateNotebook ¶
func CreateNotebook(ns NotestoreClient, notebook *Notebook, defaultNotebook bool) error
CreateNotebook creates a new notebook.
func DeleteNote ¶
func DeleteNote(db Storager, ns NotestoreClient, title, notebook string) error
DeleteNote moves a note from the notebook to the trash can.
func MoveNote ¶
func MoveNote(db Storager, ns NotestoreClient, noteTitle, notebookName string) error
MoveNote moves the note to a new notebook.
func SaveChanges ¶
func SaveChanges(ns NotestoreClient, n *Note, useRawContent bool) error
SaveChanges updates the changes to the note on the server.
func SaveNewNote ¶
func SaveNewNote(ns NotestoreClient, n *Note, raw bool) error
SaveNewNote pushes the new note to the server.
func UpdateNotebook ¶
func UpdateNotebook(db Storager, ns NotestoreClient, name string, notebook *Notebook) error
UpdateNotebook updates the notebook.
Types ¶
type APIClient ¶
type APIClient interface {
// GetNoteStore returns the note store for the user.
GetNoteStore() (NotestoreClient, error)
// GetConfig returns the client's configuration.
GetConfig() Configuration
}
APIClient is the interface for the api client.
type Configuration ¶
type Configuration interface {
io.Closer
// GetConfigFolder returns the folder used to store configurations.
GetConfigFolder() string
// GetCacheFolder returns the cache folder.
GetCacheFolder() string
// Store returns the backend storage.
Store() Storager
}
Configuration is the interface for a configuration struct.
type DefaultConfig ¶
type DefaultConfig struct {
// DB is the backend storage for the client.
DB Storager
}
DefaultConfig uses shared config and cache folder with other instances of DefaultConfig structs.
func (*DefaultConfig) Close ¶
func (c *DefaultConfig) Close() error
Close closes the BoltDB handler.
func (*DefaultConfig) GetCacheFolder ¶
func (*DefaultConfig) GetCacheFolder() string
GetCacheFolder returns the folder used to cache.
func (*DefaultConfig) GetConfigFolder ¶
func (*DefaultConfig) GetConfigFolder() string
GetConfigFolder returns the folder used to store configurations.
func (*DefaultConfig) Store ¶
func (c *DefaultConfig) Store() Storager
Store returns a handler to BoltDB.
type Note ¶
type Note struct {
// Title is the note tile.
Title string
// GUID is the unique identifier.
GUID string
// Body contains the body of the note.
Body string `xml:",innerxml"`
// MD is a Markdown representation of the note body.
MD string
// MDHash is the MD5 hash of the MD body.
MDHash [16]byte
// Deleted is set true if the note is marked for deletion.
Deleted bool
// Notebook the note belongs to.
Notebook *Notebook
// Created
Created int64
// Updated
Updated int64
}
Note is the structure of an Evernote note.
func FindNotes ¶
func FindNotes(ns NotestoreClient, filter *NoteFilter, offset int, count int) ([]*Note, error)
FindNotes searches for notes.
func GetNote ¶
func GetNote(db Storager, ns NotestoreClient, title, notebook string) (*Note, error)
GetNote gets the note metadata in the notebook from the server. If the notebook is an empty string, the first matching note will be returned.
func GetNoteWithContent ¶
func GetNoteWithContent(db Storager, ns NotestoreClient, title string) (*Note, error)
GetNoteWithContent returns the note with content from the user's notestore.
type NoteFilter ¶
type NoteFilter struct {
// NotebookGUID is the GUID for the notebook to limit the search to.
NotebookGUID string
// Words can be a search string or note title.
Words string
// Order
Order int32
}
NoteFilter is the search filter for notes.
type Notebook ¶
type Notebook struct {
// Name is the notebook's name
Name string
// GUID is the notebook's GUID.
GUID string
// Stack is the stack that the notebook belongs too.
Stack string
}
Notebook is a struct for the notebook.
func FindNotebook ¶
func FindNotebook(db Storager, ns NotestoreClient, name string) (*Notebook, error)
FindNotebook gets the notebook matching with the name. If no notebook is found, nil is returned.
func GetNotebook ¶
func GetNotebook(ns NotestoreClient, guid string) (*Notebook, error)
GetNotebook returns a notebook from the user's notestore.
func GetNotebooks ¶
func GetNotebooks(db Storager, ns NotestoreClient, forceSync bool) ([]*Notebook, error)
GetNotebooks returns all the user's notebooks.
type NotebookCacheList ¶
type NotebookCacheList struct {
// Notebooks is the list of notebooks.
Notebooks []*Notebook
// Timestamp of when the list was created.
Timestamp time.Time
// Limit is the until the list outdated.
Limit time.Duration
}
NotebookCacheList is a list of cached notebooks.
func NewNotebookCacheList ¶
func NewNotebookCacheList(notebooks []*Notebook) *NotebookCacheList
NewNotebookCacheList creates a cache list with the default expiration limit.
func NewNotebookCacheListWithLimit ¶
func NewNotebookCacheListWithLimit(notebooks []*Notebook, limit time.Duration) *NotebookCacheList
NewNotebookCacheListWithLimit creates a new cache list with the given expiration limit.
func (*NotebookCacheList) IsOutdated ¶
func (n *NotebookCacheList) IsOutdated() bool
IsOutdated returns true if the list has expired.
type NotestoreClient ¶
type NotestoreClient interface {
// FindNotes searches for the notes based on the filter.
FindNotes(filter *NoteFilter, offset, count int) ([]*Note, error)
// GetAllNotebooks returns all the of users notebooks.
GetAllNotebooks() ([]*Notebook, error)
// GetNotebook
GetNotebook(guid string) (*Notebook, error)
// CreateNotebook
CreateNotebook(b *Notebook, defaultNotebook bool) error
// GetNoteContent gets the note's content from the notestore.
GetNoteContent(guid string) (string, error)
// UpdateNote update's the note.
UpdateNote(note *Note) error
// DeleteNote removes a note from the user's notebook.
DeleteNote(guid string) error
// CreateNote creates a new note on the server.
CreateNote(note *Note) error
// UpdateNotebook updates the notebook on the server.
UpdateNotebook(book *Notebook) error
}
NotestoreClient is the interface for the notestore.
type Settings ¶
type Settings struct {
// APIKey is the user's OAuth session key.
APIKey string
}
Settings is a struct holding the user's settings for the application.
type Storager ¶
type Storager interface {
io.Closer
GetSettings() (*Settings, error)
StoreSettings(*Settings) error
// GetNotebookCache returns the stored NotebookCacheList.
GetNotebookCache() (*NotebookCacheList, error)
// StoreNotebookList saves the list to the database.
StoreNotebookList(list *NotebookCacheList) error
// SaveSearch stores a note search to the database.
SaveSearch([]*Note) error
// GetSearch returns a saved note search from the database.
GetSearch() ([]*Note, error)
}
Storager is the interface for backend storage.