README
¶
GNOTES - Terminal based S3 syncing note app
A WIP app. This is my local code and may not work for you. But you may find this useful.
Before using, you need access to a S3 server. Otherwise it will only save notes locally, and may not work correctly.
How it works
GNOTES syncs all notes and attachments to a s3 server. v1 branch will store all notes (not attachments) in one tarball. Every note is contained into that one file. With v2, each note is a seprate file on s3. This greatly improves download and upload speed when saving notes. Also, each note is checked with a sha1sum checksum to avoid downloading the notes if its already cached locally.
In v2, all notes and attachments are compressed, and encrypted before uploading to the s3 server.
Eventually, v3 will be diff based, further improving download and upload speed, and able to keep some revisions.
Installation
$ git clone https://github.com/WestleyR/gnotes
$ cd gnotes/
$ make
$ cp gnotes ~/.local/bin # or your preferred path
Setting up gnotes for your S3 server
See the config.ini
file for an example config.
The user config file for gnotes is located in:
${HOME}/.config/gnotes/config.ini
And as an example, for dreamhost, it should look like this:
[settings]
editor = vim
notes_dir = ${HOME}/.config/gnotes
[s3]
active = true
bucket = gnotes-v2
endpoint = https://objects-us-east-1.dream.io
region = us-east-1
accesskey = ACCESS_KEY
secretkey = SECRET_KEY
user_id = a-one-time-generated-uuid
crypt_key = a-16-bit-token
Inital creation
Right after installing, or if you dont have any gnote data on the s3 server, gnotes will likely print error messages. For safey reasions, if it failed to download data, it will not continue to avoid losing data.
After a fresh install, you first need to run gnotes with these flags:
$ gnotes -s -R
Then create a new note with some content.
The -s
tells gnotes to skip the download, and -R
for not looking for local
cache.
Run gnotes --help
for other flags or help.
After the inital creation, do not use those flags. Otherwise you may lose data
Basic usage
To delete a note, just select it with the ui and delete all content with your
editor. With vim type :%d
as an example. Then save, exit, and it will be
deleted. Make sure all lines are removed.
Bugs
This is in develpment, there may be bugs. Please report by opening a github issue.
Documentation
¶
Index ¶
- Variables
- func GetFileFromConfig(file string) string
- func Sha1(s string) string
- func Sha1File(file string) (string, error)
- type Book
- func (b *Book) Changed(noteIndex int)
- func (b *Book) DeleteNote(noteIndex int) error
- func (b *Book) HRModifiedTime() string
- func (book *Book) NewAttachment(noteDir, path string) error
- func (book *Book) NewNote(noteDir string, completion func()) error
- func (book *Book) NewNoteWithContentsOfFile(noteDir, path string, completion func()) error
- func (b *Book) SaveNoteIndex(noteIndex int) error
- func (n *Book) Sort()
- type CliOpts
- type Config
- type Note
- type NoteBook
- type S3Config
- func (c *S3Config) Decrypt(data []byte) ([]byte, error)
- func (c S3Config) DecryptAndDeGzip(file string) error
- func (c S3Config) Delete(s3File string) error
- func (c S3Config) DownloadFileFrom(s3File, endPath string) error
- func (c *S3Config) Encrypt(data []byte) ([]byte, error)
- func (c S3Config) GzipAndEncrypt(file string) (string, error)
- func (c S3Config) UploadFile(local, to string) error
- type SelfApp
Constants ¶
This section is empty.
Variables ¶
var ErrBookExists = errors.New("book already exists")
Functions ¶
func GetFileFromConfig ¶
Types ¶
type Book ¶
type Book struct { // Name is the sub-dir name Name string `json:"name"` // Notes contains all the notes in the sub-dir Notes []*Note `json:"notes"` Modified int64 `json:"modified"` Selected bool `json:"selected"` }
Book contains all the notes for the Name of the sub-categroies.
func (*Book) DeleteNote ¶
DeleteNote will delete a specific note. Will delete the note from s3 imetitly, and reupload the index files.
func (*Book) HRModifiedTime ¶
func (*Book) NewAttachment ¶
func (*Book) NewNoteWithContentsOfFile ¶
func (*Book) SaveNoteIndex ¶
SaveNoteIndex does the same thing as Note.Save(), but also updates the modified timestamp for the book.
type Config ¶
type Config struct { App appSettings `ini:"settings"` S3 S3Config `ini:"s3"` }
func LoadConfig ¶
type Note ¶
type Note struct { // S3Path is the path to the note on the s3 server. Also used for the local // path when caching. eg. "catigory/uuid-1/content" S3Path string `json:"path"` Created int64 `json:"created"` Modified int64 `json:"modified"` Hash string `json:"hash"` Title string `json:"title"` // For attachments IsAttachment bool `json:"attachment"` AttachmentTitle string `json:"attachment_title"` Size int64 `json:"size"` }
Note is all the data for a specific note.
func (*Note) Changed ¶
func (n *Note) Changed()
Changed will update the modified date for a note. Depercated: use Book.Changed()
type NoteBook ¶
type NoteBook struct {
Books []*Book `json:"folders"`
}
NoteBook is the collection of all sub-categroies.
func (*NoteBook) DeleteBook ¶
func (*NoteBook) GetSelected ¶
func (*NoteBook) SetSelected ¶
type S3Config ¶
type S3Config struct { Active bool `ini:"active"` Bucket string `ini:"bucket"` Endpoint string `ini:"endpoint"` Region string `ini:"region"` AccessKey string `ini:"accesskey"` SecretKey string `ini:"secretkey"` UserID string `ini:"user_id"` CryptKey string `ini:"crypt_key"` }
func (S3Config) DecryptAndDeGzip ¶
func (S3Config) DownloadFileFrom ¶
func (S3Config) UploadFile ¶
type SelfApp ¶
type SelfApp struct { // Notes Notes *NoteBook // IndexNeedsUpdating indecates if the index file needs to be uploaded // like if a new note was created. IndexNeedsUpdating bool // CLI opts CliOpts CliOpts Config *Config }
func (*SelfApp) DeleteNote ¶
DeleteNote will delete a specific note. Will delete the note from s3 imetitly, and reupload the index files. Depercated: use Book.DeleteNote()