notes

package
v0.0.0-...-168c322 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(path string) (bool, error)

Exists returns whether the given file or directory exists

func GetEmailIds

func GetEmailIds(c imapClient, sc *imap.SearchCriteria) []uint32

GetEmailIds will return a slice of uint32 ids for each message within an inbox, provided a particular search criteria. Each ID is a reference to a given message.

func LoadCompletedBooks

func LoadCompletedBooks() (*map[string]struct{}, error)

LoadCompletedBooks returns a mapping between the book title and a blank value. A book key being within the mapping indicates that it has been read, it is therefore skipped if it is noticed on the next pass of parsing email attachments.

func Save

func Save(n []*Notes) error

Save will write the titles which have been written into a 'completed notebooks' file of key-value pairs, this is done in order to avoid parsing the same titles multiple times when they have already been processed.

func Write

func Write(n *Notes) (int, error)

Write is used to write the Notes struct, for a given book, into a text file. This creates a file with the name of <book-title>-notebook.txt and writes each Note struct into it, separating each entry with a newline. TODO: Sort before writing so that notes appear before highlights etc?

Types

type Note

type Note struct {
	Type       string
	Location   string
	Annotation string
	Starred    bool
}

Note is a struct which contains a singular record about a note or highlight from a particular book. The difference between a note and a highlight is that a highlight has no annotation.

type Notes

type Notes struct {
	Title string
	Notes []Note
}

Notes are the overarching struct for the program. This encapsulates a slice of 'Note', which is the various records of information that a person has jotted down about a book, including other metadata pertaining to it.

func New

func New() *Notes

New returns a default Notes struct with none of the fields populated, this is ready to be used throughout the program.

func (*Notes) GetAmazonMessage

func (n *Notes) GetAmazonMessage(c imapClient, id uint32, section imap.BodySectionName) <-chan *imap.Message

GetAmazonMessage takes a singular ID and places it into a buffered channel, returning that channel to be read from once it has completed its work.

func (*Notes) GetMailReaders

func (n *Notes) GetMailReaders(messages <-chan *imap.Message, section imap.BodySectionName) []*mail.Reader

GetMailReaders reads from the channel that was passed in as a result of the `GetAmazonMessage` function, this function is what enables the parsing of the actual content, such as attachments and other metadata.

func (*Notes) Populate

func (n *Notes) Populate(mailReaders []*mail.Reader)

Populate will fill in data to the 'Notes' struct when the slice of mail readers are provided to it. The result here is that the relevant fields are populated by this call.

Jump to

Keyboard shortcuts

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