From bef8aeda52b5971950134d7d6199e8af9fee313c Mon Sep 17 00:00:00 2001 From: Alvie Rahman Date: Sun, 17 Sep 2023 20:47:05 +0100 Subject: [PATCH] rename to gronk --- .gitignore | 1 + Makefile | 10 ++++---- notes2web.py => gronk.py | 14 +++++------ n2w_add_uuid.py => gronk_add_uuid.py | 13 ++++++----- readme.md | 26 ++++++++------------- requirements-dev.txt | 14 +++++++++++ templates/article.html | 2 +- templates/home_index.html | 2 +- templates/index.html | 4 ++-- templates/n2w_add_uuid_frontmatter_template | 5 ---- templates/permalink_index.html | 4 ++-- templates/textarticle.html | 2 +- 12 files changed, 51 insertions(+), 46 deletions(-) rename notes2web.py => gronk.py (95%) rename n2w_add_uuid.py => gronk_add_uuid.py (82%) create mode 100644 requirements-dev.txt delete mode 100644 templates/n2w_add_uuid_frontmatter_template diff --git a/.gitignore b/.gitignore index 916a9b8..342ef14 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ env n web +planning.txt __pycache__ diff --git a/Makefile b/Makefile index 51333ee..6075608 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ install: - cp n2w_add_uuid.py /usr/local/bin - sed "s/N2W_COMMIT = \"dev\"/N2W_COMMIT = \"$$(git rev-parse --short HEAD)\"/" notes2web.py > /usr/local/bin/notes2web.py - mkdir -p /opt/notes2web - cp -r templates js css /opt/notes2web + cp gronk_add_uuid.py /usr/local/bin + sed "s/GRONK_COMMIT = \"dev\"/GRONK_COMMIT = \"$$(git rev-parse --short HEAD)\"/" gronk.py > /usr/local/bin/gronk.py + mkdir -p /opt/gronk + cp -r templates js css /opt/gronk pip3 install -r requirements.txt uninstall: - rm -rf /usr/local/bin/notes2web.py /usr/local/bin/n2w_add_uuid.py /opt/notes2web + rm -rf /usr/local/bin/gronk.py /usr/local/bin/gronk_add_uuid.py /opt/gronk diff --git a/notes2web.py b/gronk.py similarity index 95% rename from notes2web.py rename to gronk.py index 505a9fe..0cf00f1 100755 --- a/notes2web.py +++ b/gronk.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -notes2web --- view your notes as a static html site +gronk --- view your notes as a static html site """ @@ -21,17 +21,17 @@ import requests from fileproperties import FileMap -N2W_COMMIT = "dev" +GRONK_COMMIT = "dev" PANDOC_SERVER_URL = os.getenv("PANDOC_SERVER_URL", r"http://localhost:3030/") PANDOC_TIMEOUT = int(os.getenv("PANDOC_TIMEOUT", "120")) -CSS_DIR = Path(os.getenv("CSS_DIR", "/opt/notes2web/css")) -JS_DIR = Path(os.getenv("JS_DIR", "/opt/notes2web/js")) -TEMPLATES_DIR = Path(os.getenv("TEMPLATES_DIR", "/opt/notes2web/templates")) +CSS_DIR = Path(os.getenv("CSS_DIR", "/opt/gronk/css")) +JS_DIR = Path(os.getenv("JS_DIR", "/opt/gronk/js")) +TEMPLATES_DIR = Path(os.getenv("TEMPLATES_DIR", "/opt/gronk/templates")) JINJA_ENV = jinja2.Environment( - loader=jinja2.PackageLoader("notes2web", str(TEMPLATES_DIR)), + loader=jinja2.PackageLoader("gronk", str(TEMPLATES_DIR)), autoescape=jinja2.select_autoescape ) @@ -191,7 +191,7 @@ def process_home_index(args, notes_git_head_sha1=None): post['content'] = render_markdown(post['content']) html = JINJA_TEMPLATE_HOME_INDEX.render( - n2w_commit = N2W_COMMIT, + gronk_commit = GRONK_COMMIT, search_data = FILEMAP.to_search_data(), notes_git_head_sha1 = notes_git_head_sha1, post=post diff --git a/n2w_add_uuid.py b/gronk_add_uuid.py similarity index 82% rename from n2w_add_uuid.py rename to gronk_add_uuid.py index 8832c19..6707d36 100755 --- a/n2w_add_uuid.py +++ b/gronk_add_uuid.py @@ -12,10 +12,6 @@ def get_args(): import argparse parser = argparse.ArgumentParser() parser.add_argument('filename', type=pathlib.Path) - parser.add_argument('--template', - default=pathlib.Path("/opt/notes2web/templates/n2w_add_uuid_frontmatter_template"), - type=pathlib.Path - ) parser.add_argument('-w', '--write', action='store_true', help='write to file instead of stdout') return parser.parse_args() @@ -23,8 +19,13 @@ def get_args(): def main(args): """ Entry point for script """ - with open(args.template) as fp: - template_str=fp.read() + template_str= [ + "author: {{ author }}" + "date: {{ date }}" + "title: {{ title }}" + "tags: {{ tags }}" + "uuid: {{ uuid }}" + ].join("\n") with open(args.filename) as fp: fm_pre = frontmatter.load(fp) diff --git a/readme.md b/readme.md index 18136fb..6c34ed0 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# notes2web +# gronk View your notes as a static html site. Browse a live sample of it [here](https://notes.alv.cx). @@ -9,15 +9,10 @@ Tested with [pandoc v2.19.2](https://github.com/jgm/pandoc/releases/tag/2.19.2). ## Why? -I want to be able to view my notes in a more convenient way. -I was already writing them in Pandoc markdown and could view them as PDFs but that wasn't quite -doing it for me: - -- It was inconvenient to flick through multiple files of notes to find the right PDF -- It was annoying to sync to my phone -- PDFs do not scale so they were hard to read on smaller screens -- Probably more reasons I can't think of right now -- Fun +- View notes as a website, on any device +- Write notes with pandoc markdown +- Easily share notes +- Lightweight html generated ## Install @@ -27,10 +22,9 @@ doing it for me: ## Other Things to Know -- notes2web indexes [ATX-style headings](https://pandoc.org/MANUAL.html#atx-style-headings) for +- gronk indexes [ATX-style headings](https://pandoc.org/MANUAL.html#atx-style-headings) for searching -- notes2web attempts to display file history through the `git log` command -- notes2web looks for the plaintext file `LICENSE` in the root directory of your notes +- gronk looks for the plaintext file `LICENSE` in the root directory of your notes ## Custom Directory Index @@ -50,7 +44,7 @@ You can set the following frontmatter variables to customise the directory index ## Notes Metadata -notes2web reads the following YAML [frontmatter](https://jekyllrb.com/docs/front-matter/) variables for metadata: +gronk reads the following YAML [frontmatter](https://jekyllrb.com/docs/front-matter/) variables for metadata: | variable | description | |------------------|---------------------------------------------------------------------------------------| @@ -97,10 +91,10 @@ these notes are probably wrong ## CLI Usage ``` -$ notes2web.py notes_directory +$ gronk.py notes_directory ``` -Output of `notes2web.py --help`: +Output of `gronk.py --help`: TODO add cli output diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..e439a37 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,14 @@ +beautifulsoup4==4.9.3 +editfrontmatter==0.0.1 +greenlet==2.0.2 +Jinja2==3.0.3 +MarkupSafe==2.1.0 +msgpack==1.0.5 +oyaml==1.0 +pynvim==0.4.3 +pypandoc==1.5 +python-frontmatter==1.0.0 +python-magic==0.4.24 +regex==2021.11.10 +soupsieve==2.2.1 +PyYAML==6.0.1 diff --git a/templates/article.html b/templates/article.html index c4d0f96..20b1bd0 100644 --- a/templates/article.html +++ b/templates/article.html @@ -55,7 +55,7 @@ colors

- page generated by notes2web + page generated by gronk

{% if license %}
diff --git a/templates/home_index.html b/templates/home_index.html index a21e742..eda9000 100644 --- a/templates/home_index.html +++ b/templates/home_index.html @@ -19,7 +19,7 @@ Browse here or by tag here.
-

page generated by notes2web (commit {{ n2w_commit }}) {% if notes_git_head_sha1 %}notes commit {{ notes_git_head_sha1 }}{% endif %}

+

page generated by gronk (commit {{ n2w_commit }}) {% if notes_git_head_sha1 %}notes commit {{ notes_git_head_sha1 }}{% endif %}

diff --git a/templates/index.html b/templates/index.html index 59cc5ea..d4dc7f0 100644 --- a/templates/index.html +++ b/templates/index.html @@ -35,10 +35,10 @@ {% if content_after_search %} {{ content }} {% endif %} -

page generated by notes2web

+

page generated by gronk

- + diff --git a/templates/n2w_add_uuid_frontmatter_template b/templates/n2w_add_uuid_frontmatter_template deleted file mode 100644 index 3252382..0000000 --- a/templates/n2w_add_uuid_frontmatter_template +++ /dev/null @@ -1,5 +0,0 @@ -author: {{ author }} -date: {{ date }} -title: {{ title }} -tags: {{ tags }} -uuid: {{ uuid }} diff --git a/templates/permalink_index.html b/templates/permalink_index.html index ef12493..4d5e88b 100644 --- a/templates/permalink_index.html +++ b/templates/permalink_index.html @@ -12,8 +12,8 @@ You should be being redirected... Otherwise, click here.

-

page generated by notes2web

+

page generated by gronk

- + diff --git a/templates/textarticle.html b/templates/textarticle.html index 58bb3e4..568a4cc 100644 --- a/templates/textarticle.html +++ b/templates/textarticle.html @@ -1,6 +1,6 @@ {% extends "article.html" %} {% block body %} -

This file was not rendered by notes2web because it is a plaintext file, not a markdown +

This file was not rendered by gronk because it is a plaintext file, not a markdown file. You access the raw file here. Below is an unformatted representation of the file: