Documentation ¶
Index ¶
- Constants
- func DefaultSort(one, other *Node) bool
- func IsDocument(n *Node) bool
- func IsFolder(n *Node) bool
- func IsPinned(n *Node) bool
- func ReadPagedata(r io.Reader) ([]string, error)
- func SetLogLevel(level string)
- func WritePagedata(pd []string, w io.Writer) error
- type AttachmentReader
- type Content
- type Document
- func (d *Document) AttachmentReader() (io.ReadCloser, error)
- func (d *Document) CoverPage() int
- func (d *Document) CreatePage() string
- func (d *Document) Drawing(pageID string) (*lines.Drawing, error)
- func (d *Document) FileType() FileType
- func (d *Document) Orientation() Orientation
- func (d *Document) Page(pageID string) (*Page, error)
- func (d *Document) PageCount() int
- func (d *Document) Pages() []string
- func (d *Document) Validate() error
- func (d *Document) Write(repo Repository, w WriterFunc) error
- type ExtraMetadata
- type FileType
- type LayerMetadata
- type LineHeight
- type Meta
- type Node
- type NodeComparator
- type NodeFilter
- type NotebookType
- type Orientation
- type Page
- type PageMetadata
- type Repository
- type TextAlign
- type Transform
- type WriterFunc
Constants ¶
const TrashFolder = "trash"
TrashFolder is the ID whoch is used for the reMArkable trash folder. Items that have been soft-deleted have their parent ID set to this value.
Variables ¶
This section is empty.
Functions ¶
func DefaultSort ¶
DefaultSort is the comparsion function to sort nodes in the content tree with folders before documents and by name (case-insensitive). Pinned notes come before unpinned ones within a folder. The "Trash" folder comes last.
func IsDocument ¶
IsDocument is a Node filter that matches only documents (not foldeers).
func SetLogLevel ¶
func SetLogLevel(level string)
SetLogLevel sets the threshold for logging messages.
Level is one of "debug", "info", "warning" or "error".
Types ¶
type AttachmentReader ¶
type AttachmentReader func() (io.ReadCloser, error)
An AttachmentReader creates a reader for a PDF or EPUB attachment.
It must be supplied when creating documents with attachments. It must be possible to call this function multiple times.
type Content ¶
type Content struct { DummyDocument bool `json:"dummyDocument"` ExtraMetadata ExtraMetadata `json:"extraMetadata"` // FileType is the type of content (i.e. handwritten Notebook or PDF, EPUB). FileType FileType `json:"fileType"` // Orientation gives the base layout orientation. // Individual pages can have a different orientation. Orientation Orientation `json:"orientation"` // PageCount is the number of pages in this notebooks. PageCount int `json:"pageCount"` // Pages is a list of page IDs in the correct order. Pages []string `json:"pages"` // CoverPageNumber is the page that should be used as the cover in the UI. CoverPageNumber int `json:"coverPageNumber"` // FontName for EPUB, empty to use default (probably a list w/ supported font names) FontName string `json:"fontName"` // LineHeight always seems to be -1 / 150 / 200 / 100? LineHeight LineHeight `json:"lineHeight"` // MArgins are the page margins (left/right?) for EPUB and PDF files, default is 100 (180 for PDF?) Margins int `json:"margins"` // TextAlignment for EPUB, left or justify TextAlignment TextAlign `json:"textAlignment"` // TextScale for EPUB, default is 1.0, TextScale float32 `json:"textScale"` Transform Transform `json:"transform"` }
Content holds the data from the remarkable `.content` file. It describes the content for a notebook, specifically the sequence of pages. Collections have an empty content object.
func NewContent ¶
type Document ¶
type Document struct { Meta // contains filtered or unexported fields }
A Document is a notebook, PDF or EPUB with all associated metadata and Drawings.
A Document is internally backed by a Repository and can load additional content as it is requested.
func NewNotebook ¶
NewNotebook creates a new document of type "notebook" with a single emtpty page. TODO: template name?
func NewPdf ¶
func NewPdf(name, parentID string, r AttachmentReader) (*Document, error)
NewPdf creates a new document for a PDF file.
The given AttachmentReader should return a Reader for the PDF file. Note that this can return an error as the PDF needs to be read for this.
func ReadDocument ¶
func ReadDocument(r Repository, m Meta) (*Document, error)
ReadDocument is a helper function to read a full Document from a repository entry. TODO make this a method of the repository, transfer implementation to internal/
func (*Document) AttachmentReader ¶
func (d *Document) AttachmentReader() (io.ReadCloser, error)
AttachmentReader returns a reader for an associated PDF or EPUB files according to FileType().
An error is returned if this document has no associated attachment.
func (*Document) CreatePage ¶
CreatePage creates a new page with a drawing and append it to the document. TODO: Orientation? Template?
func (*Document) Drawing ¶
Drawing loads the handwritten drawing for the given pageID.
Note that not all pages have associated drawings. If a page has no drawing, an error of type "Not Found" is returned (use IsNotFound(err) to check for this).
func (*Document) FileType ¶
FileType is one of the supported types of content (Notebook, PDF, EPUB).
func (*Document) Orientation ¶
func (d *Document) Orientation() Orientation
Orientation is the base layout (Portait or Landscape) for this document.
func (*Document) PageCount ¶
PageCount returns the number of pages in this document.
Note that for PDF and EPUB files, the number of drawings can be less than the number of pages.
func (*Document) Write ¶
func (d *Document) Write(repo Repository, w WriterFunc) error
type ExtraMetadata ¶
type ExtraMetadata struct { LastBallpointColor string LastBallpointSize intStr LastBallpointv2Color string LastBallpointv2Size intStr LastBrushColor string LastBrushThicknessScale intStr LastCalligraphyColor string LastCalligraphySize intStr LastClearPageColor string LastClearPageSize intStr LastColor string LastEraseSectionColor string LastEraseSectionSize intStr LastEraserColor string LastEraserSize intStr LastEraserThicknessScale intStr LastEraserTool string //"Eraser" LastFinelinerColor string LastFinelinerSize intStr LastFinelinerv2Color string LastFinelinerv2Size intStr LastHighlighterColor string LastHighlighterSize intStr LastHighlighterv2Color string LastHighlighterv2Size intStr LastMarkerColor string LastMarkerSize intStr LastMarkerv2Color string LastMarkerv2Size intStr LastPaintbrushColor string LastPaintbrushSize intStr LastPaintbrushv2Color string LastPaintbrushv2Size intStr LastPen string // Ballpointv2 LastPenColor string LastPenThicknessScale intStr LastPencil string // SharpPencil LastPencilColor string LastPencilSize intStr LastPencilThicknessScale intStr LastPencilv2Color string LastPencilv2Size intStr LastReservedPenColor string LastReservedPenSize intStr LastSelectionToolColor string LastSelectionToolSize intStr LastSharpPencilColor string LastSharpPencilSize intStr LastSharpPencilv2Color string LastSharpPencilv2Size intStr LastSolidPenColor string LastSolidPenSize intStr LastTool string // Ballpoint LastUndefinedColor string LastUndefinedSize intStr LastZoomToolColor string LastZoomToolSize intStr ThicknessScale intStr }
func NewExtraMetadata ¶
func NewExtraMetadata() ExtraMetadata
type FileType ¶
type FileType int
FileType are the different types of supported content for a notebook.
func (FileType) MarshalJSON ¶
func (*FileType) UnmarshalJSON ¶
type LayerMetadata ¶
type LayerMetadata struct { // Name is the display name for this layer. Name string `json:"name"` }
LayerMetadata describes one layer.
func (LayerMetadata) Validate ¶
func (l LayerMetadata) Validate() error
type LineHeight ¶
type LineHeight int
const ( LineHeightDefault LineHeight = -1 LineHeightSmall LineHeight = 100 LineHeightMedium LineHeight = 150 LineHeightLarge LineHeight = 200 )
type Meta ¶
type Meta interface { ID() string Version() uint Name() string SetName(n string) Type() NotebookType Pinned() bool SetPinned(p bool) LastModified() time.Time Parent() string // Validate checks the internal state of this item // and returns an error if it is not valid. Validate() error }
Meta is the interface for a single entry (a nodebook or folder) in a Repository. These entries are used to access and change metadata for an item.
The Reader() method can be used to download additional content, i.e. the pages and drawings for a notebook.
type Node ¶
type Node struct { Meta // ParentNode holds a reference to the parent or nul. ParentNode *Node // Children is a list of all child nodes. Children []*Node }
Node is the representation for an entry in the content tree. A not can either be a document or a collection (which has child nodes).
func BuildTree ¶
BuildTree creates a tree view of all items in the given repository. Returns the root node.
func (*Node) Filtered ¶
func (n *Node) Filtered(match ...NodeFilter) *Node
Filtered returns a new node that is the root of a subtree starting at this node. The subtree will contain only nodes that match the given NodeFilter and the parent folders of the matched nodes.
func (*Node) Path ¶
Path returns the path components for this node. That is, the names of its parent and grandparent up to the root node.
func (*Node) Sort ¶
func (n *Node) Sort(compare NodeComparator)
Sort sorts the subtree starting at this node by the given sort rule. Sorting is in-place.
type NodeComparator ¶
NodeComparator is used to sort nodes in a tree. It should return true if "one" comes before "other".
type NodeFilter ¶
A NodeFilter is a function that can be used to test whether a node should be included in a filtered subset or not.
func MatchName ¶
func MatchName(s string) NodeFilter
MatchName creates a node filter that matches the given string against the Name of a node. The match is case insensitive and allows partial matches ("doc" matches "My Document").
func MatchPath ¶
func MatchPath(path string) NodeFilter
MatchPath creates a node filter that matches on the path components of a node (case insensitive).
The path to match against is expected to contain the item name, i.e. "foo/bar/baz" will match the item named "baz" in the folder "foo/bar".
type NotebookType ¶
type NotebookType int
NotebookType is used to distinguish betweeen documents and folders.
const ( DocumentType NotebookType = iota CollectionType )
func (NotebookType) MarshalJSON ¶
func (n NotebookType) MarshalJSON() ([]byte, error)
func (*NotebookType) UnmarshalJSON ¶
func (n *NotebookType) UnmarshalJSON(b []byte) error
type Orientation ¶
type Orientation int
Orientation is the layout of a notebook page. It can be Portrait or Landscape.
const ( Portrait Orientation = iota Landscape )
func (Orientation) MarshalJSON ¶
func (o Orientation) MarshalJSON() ([]byte, error)
func (Orientation) String ¶
func (o Orientation) String() string
func (*Orientation) UnmarshalJSON ¶
func (o *Orientation) UnmarshalJSON(b []byte) error
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page describes a single page within a document.
func (*Page) HasTemplate ¶
HasTemplate tells if this page is associated with a background template. Returns false for the "Blank" template.
func (*Page) Layers ¶
func (p *Page) Layers() []LayerMetadata
Layers is the metadata for the layers in this page.
type PageMetadata ¶
type PageMetadata struct { // Layers is the list of layers for a page. Layers []LayerMetadata `json:"layers"` }
PageMetadata holds the layer information for a single page.
func (PageMetadata) Validate ¶
func (p PageMetadata) Validate() error
type Repository ¶
type Repository interface { // List returns a flat list of all entries in the repository. // The list is in no particular order - use BuildTree() to recreate the // tree structure with folders and subfolders. List() ([]Meta, error) // Update changes metadata for an entry. Update(meta Meta) error // Reader creates a reader for one of the components associated with an // item, e.g. the drawing for a single page. // // This function is typically used internally by ReadDocument and friends. Reader(id string, version uint, path ...string) (io.ReadCloser, error) // PagePrefix returns the filename prefix for page related paths. // // This function is normally used internally by ReadDocument and friends. PagePrefix(pageID string, pageIndex int) string // Upload creates the given document in the repository. Upload(d *Document) error }
Repository is the interface for a storage backend.
It can either represent local files copied from the tablet or notes accessed via the Cloud API.
The repository offers methods to work on the metadata of items, allowing operations like rename or bookmark.
type TextAlign ¶
type TextAlign int
func (TextAlign) MarshalJSON ¶
func (*TextAlign) UnmarshalJSON ¶
type Transform ¶
type Transform struct { // TODO: these might also be floats // never seen anything other than identity transform with values set to 1 or 0 M11 int `json:"m11"` M12 int `json:"m12"` M13 int `json:"m13"` M21 int `json:"m21"` M22 int `json:"m22"` M23 int `json:"m23"` M31 int `json:"m31"` M32 int `json:"m32"` M33 int `json:"m33"` }
func NewTransform ¶
func NewTransform() Transform
type WriterFunc ¶
type WriterFunc func(path ...string) (io.WriteCloser, error)