Documentation ¶
Index ¶
- Constants
- Variables
- func AppendLines(t *testing.T, path string, text string)
- func AssertContentEqual(t *testing.T, expected string, file *File)
- func AssertFrontMatterEqual(t *testing.T, expected string, file *File)
- func AssertNoFiles(t *testing.T)
- func AssertNoFlashcards(t *testing.T)
- func AssertNoLinks(t *testing.T)
- func AssertNoMedias(t *testing.T)
- func AssertNoNotes(t *testing.T)
- func AssertNoReminders(t *testing.T)
- func AssertTrimEqual(t *testing.T, expected string, actual string)
- func AttributesJSON(attributes map[string]interface{}) (string, error)
- func AttributesString(attributes map[string]interface{}) (string, error)
- func AttributesYAML(attributes map[string]interface{}) (string, error)
- func BoolPointer(b bool) *bool
- func CastAttribute(value interface{}, declaredType string) interface{}
- func CastAttributes(attributes map[string]interface{}, types map[string]string) map[string]interface{}
- func CompactYAML(doc string) string
- func DetermineFileSlug(path string) string
- func DetermineNoteSlug(fileSlug string, attributeSlug string, kind NoteKind, shortTitle string) string
- func DiffKeys(a, b map[string]interface{}) []string
- func EvaluateTimeExpression(expr string) (time.Time, error)
- func ExtractBlockTagsAndAttributes(content string) ([]string, map[string]interface{})
- func FilterNonInheritableAttributes(attributes map[string]interface{}, relativePath string, kind NoteKind) map[string]interface{}
- func FormatLongTitle(titles ...string) string
- func FreezeAt(t *testing.T, point time.Time) time.Time
- func FreezeNow(t *testing.T) time.Time
- func GetSchemaAttributeType(name string) string
- func GetSchemaAttributeTypes() map[string]string
- func HumanTime(t *testing.T, str string) time.Time
- func IsArray(value interface{}) bool
- func IsBool(value interface{}) bool
- func IsComposite(value interface{}) bool
- func IsExec(mode os.FileMode) bool
- func IsExecAny(mode os.FileMode) bool
- func IsExecOther(mode os.FileMode) bool
- func IsExecOwner(mode os.FileMode) bool
- func IsFloat(value interface{}) bool
- func IsInteger(value interface{}) bool
- func IsNumber(value interface{}) bool
- func IsObject(value interface{}) bool
- func IsPrimitive(value interface{}) bool
- func IsString(value interface{}) bool
- func MatchWikilink(txt string) bool
- func MergeAttribute(attributes map[string]interface{}, name string, value interface{})
- func MergeAttributes(attributes ...map[string]interface{}) map[string]interface{}
- func MustCountFiles(t *testing.T) int
- func MustCountFlashcards(t *testing.T) int
- func MustCountLinks(t *testing.T) int
- func MustCountMedias(t *testing.T) int
- func MustCountNotes(t *testing.T) int
- func MustCountReminders(t *testing.T) int
- func MustDeleteFile(t *testing.T, path string)
- func MustWriteFile(t *testing.T, path string, content string)
- func NewOID() string
- func NewOIDFromBytes(b []byte) string
- func NonInheritableAttributes(relativePath string, kind NoteKind) []string
- func OIDToPath(oid string) string
- func ReadRefs() map[string]string
- func RemoveTagsAndAttributes(content string) string
- func ReplaceLine(t *testing.T, path string, lineNumber int, oldLine string, newLine string)
- func Reset()
- func ResetOID()
- func SetNextOIDs(t *testing.T, oids ...string)
- func SetUpRepositoryFromFileContent(t *testing.T, name, content string) string
- func SetUpRepositoryFromGoldenDir(t *testing.T) string
- func SetUpRepositoryFromGoldenDirNamed(t *testing.T, testname string) string
- func SetUpRepositoryFromGoldenFile(t *testing.T) string
- func SetUpRepositoryFromGoldenFileNamed(t *testing.T, testname string) string
- func SetUpRepositoryFromTempDir(t *testing.T) string
- func SettingsJSON(settings map[string]any) (string, error)
- func StripBlockTagsAndAttributes(content string) string
- func ToSafeYAMLNode(value interface{}) *yaml.Node
- func ToSafeYAMLValue(node *yaml.Node) interface{}
- func UnescapeTestContent(content string) string
- func UnmarshalAttributes(rawValue string) (map[string]interface{}, error)
- func UseFixedOID(t *testing.T, value string)
- func UseSequenceOID(t *testing.T)
- type Attribute
- type BlobFile
- type BlobRef
- type CardType
- type Commit
- type CommitGraph
- func (c *CommitGraph) AppendCommit(commit *Commit) error
- func (c *CommitGraph) Diff(other *CommitGraph) *CommitGraphDiff
- func (c *CommitGraph) Dump()
- func (c *CommitGraph) LastCommitsFrom(head string) ([]*Commit, error)
- func (cg *CommitGraph) Read(r io.Reader) error
- func (c *CommitGraph) Ref() string
- func (c *CommitGraph) Save() error
- func (c *CommitGraph) SaveTo(path string) error
- func (c *CommitGraph) Write(w io.Writer) error
- type CommitGraphDiff
- type Config
- type ConfigCore
- type ConfigDeck
- type ConfigFile
- type ConfigLintRule
- type ConfigLintSchema
- type ConfigLintSchemaAttribute
- type ConfigMedias
- type ConfigReference
- type ConfigRemote
- type ConfigSearch
- type DB
- func (db *DB) BeginTransaction() error
- func (db *DB) BlobExists(oid string) bool
- func (db *DB) Client() SQLClient
- func (db *DB) Close() error
- func (db *DB) Commit(msg string) error
- func (db *DB) CommitTransaction() error
- func (db *DB) CompressCommit(commit *Commit) (bool, error)
- func (db *DB) CompressPackFile(packFile *PackFile) (bool, error)
- func (db *DB) DeleteBlob(media *Media, blob *BlobRef) error
- func (db *DB) DeleteBlobs(media *Media) error
- func (db *DB) DeletePackFile(packFile *PackFile) error
- func (db *DB) Diff() (string, error)
- func (db *DB) GC() error
- func (db *DB) Head() *Commit
- func (db *DB) ObjectExists(oid string) bool
- func (db *DB) Origin() Remote
- func (db *DB) PrintIndex()
- func (db *DB) Pull() error
- func (db *DB) Push() error
- func (db *DB) ReadBlob(oid string) ([]byte, error)
- func (db *DB) ReadCommit(oid string) (*Commit, bool)
- func (db *DB) ReadCommittedObject(oid string) (StatefulObject, error)
- func (db *DB) ReadLastStagedOrCommittedObject(oid string) (StatefulObject, error)
- func (db *DB) ReadLastStagedOrCommittedObjectFromDB(oid string) (StatefulObject, error)
- func (db *DB) ReadPackFile(oid string) (*PackFile, error)
- func (db *DB) ReadPackFilesFromCommit(commit *Commit) ([]*PackFile, error)
- func (db *DB) Ref(name string) (string, bool)
- func (db *DB) Reset() error
- func (db *DB) RollbackTransaction() error
- func (db *DB) StageObject(obj StatefulObject) error
- func (db *DB) StatsOnDisk() (*StatsOnDisk, error)
- func (db *DB) WIP() *WIP
- func (db *DB) WriteBlob(oid string, data []byte) error
- type FSRemote
- type Feedback
- type File
- func NewEmptyFile(name string) *File
- func NewFileFromAttributes(parent *File, name string, attributes []Attribute) *File
- func NewFileFromParsedFile(parent *File, parsedFile *ParsedFileOld) *File
- func NewFileFromPath(parent *File, filepath string) (*File, error)
- func NewOrExistingFile(parent *File, path string) (*File, error)
- func QueryFile(db SQLClient, whereClause string, args ...any) (*File, error)
- func QueryFiles(db SQLClient, whereClause string, args ...any) ([]*File, error)
- func (f *File) AbsoluteBodyLine(bodyLine int) int
- func (f *File) Blobs() []*BlobRef
- func (f *File) Check() error
- func (f *File) Delete() error
- func (f *File) FindFlashcardByTitle(shortTitle string) *Flashcard
- func (f *File) FindNoteByKindAndShortTitle(kind NoteKind, shortTitle string) *Note
- func (f *File) ForceState(state State)
- func (f *File) FormatToHTML() string
- func (f *File) FormatToJSON() string
- func (f *File) FormatToMarkdown() string
- func (f *File) FormatToText() string
- func (f *File) FormatToYAML() string
- func (f *File) FrontMatterString() (string, error)
- func (f *File) GetAttribute(key string) interface{}
- func (f *File) GetAttributes() map[string]interface{}
- func (f *File) GetFlashcards() []*Flashcard
- func (f *File) GetMedias() []*Media
- func (f *File) GetNotes() []*Note
- func (f *File) GetTags() []string
- func (f *File) HasTag(name string) bool
- func (f *File) Insert() error
- func (f *File) Kind() string
- func (f *File) ModificationTime() time.Time
- func (f *File) New() bool
- func (f *File) Read(r io.Reader) error
- func (f *File) Refresh() (bool, error)
- func (f *File) Relations() []*Relation
- func (f *File) Save() error
- func (f *File) SaveOnDisk() error
- func (f *File) SetAlive()
- func (f *File) SetAttribute(key string, value interface{})
- func (f *File) State() State
- func (f File) String() string
- func (f *File) SubObjects() []StatefulObject
- func (f *File) UniqueOID() string
- func (f *File) Update() error
- func (f *File) Updated() bool
- func (f *File) Write(w io.Writer) error
- type Flashcard
- func MustFindFlashcardByShortTitle(t *testing.T, shortTitle string) *Flashcard
- func NewFlashcard(file *File, note *Note) *Flashcard
- func NewOrExistingFlashcard(file *File, note *Note) *Flashcard
- func QueryFlashcard(db SQLClient, whereClause string, args ...any) (*Flashcard, error)
- func QueryFlashcards(db SQLClient, whereClause string, args ...any) ([]*Flashcard, error)
- func (f *Flashcard) Blobs() []*BlobRef
- func (f *Flashcard) Check() error
- func (f *Flashcard) Delete() error
- func (f *Flashcard) ForceState(state State)
- func (f *Flashcard) Insert() error
- func (f *Flashcard) Kind() string
- func (f *Flashcard) ModificationTime() time.Time
- func (f *Flashcard) New() bool
- func (f *Flashcard) Read(r io.Reader) error
- func (f *Flashcard) Refresh() (bool, error)
- func (f *Flashcard) Relations() []*Relation
- func (f *Flashcard) Save() error
- func (f *Flashcard) State() State
- func (f Flashcard) String() string
- func (f *Flashcard) SubObjects() []StatefulObject
- func (f *Flashcard) UniqueOID() string
- func (f *Flashcard) Update() error
- func (f *Flashcard) Updated() bool
- func (f *Flashcard) Write(w io.Writer) error
- type GlobPath
- type GlobPaths
- type IgnoreFile
- type Index
- func (i *Index) AppendPackFile(commitOID string, packFile *PackFile)
- func (i *Index) CloneForRemote() *Index
- func (i *Index) CountChanges() int
- func (i *Index) CreateCommitFromStagingArea() (*Commit, []*PackFile)
- func (i *Index) Diff(other *Index) *IndexDiff
- func (i *Index) FindCommitContaining(objectOID string) (string, bool)
- func (i *Index) FindPackFileContaining(objectOID string) (string, bool)
- func (i *Index) IsOrphanBlob(oid string) bool
- func (i *Index) Read(r io.Reader) error
- func (i *Index) ReadIndexObject(objectOID string) (*IndexObject, bool)
- func (i *Index) Save() error
- func (i *Index) StageObject(obj StatefulObject) error
- func (i *Index) Write(w io.Writer) error
- type IndexDiff
- type IndexObject
- type IndexOrphanBlob
- type IndexOrphanPackFile
- type Link
- func (l *Link) Blobs() []*BlobRef
- func (l *Link) Check() error
- func (l *Link) Delete() error
- func (l *Link) ForceState(state State)
- func (l *Link) Insert() error
- func (l *Link) Kind() string
- func (l *Link) ModificationTime() time.Time
- func (l *Link) New() bool
- func (l *Link) Read(r io.Reader) error
- func (l *Link) Refresh() (bool, error)
- func (l *Link) Relations() []*Relation
- func (l *Link) Save() error
- func (l *Link) State() State
- func (l Link) String() string
- func (l *Link) SubObjects() []StatefulObject
- func (l *Link) UniqueOID() string
- func (l *Link) Update() error
- func (l *Link) Updated() bool
- func (l *Link) Write(w io.Writer) error
- type LintFile
- type LintResult
- type LintRule
- type LintRuleDefinition
- type Logger
- func (l *Logger) Debug(v ...any)
- func (l *Logger) Debugf(format string, v ...any)
- func (l *Logger) Fatal(v ...any)
- func (l *Logger) Fatalf(format string, v ...any)
- func (l *Logger) Info(v ...any)
- func (l *Logger) Infof(format string, v ...any)
- func (l *Logger) SetVerboseLevel(level VerboseLevel) *Logger
- func (l *Logger) Trace(v ...any)
- func (l *Logger) Tracef(format string, v ...any)
- func (l *Logger) Warn(v ...any)
- func (l *Logger) Warnf(format string, v ...any)
- type MarkdownFile
- func (f *MarkdownFile) FrontMatterAsMap() (map[string]interface{}, error)
- func (f *MarkdownFile) FrontMatterAsNode() (*yaml.Node, error)
- func (m *MarkdownFile) GetSections() ([]*MarkdownSection, error)
- func (m *MarkdownFile) GetTopSection() (*MarkdownSection, error)
- func (m *MarkdownFile) LastUpdateDate() time.Time
- func (m *MarkdownFile) ToParsedFile() (*ParsedFileNew, error)
- func (m *MarkdownFile) WalkSections(...) error
- type MarkdownSection
- type MatchedFile
- type Media
- func (m *Media) Blobs() []*BlobRef
- func (m *Media) Check() error
- func (m *Media) Delete() error
- func (m *Media) DeleteBlobs() error
- func (m *Media) ForceState(state State)
- func (m *Media) Insert() error
- func (m *Media) InsertBlobs() error
- func (m *Media) Kind() string
- func (m *Media) ModificationTime() time.Time
- func (m *Media) New() bool
- func (m *Media) Read(r io.Reader) error
- func (m *Media) Refresh() (bool, error)
- func (m *Media) Relations() []*Relation
- func (m *Media) Save() error
- func (m *Media) State() State
- func (m Media) String() string
- func (m *Media) SubObjects() []StatefulObject
- func (m *Media) UniqueOID() string
- func (m *Media) Update() error
- func (m *Media) UpdateBlobs()
- func (m *Media) Updated() bool
- func (m *Media) Write(w io.Writer) error
- type MediaKind
- type Note
- func MustFindNoteByPathAndTitle(t *testing.T, relativePath, longTitle string) *Note
- func NewNote(f *File, parent *Note, parsedNote *ParsedNoteOld) *Note
- func NewOrExistingNote(f *File, parent *Note, parsedNote *ParsedNoteOld) *Note
- func QueryNote(db SQLClient, whereClause string, args ...any) (*Note, error)
- func QueryNotes(db SQLClient, whereClause string, args ...any) ([]*Note, error)
- func (n *Note) Blobs() []*BlobRef
- func (n *Note) Check() error
- func (n *Note) Delete() error
- func (n *Note) ForceState(state State)
- func (n *Note) FormatToHTML() string
- func (n *Note) FormatToJSON() string
- func (n *Note) FormatToMarkdown() string
- func (n *Note) FormatToText() string
- func (n *Note) FormatToYAML() string
- func (n *Note) GetAttribute(name string) interface{}
- func (n *Note) GetAttributeString(name, defaultValue string) string
- func (n *Note) GetAttributes() map[string]interface{}
- func (n *Note) GetFile() *File
- func (n *Note) GetLinks() []*Link
- func (n *Note) GetMedias() []*Media
- func (n *Note) GetNoteAttributes() map[string]interface{}
- func (n *Note) GetNoteTags() []string
- func (n *Note) GetParentNote() *Note
- func (n *Note) GetReminders() []*Reminder
- func (n *Note) GetTags() []string
- func (n *Note) HasAttribute(name string) bool
- func (n *Note) HasTag(name string) bool
- func (n *Note) Insert() error
- func (n *Note) Kind() string
- func (n *Note) ModificationTime() time.Time
- func (n *Note) New() bool
- func (n *Note) Read(r io.Reader) error
- func (n *Note) Refresh() (bool, error)
- func (n *Note) Relations() []*Relation
- func (n *Note) ReplaceMediasByOIDLinks(md string) string
- func (n *Note) RunHooks(hookNames []string) error
- func (n *Note) Save() error
- func (n *Note) SetAttribute(name string, value interface{})
- func (n *Note) State() State
- func (n Note) String() string
- func (n *Note) SubObjects() []StatefulObject
- func (n *Note) UniqueOID() string
- func (n *Note) Update() error
- func (n *Note) Updated() bool
- func (n *Note) Write(w io.Writer) error
- type NoteKind
- type OIDGenerator
- type Object
- type ObjectData
- type PackFile
- func (p *PackFile) AppendObject(obj StatefulObject) error
- func (p *PackFile) AppendPackObject(obj *PackObject)
- func (p *PackFile) AppendStagingObject(obj *StagingObject)
- func (p *PackFile) Blobs() []*BlobRef
- func (p *PackFile) GetPackObject(oid string) (*PackObject, bool)
- func (p *PackFile) Merge(other *PackFile) (*PackFile, bool)
- func (p *PackFile) Read(r io.Reader) error
- func (p *PackFile) Ref() *PackFileRef
- func (p *PackFile) Save() error
- func (p *PackFile) SaveTo(path string) error
- func (p *PackFile) UniqueOID() string
- func (p *PackFile) UnmarshallObject(oid string, target interface{}) error
- func (p *PackFile) Write(w io.Writer) error
- type PackFileRef
- type PackFileRefs
- type PackObject
- type ParsedFileNew
- type ParsedFileOld
- func (f *ParsedFileOld) AbsoluteBodyLine(bodyLine int) int
- func (f *ParsedFileOld) Content() string
- func (f *ParsedFileOld) GetTags() []string
- func (f *ParsedFileOld) HasTag(tagName string) bool
- func (f *ParsedFileOld) Lint(ruleNames []string) ([]*Violation, error)
- func (f *ParsedFileOld) Wikilinks() []*Wikilink
- type ParsedFlashcardNew
- type ParsedLinkNew
- type ParsedMediaNew
- type ParsedMediaOld
- type ParsedNoteNew
- type ParsedNoteOld
- type ParsedReminderNew
- type Query
- type QueueType
- type Relation
- func NewRelation(oidA string, kindA string, oidB string, kindB string, relationType string) *Relation
- func NewRelationFromObjects(objA, objB Object, relationType string) *Relation
- func QueryRelation(db SQLClient, whereClause string, args ...any) (*Relation, error)
- func QueryRelations(db SQLClient, whereClause string, args ...any) ([]*Relation, error)
- type Reminder
- func NewOrExistingReminder(note *Note, descriptionRaw, tag string) (*Reminder, error)
- func NewReminder(note *Note, descriptionRaw, tag string) (*Reminder, error)
- func QueryReminder(db SQLClient, whereClause string, args ...any) (*Reminder, error)
- func QueryReminders(db SQLClient, whereClause string, args ...any) ([]*Reminder, error)
- func (r *Reminder) Blobs() []*BlobRef
- func (r *Reminder) Check() error
- func (r *Reminder) Delete() error
- func (r *Reminder) ForceState(state State)
- func (r *Reminder) Insert() error
- func (r *Reminder) Kind() string
- func (r *Reminder) ModificationTime() time.Time
- func (r *Reminder) New() bool
- func (r *Reminder) Next() error
- func (n *Reminder) Read(r io.Reader) error
- func (r *Reminder) Refresh() (bool, error)
- func (r *Reminder) Relations() []*Relation
- func (r *Reminder) Save() error
- func (r *Reminder) State() State
- func (r Reminder) String() string
- func (r *Reminder) SubObjects() []StatefulObject
- func (r *Reminder) UniqueOID() string
- func (r *Reminder) Update() error
- func (r *Reminder) Updated() bool
- func (r *Reminder) Write(w io.Writer) error
- type Remote
- type Repository
- func (r *Repository) Add(paths ...string) error
- func (r *Repository) Close()
- func (r *Repository) CountAttributes() (map[string]int, error)
- func (r *Repository) CountFiles() (int, error)
- func (r *Repository) CountFlashcards() (int, error)
- func (r *Repository) CountLinks() (int, error)
- func (r *Repository) CountMedias() (int, error)
- func (r *Repository) CountNotes() (int, error)
- func (r *Repository) CountNotesByKind() (map[NoteKind]int, error)
- func (r *Repository) CountObjectsByType() (map[string]int, error)
- func (r *Repository) CountRelations() (int, error)
- func (r *Repository) CountReminders() (int, error)
- func (r *Repository) CountTags() (map[string]int, error)
- func (r *Repository) DeleteRelations(obj Object) error
- func (r *Repository) Diff(staged bool) (string, error)
- func (r *Repository) DumpNotes() error
- func (r *Repository) FindBlobFromOID(oid string) (*BlobRef, error)
- func (r *Repository) FindBlobsFromMedia(mediaOID string) ([]*BlobRef, error)
- func (r *Repository) FindFileByRelativePath(relativePath string) (*File, error)
- func (r *Repository) FindFileByWikilink(wikilink string) (*File, error)
- func (r *Repository) FindFilesByRelativePathPrefix(relativePathPrefix string) ([]*File, error)
- func (r *Repository) FindFilesByWikilink(wikilink string) ([]*File, error)
- func (r *Repository) FindFilesLastCheckedBefore(point time.Time, path string) ([]*File, error)
- func (r *Repository) FindFlashcardByHash(hash string) (*Flashcard, error)
- func (r *Repository) FindFlashcardByShortTitle(shortTitle string) (*Flashcard, error)
- func (r *Repository) FindFlashcardsLastCheckedBefore(point time.Time, path string) ([]*Flashcard, error)
- func (r *Repository) FindLinkByGoName(goName string) (*Link, error)
- func (r *Repository) FindLinksByText(text string) ([]*Link, error)
- func (r *Repository) FindLinksLastCheckedBefore(point time.Time, path string) ([]*Link, error)
- func (r *Repository) FindMatchingNote(relativePath string, parsedNote *ParsedNoteOld) (*Note, error)
- func (r *Repository) FindMediaByHash(hash string) (*Media, error)
- func (r *Repository) FindMediaByRelativePath(relativePath string) (*Media, error)
- func (r *Repository) FindMediasLastCheckedBefore(point time.Time) ([]*Media, error)
- func (r *Repository) FindNoteByHash(hash string) (*Note, error)
- func (r *Repository) FindNoteByPathAndTitle(relativePath string, title string) (*Note, error)
- func (r *Repository) FindNoteBySlug(slug string) (*Note, error)
- func (r *Repository) FindNoteByTitle(title string) (*Note, error)
- func (r *Repository) FindNoteByWikilink(wikilink string) (*Note, error)
- func (r *Repository) FindNotesByFileOID(oid string) ([]*Note, error)
- func (r *Repository) FindNotesByWikilink(wikilink string) ([]*Note, error)
- func (r *Repository) FindNotesLastCheckedBefore(point time.Time, path string) ([]*Note, error)
- func (r *Repository) FindRelations() ([]*Relation, error)
- func (r *Repository) FindRelationsFrom(oid string) ([]*Relation, error)
- func (r *Repository) FindRelationsTo(oid string) ([]*Relation, error)
- func (r *Repository) FindReminders() ([]*Reminder, error)
- func (r *Repository) FindRemindersByUpcomingDate(deadline time.Time) ([]*Reminder, error)
- func (r *Repository) FindRemindersLastCheckedBefore(point time.Time, path string) ([]*Reminder, error)
- func (r *Repository) FindRemindersMatching(noteOID string, descriptionRaw string) ([]*Reminder, error)
- func (r *Repository) GetAbsolutePath(path string) string
- func (r *Repository) GetFileRelativePath(fileAbsolutePath string) (string, error)
- func (r *Repository) GetNoteRelativePath(fileRelativePath string, srcPath string) (string, error)
- func (r *Repository) Lint(ruleNames []string, paths ...string) (*LintResult, error)
- func (r *Repository) LoadFileByOID(oid string) (*File, error)
- func (r *Repository) LoadFlashcardByNoteOID(noteID string) (*Flashcard, error)
- func (r *Repository) LoadFlashcardByOID(oid string) (*Flashcard, error)
- func (r *Repository) LoadLinkByOID(oid string) (*Link, error)
- func (r *Repository) LoadMediaByOID(oid string) (*Media, error)
- func (r *Repository) LoadNoteByOID(oid string) (*Note, error)
- func (r *Repository) LoadReminderByOID(oid string) (*Reminder, error)
- func (r *Repository) SearchNotes(q string) ([]*Note, error)
- func (r *Repository) Stats() (*Stats, error)
- func (r *Repository) StatsInDB() (*StatsInDB, error)
- func (r *Repository) Status() (string, error)
- func (r *Repository) UpdateRelations(source Object) error
- type Review
- type S3Remote
- type SQLClient
- type StagingArea
- func (sa *StagingArea) ContainsFile(relpath string) (*StagingObject, bool)
- func (sa *StagingArea) Count() int
- func (sa *StagingArea) CountByState(state State) int
- func (sa *StagingArea) ReadObject(objectOID string) (StatefulObject, bool)
- func (sa *StagingArea) ReadStagingObject(objectOID string) (*StagingObject, bool)
- type StagingObject
- type State
- type StatefulObject
- type Stats
- type StatsInDB
- type StatsOnDisk
- type StorjRemote
- type Study
- func (s *Study) Blobs() []*BlobRef
- func (s *Study) ForceState(state State)
- func (s *Study) Kind() string
- func (s *Study) ModificationTime() time.Time
- func (s *Study) Read(r io.Reader) error
- func (s *Study) Refresh() (bool, error)
- func (s *Study) Relations() []*Relation
- func (s *Study) Save() error
- func (s *Study) State() State
- func (s Study) String() string
- func (s *Study) SubObjects() []StatefulObject
- func (s *Study) UniqueOID() string
- func (s *Study) Write(w io.Writer) error
- type VerboseLevel
- type Violation
- func CheckAttribute(file *ParsedFileOld, args []string) ([]*Violation, error)
- func MaxLinesBetweenNotes(file *ParsedFileOld, args []string) ([]*Violation, error)
- func MinLinesBetweenNotes(file *ParsedFileOld, args []string) ([]*Violation, error)
- func NoAmbiguousWikilink(file *ParsedFileOld, args []string) ([]*Violation, error)
- func NoDanglingMedia(file *ParsedFileOld, args []string) ([]*Violation, error)
- func NoDeadWikilink(file *ParsedFileOld, args []string) ([]*Violation, error)
- func NoDuplicateNoteTitle(file *ParsedFileOld, args []string) ([]*Violation, error)
- func NoDuplicateSlug(file *ParsedFileOld, args []string) ([]*Violation, error)
- func NoExtensionWikilink(file *ParsedFileOld, args []string) ([]*Violation, error)
- func NoFreeNote(file *ParsedFileOld, args []string) ([]*Violation, error)
- func NoteTitleMatch(file *ParsedFileOld, args []string) ([]*Violation, error)
- func RequireQuoteTag(file *ParsedFileOld, args []string) ([]*Violation, error)
- type WIP
- type Wikilink
Examples ¶
Constants ¶
const ( DefaultSRSBoostFactor = 100 DefaultSRSAlgorithm = "Anki2" DefaultSRSEaseFactor = 2.5 )
SRS
const DefaultConfig = `` /* 183-byte string literal not displayed */
Default .nt/config content
const DefaultEaseFactor = 2.5 // Same as Anki
const DefaultFirstInterval = 1 // day
const DefaultGitIgnore = `
/database.db
/database.db-journal
/objects/
/index
/refs/
`
Default .nt/.gitignore content
const DefaultIgnore = `
build/
README.md
`
Default .ntignore content
const DefaultLint = `` /* 366-byte string literal not displayed */
const Indent int = 2
Default indentation in front matter
const LargeMaxWidthOrHeight = 1980
Maximum width and/or height for large blobs.
const MaxObjectsPerPackFileDefault = 100
Database
const MinEaseFactor = 1.3 // Same as Anki
const NoteLongTitleSeparator string = " / "
NoteLongTitleSeparator represents the separator when determine the long title of a note.
const PreviewMaxWidthOrHeight = 600
Maximum width and/or height for preview blobs.
const ReferenceKindAuthor = "author"
const ReferenceKindBook = "book"
Variables ¶
var AudioExtensions = []string{".mp3", ".wav"}
List of supported audio formats
var (
ErrObjectNotExist = errors.New("object does not exist")
)
var IndexFilesFirst = func(a, b string) bool { dirA := filepath.Dir(a) dirB := filepath.Dir(b) if dirA != dirB { return a < b } baseA := text.TrimExtension(filepath.Base(a)) baseB := text.TrimExtension(filepath.Base(b)) if strings.EqualFold(baseA, "index") { return true } else if strings.EqualFold(baseB, "index") { return false } return a < b }
IndexFilesFirst ensures index files are processed first.
var LintRules = map[string]LintRuleDefinition{ "no-duplicate-note-title": { Eval: NoDuplicateNoteTitle, }, "no-duplicate-slug": { Eval: NoDuplicateSlug, }, "min-lines-between-notes": { Eval: MinLinesBetweenNotes, }, "max-lines-between-notes": { Eval: MaxLinesBetweenNotes, }, "note-title-match": { Eval: NoteTitleMatch, }, "no-free-note": { Eval: NoFreeNote, }, "no-dangling-media": { Eval: NoDanglingMedia, }, "no-dead-wikilink": { Eval: NoDeadWikilink, }, "no-extension-wikilink": { Eval: NoExtensionWikilink, }, "no-ambiguous-wikilink": { Eval: NoAmbiguousWikilink, }, "check-attribute": { Eval: CheckAttribute, }, "require-quote-tag": { Eval: RequireQuoteTag, }, }
var PictureExtensions = []string{".jpg", ".jpeg", ".png", ".gif", ".svg", ".avif"}
List of supported picture formats
var VideoExtensions = []string{".mp4", ".ogg", ".webm"}
List of supported picture formats
Functions ¶
func AppendLines ¶
AppendLines append multiple lines in a file.
func AssertFrontMatterEqual ¶
func AssertNoFiles ¶
func AssertNoFlashcards ¶
func AssertNoLinks ¶
func AssertNoMedias ¶
func AssertNoNotes ¶
func AssertNoReminders ¶
func AttributesJSON ¶
func AttributesString ¶
AttributesString formats the current attributes to the YAML front matter format.
func AttributesYAML ¶
func BoolPointer ¶
func CastAttribute ¶
func CastAttribute(value interface{}, declaredType string) interface{}
CastAttribute enforces the type declared in linter schemas.
func CastAttributes ¶
func CastAttributes(attributes map[string]interface{}, types map[string]string) map[string]interface{}
CastAttributes enforces the types declared in linter schemas.
func CompactYAML ¶
CompactYAML removes leading spaces in front of sequences.
Ex:
doc: - toto: tata
Becomes
doc: - toto: tata
Example (Dump) ¶
doc := ` creator: name: Julien hobbies: - name: Running frequency: 3/weeks ` var node yaml.Node err := yaml.Unmarshal([]byte(doc), &node) if err != nil { log.Fatal(err) } spew.Dump(node) // (yaml.Node) { // Kind: DocumentNode, // Style: "", // Tag: (string) "", // Value: (string) "", // Content: ([]*yaml.Node) (len=1 cap=1) { // (*yaml.Node)(0xc0000b8be0)({ // Kind: MappingNode, // Style: "", // Tag: (string) (len=5) "!!map", // Value: (string) "", // Content: ([]*yaml.Node) (len=2 cap=2) { // (*yaml.Node)(0xc0000b8c80)({ // Kind: ScalarNode, // Style: "", // Tag: (string) (len=5) "!!str", // Value: (string) (len=7) "creator", // Content: ([]*yaml.Node) <nil>, // }), // (*yaml.Node)(0xc0000b8d20)({ // Kind: MappingNode, // Style: "", // Tag: (string) (len=5) "!!map", // Value: (string) "", // Content: ([]*yaml.Node) (len=4 cap=4) { // (*yaml.Node)(0xc0000b8dc0)({ // Kind: ScalarNode, // Style: "", // Tag: (string) (len=5) "!!str", // Value: (string) (len=4) "name", // Content: ([]*yaml.Node) <nil>, // }), // (*yaml.Node)(0xc0000b8e60)({ // Kind: ScalarNode, // Style: "", // Tag: (string) (len=5) "!!str", // Value: (string) (len=6) "Julien", // Content: ([]*yaml.Node) <nil>, // }), // (*yaml.Node)(0xc0000b8f00)({ // Kind: ScalarNode, // Style: "", // Tag: (string) (len=5) "!!str", // Value: (string) (len=7) "hobbies", // Content: ([]*yaml.Node) <nil>, // }), // (*yaml.Node)(0xc0000b8fa0)({ // Kind: SequenceNode, // Style: "", // Tag: (string) (len=5) "!!seq", // Value: (string) "", // Content: ([]*yaml.Node) (len=1 cap=1) { // (*yaml.Node)(0xc0000b9040)({ // Kind: MappingNode, // Style: "", // Tag: (string) (len=5) "!!map", // Value: (string) "", // Content: ([]*yaml.Node) (len=4 cap=4) { // (*yaml.Node)(0xc0000b90e0)({ // Kind: ScalarNode, // Style: "", // Tag: (string) (len=5) "!!str", // Value: (string) (len=4) "name", // Content: ([]*yaml.Node) <nil>, // }), // (*yaml.Node)(0xc0000b9180)({ // Kind: ScalarNode, // Style: "", // Tag: (string) (len=5) "!!str", // Value: (string) (len=7) "Running", // Content: ([]*yaml.Node) <nil>, // }), // (*yaml.Node)(0xc0000b9220)({ // Kind: ScalarNode, // Style: "", // Tag: (string) (len=5) "!!str", // Value: (string) (len=9) "frequency", // Content: ([]*yaml.Node) <nil>, // }), // (*yaml.Node)(0xc0000b92c0)({ // Kind: ScalarNode, // Style: "", // Tag: (string) (len=5) "!!str", // Value: (string) (len=7) "3/weeks", // Content: ([]*yaml.Node) <nil>, // }) // }, // }) // }, // }) // }, // }) // }, // }) // }, // }
Output:
Example (WithObject) ¶
type Person struct { Name string Age int } me := Person{ Name: "Julien", Age: 36, } var meNode yaml.Node data, err := yaml.Marshal(&me) if err != nil { log.Fatal(err) } err = yaml.Unmarshal(data, &meNode) if err != nil { log.Fatal(err) } config := &yaml.Node{ Kind: yaml.DocumentNode, Content: []*yaml.Node{ { Kind: yaml.MappingNode, Content: []*yaml.Node{ { Kind: yaml.ScalarNode, Value: "creator", LineComment: "# Who?", }, meNode.Content[0], }, }, }, } bytes, err := yaml.Marshal(config) if err != nil { log.Fatalf("Unable to marshall: %v", err) } log.Println("\n---\n" + string(bytes) + "---")
Output:
Example (WithScalars) ¶
config := &yaml.Node{ Kind: yaml.DocumentNode, Content: []*yaml.Node{ { Kind: yaml.MappingNode, Content: []*yaml.Node{ { Kind: yaml.ScalarNode, Value: "key1", HeadComment: "# This section is for key1", LineComment: "# TODO Complete", }, { Kind: yaml.ScalarNode, Style: yaml.DoubleQuotedStyle, Value: "value1", }, { Kind: yaml.ScalarNode, Value: "key2", }, { Kind: yaml.ScalarNode, Style: yaml.DoubleQuotedStyle, Value: "value2", }, }, }, }, } bytes, err := yaml.Marshal(config) if err != nil { log.Fatalf("Unable to marshall: %v", err) } log.Printf("\n---\n" + string(bytes) + "---")
Output:
func DetermineFileSlug ¶
DetermineFileSlug generates a slug from a file path.
func DetermineNoteSlug ¶
func DetermineNoteSlug(fileSlug string, attributeSlug string, kind NoteKind, shortTitle string) string
DetermineNoteSlug determines the note slug from the attributes.
func EvaluateTimeExpression ¶
EvaluateTimeExpression determine the next matching reminder date
func ExtractBlockTagsAndAttributes ¶
ExtractBlockTagsAndAttributes searches for all tags and attributes declared on standalone lines (in comparison with tags/attributes defined, for example, on To-Do list items).
func FilterNonInheritableAttributes ¶
func FilterNonInheritableAttributes(attributes map[string]interface{}, relativePath string, kind NoteKind) map[string]interface{}
FilterNonInheritableAttributes removes from the list all non-inheritable attributes.
func FormatLongTitle ¶
FormatLongTitle formats the long title of a note.
func FreezeAt ¶
FreezeAt wraps the clock API to register the cleanup function at the end of the test.
func FreezeNow ¶
FreezeNow wraps the clock API to register the cleanup function at the end of the test.
func GetSchemaAttributeType ¶
GetSchemaAttributeType returns the type for the given attribute and defaults to string if no declaration is found.
func GetSchemaAttributeTypes ¶
GetSchemaAttributeTypes returns all declared attributes with their JSON types.
func IsComposite ¶
func IsComposite(value interface{}) bool
IsComposite returns if a variable is a composite type.
func IsExecOther ¶
func IsExecOwner ¶
func IsFloat ¶
func IsFloat(value interface{}) bool
IsFloat returns if a variable is a JSON number of float type.
func IsInteger ¶
func IsInteger(value interface{}) bool
IsInteger returns if a variable is a JSON number of integer type.
func IsNumber ¶
func IsNumber(value interface{}) bool
IsNumber returns if a variable is a JSON number.
func IsPrimitive ¶
func IsPrimitive(value interface{}) bool
IsPrimitive returns if a variable is a primitive type.
func IsString ¶
func IsString(value interface{}) bool
IsString returns if a variable is a JSON string.
func MatchWikilink ¶
MatchWikilink tests if a text is a wikilink.
func MergeAttribute ¶
func MergeAttributes ¶
func MustCountFiles ¶
func MustCountFlashcards ¶
func MustCountLinks ¶
func MustCountMedias ¶
func MustCountNotes ¶
func MustCountReminders ¶
func MustDeleteFile ¶
MustDeleteFile remove a file iin the current repository.
func MustWriteFile ¶
MustWriteFile edits the file in the current repository to force the given content.
func NewOIDFromBytes ¶
func NonInheritableAttributes ¶
NonInheritableAttributes returns the attributes that must not be inherited.
func RemoveTagsAndAttributes ¶
RemoveTagsAndAttributes removes all tags and attributes from a text.
func ReplaceLine ¶
ReplaceLine replaces a line inside a file.
func ResetOID ¶
func ResetOID()
ResetOID restores the original unique OID generator. Useful in tests with a defer after overriding the default generator.
func SetNextOIDs ¶
SetNextOIDs configures a predefined list of OID
func SetUpRepositoryFromFileContent ¶
SetUpRepositoryFromFileContent populates a temp directory based on the given file content.
func SetUpRepositoryFromGoldenDir ¶
SetUpRepositoryFromGoldenDir populates a temp directory containing a valid .nt repository.
func SetUpRepositoryFromGoldenDirNamed ¶
SetUpRepositoryFromGoldenDir populates a temp directory based on the given golden dir name.
func SetUpRepositoryFromGoldenFile ¶
SetUpRepositoryFromGoldenFile populates a temp directory containing a valid .nt repository and a single file.
func SetUpRepositoryFromGoldenFileNamed ¶
SetUpRepositoryFromGoldenFileNamed populates a temp directory based on the given golden file name.
func SetUpRepositoryFromTempDir ¶
SetUpRepositoryFromTempDir populates a temp directory containing a valid .nt repository.
func StripBlockTagsAndAttributes ¶
StripTagsAndAttributes remove all tags and attributes.
func ToSafeYAMLNode ¶
func ToSafeYAMLNode(value interface{}) *yaml.Node
func ToSafeYAMLValue ¶
func ToSafeYAMLValue(node *yaml.Node) interface{}
func UnescapeTestContent ¶
UnescapeTestContent supports content using a special character instead of backticks.
func UnmarshalAttributes ¶
UnmarshalAttributes unmarshall attributes and ensure the right types are used.
func UseFixedOID ¶
UseFixedOID configures a fixed OID value
Types ¶
type BlobFile ¶
func NewBlobFile ¶
type BlobRef ¶
type BlobRef struct { // OID to locate the blob file in .nt/objects OID string `yaml:"oid"` MimeType string `yaml:"mime"` Attributes map[string]interface{} `yaml:"attributes"` Tags []string `yaml:"tags"` }
func MustWriteBlob ¶
MustWriteBlob writes a new blob object or fails.
type Commit ¶
type Commit struct { OID string `yaml:"oid"` CTime time.Time `yaml:"ctime"` MTime time.Time `yaml:"mtime"` PackFiles PackFileRefs `yaml:"packfiles"` }
func NewCommitFromPackFiles ¶
NewCommitFromPackFiles initializes a new commit referencing the given pack files.
func NewCommitWithOID ¶
NewCommitWithOID initializes a new commit with a given OID.
func (*Commit) AppendPackFile ¶
AppendPackFile appends a new pack file OID in the commit.
func (*Commit) IncludePackFile ¶
func (c *Commit) IncludePackFile(oid string) (*PackFileRef, bool)
IncludePackFile returns the pack file is present in the commit.
type CommitGraph ¶
type CommitGraph struct { UpdatedAt time.Time `yaml:"updated_at,omitempty"` Commits []*Commit `yaml:"commits,omitempty"` }
CommitGraph represents a .nt/objects/info/commit-graph file. See https://git-scm.com/docs/commit-graph for inspiration.
The commit graph is used to quickly finds commit to download and/or diffs between local and remote directories. Useful when pulling or pushing commits.
func NewCommitGraph ¶
func NewCommitGraph() *CommitGraph
NewCommitGraph instantiates a new commit graph.
func NewCommitGraphFromPath ¶
func NewCommitGraphFromPath(path string) (*CommitGraph, error)
NewCommitGraphFromPath loads a commit-graph file from a path.
func ReadCommitGraph ¶
func ReadCommitGraph() *CommitGraph
func (*CommitGraph) AppendCommit ¶
func (c *CommitGraph) AppendCommit(commit *Commit) error
AppendCommit pushes a new commit.
func (*CommitGraph) Diff ¶
func (c *CommitGraph) Diff(other *CommitGraph) *CommitGraphDiff
Diff reports differences to reconcile the receiver with the given commit graph.
func (*CommitGraph) LastCommitsFrom ¶
func (c *CommitGraph) LastCommitsFrom(head string) ([]*Commit, error)
LastCommits returns all commits pushed after head.
func (*CommitGraph) Read ¶
func (cg *CommitGraph) Read(r io.Reader) error
Read instantiates a commit graph from an existing file
func (*CommitGraph) Ref ¶
func (c *CommitGraph) Ref() string
Ref returns the commit OID of the last commit.
func (*CommitGraph) Save ¶
func (c *CommitGraph) Save() error
Save persists the commit-graph locally.
func (*CommitGraph) SaveTo ¶
func (c *CommitGraph) SaveTo(path string) error
SaveTo persists the commit-graph to the given path.
type CommitGraphDiff ¶
type CommitGraphDiff struct { // Commits present only in the compared commit graph MissingCommits []*Commit // Pack files present only in the compared commit graph MissingPackFiles PackFileRefs // Pack files no longer present in the compared commit graph ObsoletePackFiles PackFileRefs // Pack files edited since by a gc EditedPackFiles PackFileRefs }
type Config ¶
type Config struct { // Absolute top directory containing the .nt sub-directory RootDirectory string // .nt/config content ConfigFile ConfigFile // .nt/lint content LintFile LintFile // .ntignore content IgnoreFile IgnoreFile // Toggle this flag to skip some side-effects DryRun bool // contains filtered or unexported fields }
func CurrentConfig ¶
func CurrentConfig() *Config
func InitConfigFromDirectory ¶
InitConfigFromDirectory creates the .nt configuration directory with default files including .ntignore.
func ReadConfigFromDirectory ¶
ReadConfigFromDirectory loads the configuration by searching for a .nt directory in the given directory or any parent directories. It fails if a directory already exists.
func (*Config) Converter ¶
Converter returns the convertor to use when creating blobs from media files.
func (*Config) SetParallel ¶
SetParallel overrides the value in config file.
type ConfigCore ¶
type ConfigDeck ¶
type ConfigDeck struct { Name string Query string // General attributes BoostFactor int // How passionate I am on this topic (100 = neutral, 80 = challenging, 120 = smooth) NewFlashcardsPerDay int // How many new flashcards to add every day (= 0 no more cards for now) MaxFlashcardsPerDay int // How many flashcards (including new) to review every day (= 0 no limit, review what is due) // Specific attributes Algorithm string // Anki2 AlgorithmSettings map[string]any // SRS-specific attributes }
type ConfigFile ¶
type ConfigFile struct { Core ConfigCore Medias ConfigMedias Remote ConfigRemote Deck map[string]*ConfigDeck Search map[string]*ConfigSearch Reference map[string]*ConfigReference }
Note: Fields must be public for toml package to unmarshall
func (*ConfigFile) ConfigureFSRemote ¶
func (f *ConfigFile) ConfigureFSRemote(dir string) *ConfigFile
ConfigureFSRemote defines a local remote using the file system.
func (*ConfigFile) ConfigureS3Remote ¶
func (f *ConfigFile) ConfigureS3Remote(bucketName, accessKey, secretKey string) *ConfigFile
ConfigureS3Remote defines a remote using a S3 backend.
func (*ConfigFile) SupportExtension ¶
func (f *ConfigFile) SupportExtension(path string) bool
SupportExtension checks if the given file extension must be considered.
type ConfigLintRule ¶
type ConfigLintRule struct { // Name of the rule. Must exists in the registry of rules. Name string `yaml:"name"` // Severity of the rule: "error", "warning". Default to "error". Severity string `yaml:"severity"` // Optional arguments for the rule. Args []string `yaml:"args"` // PathRestrictions returns on which paths to evaluate the rule. // Glob expressions are supported and ! as prefix indicated to exclude. Includes GlobPaths `yaml:"includes"` }
type ConfigLintSchema ¶
type ConfigLintSchema struct { // Name of the schema used when reporting violations. Name string `yaml:"name"` Kind string `yaml:"kind"` Path string `yaml:"path"` Attributes []*ConfigLintSchemaAttribute `yaml:"attributes"` }
func (ConfigLintSchema) MatchesPath ¶
func (c ConfigLintSchema) MatchesPath(path string) bool
type ConfigLintSchemaAttribute ¶
type ConfigLintSchemaAttribute struct { Name string `yaml:"name"` Type string `yaml:"type"` Aliases []string `yaml:"aliases"` Pattern string `yaml:"pattern"` Required *bool `yaml:"required"` Inherit *bool `yaml:"inherit"` }
func GetSchemaAttributes ¶
func GetSchemaAttributes(relativePath string, kind NoteKind) []*ConfigLintSchemaAttribute
GetSchemaAttributes calculates the list of declared attributes for a given note.
func (ConfigLintSchemaAttribute) String ¶
func (a ConfigLintSchemaAttribute) String() string
type ConfigMedias ¶
type ConfigReference ¶
type ConfigRemote ¶
type ConfigSearch ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) BeginTransaction ¶
BeginTransaction starts a new transaction.
func (*DB) BlobExists ¶
BlobExists checks if a blob exists locally.
func (*DB) CommitTransaction ¶
CommitTransaction ends the current transaction.
func (*DB) CompressCommit ¶
CompressCommit remove obsolete pack objects and merge small pack files together.
func (*DB) CompressPackFile ¶
CompressPackFile parses a pack file to remove obsolete pack objects.
func (*DB) DeleteBlob ¶
DeleteBlob removes a single blob on disk
func (*DB) DeleteBlobs ¶
DeleteBlobs removes all blobs on disk from a media
func (*DB) DeletePackFile ¶
DeletePackFile removes a single pack file on disk
func (*DB) ObjectExists ¶
ObjectExists checks if a blob exists locally.
func (*DB) PrintIndex ¶
func (db *DB) PrintIndex()
func (*DB) ReadCommit ¶
ReadCommit checks for a commit with the given id.
func (*DB) ReadCommittedObject ¶
func (db *DB) ReadCommittedObject(oid string) (StatefulObject, error)
ReadCommittedObject reads the last known committed version of stateful object on disk.
func (*DB) ReadLastStagedOrCommittedObject ¶
func (db *DB) ReadLastStagedOrCommittedObject(oid string) (StatefulObject, error)
ReadLastStagedOrCommittedObject reads the last known version of stateful object in staging area or in commits.
func (*DB) ReadLastStagedOrCommittedObjectFromDB ¶
func (db *DB) ReadLastStagedOrCommittedObjectFromDB(oid string) (StatefulObject, error)
ReadLastStagedOrCommittedObjectFromDB reads the last known version (in staging or committed) by rereading the database.
func (*DB) ReadPackFile ¶
ReadPackFile reads a pack file on disk.
func (*DB) ReadPackFilesFromCommit ¶
ReadPackFilesFromCommit reads all pack files referenced by the commit.
func (*DB) RollbackTransaction ¶
RollbackTransaction aborts the current transaction.
func (*DB) StageObject ¶
func (db *DB) StageObject(obj StatefulObject) error
func (*DB) StatsOnDisk ¶
func (db *DB) StatsOnDisk() (*StatsOnDisk, error)
StatsOnDisk returns various statistics about the .nt/objects directory.
type FSRemote ¶
type FSRemote struct {
// contains filtered or unexported fields
}
func NewFSRemote ¶
func (*FSRemote) DeleteObject ¶
type Feedback ¶
type Feedback string
const ( // Anki-inspired feedbacks FeedbackEasy Feedback = "easy" FeedbackGood Feedback = "good" FeedbackAgain Feedback = "again" FeedbackHard Feedback = "hard" // Special feedbacks FeedbackTooEasy Feedback = "too-easy" // Used to bury a card to max interval FeedbackTooHard Feedback = "too-hard" // Used to relearn a card from scratch )
type File ¶
type File struct { // A unique identifier among all files OID string `yaml:"oid"` // A unique human-friendly slug Slug string `yaml:"slug"` // Optional parent file (= index.md) ParentFileOID string `yaml:"file_oid,omitempty"` ParentFile *File `yaml:"-"` // Lazy-loaded // A relative path to the repository directory RelativePath string `yaml:"relative_path"` // The full wikilink to this file (without the extension) Wikilink string `yaml:"wikilink"` // The FrontMatter for the note file FrontMatter *yaml.Node `yaml:"front_matter"` // Merged attributes Attributes map[string]interface{} `yaml:"attributes,omitempty"` // Original title of the main heading without leading # characters Title string `yaml:"title,omitempty"` // Short title of the main heading without the kind prefix if present ShortTitle string `yaml:"short_title,omitempty"` Body string `yaml:"body"` BodyLine int `yaml:"body_line"` // Permission of the file (required to save back) Mode fs.FileMode `yaml:"mode"` // Size of the file (can be useful to detect changes) Size int64 `yaml:"size"` // Hash of the content (can be useful to detect changes too) Hash string `yaml:"hash"` // Content last modification date MTime time.Time `yaml:"mtime"` CreatedAt time.Time `yaml:"created_at"` UpdatedAt time.Time `yaml:"updated_at"` DeletedAt time.Time `yaml:"deleted_at,omitempty"` LastCheckedAt time.Time `yaml:"-"` // contains filtered or unexported fields }
func NewEmptyFile ¶
func NewFileFromAttributes ¶
func NewFileFromParsedFile ¶
func NewFileFromParsedFile(parent *File, parsedFile *ParsedFileOld) *File
func (*File) AbsoluteBodyLine ¶
AbsoluteBodyLine returns the line number in the file by taking into consideration the front matter.
func (*File) FindFlashcardByTitle ¶
FindFlashcardByTitle searches for a given flashcard based on its title.
func (*File) FindNoteByKindAndShortTitle ¶
FindNoteByKindAndShortTitle searches for a given note based on its kind and title.
func (*File) ForceState ¶
func (*File) FormatToHTML ¶
func (*File) FormatToJSON ¶
func (*File) FormatToMarkdown ¶
func (*File) FormatToText ¶
func (*File) FormatToYAML ¶
func (*File) FrontMatterString ¶
FrontMatterString formats the current attributes to the YAML front matter format.
func (*File) GetAttribute ¶
GetAttribute extracts a single attribute value at the top.
func (*File) GetAttributes ¶
GetAttributes returns all file-specific and inherited attributes.
func (*File) GetFlashcards ¶
GetFlashcards extracts flashcards from the file.
func (*File) ModificationTime ¶
func (*File) SaveOnDisk ¶
func (*File) SetAttribute ¶
SetAttribute overrides or defines a single attribute.
func (*File) SubObjects ¶
func (f *File) SubObjects() []StatefulObject
type Flashcard ¶
type Flashcard struct { OID string `yaml:"oid"` // Short title of the note (denormalized field) ShortTitle string `yaml:"short_title"` // File FileOID string `yaml:"file_oid"` File *File `yaml:"-"` // Lazy-loaded // Note representing the flashcard NoteOID string `yaml:"note_oid"` Note *Note `yaml:"-"` // Lazy-loaded // The filepath of the file containing the note (denormalized field) RelativePath string `yaml:"relative_path"` // List of tags Tags []string `yaml:"tags,omitempty"` // Fields in Markdown (best for editing) FrontMarkdown string `yaml:"front_markdown"` BackMarkdown string `yaml:"back_markdown"` // Fields in HTML (best for rendering) FrontHTML string `yaml:"front_html"` BackHTML string `yaml:"back_html"` // Fields in raw text (best for indexing) FrontText string `yaml:"front_text"` BackText string `yaml:"back_text"` // Timestamps to track changes CreatedAt time.Time `yaml:"created_at"` UpdatedAt time.Time `yaml:"updated_at"` DeletedAt time.Time `yaml:"deleted_at,omitempty"` LastCheckedAt time.Time `yaml:"-"` // SRS DueAt time.Time `yaml:"due_at,omitempty"` StudiedAt time.Time `yaml:"studied_at,omitempty"` Settings map[string]any `yaml:"settings,omitempty"` // contains filtered or unexported fields }
func NewFlashcard ¶
NewFlashcard initializes a new flashcard.
func NewOrExistingFlashcard ¶
func QueryFlashcard ¶
func QueryFlashcards ¶
func (*Flashcard) ForceState ¶
func (*Flashcard) ModificationTime ¶
func (*Flashcard) SubObjects ¶
func (f *Flashcard) SubObjects() []StatefulObject
type GlobPath ¶
type GlobPath string
type IgnoreFile ¶
type IgnoreFile struct {
Entries GlobPaths
}
func (*IgnoreFile) MustExcludeFile ¶
func (i *IgnoreFile) MustExcludeFile(path string, dir bool) bool
type Index ¶
type Index struct { Objects []*IndexObject `yaml:"objects"` // Mapping between pack files and their commit OID PackFiles map[string]string `yaml:"packfiles"` // A list of pack files that is known to be orphans OrphanPackFiles []*IndexOrphanPackFile `yaml:"orphan_packfiles"` // A list of blobs that is known to be orphans OrphanBlobs []*IndexOrphanBlob `yaml:"orphan_blobs"` StagingArea StagingArea `yaml:"staging"` // contains filtered or unexported fields }
Index See https://git-scm.com/docs/index-format for inspiration.
The index file is used to determine if an object is new and to quickly locate which the commit file containing the object otherwise. Useful when adding or restoring objects.
func NewIndexFromPath ¶
NewIndexFromPath loads an index file from a file.
func (*Index) AppendPackFile ¶
AppendPackFile completes the index with object from a pack file.
func (*Index) CloneForRemote ¶
CloneForRemote prepares a cleaned index before a push.
func (*Index) CountChanges ¶
CountChanges returns the number of changes currently present in the staging area.
func (*Index) CreateCommitFromStagingArea ¶
CreateCommit generates a new commit from current changes in the staging area.
func (*Index) FindCommitContaining ¶
FindCommitContaining returns the commit associated with a given object.
func (*Index) FindPackFileContaining ¶
FindPackFileContaining returns the pack file associated with a given object.
func (*Index) IsOrphanBlob ¶
IsOrphanBlob checks if the blob has already beeing deleted.
func (*Index) ReadIndexObject ¶
func (i *Index) ReadIndexObject(objectOID string) (*IndexObject, bool)
ReadIndexObject searches for the given object in the index.
func (*Index) StageObject ¶
func (i *Index) StageObject(obj StatefulObject) error
StageObject registers a changed object into the staging area
type IndexDiff ¶
type IndexDiff struct { // Objects present only in the compared index MissingObjects []*IndexObject // Pack Files no longer present in the compared index MissingOrphanPackFiles []string // Blobs no longer present in the compared index MissingOrphanBlobs []string }
type IndexObject ¶
type IndexObject struct { OID string `yaml:"oid"` Kind string `yaml:"kind"` MTime time.Time `yaml:"mtime"` // The commit (and its packfile) containing the latest version (empty for uncommitted object) CommitOID string `yaml:"commit_oid"` PackFileOID string `yaml:"packfile_oid"` }
func (IndexObject) String ¶
func (i IndexObject) String() string
type IndexOrphanBlob ¶
type IndexOrphanPackFile ¶
type Link ¶
type Link struct { OID string `yaml:"oid"` NoteOID string `yaml:"note_oid"` // The filepath of the file containing the note (denormalized field) RelativePath string `yaml:"relative_path"` // The link text Text string `yaml:"text"` // The link destination URL string `yaml:"url"` // The optional link title Title string `yaml:"title"` // The optional GO name GoName string `yaml:"go_name"` // Timestamps to track changes CreatedAt time.Time `yaml:"created_at"` UpdatedAt time.Time `yaml:"updated_at"` DeletedAt time.Time `yaml:"deleted_at,omitempty"` LastCheckedAt time.Time `yaml:"-"` // contains filtered or unexported fields }
func NewOrExistingLink ¶
func (*Link) ForceState ¶
func (*Link) ModificationTime ¶
func (*Link) SubObjects ¶
func (l *Link) SubObjects() []StatefulObject
type LintFile ¶
type LintFile struct { Rules []ConfigLintRule `yaml:"rules"` Schemas []ConfigLintSchema `yaml:"schemas"` }
func (*LintFile) GetAttributeDefinition ¶
func (l *LintFile) GetAttributeDefinition(name string, filter func(schema ConfigLintSchema) bool) *ConfigLintSchemaAttribute
GetAttributeDefinition returns the attribute definition to use.
func (*LintFile) IsInheritableAttribute ¶
IsInheritableAttribute returns if an attribute can be inherited between files/notes.
type LintResult ¶
type LintResult struct { AnalyzedFiles int AffectedFiles int Warnings []*Violation Errors []*Violation }
func (*LintResult) Append ¶
func (r *LintResult) Append(violations ...*Violation)
Append merges new violations into the current result.
func (LintResult) String ¶
func (r LintResult) String() string
type LintRule ¶
type LintRule func(*ParsedFileOld, []string) ([]*Violation, error)
LintRule describes the interface that rules must conform.
type LintRuleDefinition ¶
type LintRuleDefinition struct {
Eval LintRule
}
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func CurrentLogger ¶
func CurrentLogger() *Logger
func (*Logger) SetVerboseLevel ¶
func (l *Logger) SetVerboseLevel(level VerboseLevel) *Logger
SetVerboseLevel overrides the default verbose level
type MarkdownFile ¶
type MarkdownFile struct { AbsolutePath string Content []byte LStat fs.FileInfo Stat fs.FileInfo FrontMatter string Body string BodyLine int }
func ParseMarkdownFile ¶
func ParseMarkdownFile(path string) (*MarkdownFile, error)
ParseMarkdownFile parses a Markdown file.
func (*MarkdownFile) FrontMatterAsMap ¶
func (f *MarkdownFile) FrontMatterAsMap() (map[string]interface{}, error)
func (*MarkdownFile) FrontMatterAsNode ¶
func (f *MarkdownFile) FrontMatterAsNode() (*yaml.Node, error)
func (*MarkdownFile) GetSections ¶
func (m *MarkdownFile) GetSections() ([]*MarkdownSection, error)
func (*MarkdownFile) GetTopSection ¶
func (m *MarkdownFile) GetTopSection() (*MarkdownSection, error)
func (*MarkdownFile) LastUpdateDate ¶
func (m *MarkdownFile) LastUpdateDate() time.Time
func (*MarkdownFile) ToParsedFile ¶
func (m *MarkdownFile) ToParsedFile() (*ParsedFileNew, error)
func (*MarkdownFile) WalkSections ¶
func (m *MarkdownFile) WalkSections(walkFn func(parent *MarkdownSection, current *MarkdownSection, children []*MarkdownSection) error) error
type MarkdownSection ¶
type MarkdownSection struct { Parent *MarkdownSection HeadingText string HeadingLevel int ContentText string FileLineStart int // 1-based index based on Markdown file FileLineEnd int BodyLineStart int // 1-based index based on body (ignored the Front Matter) BodyLineEnd int }
func (MarkdownSection) String ¶
func (m MarkdownSection) String() string
type MatchedFile ¶
type Media ¶
type Media struct { OID string `yaml:"oid"` // Relative path RelativePath string `yaml:"relative_path"` // Type of media MediaKind MediaKind `yaml:"kind"` // Media exists on disk Dangling bool `yaml:"dangling"` // File extension in lowercase Extension string `yaml:"extension"` // Content last modification date MTime time.Time `yaml:"mtime"` // MD5 Checksum Hash string `yaml:"hash"` // Size of the file Size int64 `yaml:"size"` // Permission of the file Mode fs.FileMode `yaml:"mode"` // Eager-loaded list of blobs BlobRefs []*BlobRef `yaml:"blobs"` // Timestamps to track changes CreatedAt time.Time `yaml:"created_at"` UpdatedAt time.Time `yaml:"updated_at"` DeletedAt time.Time `yaml:"deleted_at,omitempty"` LastCheckedAt time.Time `yaml:"-"` // contains filtered or unexported fields }
func NewOrExistingMedia ¶
func QueryMedias ¶
func (*Media) DeleteBlobs ¶
func (*Media) ForceState ¶
func (*Media) InsertBlobs ¶
func (*Media) ModificationTime ¶
func (*Media) SubObjects ¶
func (m *Media) SubObjects() []StatefulObject
func (*Media) UpdateBlobs ¶
func (m *Media) UpdateBlobs()
type MediaKind ¶
type MediaKind string
func DetectMediaKind ¶
DetectMediaKind returns the media kind based on a file path.
type Note ¶
type Note struct { // A unique identifier among all files OID string `yaml:"oid"` // A unique human-friendly slug Slug string `yaml:"slug"` // File containing the note FileOID string `yaml:"file_oid"` File *File `yaml:"-"` // Lazy-loaded // Parent Note surrounding the note ParentNoteOID string `yaml:"parent_note_oid"` ParentNote *Note `yaml:"-"` // Lazy-loaded // Type of note NoteKind NoteKind `yaml:"kind"` // Original title of the note without leading # characters Title string `yaml:"title"` // Long title of the note without the kind prefix but prefixed by parent note's short titles LongTitle string `yaml:"long_title"` // Short title of the note without the kind prefix ShortTitle string `yaml:"short_title"` // The filepath of the file containing the note (denormalized field) RelativePath string `yaml:"relative_path"` // The full wikilink to this note (without the extension) Wikilink string `yaml:"wikilink"` // Merged attributes Attributes map[string]interface{} `yaml:"attributes,omitempty"` // Merged tags Tags []string `yaml:"tags,omitempty"` // Line number (1-based index) of the note section title Line int `yaml:"line"` // Content in various formats (best for editing, rendering, writing, etc.) ContentRaw string `yaml:"content_raw"` Hash string `yaml:"content_hash"` TitleMarkdown string `yaml:"title_markdown"` TitleHTML string `yaml:"title_html"` TitleText string `yaml:"title_text"` ContentMarkdown string `yaml:"content_markdown"` ContentHTML string `yaml:"content_html"` ContentText string `yaml:"content_text"` CommentMarkdown string `yaml:"comment_markdown,omitempty"` CommentHTML string `yaml:"comment_html,omitempty"` CommentText string `yaml:"comment_text,omitempty"` // Timestamps to track changes CreatedAt time.Time `yaml:"created_at"` UpdatedAt time.Time `yaml:"updated_at"` DeletedAt time.Time `yaml:"deleted_at,omitempty"` LastCheckedAt time.Time `yaml:"-"` // contains filtered or unexported fields }
func NewNote ¶
func NewNote(f *File, parent *Note, parsedNote *ParsedNoteOld) *Note
NewNote creates a new note from given attributes.
func NewOrExistingNote ¶
func NewOrExistingNote(f *File, parent *Note, parsedNote *ParsedNoteOld) *Note
NewOrExistingNote loads and updates an existing note or creates a new one if new.
func (*Note) ForceState ¶
func (*Note) FormatToHTML ¶
func (*Note) FormatToJSON ¶
func (*Note) FormatToMarkdown ¶
func (*Note) FormatToText ¶
func (*Note) FormatToYAML ¶
func (*Note) GetAttribute ¶
func (*Note) GetAttributeString ¶
func (*Note) GetAttributes ¶
func (*Note) GetNoteAttributes ¶
GetNoteAttributes returns the attributes specifically present on the note.
func (*Note) GetNoteTags ¶
GetNoteTags returns the tags specifically present on the note.
func (*Note) GetParentNote ¶
GetParentNote returns the parent note, loading it from database if necessary.
func (*Note) GetReminders ¶
GetReminders extracts reminders from the note.
func (*Note) HasAttribute ¶
func (*Note) ModificationTime ¶
func (*Note) ReplaceMediasByOIDLinks ¶
ReplaceMediasByOIDLinks replaces all non-dangling links by a OID fake link.
func (*Note) SetAttribute ¶
func (*Note) SubObjects ¶
func (n *Note) SubObjects() []StatefulObject
type NoteKind ¶
type NoteKind string
const ( KindFree NoteKind = "free" KindReference NoteKind = "reference" KindNote NoteKind = "note" KindFlashcard NoteKind = "flashcard" KindCheatsheet NoteKind = "cheatsheet" KindQuote NoteKind = "quote" KindJournal NoteKind = "journal" KindTodo NoteKind = "todo" KindArtwork NoteKind = "artwork" KindSnippet NoteKind = "snippet" )
type OIDGenerator ¶
type Object ¶
type Object interface { // Kind returns the object kind to determine which kind of object to create. Kind() string // UniqueOID returns the OID of the object. UniqueOID() string // ModificationTime returns the last modification time. ModificationTime() time.Time // SubObjects returns the objects directly contained by this object. SubObjects() []StatefulObject // Blobs returns the optional blobs associated with this object. Blobs() []*BlobRef // Relations returns the relations where the current object is the source. Relations() []*Relation // Read rereads the object from YAML. Read(r io.Reader) error // Write writes the object to YAML. Write(w io.Writer) error // String returns a one-line description String() string }
Object groups method common to all kinds of managed objects. Useful when creating commits in a generic way where a single commit groups different kinds of objects inside the same object.
type ObjectData ¶
type ObjectData []byte // alias to serialize to YAML easily
ObjectData serializes any Object to base64 after zlib compression.
func NewObjectData ¶
func NewObjectData(obj Object) (ObjectData, error)
NewObjectData creates a compressed-string representation of the object.
func (ObjectData) MarshalYAML ¶
func (od ObjectData) MarshalYAML() (interface{}, error)
func (ObjectData) Unmarshal ¶
func (od ObjectData) Unmarshal(target interface{}) error
func (*ObjectData) UnmarshalYAML ¶
func (od *ObjectData) UnmarshalYAML(node *yaml.Node) error
type PackFile ¶
type PackFile struct { OID string `yaml:"oid"` CTime time.Time `yaml:"ctime"` MTime time.Time `yaml:"mtime"` PackObjects []*PackObject `yaml:"objects"` }
func NewPackFileFromPath ¶
NewPackFileFromPath reads a pack file file on disk or returns an empty instance.
func NewPackFileWithOID ¶
NewPackFileWithOID initializes a new empty pack file with a given OID.
func (*PackFile) AppendObject ¶
func (p *PackFile) AppendObject(obj StatefulObject) error
AppendObject registers a new object inside the pack file.
func (*PackFile) AppendPackObject ¶
func (p *PackFile) AppendPackObject(obj *PackObject)
AppendPackObject registers a new stateful object inside the pack file.
func (*PackFile) AppendStagingObject ¶
func (p *PackFile) AppendStagingObject(obj *StagingObject)
Append registers a new staged object inside a pack file.
func (*PackFile) GetPackObject ¶
func (p *PackFile) GetPackObject(oid string) (*PackObject, bool)
GetPackObject retrieves an object from a pack file.
func (*PackFile) Merge ¶
Merge tries to merge two pack files together by returning a new pack file containing the concatenation of both pack files.
func (*PackFile) UnmarshallObject ¶
UnmarshallObject extract a single object from a commit.
type PackFileRef ¶
type PackFileRef struct { OID string `yaml:"oid"` CTime time.Time `yaml:"ctime"` MTime time.Time `yaml:"mtime"` }
func NewPackFileRefWithOID ¶
func NewPackFileRefWithOID(oid string) *PackFileRef
NewPackFileRefWithOID initializes a new empty pack file ref with a given OID.
type PackFileRefs ¶
type PackFileRefs []*PackFileRef
Convenient type to add methods
func (PackFileRefs) OIDs ¶
func (p PackFileRefs) OIDs() []string
type PackObject ¶
type PackObject struct { OID string `yaml:"oid"` Kind string `yaml:"kind"` State State `yaml:"state"` // (A) added, (D) deleted, (M) modified, (R) renamed MTime time.Time `yaml:"mtime"` Description string `yaml:"desc"` Data ObjectData `yaml:"data"` }
func (*PackObject) ReadObject ¶
func (p *PackObject) ReadObject() StatefulObject
ReadObject recreates the core object from a commit object.
type ParsedFileNew ¶
type ParsedFileNew struct { Markdown *MarkdownFile // Main Heading Slug string Title string ShortTitle string // File attributes extracted from the Front Matter FileAttributes map[string]interface{} // Extracted objects Notes []*ParsedNoteNew Medias []*ParsedMediaNew }
func ParseFileFromMarkdownFile ¶
func ParseFileFromMarkdownFile(md *MarkdownFile) (*ParsedFileNew, error)
type ParsedFileOld ¶
type ParsedFileOld struct { // The paths to the file AbsolutePath string RelativePath string // Stat Stat fs.FileInfo LStat fs.FileInfo // The raw file bytes Bytes []byte // Main Heading Slug string Title string ShortTitle string // The YAML Front Matter FrontMatter *yaml.Node // File attributes extracted from the Front Matter FileAttributes map[string]interface{} // The body (= content minus the front matter) Body string BodyLine int }
func ParseFile ¶
func ParseFile(path string) (*ParsedFileOld, error)
ParseFile contains the main logic to parse a raw note file.
func (*ParsedFileOld) AbsoluteBodyLine ¶
func (f *ParsedFileOld) AbsoluteBodyLine(bodyLine int) int
AbsoluteBodyLine returns the line number in the file by taking into consideration the front matter.
func (*ParsedFileOld) Content ¶
func (f *ParsedFileOld) Content() string
Content returns the raw file content.
func (*ParsedFileOld) GetTags ¶
func (f *ParsedFileOld) GetTags() []string
GetTags returns all defined tags on file.
func (*ParsedFileOld) HasTag ¶
func (f *ParsedFileOld) HasTag(tagName string) bool
HasTag returns if the file has specifically a given tag.
func (*ParsedFileOld) Wikilinks ¶
func (f *ParsedFileOld) Wikilinks() []*Wikilink
Wikilinks returns the wikilinks present inside a file.
type ParsedFlashcardNew ¶
type ParsedLinkNew ¶
type ParsedMediaNew ¶
type ParsedMediaNew struct { // The path as specified in the file. (Ex: "../medias/pic.png") RawPath string // The absolute path AbsolutePath string // The file extension Extension string // Type of media MediaKind MediaKind // Media exists on disk Dangling bool // Content last modification date MTime time.Time // Size of the file Size int64 // Permission of the file Mode fs.FileMode // Line number where the link present. Line int }
type ParsedMediaOld ¶
type ParsedMediaOld struct { // The path as specified in the file. (Ex: "../medias/pic.png") RawPath string // The path relative to the root repository directory. (Ex: "references/medias/pic.png") RelativePath string // The absolute path. (Ex: "$HOME/notes/references/medias/pic.png") AbsolutePath string // Line number where the link present. Line int }
func ParseMedias ¶
func ParseMedias(fileRelativePath, fileBody string) []*ParsedMediaOld
ParseMedias extracts raw paths from a file or note body content.
type ParsedNoteNew ¶
type ParsedNoteNew struct { Level int Kind NoteKind // Heading Slug string Title string ShortTitle string Line int Body string NoteAttributes map[string]interface{} NoteTags []string // Extracted objects Flashcard *ParsedFlashcardNew Links []*ParsedLinkNew Reminders []*ParsedReminderNew }
ParsedNote represents a single raw note inside a file.
type ParsedNoteOld ¶
type ParsedNoteOld struct { Level int Kind NoteKind Slug string Title string ShortTitle string Line int Body string NoteAttributes map[string]interface{} NoteTags []string }
ParsedNote represents a single raw note inside a file.
func MustParseNote ¶
func MustParseNote(noteContent string, fileSlug string) *ParsedNoteOld
MustParseNote is pratical in unit test to setup a new note.
func ParseNotes ¶
func ParseNotes(fileBody string, fileSlug string) []*ParsedNoteOld
ParseNotes extracts the notes from a file body.
func (*ParsedNoteOld) Hash ¶
func (n *ParsedNoteOld) Hash() string
Hash returns the current hash to use when searching for an existing note in database to avoid recreating it.
func (*ParsedNoteOld) Wikilinks ¶
func (n *ParsedNoteOld) Wikilinks() []*Wikilink
Wikilinks returns the wikilinks present in the note.
type ParsedReminderNew ¶
type Query ¶
type QueueType ¶
type QueueType int
const ( QueueSuspend QueueType = -1 // leeches as manual suspension is not supported QueueNew QueueType = 0 // new (never shown) QueueLearn QueueType = 1 // learning/relearning QueueReview QueueType = 2 // review (as for type) QueueDayLearn QueueType = 3 // in learning, next review in at least a day after the previous review )
type Relation ¶
type Relation struct { // Source SourceOID string `yaml:"source_oid"` SourceKind string `yaml:"source_kind"` // Target TargetOID string `yaml:"target_oid"` TargetKind string `yaml:"target_kind"` Type string `yaml:"type"` }
func NewRelation ¶
func NewRelation(oidA string, kindA string, oidB string, kindB string, relationType string) *Relation
NewRelation instantiates a new relation.
func NewRelationFromObjects ¶
func QueryRelation ¶
func QueryRelations ¶
type Reminder ¶
type Reminder struct { OID string `yaml:"oid"` // File FileOID string `yaml:"file_oid"` File *File `yaml:"-"` // Lazy-loaded // Note representing the flashcard NoteOID string `yaml:"note_oid"` Note *Note `yaml:"-"` // Lazy-loaded // The filepath of the file containing the note (denormalized field) RelativePath string `yaml:"relative_path"` // Description DescriptionRaw string `yaml:"description_raw"` DescriptionMarkdown string `yaml:"description_markdown"` DescriptionHTML string `yaml:"description_html"` DescriptionText string `yaml:"description_text"` // Tag value containig the formula to determine the next occurence Tag string `yaml:"tag"` // Timestamps to track progress LastPerformedAt time.Time `yaml:"last_performed_at"` NextPerformedAt time.Time `yaml:"next_performed_at"` // Timestamps to track changes CreatedAt time.Time `yaml:"created_at"` UpdatedAt time.Time `yaml:"updated_at"` DeletedAt time.Time `yaml:"deleted_at,omitempty"` LastCheckedAt time.Time `yaml:"-"` // contains filtered or unexported fields }
func NewOrExistingReminder ¶
func NewReminder ¶
NewReminder instantiates a new reminder.
func QueryReminder ¶
func QueryReminders ¶
func (*Reminder) ForceState ¶
func (*Reminder) ModificationTime ¶
func (*Reminder) SubObjects ¶
func (r *Reminder) SubObjects() []StatefulObject
type Remote ¶
type Remote interface { GetObject(key string) ([]byte, error) PutObject(key string, content []byte) error DeleteObject(key string) error }
Remote provides an abstraction in front of remote implementations.
A remote must be able to save different files: - info files (ex: commit-graph) - object files (ex: Commit, or File, Note, Flaschard, ...) - blob files (ex: medias in various sizes)
A remote is free to save files in any format as long as it can retrieve the same field when querying using the same key.
type Repository ¶
type Repository struct {
Path string `yaml:"path"`
}
func CurrentRepository ¶
func CurrentRepository() *Repository
func NewRepository ¶
func NewRepository() (*Repository, error)
func (*Repository) Add ¶
func (r *Repository) Add(paths ...string) error
Add implements the command `nt add`.`
func (*Repository) Close ¶
func (r *Repository) Close()
func (*Repository) CountAttributes ¶
func (r *Repository) CountAttributes() (map[string]int, error)
CountAttributes returns the attributes with their associated count.
func (*Repository) CountFiles ¶
func (r *Repository) CountFiles() (int, error)
CountFiles returns the total number of files.
func (*Repository) CountFlashcards ¶
func (r *Repository) CountFlashcards() (int, error)
CountFlashcards returns the total number of flashcards.
func (*Repository) CountLinks ¶
func (r *Repository) CountLinks() (int, error)
CountLinks returns the total number of links.
func (*Repository) CountMedias ¶
func (r *Repository) CountMedias() (int, error)
CountMedias returns the total number of medias.
func (*Repository) CountNotes ¶
func (r *Repository) CountNotes() (int, error)
CountNotes returns the total number of notes.
func (*Repository) CountNotesByKind ¶
func (r *Repository) CountNotesByKind() (map[NoteKind]int, error)
CountNotesByKind returns the total number of notes for every kind.
func (*Repository) CountObjectsByType ¶
func (r *Repository) CountObjectsByType() (map[string]int, error)
CountObjectsByType returns the total number of objects for every type.
func (*Repository) CountRelations ¶
func (r *Repository) CountRelations() (int, error)
CountRelations returns the total number of relations.
func (*Repository) CountReminders ¶
func (r *Repository) CountReminders() (int, error)
CountReminders returns the total number of reminders.
func (*Repository) CountTags ¶
func (r *Repository) CountTags() (map[string]int, error)
CountTags returns the tags with their associated count.
func (*Repository) DeleteRelations ¶
func (r *Repository) DeleteRelations(obj Object) error
func (*Repository) Diff ¶
func (r *Repository) Diff(staged bool) (string, error)
Diff show changes between commits and working tree.
func (*Repository) DumpNotes ¶
func (r *Repository) DumpNotes() error
func (*Repository) FindBlobFromOID ¶
func (r *Repository) FindBlobFromOID(oid string) (*BlobRef, error)
func (*Repository) FindBlobsFromMedia ¶
func (r *Repository) FindBlobsFromMedia(mediaOID string) ([]*BlobRef, error)
func (*Repository) FindFileByRelativePath ¶
func (r *Repository) FindFileByRelativePath(relativePath string) (*File, error)
func (*Repository) FindFileByWikilink ¶
func (r *Repository) FindFileByWikilink(wikilink string) (*File, error)
func (*Repository) FindFilesByRelativePathPrefix ¶
func (r *Repository) FindFilesByRelativePathPrefix(relativePathPrefix string) ([]*File, error)
func (*Repository) FindFilesByWikilink ¶
func (r *Repository) FindFilesByWikilink(wikilink string) ([]*File, error)
func (*Repository) FindFilesLastCheckedBefore ¶
func (*Repository) FindFlashcardByHash ¶
func (r *Repository) FindFlashcardByHash(hash string) (*Flashcard, error)
func (*Repository) FindFlashcardByShortTitle ¶
func (r *Repository) FindFlashcardByShortTitle(shortTitle string) (*Flashcard, error)
func (*Repository) FindFlashcardsLastCheckedBefore ¶
func (*Repository) FindLinkByGoName ¶
func (r *Repository) FindLinkByGoName(goName string) (*Link, error)
func (*Repository) FindLinksByText ¶
func (r *Repository) FindLinksByText(text string) ([]*Link, error)
func (*Repository) FindLinksLastCheckedBefore ¶
func (*Repository) FindMatchingNote ¶
func (r *Repository) FindMatchingNote(relativePath string, parsedNote *ParsedNoteOld) (*Note, error)
func (*Repository) FindMediaByHash ¶
func (r *Repository) FindMediaByHash(hash string) (*Media, error)
func (*Repository) FindMediaByRelativePath ¶
func (r *Repository) FindMediaByRelativePath(relativePath string) (*Media, error)
func (*Repository) FindMediasLastCheckedBefore ¶
func (r *Repository) FindMediasLastCheckedBefore(point time.Time) ([]*Media, error)
func (*Repository) FindNoteByHash ¶
func (r *Repository) FindNoteByHash(hash string) (*Note, error)
func (*Repository) FindNoteByPathAndTitle ¶
func (r *Repository) FindNoteByPathAndTitle(relativePath string, title string) (*Note, error)
func (*Repository) FindNoteBySlug ¶
func (r *Repository) FindNoteBySlug(slug string) (*Note, error)
func (*Repository) FindNoteByTitle ¶
func (r *Repository) FindNoteByTitle(title string) (*Note, error)
func (*Repository) FindNoteByWikilink ¶
func (r *Repository) FindNoteByWikilink(wikilink string) (*Note, error)
func (*Repository) FindNotesByFileOID ¶
func (r *Repository) FindNotesByFileOID(oid string) ([]*Note, error)
func (*Repository) FindNotesByWikilink ¶
func (r *Repository) FindNotesByWikilink(wikilink string) ([]*Note, error)
func (*Repository) FindNotesLastCheckedBefore ¶
func (*Repository) FindRelations ¶
func (r *Repository) FindRelations() ([]*Relation, error)
func (*Repository) FindRelationsFrom ¶
func (r *Repository) FindRelationsFrom(oid string) ([]*Relation, error)
func (*Repository) FindRelationsTo ¶
func (r *Repository) FindRelationsTo(oid string) ([]*Relation, error)
func (*Repository) FindReminders ¶
func (r *Repository) FindReminders() ([]*Reminder, error)
func (*Repository) FindRemindersByUpcomingDate ¶
func (r *Repository) FindRemindersByUpcomingDate(deadline time.Time) ([]*Reminder, error)
func (*Repository) FindRemindersLastCheckedBefore ¶
func (*Repository) FindRemindersMatching ¶
func (r *Repository) FindRemindersMatching(noteOID string, descriptionRaw string) ([]*Reminder, error)
func (*Repository) GetAbsolutePath ¶
func (r *Repository) GetAbsolutePath(path string) string
GetAbsolutePath converts a relative path from the repository to an absolute path on disk.
func (*Repository) GetFileRelativePath ¶
func (r *Repository) GetFileRelativePath(fileAbsolutePath string) (string, error)
GetFileRelativePath converts a relative path of a file to a relative path from the repository.
func (*Repository) GetNoteRelativePath ¶
func (r *Repository) GetNoteRelativePath(fileRelativePath string, srcPath string) (string, error)
GetNoteRelativePath converts a relative path from a note to a relative path from the repository root directory.
func (*Repository) Lint ¶
func (r *Repository) Lint(ruleNames []string, paths ...string) (*LintResult, error)
Lint run linter rules on all files under the given paths.
func (*Repository) LoadFileByOID ¶
func (r *Repository) LoadFileByOID(oid string) (*File, error)
func (*Repository) LoadFlashcardByNoteOID ¶
func (r *Repository) LoadFlashcardByNoteOID(noteID string) (*Flashcard, error)
func (*Repository) LoadFlashcardByOID ¶
func (r *Repository) LoadFlashcardByOID(oid string) (*Flashcard, error)
func (*Repository) LoadLinkByOID ¶
func (r *Repository) LoadLinkByOID(oid string) (*Link, error)
func (*Repository) LoadMediaByOID ¶
func (r *Repository) LoadMediaByOID(oid string) (*Media, error)
func (*Repository) LoadNoteByOID ¶
func (r *Repository) LoadNoteByOID(oid string) (*Note, error)
func (*Repository) LoadReminderByOID ¶
func (r *Repository) LoadReminderByOID(oid string) (*Reminder, error)
func (*Repository) SearchNotes ¶
func (r *Repository) SearchNotes(q string) ([]*Note, error)
SearchNotes query notes to find the ones matching a list of criteria.
Examples:
tag:favorite kind:reference kind:note path:projects/
func (*Repository) Stats ¶
func (r *Repository) Stats() (*Stats, error)
Stats returns various statitics about the storage.
func (*Repository) StatsInDB ¶
func (r *Repository) StatsInDB() (*StatsInDB, error)
StatsInDB returns various statistics about the .nt/database.db file.
func (*Repository) Status ¶
func (r *Repository) Status() (string, error)
Status displays current objects in staging area.
func (*Repository) UpdateRelations ¶
func (r *Repository) UpdateRelations(source Object) error
type Review ¶
type Review struct { FlashcardOID string `yaml:"flashcard_oid"` Feedback Feedback `yaml:"feedback"` DurationInMs int `yaml:"duration_ms"` CompletedAt time.Time `yaml:"completed_at"` DueAt time.Time `yaml:"due_at"` Settings map[string]any `yaml:"settings"` // Include algorithm-specific attributes (like the e-factor in SM-2) }
type S3Remote ¶
type S3Remote struct {
// contains filtered or unexported fields
}
func (*S3Remote) DeleteObject ¶
type SQLClient ¶
type SQLClient interface { PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) Prepare(query string) (*sql.Stmt, error) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) Exec(query string, args ...any) (sql.Result, error) QueryRow(query string, args ...any) *sql.Row Query(query string, args ...any) (*sql.Rows, error) }
Queryable provides a common interface between sql.DB and sql.Tx to make methods compatible with both.
type StagingArea ¶
type StagingArea []*StagingObject
func (*StagingArea) ContainsFile ¶
func (sa *StagingArea) ContainsFile(relpath string) (*StagingObject, bool)
Contains file returns the staging object from a given file path.
func (*StagingArea) Count ¶
func (sa *StagingArea) Count() int
Count returns the number of objects inside the staging area.
func (*StagingArea) CountByState ¶
func (sa *StagingArea) CountByState(state State) int
CountByState returns the number of objects inside the staging area in a given state.
func (*StagingArea) ReadObject ¶
func (sa *StagingArea) ReadObject(objectOID string) (StatefulObject, bool)
ReadObject searches for the given object in staging area
func (*StagingArea) ReadStagingObject ¶
func (sa *StagingArea) ReadStagingObject(objectOID string) (*StagingObject, bool)
ReadStagingObject searches for the given staging object in staging area
type StagingObject ¶
type StagingObject struct { PackObject PreviousCommitOID string `yaml:"previous_commit_oid"` PreviousPackFileOID string `yaml:"previous_packfile_oid"` }
func (StagingObject) String ¶
func (s StagingObject) String() string
type StatefulObject ¶
type StatefulObject interface { Object Refresh() (bool, error) // State returns the current state. State() State // ForceState marks the object in the given state ForceState(newState State) // Save persists to DB Save() error }
StatefulObject to represent the subset of updatable objects persisted in database.
type Stats ¶
type Stats struct { OnDisk *StatsOnDisk InDB *StatsInDB }
type StatsInDB ¶
type StatsInDB struct { Objects map[string]int Kinds map[NoteKind]int Tags map[string]int Attributes map[string]int SizeKB int64 }
func NewStatsInDBEmpty ¶
func NewStatsInDBEmpty() *StatsInDB
type StatsOnDisk ¶
type StatsOnDisk struct { // Number of files under .nt/objects ObjectFiles int // Number of commits in .nt/commit-graph Commits int // Number of blobs under .nt/objects Blobs int // Number of objects (file, note, etc.) present in commits Objects map[string]int // Number of objects listed in .nt/objects/index IndexObjects int // Total size of directory .nt/objects TotalSizeKB int64 }
func NewStatsOnDiskEmpty ¶
func NewStatsOnDiskEmpty() *StatsOnDisk
type StorjRemote ¶
type StorjRemote struct {
// contains filtered or unexported fields
}
func NewStorjRemoteFromProject ¶
func NewStorjRemoteFromProject(bucketName string, project *uplink.Project) (*StorjRemote, error)
NewStorjRemoteFromProject instantiates a client using a project (useful for testing purposes).
func NewStorjRemoteWithCredentials ¶
func NewStorjRemoteWithCredentials(bucketName string, accessGrant string) (*StorjRemote, error)
NewStorjRemoteWithCredentials instantiates a client using the access grant.
func (*StorjRemote) DeleteObject ¶
func (r *StorjRemote) DeleteObject(key string) error
type Study ¶
type Study struct { OID string `yaml:"oid"` // Not persisted in database but can be useful to deduplicate, etc. StartedAt time.Time `yaml:"started_at"` // Timestamp when the first card was revealed EndedAt time.Time `yaml:"ended_at"` // Timestamp when the last card was completed Reviews []*Review `yaml:"reviews"` }
func (*Study) ForceState ¶
func (*Study) ModificationTime ¶
func (*Study) SubObjects ¶
func (s *Study) SubObjects() []StatefulObject
type VerboseLevel ¶
type VerboseLevel int
const ( VerboseOff VerboseLevel = iota VerboseInfo VerboseDebug VerboseTrace )
type Violation ¶
type Violation struct { // The name of the violation Name string // The human-readable description of the violation Message string // The relative path to the file containing the violation RelativePath string // The line number in the file containing the violation Line int }
func CheckAttribute ¶
func CheckAttribute(file *ParsedFileOld, args []string) ([]*Violation, error)
CheckAttribute implements the rule "check-attribute"
func MaxLinesBetweenNotes ¶
func MaxLinesBetweenNotes(file *ParsedFileOld, args []string) ([]*Violation, error)
MaxLinesBetweenNotes implements the rule "min-lines-between-notes".
func MinLinesBetweenNotes ¶
func MinLinesBetweenNotes(file *ParsedFileOld, args []string) ([]*Violation, error)
MinLinesBetweenNotes implements the rule "min-lines-between-notes".
func NoAmbiguousWikilink ¶
func NoAmbiguousWikilink(file *ParsedFileOld, args []string) ([]*Violation, error)
NoAmbiguousWikilink implements the rule "no-ambiguous-wikilink"
func NoDanglingMedia ¶
func NoDanglingMedia(file *ParsedFileOld, args []string) ([]*Violation, error)
NoDanglingMedia implements the rule "no-dangling-media".
func NoDeadWikilink ¶
func NoDeadWikilink(file *ParsedFileOld, args []string) ([]*Violation, error)
NoDeadWikilink implements the rule "no-dead-wikilink".
func NoDuplicateNoteTitle ¶
func NoDuplicateNoteTitle(file *ParsedFileOld, args []string) ([]*Violation, error)
NoDuplicateNoteTitle implements the rule "no-duplicate-note-title".
func NoDuplicateSlug ¶
func NoDuplicateSlug(file *ParsedFileOld, args []string) ([]*Violation, error)
NoDuplicateSlug implements the rule "no-duplicate-slug".
func NoExtensionWikilink ¶
func NoExtensionWikilink(file *ParsedFileOld, args []string) ([]*Violation, error)
NoExtensionWikilink implements the rule "no-extension-wikilink".
func NoFreeNote ¶
func NoFreeNote(file *ParsedFileOld, args []string) ([]*Violation, error)
NoFreeNote implements the rule "no-free-note".
func NoteTitleMatch ¶
func NoteTitleMatch(file *ParsedFileOld, args []string) ([]*Violation, error)
NoteTitleMatch implements the rule "note-title-match".
func RequireQuoteTag ¶
func RequireQuoteTag(file *ParsedFileOld, args []string) ([]*Violation, error)
RequireQuoteTag implements the rule "require-quote-tag"
type WIP ¶
type WIP struct {
// contains filtered or unexported fields
}
func (*WIP) FindNoteByWikilink ¶
type Wikilink ¶
Wikilink is an internal link. See https://en.wikipedia.org/wiki/Help:Link
func NewWikilink ¶
NewWikilink instantiates a new wikilink.
func ParseWikilinks ¶
ParseWikilinks extracts wikilinks from a text.
func (*Wikilink) Anchored ¶
Anchored indicates if a link points to a section in the current file. (ex: [[#A section below]])
func (*Wikilink) ContainsExtension ¶
ContainsExtenstion tests if the extension is specified in the link.
func (*Wikilink) Piped ¶
Piped indicates if a text is present to describe the link. (ex: [[link|A text]])