Documentation
¶
Index ¶
- Constants
- Variables
- func CollectPath(splitted []string) string
- func PrettyFromEntry(e os.DirEntry) string
- func SplitPath(str string) []string
- type EditNode
- type Folder
- type Node
- func (s *Node) FromJson(data map[string]interface{}) error
- func (s *Node) GenPretty() string
- func (n *Node) GetPath(service string) string
- func (n *Node) IsFile() bool
- func (n *Node) IsFolder() bool
- func (n *Node) RebuildParent(parentCurrent, parentNew Node, service string, s Settings) *Node
- func (n *Node) ToFolder() Folder
- func (s *Node) ToJSON() map[string]interface{}
- func (n *Node) ToNote() Note
- func (n *Node) UpdatePath(service, path string) *Node
- type NodeType
- type Note
- type Settings
- type StdArgs
Constants ¶
const ( DefaultAppName = "notya" SettingsName = ".settings.json" DefaultEditor = "vi" DefaultLocalPath = "notya" )
Constant values of settings.
Variables ¶
var ( // Early defined pretties. NotePretty = "" FolderPretty = "" )
var NotyaIgnoreFiles []string = []string{ SettingsName, ".DS_Store", ".git", }
NotyaIgnoreFiles are those files that shouldn't be represented as note files.
Functions ¶
func CollectPath ¶
CollectPath is reversed implementation of SplitPath, which collects the fields that is splitted via SplitPath function.
func PrettyFromEntry ¶
PrettyFromEntry generates a pretty icon appropriate to provided entry.
Types ¶
type EditNode ¶
EditNote is wrapper structure used to store two new/current nodes.
type Folder ¶
type Folder struct {
// Title is the name(not path) of "current" folder.
Title string `json:"title"`
// Path is the full-path string name of "current" folder.
Path map[string]string `json:"path"`
}
Folder is a w-directory representation data structure.
EXAMPLE:
╭───────────────╮ │ ~/notya-path/ │ │───────────────╯ │─ new_note.txt │─ todo/ ◀──── Sub directory of main notes folder. │ │── today.md │ │── tomorrow.md │ ╰── insolite-notya/ ◀── Sub directory of "todo" folder. │ │── issues.txt │ ╰── features.txt │─ ted-talks.tx ╰─ psyco.txt
type Node ¶
type Node struct {
// Type represents the exact type of current node.
// It can be `file` or `folder`.
Type NodeType `json:"typ"`
// Title is the name(not path) of "current" node.
Title string `json:"title"`
// Path is the full-path string name of "current" node.
Path map[string]string `json:"path"`
// A field representation of [Note]'s [Body].
Body string `json:"body,omitempty"`
// Pretty is Title but powered with ascii emojis.
// Shouldn't used as a production field.
Pretty []string `json:"pretty,omitempty"`
}
Node is general purpose data object that used as abstract of Folder and Note structure models.
func (*Node) GenPretty ¶
GenPretty generates default pretty ASCII icon based on pointed node's type.
func (*Node) GetPath ¶
GetPath returns exact path of provided service. If path for provided service doesn't exists result will be empty string.
func (*Node) RebuildParent ¶
RebuildParent updates the parent(s) of node in [Title] and [Path].
type Note ¶
type Note struct {
Title string `json:"title"`
Path map[string]string `json:"path"`
Body string `json:"body"`
}
Note is the main note model of application.
Example:
╭─────────────────────────────────────────────╮ │ Title: new_note.txt │ │ Path: /User/random-user/notya/new_note.txt │ │ Body: ... Note content here ... │ ╰─────────────────────────────────────────────╯
func (*Note) GetPath ¶
GetPath returns exact path of provided service. If path for provided service doesn't exists result will be empty string.
type Settings ¶
type Settings struct {
// Alert: development related field, shouldn't be used in production.
ID string `json:",omitempty"`
// The custom name of your notya application.
Name string `json:"name" default:"notya"`
// Editor app of application.
// Could be:
// - vi
// - vim
// - nvim
// - code
// - code-insiders
// and etc. shortly each code editor that could be opened by its command.
// like: `code .` or `nvim .`.
Editor string `json:"editor" default:"vi"`
// Local "notes" folder path for notes, independently from [~/notya/] folder.
// Must be given full path, like: "./User/john-doe/.../my-notya-notes/"
//
// Does same job as [FirebaseCollection] for local env.
NotesPath string `json:"notes_path" mapstructure:"notes_path" survey:"notes_path"`
// The project id of your firebase project.
//
// It is required for firebase remote connection.
FirebaseProjectID string `json:"fire_project_id,omitempty" mapstructure:"fire_project_id,omitempty" survey:"fire_project_id"`
// The path of key of "firebase-service" account file.
// Must be given full path, like: "./User/john-doe/.../..."
//
// It is required for firebase remote connection.
FirebaseAccountKey string `json:"fire_account_key,omitempty" mapstructure:"fire_account_key,omitempty" survey:"fire_account_key"`
// The concrete collection of nodes.
// Does same job as [NotesPath] but has to take just name of collection.
FirebaseCollection string `json:"fire_collection,omitempty" mapstructure:"fire_collection,omitempty" survey:"fire_collection"`
}
Settings is a main structure model of application settings.
Example:
╭────────────────────────────────────────────────────╮ │ Name: notya │ │ Editor: vi │ │ Notes Path: /User/random-user/notya/notes │ │ Firebase Project ID: notya-98tf3 │ │ Firebase Account Key: /User/.../notya/key.json │ │ Firebase Collection: notya-notes │ ╰────────────────────────────────────────────────────╯
func DecodeSettings ¶
DecodeSettings converts string(map) value to Settings structure.
func InitSettings ¶
InitSettings returns default variant of settings structure model.
func (*Settings) CopyWith ¶
func (s *Settings) CopyWith( ID *string, Name *string, Editor *string, NotesPath *string, FirebaseProjectID *string, FirebaseAccountKey *string, FirebaseCollection *string, ) Settings
CopyWith updates pointed settings with a new data. if given argument is not nil, it will be overwritten inside pointed settings model.