minidoc

package module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: MIT Imports: 27 Imported by: 0

README

minidoc

Manage small pieces of information using minidoc. Currently, you can manage URLs, TODOs, and Notes. I will either enable plugin or ability to define schemas on the fly.

Installation using homebrew

$ brew tap 7onetella/minidoc
$ brew install minidoc
$ minidoc

Getting started

This project requires Go to be installed. On OS X with Homebrew you can just run brew install go.

Running it then should be as simple as:

$ cd minidoc
$ go build && ./minidoc
Testing
$ go test 
Asciicast

asciicast

Documentation

Index

Constants

View Source
const (
	DIRECTION_NONE = iota
	DOWN
	UP
)

Variables

This section is empty.

Functions

func ConfirmDeleteModal

func ConfirmDeleteModal(s *Search, json interface{}, deleteFunc func(doc MiniDoc) error)

func ConfirmationModal

func ConfirmationModal(app *SimpleApp, message string, action func())

func CreateMinidocHomeIfNotFound added in v0.1.8

func CreateMinidocHomeIfNotFound() string

func DeleteFile

func DeleteFile(filepath string) (success bool)

func DocumentMapping

func DocumentMapping(indexedFields []string, excludedFields []string) *mapping.DocumentMapping

func DoesBinaryExists

func DoesBinaryExists(binary string) bool

func Exec

func Exec(args []string) error

Exec exec.Command

func Execute

func Execute(args []string) (string, error)

Execute execute

func ExtractFieldValues

func ExtractFieldValues(jh *JsonMapWrapper, f *tview.Form)

func GetCheckBoxChecked

func GetCheckBoxChecked(form *tview.Form, label string) bool

func GetInputValue

func GetInputValue(form *tview.Form, label string) *string

func IndexMapping

func IndexMapping() (*mapping.IndexMappingImpl, error)

func JsonMapFrom

func JsonMapFrom(minidoc MiniDoc) interface{}

func NewCell

func NewCell(reference interface{}, text string, color tcell.Color) *tview.TableCell

func NewCellWithBG

func NewCellWithBG(reference interface{}, text string, color, bg tcell.Color) *tview.TableCell

func NewDocFlow

func NewDocFlow(doctype string, app *SimpleApp) error

func NewEditForm

func NewEditForm(s *Search, doc MiniDoc) *tview.Form

func NewFormWithFields

func NewFormWithFields(doc MiniDoc) *tview.Form

func NewLoggingRows

func NewLoggingRows() *tview.Table

func NextSequence

func NextSequence(bx *buckets.DB, sequenceName string) ([]byte, error)

NextSequence returns next sequence

func OpenFileIfNoneExist

func OpenFileIfNoneExist(filepath, content string) error

func OpenVim

func OpenVim(app *SimpleApp, filepath string)

this works perfectly

func ReadFromFile

func ReadFromFile(filepath string) (string, error)

func Reindex

func Reindex(ih *IndexHandler, db *BucketHandler)

func WriteToFile

func WriteToFile(filepath, content string) (done bool)

Types

type BaseDoc

type BaseDoc struct {
	CreatedDate string `json:"created_date"`
	ID          uint32 `json:"id"`
	Type        string `json:"type"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Tags        string `json:"tags"`
	Fragments   string `json:"-"`
	Selected    bool   `json:"-"`
	Toggled     bool   `json:"-"`
}

func (*BaseDoc) GetAvailableActions

func (M *BaseDoc) GetAvailableActions() string

func (*BaseDoc) GetDescription

func (m *BaseDoc) GetDescription() string

func (*BaseDoc) GetDisplayFields

func (m *BaseDoc) GetDisplayFields() []string

func (*BaseDoc) GetEditFields

func (m *BaseDoc) GetEditFields() []string

func (*BaseDoc) GetID

func (m *BaseDoc) GetID() uint32

func (*BaseDoc) GetIDString

func (m *BaseDoc) GetIDString() string

func (*BaseDoc) GetJSON

func (m *BaseDoc) GetJSON() interface{}

func (*BaseDoc) GetMarkdown

func (m *BaseDoc) GetMarkdown() string

func (*BaseDoc) GetSearchFragments

func (m *BaseDoc) GetSearchFragments() string

func (*BaseDoc) GetTags

func (m *BaseDoc) GetTags() string

func (*BaseDoc) GetTitle

func (m *BaseDoc) GetTitle() string

func (*BaseDoc) GetToggle

func (m *BaseDoc) GetToggle() bool

func (*BaseDoc) GetToggleValueAsString

func (m *BaseDoc) GetToggleValueAsString() string

func (*BaseDoc) GetType

func (m *BaseDoc) GetType() string

func (*BaseDoc) GetViEditFields

func (m *BaseDoc) GetViEditFields() []string

func (*BaseDoc) HandleEvent

func (m *BaseDoc) HandleEvent(event *tcell.EventKey)

func (*BaseDoc) IsSelected

func (m *BaseDoc) IsSelected() bool

func (*BaseDoc) IsSelectedString

func (m *BaseDoc) IsSelectedString() string

func (*BaseDoc) IsTogglable

func (m *BaseDoc) IsTogglable() bool

func (*BaseDoc) SetCreatedDate

func (m *BaseDoc) SetCreatedDate(createdDate string)

func (*BaseDoc) SetID

func (m *BaseDoc) SetID(ID uint32)

func (*BaseDoc) SetIsSelected

func (m *BaseDoc) SetIsSelected(selected bool)

func (*BaseDoc) SetSearchFragments

func (m *BaseDoc) SetSearchFragments(fragments string)

func (*BaseDoc) SetTags

func (m *BaseDoc) SetTags(tags string)

func (*BaseDoc) SetToggle

func (m *BaseDoc) SetToggle(toggle bool)

func (*BaseDoc) SetType

func (m *BaseDoc) SetType(doctype string)

type BucketHandler

type BucketHandler struct {
	DBPath string
	// contains filtered or unexported fields
}

func NewBucketHandler

func NewBucketHandler(opts ...BucketHandlerOption) *BucketHandler

func (*BucketHandler) Delete

func (bh *BucketHandler) Delete(doc MiniDoc) error

func (*BucketHandler) Read

func (bh *BucketHandler) Read(key uint32, doctype string) (MiniDoc, error)

func (*BucketHandler) ReadAll

func (bh *BucketHandler) ReadAll(doctype string) ([]MiniDoc, error)

func (*BucketHandler) Write

func (bh *BucketHandler) Write(doc MiniDoc) (uint32, error)

type BucketHandlerOption

type BucketHandlerOption func(*BucketHandler)

func WithBucketHandlerDBPath

func WithBucketHandlerDBPath(path string) BucketHandlerOption

func WithBucketHandlerDebug

func WithBucketHandlerDebug(debug func(string)) BucketHandlerOption

type CellData

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

type DataHandler

type DataHandler struct {
	BucketHandler *BucketHandler
	IndexHandler  *IndexHandler
}

func (*DataHandler) Delete

func (dh *DataHandler) Delete(doc MiniDoc) error

func (*DataHandler) Write

func (dh *DataHandler) Write(doc MiniDoc) (uint32, error)

type DebugView

type DebugView struct {
	App       *SimpleApp
	Layout    *tview.Flex
	Rows      *tview.Table
	IsDebugOn bool
}

func NewDebugView

func NewDebugView(app *SimpleApp) *DebugView

func (*DebugView) Debug

func (d *DebugView) Debug(message string)

type Edit

type Edit struct {
	Form   *tview.Form
	Search *Search
	// contains filtered or unexported fields
}

func (*Edit) CancelAction

func (e *Edit) CancelAction()

func (*Edit) DeleteAction

func (e *Edit) DeleteAction()

func (*Edit) UpdateAction

func (e *Edit) UpdateAction()

type Error

type Error int
const (
	ErrorGeneric Error = iota
	ErrorCSVDoesNotExist
)

func (Error) Error

func (e Error) Error() string

type Help

type Help struct {
	App *SimpleApp

	Content *tview.TextView
	// contains filtered or unexported fields
}

func NewHelp

func NewHelp() *Help

func (*Help) Page

func (h *Help) Page() (title string, content tview.Primitive)

func (*Help) SetApp

func (h *Help) SetApp(app *SimpleApp)

type IndexHandler

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

func NewIndexHandler

func NewIndexHandler(opts ...IndexHandlerOption) *IndexHandler

func (*IndexHandler) Delete

func (ih *IndexHandler) Delete(doc MiniDoc) error

func (*IndexHandler) Index

func (ih *IndexHandler) Index(doc MiniDoc) error

func (*IndexHandler) Search

func (ih *IndexHandler) Search(queryString string) ([]MiniDoc, string)

indexCmd will index given csv file

type IndexHandlerOption

type IndexHandlerOption func(*IndexHandler)

func WithIndexHandlerDebug

func WithIndexHandlerDebug(debug func(string)) IndexHandlerOption

func WithIndexHandlerIndexPath

func WithIndexHandlerIndexPath(indexPath string) IndexHandlerOption

type JsonMapWrapper

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

func NewJsonMapWrapper

func NewJsonMapWrapper(jsonMap interface{}) *JsonMapWrapper

type MiniDoc

type MiniDoc interface {
	GetID() uint32
	SetID(uint32)
	GetIDString() string
	GetType() string
	SetType(string)
	GetTitle() string
	GetDescription() string
	GetTags() string
	SetTags(string)
	GetSearchFragments() string
	SetSearchFragments(string)
	GetJSON() interface{}
	SetCreatedDate(string)
	GetDisplayFields() []string
	GetEditFields() []string
	IsSelected() bool
	SetIsSelected(bool)
	IsSelectedString() string
	HandleEvent(event *tcell.EventKey)
	GetMarkdown() string
	GetAvailableActions() string
	GetViEditFields() []string
	GetToggleValueAsString() string
	SetToggle(toggle bool)
	GetToggle() bool
	IsTogglable() bool
}

func EditWithVim

func EditWithVim(app *SimpleApp, doc MiniDoc) (MiniDoc, bool)

func MiniDocFrom

func MiniDocFrom(jsonMap interface{}) (MiniDoc, error)

func NewDoc

func NewDoc(doctype string) (MiniDoc, error)

type New

type New struct {
	App    *SimpleApp
	Layout *tview.Flex
	Form   *tview.Form

	IndexHandler  *IndexHandler
	BucketHandler *BucketHandler
	// contains filtered or unexported fields
}

func NewNewPage

func NewNewPage(doc MiniDoc) *New

func (*New) CancelAction

func (n *New) CancelAction()

func (*New) CreateAction

func (n *New) CreateAction()

func (*New) Page

func (n *New) Page() (title string, content tview.Primitive)

func (*New) SetApp

func (n *New) SetApp(app *SimpleApp)

type NoteDoc

type NoteDoc struct {
	BaseDoc
	Note string `json:"note"`
}

-------------------------------------------------------------------------------- Note Doc --------------------------------------------------------------------------------

func (*NoteDoc) GetAvailableActions

func (d *NoteDoc) GetAvailableActions() string

func (*NoteDoc) GetDisplayFields

func (d *NoteDoc) GetDisplayFields() []string

func (*NoteDoc) GetEditFields

func (d *NoteDoc) GetEditFields() []string

func (*NoteDoc) GetJSON

func (d *NoteDoc) GetJSON() interface{}

func (*NoteDoc) GetMarkdown

func (d *NoteDoc) GetMarkdown() string

func (*NoteDoc) GetViEditFields

func (d *NoteDoc) GetViEditFields() []string

type PageFunc

type PageFunc func() (title string, content tview.Primitive)

Page object represent a page for Pages

type PageItem

type PageItem interface {
	Page() (title string, content tview.Primitive)
	SetApp(*SimpleApp)
}

type PagesHandler

type PagesHandler struct {
	Pages         *tview.Pages
	PageIndex     map[string]string
	MenuBar       *tview.TextView
	CurrPageIndex int
	PageItems     []PageItem
	PrevMenuText  string
}

PagesHandler handles Pages

func (*PagesHandler) AddPage

func (p *PagesHandler) AddPage(s *SimpleApp, pi PageItem)

func (*PagesHandler) GoToNextPage

func (p *PagesHandler) GoToNextPage()

GoToNextPage goes to next page

func (*PagesHandler) GoToPrevPage

func (p *PagesHandler) GoToPrevPage()

GoToPrevPage goes to previous page

func (*PagesHandler) GotoPageByTitle

func (p *PagesHandler) GotoPageByTitle(title string)

GotoPageByTitle goes to page with specified title

func (*PagesHandler) HasPage

func (p *PagesHandler) HasPage(title string) bool

func (*PagesHandler) LoadPages

func (p *PagesHandler) LoadPages(s *SimpleApp)

LoadPages loads pages

func (*PagesHandler) RemoveLastPage

func (p *PagesHandler) RemoveLastPage(s *SimpleApp)

func (*PagesHandler) UnloadPages

func (p *PagesHandler) UnloadPages()

UnloadPages unload pages

type ResultList

type ResultList struct {
	*tview.Table
	Search *Search
}

func NewResultList

func NewResultList(s *Search) *ResultList

func (*ResultList) GetCellRefBool

func (rl *ResultList) GetCellRefBool(rowIndex, colIndex int) (bool, error)

func (*ResultList) GetCellRefString

func (rl *ResultList) GetCellRefString(rowIndex, colIndex int) (string, error)

func (*ResultList) GetCellRefUint32

func (rl *ResultList) GetCellRefUint32(rowIndex, colIndex int) (uint32, error)

func (*ResultList) InputCapture

func (rl *ResultList) InputCapture() func(event *tcell.EventKey) *tcell.EventKey

func (*ResultList) InsertColumns

func (rl *ResultList) InsertColumns(size int)

func (*ResultList) LoadMiniDocFromDB

func (rl *ResultList) LoadMiniDocFromDB(rowIndex int) (MiniDoc, error)

func (*ResultList) MoveRow

func (rl *ResultList) MoveRow(direction int)

func (*ResultList) SetColumnCells

func (rl *ResultList) SetColumnCells(rowIndex int, cd []CellData)

func (*ResultList) UpdateRow

func (rl *ResultList) UpdateRow(row int, doc MiniDoc)
type Search struct {
	App             *SimpleApp
	SearchBar       *tview.Form
	ResultList      *ResultList
	Detail          *tview.TextView
	Columns         *tview.Flex
	Layout          *tview.Flex
	IsEditMode      bool
	EditForm        *tview.Form
	CurrentRowIndex int
	// contains filtered or unexported fields
}

func NewSearch

func NewSearch() *Search

func (*Search) BatchDeleteActionFunc

func (s *Search) BatchDeleteActionFunc()

func (*Search) BatchDeleteConfirmation

func (s *Search) BatchDeleteConfirmation()

func (*Search) DelegateEventHandlingMiniDoc

func (s *Search) DelegateEventHandlingMiniDoc(event *tcell.EventKey) *tcell.EventKey

func (*Search) Edit

func (s *Search) Edit()

func (*Search) GoToSearchBar

func (s *Search) GoToSearchBar(clear bool)

func (*Search) GoToSearchResult

func (s *Search) GoToSearchResult()

func (*Search) HandleCommand

func (s *Search) HandleCommand(command string)

func (*Search) InitSearchBar

func (s *Search) InitSearchBar()

func (*Search) InputCapture

func (s *Search) InputCapture(input *tview.InputField) func(event *tcell.EventKey) *tcell.EventKey

func (*Search) LoadMiniDocFromDB

func (s *Search) LoadMiniDocFromDB(row int) (MiniDoc, error)

func (*Search) Page

func (s *Search) Page() (title string, content tview.Primitive)

SearchPage returns search page

func (*Search) Preview

func (s *Search) Preview(direction int)

func (*Search) Search

func (s *Search) Search(searchby string) bool

func (*Search) SelectAllRows

func (s *Search) SelectAllRows()

func (*Search) SelectRow

func (s *Search) SelectRow(row int)

func (*Search) SetApp

func (s *Search) SetApp(app *SimpleApp)

func (*Search) ToggleAllRows

func (s *Search) ToggleAllRows()

func (*Search) ToggleSelected

func (s *Search) ToggleSelected()

func (*Search) ToggleTogglable

func (s *Search) ToggleTogglable()

func (*Search) UnLoadEdit

func (s *Search) UnLoadEdit()

func (*Search) UpdateCurrRowIndexFromSelectedRow

func (s *Search) UpdateCurrRowIndexFromSelectedRow(direction int)

func (*Search) UpdateResult

func (s *Search) UpdateResult(result []MiniDoc)

type SetAppAdapter

type SetAppAdapter struct{}

func (SetAppAdapter) SetApp

func (a SetAppAdapter) SetApp(app *SimpleApp)

type ShortcutKeyDoc

type ShortcutKeyDoc struct {
	BaseDoc
	ShortCutKey string `json:"shortcut"`
}

-------------------------------------------------------------------------------- ShortcutKey Doc --------------------------------------------------------------------------------

func (*ShortcutKeyDoc) GetDisplayFields

func (d *ShortcutKeyDoc) GetDisplayFields() []string

func (*ShortcutKeyDoc) GetEditFields

func (d *ShortcutKeyDoc) GetEditFields() []string

func (*ShortcutKeyDoc) GetJSON

func (d *ShortcutKeyDoc) GetJSON() interface{}

type SimpleApp

type SimpleApp struct {
	*tview.Application
	MenuBar      *tview.TextView
	StatusBar    *tview.TextView
	Layout       *tview.Flex
	Rows         *tview.Flex
	PagesHandler *PagesHandler
	DebugView    *DebugView
	PrevFocused  tview.Primitive

	IndexHandler  *IndexHandler
	BucketHandler *BucketHandler

	DataHandler *DataHandler
	// contains filtered or unexported fields
}

SimpleApp comes with the menu and debug pane

func NewSimpleApp

func NewSimpleApp(opts ...SimpleAppOption) *SimpleApp

func (*SimpleApp) ClearDebug

func (app *SimpleApp) ClearDebug()

func (*SimpleApp) ClearMenu

func (app *SimpleApp) ClearMenu()

func (*SimpleApp) Exit

func (app *SimpleApp) Exit()

func (*SimpleApp) GetInputCaptureFunc

func (app *SimpleApp) GetInputCaptureFunc() func(event *tcell.EventKey) *tcell.EventKey

func (*SimpleApp) GoToDebugView

func (app *SimpleApp) GoToDebugView()

func (*SimpleApp) ToggleDebug

func (app *SimpleApp) ToggleDebug()

type SimpleAppOption

type SimpleAppOption func(*SimpleApp)

func WithSimpleAppConfirmExit

func WithSimpleAppConfirmExit(confirm bool) SimpleAppOption

func WithSimpleAppDataFolderPath

func WithSimpleAppDataFolderPath(path string) SimpleAppOption

func WithSimpleAppDebugOn

func WithSimpleAppDebugOn() SimpleAppOption

func WithSimpleAppDelegateKeyEvent

func WithSimpleAppDelegateKeyEvent(keyEvent func(event *tcell.EventKey) *tcell.EventKey) SimpleAppOption

func WithSimpleAppDocsReindexed

func WithSimpleAppDocsReindexed(reindex bool) SimpleAppOption

func WithSimpleAppPages

func WithSimpleAppPages(pages []PageItem) SimpleAppOption

type ToDoDoc

type ToDoDoc struct {
	BaseDoc
	Task string `json:"task"`
	Done bool   `json:"done"`
}

-------------------------------------------------------------------------------- TODO Doc --------------------------------------------------------------------------------

func (*ToDoDoc) GetAvailableActions

func (d *ToDoDoc) GetAvailableActions() string

func (*ToDoDoc) GetDisplayFields

func (d *ToDoDoc) GetDisplayFields() []string

func (*ToDoDoc) GetEditFields

func (d *ToDoDoc) GetEditFields() []string

func (*ToDoDoc) GetJSON

func (d *ToDoDoc) GetJSON() interface{}

func (*ToDoDoc) GetMarkdown

func (d *ToDoDoc) GetMarkdown() string

func (*ToDoDoc) GetTitle

func (d *ToDoDoc) GetTitle() string

func (*ToDoDoc) GetToggle

func (d *ToDoDoc) GetToggle() bool

func (*ToDoDoc) GetToggleValueAsString

func (d *ToDoDoc) GetToggleValueAsString() string

func (*ToDoDoc) HandleEvent

func (d *ToDoDoc) HandleEvent(event *tcell.EventKey)

func (*ToDoDoc) SetToggle

func (d *ToDoDoc) SetToggle(toggle bool)

type URLDoc

type URLDoc struct {
	BaseDoc
	URL        string `json:"url"`
	WatchLater bool   `json:"watch_later"`
}

-------------------------------------------------------------------------------- URL Doc --------------------------------------------------------------------------------

func (*URLDoc) GetAvailableActions

func (d *URLDoc) GetAvailableActions() string

func (*URLDoc) GetDisplayFields

func (d *URLDoc) GetDisplayFields() []string

func (*URLDoc) GetEditFields

func (d *URLDoc) GetEditFields() []string

func (*URLDoc) GetJSON

func (d *URLDoc) GetJSON() interface{}

func (*URLDoc) GetMarkdown

func (d *URLDoc) GetMarkdown() string

func (*URLDoc) GetToggle

func (d *URLDoc) GetToggle() bool

func (*URLDoc) GetToggleValueAsString

func (d *URLDoc) GetToggleValueAsString() string

func (*URLDoc) HandleEvent

func (d *URLDoc) HandleEvent(event *tcell.EventKey)

func (*URLDoc) SetToggle

func (d *URLDoc) SetToggle(toggle bool)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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