repository

package
v0.0.0-...-432af0c Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IDColor     = color.New(color.Bold, color.FgCyan)
	DateColor   = color.New(color.Faint)
	TagColor    = color.New(color.FgYellow)
	URLColor    = color.New(color.Bold, color.FgMagenta)
	HeaderColor = color.New(color.Bold)
	DimColor    = color.New(color.Faint)
)

Display colors (package-level, can be disabled via NO_COLOR).

View Source
var (
	ErrDuplicate    = errors.New("record already exists")
	ErrNotExists    = errors.New("row does not exist")
	ErrUpdateFailed = errors.New("update failed")
	ErrDeleteFailed = errors.New("delete failed")
)

Functions

func ContentWidth

func ContentWidth() int

ContentWidth calculates the available width for content based on terminal width. This function is deprecated in favor of inline calculations in format functions.

func ExpandDateRange

func ExpandDateRange(start, end string) (string, string, error)

func ExpandEndDate

func ExpandEndDate(dateStr string) (string, error)

ExpandEndDate expands a partial date to the end of that period. E.g., "2025-12" becomes "2025-12-31T23:59:59".

func ExpandStartDate

func ExpandStartDate(dateStr string) (string, error)

ExpandStartDate expands a partial date to the start of that period. E.g., "2025-12" becomes "2025-12-01T00:00:00".

func FTS5Available

func FTS5Available() bool

FTS5Available returns whether FTS5 full-text search is available.

func FormatDate

func FormatDate() string

FormatDate returns the current time formatted for entry timestamps.

func FormatEntryCompact

func FormatEntryCompact(entry Entry, id int64, notruncate bool, showJournal bool) string

FormatEntryCompact formats an entry in git-style compact format. Tags appear inline at the end of the content.

func FormatEntryMinimal

func FormatEntryMinimal(entry Entry, id int64, notruncate bool, showJournal bool) string

FormatEntryMinimal formats an entry with tags at the end of the line.

func FormatEntryTabular

func FormatEntryTabular(entry Entry, id int64, notruncate bool, showJournal bool) string

FormatEntryTabular formats an entry with aligned columns.

func FormatFullEntry

func FormatFullEntry(entry Entry) string

FormatFullEntry formats a complete entry for detailed display. Note: For encrypted entries, the caller should decrypt the content first before calling this function, or the raw encrypted content will be shown.

func FormatSearchResult

func FormatSearchResult(entry Entry, id int64, notruncate bool) string

FormatSearchResult formats an entry for display in search/list results. Defaults to tabular format for backward compatibility.

func OpenBrowser

func OpenBrowser(url string) error

OpenBrowser opens the given URL in the system's default browser.

func ParseDate

func ParseDate(dateStr string) (time.Time, error)

ParseDate parses a date string in the entry timestamp format.

func SaveConfig

func SaveConfig(config Config) error

func SetDefaultJournal

func SetDefaultJournal(name string) error

func SetUp

func SetUp(d getUserConfigDir) (string, error)

SetUp creates the config directory and database file if needed.

func TabularHeader

func TabularHeader(showJournal bool) string

TabularHeader returns the header row for tabular format.

Types

type Config

type Config struct {
	DefaultJournal      string           `json:"default_journal"`
	DateFormat          string           `json:"date_format"`
	DefaultExportFormat string           `json:"default_export_format"`
	Syncthing           *SyncthingConfig `json:"syncthing,omitempty"`
}

Config holds user configuration settings.

func LoadConfig

func LoadConfig() (Config, error)

type DBPathChecker

type DBPathChecker struct {
	// contains filtered or unexported fields
}

DBPathChecker contains the func used to create the user config dir.

func NewDBPathChecker

func NewDBPathChecker(f getUserConfigDir) *DBPathChecker

NewDBPathChecker creates a DBPathChecker using the provided config dir function.

func (*DBPathChecker) Check

func (db *DBPathChecker) Check() bool

Check returns true if the database file exists, false otherwise.

type DisplayFormat

type DisplayFormat int

DisplayFormat represents the output format style.

const (
	FormatTabular DisplayFormat = iota // Default: aligned columns
	FormatCompact                      // Git-style, tags inline with content
	FormatMinimal                      // Tags at end of line
)

func ParseDisplayFormat

func ParseDisplayFormat(s string) DisplayFormat

ParseDisplayFormat converts a string to DisplayFormat.

type Entry

type Entry struct {
	ID          int64
	Time        string
	Content     string
	URL         *string
	Journal     int64
	JournalName string
	Tags        []Tag
	Encrypted   bool
}

Entry represents a journal entry.

type EntryReader

type EntryReader interface {
	GetByID(id int64) (*Entry, error)
	GetByIDWithTags(id int64) (*Entry, error)
	GetByJournal(journalName string) ([]Entry, error)
	GetRecent(limit int, journalName string) ([]Entry, error)
	AllWithTags() ([]Entry, error)
}

EntryReader provides read operations for entries.

type EntryWriter

type EntryWriter interface {
	CreateWithTags(entry Entry, tagNames []string) (*Entry, error)
	Update(id int64, updated Entry) (*Entry, error)
	UpdateWithTags(id int64, entry Entry, tagNames []string) (*Entry, error)
	Delete(id int64) error
}

EntryWriter provides write operations for entries.

type ExportOptions

type ExportOptions struct {
	JournalName       string
	OutputPath        string
	Encrypt           bool
	Passphrase        string
	RemoveAfterExport bool
	DryRun            bool
}

ExportOptions configures journal archive export.

func (ExportOptions) GetFinalOutputPath

func (opts ExportOptions) GetFinalOutputPath() string

GetFinalOutputPath returns the final output path for an export.

type Exporter

type Exporter interface {
	ExportToMarkdown(entries []Entry, w io.Writer) error
	ExportToMarkdownByDate(entries []Entry, w io.Writer) error
	ExportToText(entries []Entry, w io.Writer) error
	ExportJournal(opts ExportOptions) error
	ImportJournal(opts ImportOptions) error
}

Exporter provides export operations for entries.

type ImportOptions

type ImportOptions struct {
	ArchivePath string
	JournalName string
	Passphrase  string
	DryRun      bool
}

ImportOptions configures journal archive import.

type Journal

type Journal struct {
	ID   int64
	Name string
}

Journal represents a named collection of entries.

type JournalMetadata

type JournalMetadata struct {
	JournalName string `json:"journal_name"`
	ExportDate  string `json:"export_date"`
	EntryCount  int    `json:"entry_count"`
	Version     string `json:"version"`
}

JournalMetadata holds metadata for exported journal archives.

type JournalRepository

type JournalRepository interface {
	CreateJournal(journal Journal) (*Journal, error)
	DeleteJournal(name string) error
	JournalExists(name string) (bool, error)
	GetJournalEntryCount(name string) (int, error)
	GetAllJournalEntries(name string) ([]Entry, error)
	ListJournals() ([]Journal, error)
	RenameJournal(oldName, newName string) error
}

JournalRepository provides operations for managing journals.

type Options

type Options struct {
	DBPath string
}

Options holds repository configuration.

type ParsedEntry

type ParsedEntry struct {
	Date    string
	Time    string
	Content string
	Tags    []string
	URL     *string
}

ParsedEntry represents an entry parsed from markdown during import.

type SQLiteRepository

type SQLiteRepository struct {
	// contains filtered or unexported fields
}

SQLiteRepository implements repository operations using SQLite.

func NewSQLiteRepository

func NewSQLiteRepository(db *sql.DB) *SQLiteRepository

NewSQLiteRepository creates a new SQLite-backed repository.

func (*SQLiteRepository) All

func (r *SQLiteRepository) All() ([]Entry, error)

All returns all entries without tags (used by tests).

func (*SQLiteRepository) AllWithTags

func (r *SQLiteRepository) AllWithTags() ([]Entry, error)

func (*SQLiteRepository) Create

func (r *SQLiteRepository) Create(entry Entry) (*Entry, error)

Create inserts a new entry without tags (used by tests).

func (*SQLiteRepository) CreateJournal

func (r *SQLiteRepository) CreateJournal(journal Journal) (*Journal, error)

func (*SQLiteRepository) CreateWithTags

func (r *SQLiteRepository) CreateWithTags(entry Entry, tagNames []string) (*Entry, error)

func (*SQLiteRepository) Delete

func (r *SQLiteRepository) Delete(id int64) error

func (*SQLiteRepository) DeleteJournal

func (r *SQLiteRepository) DeleteJournal(name string) error

func (*SQLiteRepository) DeleteTag

func (r *SQLiteRepository) DeleteTag(name string) error

func (*SQLiteRepository) ExportJournal

func (r *SQLiteRepository) ExportJournal(opts ExportOptions) error

func (*SQLiteRepository) ExportToMarkdown

func (r *SQLiteRepository) ExportToMarkdown(entries []Entry, w io.Writer) error

func (*SQLiteRepository) ExportToMarkdownByDate

func (r *SQLiteRepository) ExportToMarkdownByDate(entries []Entry, w io.Writer) error

func (*SQLiteRepository) ExportToText

func (r *SQLiteRepository) ExportToText(entries []Entry, w io.Writer) error

func (*SQLiteRepository) FindSimilarTags

func (r *SQLiteRepository) FindSimilarTags(name string) ([]Tag, error)

func (*SQLiteRepository) GetAllJournalEntries

func (r *SQLiteRepository) GetAllJournalEntries(name string) ([]Entry, error)

func (*SQLiteRepository) GetByID

func (r *SQLiteRepository) GetByID(id int64) (*Entry, error)

func (*SQLiteRepository) GetByIDWithTags

func (r *SQLiteRepository) GetByIDWithTags(id int64) (*Entry, error)

func (*SQLiteRepository) GetByJournal

func (r *SQLiteRepository) GetByJournal(journalName string) ([]Entry, error)

func (*SQLiteRepository) GetJournalEntryCount

func (r *SQLiteRepository) GetJournalEntryCount(name string) (int, error)

func (*SQLiteRepository) GetOrCreateTag

func (r *SQLiteRepository) GetOrCreateTag(name string) (*Tag, error)

func (*SQLiteRepository) GetRecent

func (r *SQLiteRepository) GetRecent(limit int, journalName string) ([]Entry, error)

func (*SQLiteRepository) GetTagEntries

func (r *SQLiteRepository) GetTagEntries(tagName string) ([]Entry, error)

func (*SQLiteRepository) GetTagEntryCount

func (r *SQLiteRepository) GetTagEntryCount(name string) (int, error)

func (*SQLiteRepository) ImportJournal

func (r *SQLiteRepository) ImportJournal(opts ImportOptions) error

func (*SQLiteRepository) JournalExists

func (r *SQLiteRepository) JournalExists(name string) (bool, error)

func (*SQLiteRepository) ListJournals

func (r *SQLiteRepository) ListJournals() ([]Journal, error)

ListJournals returns all journals ordered by name.

func (*SQLiteRepository) ListTags

func (r *SQLiteRepository) ListTags() ([]Tag, error)

func (*SQLiteRepository) Migrate

func (r *SQLiteRepository) Migrate() error

Migrate creates database tables and runs schema migrations.

func (*SQLiteRepository) RenameJournal

func (r *SQLiteRepository) RenameJournal(oldName, newName string) error

func (*SQLiteRepository) RenameTag

func (r *SQLiteRepository) RenameTag(oldName, newName string) error

func (*SQLiteRepository) Search

func (r *SQLiteRepository) Search(query string, journalName string) ([]Entry, error)

func (*SQLiteRepository) SearchByDateRange

func (r *SQLiteRepository) SearchByDateRange(start, end, journalName string) ([]Entry, error)

func (*SQLiteRepository) SearchByDateRangeWithQuery

func (r *SQLiteRepository) SearchByDateRangeWithQuery(start, end, query, journalName string) ([]Entry, error)

func (*SQLiteRepository) TagExists

func (r *SQLiteRepository) TagExists(name string) (bool, error)

func (*SQLiteRepository) Update

func (r *SQLiteRepository) Update(id int64, updated Entry) (*Entry, error)

func (*SQLiteRepository) UpdateWithTags

func (r *SQLiteRepository) UpdateWithTags(id int64, entry Entry, tagNames []string) (*Entry, error)

type Searcher

type Searcher interface {
	Search(query string, journalName string) ([]Entry, error)
	SearchByDateRange(start, end, journalName string) ([]Entry, error)
	SearchByDateRangeWithQuery(start, end, query, journalName string) ([]Entry, error)
}

Searcher provides search operations for entries.

type SyncthingConfig

type SyncthingConfig struct {
	Enabled  bool   `json:"enabled"`
	APIURL   string `json:"api_url"`
	APIKey   string `json:"api_key"`
	FolderID string `json:"folder_id"`
	FilePath string `json:"file_path"`
}

SyncthingConfig holds Syncthing integration settings for sync safety.

type Tag

type Tag struct {
	ID   int64
	Name string
}

Tag represents a tag that can be applied to entries.

type TagRepository

type TagRepository interface {
	GetOrCreateTag(name string) (*Tag, error)
	FindSimilarTags(name string) ([]Tag, error)
	ListTags() ([]Tag, error)
	GetTagEntries(tagName string) ([]Entry, error)
	RenameTag(oldName, newName string) error
	DeleteTag(name string) error
}

TagRepository provides operations for managing tags.

Jump to

Keyboard shortcuts

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