Rename every occurrence of "slip box" into "notebook"

pull/6/head
Mickaël Menu 3 years ago
parent 55ea92f52b
commit 4c8a7b4105
No known key found for this signature in database
GPG Key ID: 53D73664CD359895

@ -22,7 +22,7 @@ type NoteFinder struct {
// NoteFinderOpts holds the configuration for the fzf notes finder. // NoteFinderOpts holds the configuration for the fzf notes finder.
// //
// The absolute path to the slip box (BasePath) and the working directory // The absolute path to the notebook (BasePath) and the working directory
// (CurrentPath) are used to make the path of each note relative to the working // (CurrentPath) are used to make the path of each note relative to the working
// directory. // directory.
type NoteFinderOpts struct { type NoteFinderOpts struct {
@ -33,7 +33,7 @@ type NoteFinderOpts struct {
// When non nil, a "create new note from query" binding will be added to // When non nil, a "create new note from query" binding will be added to
// fzf to create a note in this directory. // fzf to create a note in this directory.
NewNoteDir *zk.Dir NewNoteDir *zk.Dir
// Absolute path to the slip box. // Absolute path to the notebook.
BasePath string BasePath string
// Path to the working directory. // Path to the working directory.
CurrentPath string CurrentPath string

@ -66,7 +66,7 @@ func (c *Container) NoteFinder(tx sqlite.Transaction, opts fzf.NoteFinderOpts) *
return fzf.NewNoteFinder(opts, notes, c.Terminal) return fzf.NewNoteFinder(opts, notes, c.Terminal)
} }
// Database returns the DB instance for the given slip box, after executing any // Database returns the DB instance for the given notebook, after executing any
// pending migration. // pending migration.
func (c *Container) Database(path string) (*sqlite.DB, error) { func (c *Container) Database(path string) (*sqlite.DB, error) {
db, err := sqlite.Open(path) db, err := sqlite.Open(path)

@ -11,7 +11,7 @@ import (
"github.com/schollz/progressbar/v3" "github.com/schollz/progressbar/v3"
) )
// Index indexes the content of all the notes in the slip box. // Index indexes the content of all the notes in the notebook.
type Index struct { type Index struct {
Force bool `short:"f" help:"Force indexing all the notes."` Force bool `short:"f" help:"Force indexing all the notes."`
Quiet bool `short:"q" help:"Do not print statistics nor progress."` Quiet bool `short:"q" help:"Do not print statistics nor progress."`

@ -7,9 +7,9 @@ import (
"github.com/mickael-menu/zk/core/zk" "github.com/mickael-menu/zk/core/zk"
) )
// Init creates a slip box in the given directory // Init creates a notebook in the given directory
type Init struct { type Init struct {
Directory string `arg optional type:"path" default:"." help:"Directory containing the slip box."` Directory string `arg optional type:"path" default:"." help:"Directory containing the notebook."`
} }
func (cmd *Init) Run() error { func (cmd *Init) Run() error {
@ -20,7 +20,7 @@ func (cmd *Init) Run() error {
path = cmd.Directory path = cmd.Directory
} }
fmt.Printf("Initialized a slip box in %v\n", path) fmt.Printf("Initialized a notebook in %v\n", path)
} }
return err return err
} }

@ -9,7 +9,7 @@ import (
"github.com/mickael-menu/zk/util/os" "github.com/mickael-menu/zk/util/os"
) )
// New adds a new note to the slip box. // New adds a new note to the notebook.
type New struct { type New struct {
Directory string `arg optional type:"path" default:"." help:"Directory in which to create the note."` Directory string `arg optional type:"path" default:"." help:"Directory in which to create the note."`

@ -22,7 +22,7 @@ type Formatter struct {
// NewFormatter creates a Formatter from a given format template. // NewFormatter creates a Formatter from a given format template.
// //
// The absolute path to the slip box (basePath) and the working directory // The absolute path to the notebook (basePath) and the working directory
// (currentPath) are used to make the path of each note relative to the working // (currentPath) are used to make the path of each note relative to the working
// directory. // directory.
func NewFormatter(basePath string, currentPath string, format opt.String, templates templ.Loader, styler style.Styler) (*Formatter, error) { func NewFormatter(basePath string, currentPath string, format opt.String, templates templ.Loader, styler style.Styler) (*Formatter, error) {

@ -64,7 +64,7 @@ type Indexer interface {
Remove(path string) error Remove(path string) error
} }
// Index indexes the content of the notes in the given slip box. // Index indexes the content of the notes in the given notebook.
func Index(zk *zk.Zk, force bool, parser Parser, indexer Indexer, logger util.Logger, callback func(change paths.DiffChange)) (IndexingStats, error) { func Index(zk *zk.Zk, force bool, parser Parser, indexer Indexer, logger util.Logger, callback func(change paths.DiffChange)) (IndexingStats, error) {
wrap := errors.Wrapper("indexing failed") wrap := errors.Wrapper("indexing failed")
@ -139,7 +139,7 @@ func metadata(path string, zk *zk.Zk, parser Parser) (Metadata, error) {
for _, link := range contentParts.Links { for _, link := range contentParts.Links {
if !strutil.IsURL(link.Href) { if !strutil.IsURL(link.Href) {
// Make the href relative to the slip box root. // Make the href relative to the notebook root.
href := filepath.Join(filepath.Dir(absPath), link.Href) href := filepath.Join(filepath.Dir(absPath), link.Href)
link.Href, err = zk.RelPath(href) link.Href, err = zk.RelPath(href)
if err != nil { if err != nil {

@ -15,7 +15,7 @@ type Rule string
var ( var (
// Title of a note. // Title of a note.
RuleTitle = Rule("title") RuleTitle = Rule("title")
// Path to slip box file. // Path to notebook file.
RulePath = Rule("path") RulePath = Rule("path")
// Searched for term in a note. // Searched for term in a note.
RuleTerm = Rule("term") RuleTerm = Rule("term")

@ -135,17 +135,17 @@ const defaultConfig = `# zk configuration file
#conf = '$EDITOR "$ZK_PATH/.zk/config.toml"' #conf = '$EDITOR "$ZK_PATH/.zk/config.toml"'
` `
// Zk (Zettelkasten) represents an opened slip box. // Zk (Zettelkasten) represents an opened notebook.
type Zk struct { type Zk struct {
// Slip box root path. // Notebook root path.
Path string Path string
// Global user configuration. // Global user configuration.
Config Config Config Config
} }
// Dir represents a directory inside a slip box. // Dir represents a directory inside a notebook.
type Dir struct { type Dir struct {
// Name of the directory, which is the path relative to the slip box's root. // Name of the directory, which is the path relative to the notebook's root.
Name string Name string
// Absolute path to the directory. // Absolute path to the directory.
Path string Path string
@ -153,7 +153,7 @@ type Dir struct {
Config DirConfig Config DirConfig
} }
// Open locates a slip box at the given path and parses its configuration. // Open locates a notebook at the given path and parses its configuration.
func Open(path string) (*Zk, error) { func Open(path string) (*Zk, error) {
wrap := errors.Wrapper("open failed") wrap := errors.Wrapper("open failed")
@ -183,7 +183,7 @@ func Open(path string) (*Zk, error) {
}, nil }, nil
} }
// Create initializes a new slip box at the given path. // Create initializes a new notebook at the given path.
func Create(path string) error { func Create(path string) error {
wrap := errors.Wrapper("init failed") wrap := errors.Wrapper("init failed")
@ -193,7 +193,7 @@ func Create(path string) error {
} }
if existingPath, err := locateRoot(path); err == nil { if existingPath, err := locateRoot(path); err == nil {
return wrap(fmt.Errorf("a slip box already exists in %v", existingPath)) return wrap(fmt.Errorf("a notebook already exists in %v", existingPath))
} }
// Create .zk and .zk/templates directories. // Create .zk and .zk/templates directories.
@ -215,7 +215,7 @@ func Create(path string) error {
return nil return nil
} }
// locate finds the root of the slip box containing the given path. // locate finds the root of the notebook containing the given path.
func locateRoot(path string) (string, error) { func locateRoot(path string) (string, error) {
if !filepath.IsAbs(path) { if !filepath.IsAbs(path) {
panic("absolute path expected") panic("absolute path expected")
@ -224,7 +224,7 @@ func locateRoot(path string) (string, error) {
var locate func(string) (string, error) var locate func(string) (string, error)
locate = func(currentPath string) (string, error) { locate = func(currentPath string) (string, error) {
if currentPath == "/" || currentPath == "." { if currentPath == "/" || currentPath == "." {
return "", fmt.Errorf("no slip box found in %v or a parent directory", path) return "", fmt.Errorf("no notebook found in %v or a parent directory", path)
} }
exists, err := paths.DirExists(filepath.Join(currentPath, ".zk")) exists, err := paths.DirExists(filepath.Join(currentPath, ".zk"))
switch { switch {
@ -240,14 +240,14 @@ func locateRoot(path string) (string, error) {
return locate(path) return locate(path)
} }
// DBPath returns the path to the slip box database. // DBPath returns the path to the notebook database.
func (zk *Zk) DBPath() string { func (zk *Zk) DBPath() string {
return filepath.Join(zk.Path, ".zk/data.db") return filepath.Join(zk.Path, ".zk/data.db")
} }
// RelPath returns the path relative to the slip box root to the given path. // RelPath returns the path relative to the notebook root to the given path.
func (zk *Zk) RelPath(path string) (string, error) { func (zk *Zk) RelPath(path string) (string, error) {
wrap := errors.Wrapperf("%v: not a valid slip box path", path) wrap := errors.Wrapperf("%v: not a valid notebook path", path)
path, err := filepath.Abs(path) path, err := filepath.Abs(path)
if err != nil { if err != nil {
@ -263,7 +263,7 @@ func (zk *Zk) RelPath(path string) (string, error) {
return path, nil return path, nil
} }
// RootDir returns the root Dir for this slip box. // RootDir returns the root Dir for this notebook.
func (zk *Zk) RootDir() Dir { func (zk *Zk) RootDir() Dir {
return Dir{ return Dir{
Name: "", Name: "",
@ -272,11 +272,11 @@ func (zk *Zk) RootDir() Dir {
} }
} }
// DirAt returns a Dir representation of the slip box directory at the given path. // DirAt returns a Dir representation of the notebook directory at the given path.
func (zk *Zk) DirAt(path string, overrides ...ConfigOverrides) (*Dir, error) { func (zk *Zk) DirAt(path string, overrides ...ConfigOverrides) (*Dir, error) {
path, err := filepath.Abs(path) path, err := filepath.Abs(path)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "%v: not a valid slip box directory", path) return nil, errors.Wrapf(err, "%v: not a valid notebook directory", path)
} }
name, err := zk.RelPath(path) name, err := zk.RelPath(path)

@ -15,10 +15,10 @@ var Version = "dev"
var Build = "dev" var Build = "dev"
var cli struct { var cli struct {
Init cmd.Init `cmd group:"zk" help:"Create a new slip box in the given directory."` Init cmd.Init `cmd group:"zk" help:"Create a new notebook in the given directory."`
Index cmd.Index `cmd group:"zk" help:"Index the notes to be searchable."` Index cmd.Index `cmd group:"zk" help:"Index the notes to be searchable."`
New cmd.New `cmd group:"notes" help:"Create a new note in the given slip box directory."` New cmd.New `cmd group:"notes" help:"Create a new note in the given notebook directory."`
List cmd.List `cmd group:"notes" help:"List notes matching the given criteria."` List cmd.List `cmd group:"notes" help:"List notes matching the given criteria."`
Edit cmd.Edit `cmd group:"notes" help:"Edit notes matching the given criteria."` Edit cmd.Edit `cmd group:"notes" help:"Edit notes matching the given criteria."`
@ -85,7 +85,7 @@ func options(container *cmd.Container) []kong.Option {
"sort": "Sorting", "sort": "Sorting",
"format": "Formatting", "format": "Formatting",
"notes": term.MustStyle("NOTES", style.RuleYellow, style.RuleBold) + "\n" + term.MustStyle("Edit or browse your notes", style.RuleBold), "notes": term.MustStyle("NOTES", style.RuleYellow, style.RuleBold) + "\n" + term.MustStyle("Edit or browse your notes", style.RuleBold),
"zk": term.MustStyle("SLIP BOX", style.RuleYellow, style.RuleBold) + "\n" + term.MustStyle("A slip box is a directory containing your notes", style.RuleBold), "zk": term.MustStyle("NOTEBOOK", style.RuleYellow, style.RuleBold) + "\n" + term.MustStyle("A notebook is a directory containing a collection of notes", style.RuleBold),
}), }),
} }
} }
@ -97,7 +97,7 @@ func fatalIfError(err error) {
} }
} }
// indexZk will index any slip box in the working directory. // indexZk will index any notebook in the working directory.
func indexZk(container *cmd.Container) { func indexZk(container *cmd.Container) {
if len(os.Args) > 1 && os.Args[1] != "index" { if len(os.Args) > 1 && os.Args[1] != "index" {
(&cmd.Index{Quiet: true}).Run(container) (&cmd.Index{Quiet: true}).Run(container)

Loading…
Cancel
Save