Skip to content

Commit

Permalink
Update the README with new usage information
Browse files Browse the repository at this point in the history
  • Loading branch information
thijzert committed Feb 17, 2023
1 parent 2502854 commit 7ba6ee8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
39 changes: 31 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,54 @@ This is a Journaling utility I wrote in Go. It features a command-line utility f

Go-journal was originally created as a replacement for [jrnl](https://github.com/maebert/jrnl), but other than the storage format the two share very little.

Usage
Overview
-----
This repository builds two executables. The first, `jrnl`, kinda sorta emulates what @maebert did. One can either pass the `--create` flag to add an entry by piping some text to stdin, or the `--search` flag to look for any journal entries that contain all of the following arguments.

The `journal-server` spins up a web server with an interface for adding entries to the journal. (Not reading them!)
It's secured via the very advanced 'secret bookmark' method, which easily enables one to use the interface on your smartphone, no matter the species. Loss of this bookmark may result in some spam entries being added, but since the web interface is write-only your journal itself remains safe from prying eyes.
It's secured via the very advanced 'secret bookmark' method, which easily enables one to use the interface on your smartphone, no matter the species. Accidental exposure of this bookmark may result in some spam entries being added, but since the web interface is write-only your journal itself remains safe from prying eyes.

There are two notable exceptions to the "write-only" policy in the web server. First, there's the special `@BWV` tag. If you're anything like me, you like keeping track of which music you've played, and in particular, which [BWV numbers](https://en.wikipedia.org/wiki/List_of_compositions_by_Johann_Sebastian_Bach#BWV) you can cross off. `journal-server` exposes a (non-exhaustive) list of BWV numbers, that turn green as they become tagged in your journal.

Second, if you specify a projects directory, the file names in that directory can be selected through a dropdown list. If a project log file is selected, the journal entry is appended to that file in addition to the journal file.

Usage
-----
### `jrnl`
Add entries to the journal, or search for past entries.

Command-line arguments:

* `--journal_file=FILE`: read or write journal entries to or from `FILE`.
* `--search`: search the journal and print matching entries. All other command-line arguments are search terms.
* `--create`: add a new journal entry. This reads input from stdin and adds it to the journal.
* `--date=DATE`: (when adding an entry) use `DATE` for the new journal entry, instead of the current date and time.

### `journal-server`
Start a web server

Command-line arguments:

One notable exception to the "write-only" policy is the special `@BWV` tag. If you're anything like me, you like keeping track of which music you've played, and in particular, which [BWV numbers](https://en.wikipedia.org/wiki/List_of_compositions_by_Johann_Sebastian_Bach#BWV) you can cross off. `journal-server` exposes a (non-exhaustive) list of BWV numbers, that turn green as they become tagged in your journal.
* `--listen=IP:PORT`: listen on port `PORT`, on IP `IP`. Defaults to ':8848'.
* `--journal_file=FILE`: read or write journal entries to or from `FILE`. `FILE` defaults to 'journal.txt' in the current directory.
* `--password_file=FILE`: read passwords from `FILE`. This file should be in the apache htpasswd format, with bcrypt hashes. `FILE` defaults to '.htpasswd' in the current directory.
* `--secret_parameter=URLKEY`: Pass the API key in this URL parameter, making it less obvious to find and brute force. Defaults to 'apikey'
* `--attachments_dir=DIR`: Directory for storing attached files. If this parameter is not specified, attaching uploaded files is disabled.
* `--projects_dir=DIR`: Directory with project log files. If this parameter is not specified, adding entries to a project log is disabled.

Building
--------
First install or update the prerequisites:

```
go get ./...
gem install scss
go get -u github.com/jteeuwen/go-bindata/...
go get -u github.com/gorilla/mux
go get -u github.com/gorilla/context
go get -u golang.org/x/crypto/bcrypt
```

Afterwards, execute `build.sh` to build both binaries.

`journal-server` listens on port 8848 by default, and uses the file `journal.txt` in the current directory for storage. These options can be tweaked using the `--listen` and `--journal-file` flags respectively.
Furthermore, it needs a `.htpasswd` file to verify the bookmarked API key. Use your favorite utility to create it. (Use the bcrypt hash!)
Furthermore, it needs a `.htpasswd` file to verify the bookmarked API key. This file should take the Apache htpasswd format; use any standard utility to create it. (But tell it to use the bcrypt hash.)

If you just want to quickly give it a go, create a file `.htpasswd` with the following contents:

Expand Down
1 change: 0 additions & 1 deletion bin/journal-server/journal-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ func DailyHandler(w http.ResponseWriter, r *http.Request) {
func saveJournalEntry(timestamp time.Time, contents string, project string, starred bool) error {
if project != "" && *projects_dir != "" {
prf := path.Join(*projects_dir, strings.Replace(strings.Replace(project, "/", "", -1), "\\", "", -1))
//log.Printf("Also adding post to project %s → %s", project, prf)
if f, err := os.OpenFile(prf, os.O_APPEND|os.O_WRONLY, 0600); err == nil {
fmt.Fprintf(f, "\n=== %s ===\n%s\n", timestamp.Format("2006-01-02"), contents)
f.Close()
Expand Down

0 comments on commit 7ba6ee8

Please sign in to comment.