Documentation ¶
Index ¶
- Constants
- Variables
- func ClearActionLog(ctx infra.DnoteCtx) error
- func FilterNotes(notes []infra.Note, testFunc func(infra.Note) bool) []infra.Note
- func GetActionPath(ctx infra.DnoteCtx) string
- func GetConfigPath(ctx infra.DnoteCtx) string
- func GetDnote(ctx infra.DnoteCtx) (infra.Dnote, error)
- func GetDnotePath(ctx infra.DnoteCtx) string
- func GetDnoteTmpContentPath(ctx infra.DnoteCtx) string
- func GetEditorInput(ctx infra.DnoteCtx, fpath string, content *string) error
- func GetTimestampPath(ctx infra.DnoteCtx) string
- func GetUpdatedBook(book infra.Book, notes []infra.Note) infra.Book
- func InitActionFile(ctx infra.DnoteCtx) error
- func InitConfigFile(ctx infra.DnoteCtx) error
- func InitDnoteDir(ctx infra.DnoteCtx) error
- func InitDnoteFile(ctx infra.DnoteCtx) error
- func InitTimestampFile(ctx infra.DnoteCtx) error
- func IsFreshInstall(ctx infra.DnoteCtx) (bool, error)
- func LogAction(ctx infra.DnoteCtx, action Action) error
- func LogActionAddBook(ctx infra.DnoteCtx, name string) error
- func LogActionAddNote(ctx infra.DnoteCtx, noteUUID, bookName, content string, timestamp int64) error
- func LogActionEditNote(ctx infra.DnoteCtx, noteUUID, bookName, content string, ts int64) error
- func LogActionRemoveBook(ctx infra.DnoteCtx, name string) error
- func LogActionRemoveNote(ctx infra.DnoteCtx, noteUUID, bookName string) error
- func MigrateToDnoteDir(ctx infra.DnoteCtx) error
- func NewBook(name string) infra.Book
- func NewNote(content string, ts int64) infra.Note
- func ReadActionLogContent(ctx infra.DnoteCtx) ([]byte, error)
- func ReadConfig(ctx infra.DnoteCtx) (infra.Config, error)
- func ReadNoteContent(ctx infra.DnoteCtx) ([]byte, error)
- func ReadTimestamp(ctx infra.DnoteCtx) (infra.Timestamp, error)
- func Reduce(ctx infra.DnoteCtx, action Action) error
- func ReduceAll(ctx infra.DnoteCtx, actions []Action) error
- func SanitizeContent(s string) string
- func UpdateLastActionTimestamp(ctx infra.DnoteCtx, val int64) error
- func WriteActionLog(ctx infra.DnoteCtx, actions []Action) error
- func WriteConfig(ctx infra.DnoteCtx, config infra.Config) error
- func WriteDnote(ctx infra.DnoteCtx, dnote infra.Dnote) error
- func WriteTimestamp(ctx infra.DnoteCtx, timestamp infra.Timestamp) error
- type Action
- type AddBookData
- type AddNoteData
- type EditNoteData
- type RemoveBookData
- type RemoveNoteData
- type RunEFunc
Constants ¶
const ( // Version is the current version of dnote Version = "0.2.1" // TimestampFilename is the name of the file containing upgrade info TimestampFilename = "timestamps" // DnoteDirName is the name of the directory containing dnote files DnoteDirName = ".dnote" ConfigFilename = "dnoterc" DnoteFilename = "dnote" ActionFilename = "actions" TmpContentFilename = "DNOTE_TMPCONTENT" )
Variables ¶
var ( ActionAddNote = "add_note" ActionRemoveNote = "remove_note" ActionEditNote = "edit_note" ActionAddBook = "add_book" ActionRemoveBook = "remove_book" )
Functions ¶
func ClearActionLog ¶
func FilterNotes ¶
func GetActionPath ¶
GetActionPath returns the path to the file containing user actions
func GetConfigPath ¶
GetConfigPath returns the path to the dnote config file
func GetDnotePath ¶
GetDnotePath returns the path to the dnote file
func GetDnoteTmpContentPath ¶
GetDnoteTmpContentPath returns the path to the temporary file containing content being added or edited
func GetEditorInput ¶
GetEditorInput gets the user input by launching a text editor and waiting for it to exit
func GetTimestampPath ¶
GetTimestampPath returns the path to the file containing dnote upgrade information
func InitActionFile ¶
InitActionFile populates action file if it does not exist
func InitConfigFile ¶
InitConfigFile populates a new config file if it does not exist yet
func InitDnoteDir ¶
InitDnoteDir initializes dnote directory if it does not exist yet
func InitDnoteFile ¶
InitDnoteFile creates an empty dnote file
func InitTimestampFile ¶
InitTimestampFile creates an empty dnote upgrade file
func IsFreshInstall ¶
IsFreshInstall checks if the dnote files have been initialized
func LogAction ¶
LogAction appends the action to the action log and updates the last_action timestamp
func LogActionAddNote ¶
func LogActionEditNote ¶
func LogActionRemoveNote ¶
func MigrateToDnoteDir ¶
MigrateToDnoteDir creates dnote directory if artifacts from the previous version of dnote are present, and moves the artifacts to the directory.
func ReadNoteContent ¶
ReadNoteContent reads the content of dnote
func ReadTimestamp ¶
ReadTimestamp gets the content of the timestamp file
func Reduce ¶
Reduce transitions the local dnote state by consuming the action returned from the server
func WriteDnote ¶
WriteDnote persists the state of Dnote into the dnote file
Types ¶
type Action ¶
type Action struct { ID int `json:"id"` Type string `json:"type"` Data json.RawMessage `json:"data"` Timestamp int64 `json:"timestamp"` }
type AddBookData ¶
type AddBookData struct {
BookName string `json:"book_name"`
}
type AddNoteData ¶
type EditNoteData ¶
type RemoveBookData ¶
type RemoveBookData struct {
BookName string `json:"book_name"`
}