Skip to content

Commit

Permalink
Merge pull request #4 from iambenzo/ft/gui
Browse files Browse the repository at this point in the history
  • Loading branch information
iambenzo authored Nov 19, 2024
2 parents c206d97 + 1b14cdf commit 9621947
Show file tree
Hide file tree
Showing 10 changed files with 5,315 additions and 369 deletions.
4,720 changes: 4,363 additions & 357 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
members = [
"kindle_clippings",
"cli",
"gui",
]
resolver = "2"
5 changes: 5 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ cover:
cargo tarpaulin -o html
firefox ./tarpaulin-report.html

# build and run gui app
gui:
cargo build
./target/debug/ktr_gui

# format and check for syntax enhancements
tidy:
cargo fmt --all
Expand Down
68 changes: 63 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,67 @@
# KTR

The idea of this utility is to convert the highlights I've made in my Kindle to a format that I can use in my Zettelkasten (Obsidian).

## Goals
## Installation

There are no binaries currently provided via a github release, the only way to install is via `cargo`:

```sh
cargo install --git https://github.com/iambenzo/ktr.git --branch main
```

This will install the `ktr` CLI tool and a `ktr_gui` GUI tool.

> If there's demand, I'll create a release action.
## Usage

This application doesn't do anything too fancy. It takes a path to your 'My Clippings.txt' file, found on your Kindle under the `documents` directory.

You can optionally supply your own [Tera](https://github.com/Keats/tera) template if you want to deviate from the [default output](./kindle_clippings/src/templates/default.md)/structure.

Finally, you need to provide a path to a directory for the output files to land in.

The output is a set of files, one per book, containing your Kindle highlights ready for augmenting into your Zettelkasten. Any Kindle notes attached to a highlight will also be included by the default template.

### CLI

For the CLI, a default `output` directory will be created if one isn't supplied by you, the user.

The CLI will parse your entire clippings file every time.

```sh
Usage: ktr [OPTIONS] <CLIPPINGS_FILE>

Arguments:
<CLIPPINGS_FILE>

Options:
-t, --template <TEMPLATE_FILE>
-o, --output <OUTPUT_DIR>
-h, --help Print help
-V, --version Print version
```

> [!WARNING]
> The error messages aren't pretty.
### GUI

The GUI is a wizard style application.

The benefit of the GUI over the CLI is that it will allow you to select which books are processed into output files...though you will have to use your mouse.

## Templating

For those of you comfortable reading a little Rust, you can take a look at [this file](./kindle_clippings/src/output.rs) to understand what objects are available to your custom template.

For those of you who like tables, here you go:

- [x] Read the "My Clippings.txt" file from file system
- [ ] Output to markdown using a default template
- [ ] Allow the use of a user-defined output template (a la Tera)
- [ ] Have actionable documentation
| Object | Type | Notes |
| ------ | ---- | ----- |
| date | String | Today's date, excluding time |
| highlights | Vec | An iterable list of a book's highlights |
| quotes | Vec | An iterable list of a book's quotes |

If you take a look at the [model](./kindle_clippings/src/model.rs), you'll see that there's opportunity to make more objects available for templating. If there's demand, then I could look to expand the list of available objects for templating.
5 changes: 4 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ pub fn run(clippings: PathBuf, template: Option<PathBuf>, output_dir: &Path) {
let books = parse_clippings(s);

for (_, book) in books.iter() {
render_output(book, &template, output_dir);
if let Err(e) = render_output(book, &template, output_dir) {
eprintln!("{}", e);
::std::process::exit(1);
}
}
} else {
panic!("error reading file");
Expand Down
14 changes: 14 additions & 0 deletions gui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "ktr_gui"
description = "Converts Kindle highlights to a reference format for use in a Zettelkasten"
keywords = ["kindle", "highlights", "zettelkasten"]
version = "0.1.0"
edition = "2021"
authors = ["Ben Burbage"]
publish = false

[dependencies]
iced = {version="0.13.1", features = ["tokio", "advanced"]}
kindle_clippings = { path = "../kindle_clippings"}
rfd = "0.15.0"
# tokio = { version = "1.41.1", features = ["rt"] }
Loading

0 comments on commit 9621947

Please sign in to comment.