gronk/readme.md

152 lines
5.6 KiB
Markdown
Raw Normal View History

2023-09-17 19:47:05 +00:00
# gronk
2021-04-30 21:01:08 +00:00
2024-01-02 18:38:35 +00:00
Formerly notes2web.
2021-04-30 21:01:08 +00:00
2024-01-02 18:38:35 +00:00
View your notes as a static HTML site. Powers [notes.alv.cx](https://notes.alv.cx).
2021-05-01 11:04:45 +00:00
2024-01-02 18:38:35 +00:00
![](./screenshot.png)
2022-11-10 16:46:59 +00:00
2021-06-29 18:27:31 +00:00
## Why?
2023-09-17 19:47:05 +00:00
- View notes as a website, on any device
- Easily share notes
2024-01-02 04:19:15 +00:00
- Powered by Pandoc, and therefore supports [Pandoc's markdown](https://pandoc.org/MANUAL.html#pandocs-markdown) (I mainly care about equations)
- [flatnotes](https://github.com/Dullage/flatnotes) is cool but I really would rather type my notes in Vim
2023-09-17 19:49:50 +00:00
- Lightweight HTML generated
- Minimal JavaScript
2021-06-29 18:27:31 +00:00
2021-04-30 21:01:08 +00:00
## Install
2024-01-02 18:24:27 +00:00
### Docker
Run the following, modifing the `-v` arguments as needed to mount the correct folders and
setting the value of `ARCH` to either `amd64` or `arm64` as appropriate.
```
docker build . -t gronk --build-arg ARCH=amd64
docker run -v ./n:/usr/src/app/notes -v ./web:/usr/src/app/web gronk
```
#### Compose
A [docker compose file](./docker-compose.yml) file has been provided.
Set the following environment variables (or create a .env file) and run `docker compose up`:
- `ARCH`
- `SOURCE`
- `OUTPUT`
### Locally
0. Install [Pandoc](https://pandoc.org/index.html) and [Pip](https://github.com/pypa/pip), python3-dev, and a C compiler
2024-01-02 18:24:27 +00:00
1. `sudo make install`
2021-04-30 21:01:08 +00:00
2024-01-02 18:22:15 +00:00
## Other Things to Know
2023-09-17 19:47:05 +00:00
- gronk indexes [ATX-style headings](https://pandoc.org/MANUAL.html#atx-style-headings) for
2021-09-01 12:34:19 +00:00
searching
2023-09-17 19:47:05 +00:00
- gronk looks for the plaintext file `LICENSE` in the root directory of your notes
2021-09-01 17:26:18 +00:00
2021-08-21 02:20:23 +00:00
2024-01-02 04:19:15 +00:00
## Custom Directory Index and Metadata
2024-01-02 18:22:15 +00:00
2024-01-02 18:20:47 +00:00
To add custom content to a directory index, put it in a file called `readme.md` under the directory.
2024-01-02 18:22:15 +00:00
You can set the following frontmatter variables to customise the directory index of a directory:
| variable | default value | description |
|------------------------|-------------------|--------------------------------------------------------------------------------------------|
| `tags` | `[]` | list of tags, used by search and inherited by any notes and subdirectories |
| `uuid` | none | unique id to reference directory, used for permalinking |
2024-01-02 18:20:47 +00:00
| `content_after_search` | `false` | show custom content in `readme.md` after search bar and directory index |
2024-01-02 18:22:15 +00:00
| `automatic_index` | `true` | show the automatically generated directory index. required for search bar to function. |
| `search_bar` | `true` | show search bar to search directory items. requires `automatic_index` (enabled by default) |
## Notes Metadata
2023-09-17 19:47:05 +00:00
gronk reads the following YAML [frontmatter](https://jekyllrb.com/docs/front-matter/) variables for metadata:
2024-01-02 18:22:15 +00:00
| variable | description |
|------------------|---------------------------------------------------------------------------------------|
| `author` | The person(s) who wrote the article |
| `tags` | A YAML list of tags which the article relates to - this is used for browsing and also |
| `title` | The title of the article |
| `uuid` | A unique identifier used for permalinks. |
| `lecture_slides` | a list of paths pointing to lecture slides used while taking notes |
| `lecture_notes` | a list of paths pointing to other notes used while taking notes |
## Permalinks
2022-04-03 21:44:17 +00:00
Permalinks are currently rather basic and requires JavaScript to be enabled on the local computer.
In order to identify documents between file changes, a unique identifier is used to identify a file.
This unique identifier can be generated using the `uuidgen` command in the `uuid-runtime` package or
`str(uuid.uuid())` in the `uuid` python package.
The included `n2w_add_uuid.py` will add a UUID to a markdown file which does not have a UUID in it
already.
Combine it with `find` to UUIDify all your markdown files (but make a backup first).
2024-01-02 18:22:15 +00:00
## Custom Styling
2022-11-11 12:06:46 +00:00
2024-01-02 03:54:09 +00:00
To completely replace the existing styling, set the environment variable `GRONK_CSS_DIR` to another directory with
2024-01-02 18:22:15 +00:00
a file called `styles.css`.
2022-11-11 12:06:46 +00:00
2024-01-02 18:22:15 +00:00
To add additional styling, the default styling will attempt to import `styles.css` from the root of the notes
directory.
2022-11-11 12:06:46 +00:00
2024-01-02 18:20:47 +00:00
To add additional content to the homepage, create a file called `readme.md` at the top level of your notes directory.
To set the HTML `title` tag, set `title` in the frontmatter of `readme.md`:
2023-09-17 19:18:24 +00:00
```markdown
---
title: "alv's notes"
---
# alv's notes
these notes are probably wrong
```
2021-08-21 02:20:23 +00:00
## CLI Usage
2021-04-30 21:01:08 +00:00
```
2023-09-17 19:47:05 +00:00
$ gronk.py notes_directory
2021-04-30 21:01:08 +00:00
```
2023-09-17 19:47:05 +00:00
Output of `gronk.py --help`:
2021-06-29 13:35:21 +00:00
2024-01-02 18:24:27 +00:00
```
usage: gronk.py [-h] [-o OUTPUT_DIR] [-F] notes
positional arguments:
notes
options:
-h, --help show this help message and exit
-o OUTPUT_DIR, --output-dir OUTPUT_DIR
-F, --force Generate new output html even if source file was modified before output
html
```
2021-06-29 18:17:44 +00:00
The command will generate a website in the `output-dir` directory (`./web` by default).
It will then generate a list of all note files and put it in `index.html`.
2021-05-01 10:48:04 +00:00
2021-06-29 18:17:44 +00:00
Then you just have to point a webserver at `output-dir`.
2021-05-01 10:48:04 +00:00
2021-04-30 21:01:08 +00:00
## Uninstall
```
# make uninstall
```
2021-09-01 15:37:47 +00:00
## Acknowledgements
Default synatx highlighting is based off [Pygments](https://pygments.org/)' default theme and
made using Pandoc v2.7.2.
I found the theme [here](https://github.com/tajmone/pandoc-goodies/blob/master/skylighting/css/built-in-styles/pygments.css).