rename to gronk

This commit is contained in:
Akbar Rahman 2023-09-17 20:47:05 +01:00 committed by Akbar Rahman
parent 5bb40a57d1
commit bef8aeda52
Signed by: alvierahman90
GPG Key ID: 6217899F07CA2BDF
12 changed files with 51 additions and 46 deletions

1
.gitignore vendored
View File

@ -2,4 +2,5 @@
env env
n n
web web
planning.txt
__pycache__ __pycache__

View File

@ -1,9 +1,9 @@
install: install:
cp n2w_add_uuid.py /usr/local/bin cp gronk_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 sed "s/GRONK_COMMIT = \"dev\"/GRONK_COMMIT = \"$$(git rev-parse --short HEAD)\"/" gronk.py > /usr/local/bin/gronk.py
mkdir -p /opt/notes2web mkdir -p /opt/gronk
cp -r templates js css /opt/notes2web cp -r templates js css /opt/gronk
pip3 install -r requirements.txt pip3 install -r requirements.txt
uninstall: 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

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/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 from fileproperties import FileMap
N2W_COMMIT = "dev" GRONK_COMMIT = "dev"
PANDOC_SERVER_URL = os.getenv("PANDOC_SERVER_URL", r"http://localhost:3030/") PANDOC_SERVER_URL = os.getenv("PANDOC_SERVER_URL", r"http://localhost:3030/")
PANDOC_TIMEOUT = int(os.getenv("PANDOC_TIMEOUT", "120")) PANDOC_TIMEOUT = int(os.getenv("PANDOC_TIMEOUT", "120"))
CSS_DIR = Path(os.getenv("CSS_DIR", "/opt/notes2web/css")) CSS_DIR = Path(os.getenv("CSS_DIR", "/opt/gronk/css"))
JS_DIR = Path(os.getenv("JS_DIR", "/opt/notes2web/js")) JS_DIR = Path(os.getenv("JS_DIR", "/opt/gronk/js"))
TEMPLATES_DIR = Path(os.getenv("TEMPLATES_DIR", "/opt/notes2web/templates")) TEMPLATES_DIR = Path(os.getenv("TEMPLATES_DIR", "/opt/gronk/templates"))
JINJA_ENV = jinja2.Environment( JINJA_ENV = jinja2.Environment(
loader=jinja2.PackageLoader("notes2web", str(TEMPLATES_DIR)), loader=jinja2.PackageLoader("gronk", str(TEMPLATES_DIR)),
autoescape=jinja2.select_autoescape autoescape=jinja2.select_autoescape
) )
@ -191,7 +191,7 @@ def process_home_index(args, notes_git_head_sha1=None):
post['content'] = render_markdown(post['content']) post['content'] = render_markdown(post['content'])
html = JINJA_TEMPLATE_HOME_INDEX.render( html = JINJA_TEMPLATE_HOME_INDEX.render(
n2w_commit = N2W_COMMIT, gronk_commit = GRONK_COMMIT,
search_data = FILEMAP.to_search_data(), search_data = FILEMAP.to_search_data(),
notes_git_head_sha1 = notes_git_head_sha1, notes_git_head_sha1 = notes_git_head_sha1,
post=post post=post

View File

@ -12,10 +12,6 @@ def get_args():
import argparse import argparse
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('filename', type=pathlib.Path) 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', parser.add_argument('-w', '--write', action='store_true',
help='write to file instead of stdout') help='write to file instead of stdout')
return parser.parse_args() return parser.parse_args()
@ -23,8 +19,13 @@ def get_args():
def main(args): def main(args):
""" Entry point for script """ """ Entry point for script """
with open(args.template) as fp: template_str= [
template_str=fp.read() "author: {{ author }}"
"date: {{ date }}"
"title: {{ title }}"
"tags: {{ tags }}"
"uuid: {{ uuid }}"
].join("\n")
with open(args.filename) as fp: with open(args.filename) as fp:
fm_pre = frontmatter.load(fp) fm_pre = frontmatter.load(fp)

View File

@ -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). 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? ## Why?
I want to be able to view my notes in a more convenient way. - View notes as a website, on any device
I was already writing them in Pandoc markdown and could view them as PDFs but that wasn't quite - Write notes with pandoc markdown
doing it for me: - Easily share notes
- Lightweight html generated
- 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
## Install ## Install
@ -27,10 +22,9 @@ doing it for me:
## Other Things to Know ## 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 searching
- notes2web attempts to display file history through the `git log` command - gronk looks for the plaintext file `LICENSE` in the root directory of your notes
- notes2web looks for the plaintext file `LICENSE` in the root directory of your notes
## Custom Directory Index ## Custom Directory Index
@ -50,7 +44,7 @@ You can set the following frontmatter variables to customise the directory index
## Notes Metadata ## 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 | | variable | description |
|------------------|---------------------------------------------------------------------------------------| |------------------|---------------------------------------------------------------------------------------|
@ -97,10 +91,10 @@ these notes are probably wrong
## CLI Usage ## CLI Usage
``` ```
$ notes2web.py notes_directory $ gronk.py notes_directory
``` ```
Output of `notes2web.py --help`: Output of `gronk.py --help`:
TODO add cli output TODO add cli output

14
requirements-dev.txt Normal file
View File

@ -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

View File

@ -55,7 +55,7 @@
colors colors
</p> </p>
<p class="smallText metadata"> <p class="smallText metadata">
page generated by <a href="https://git.alv.cx/alvierahman90/notes2web">notes2web</a> page generated by <a href="https://git.alv.cx/alvierahman90/gronk">gronk</a>
</p> </p>
{% if license %} {% if license %}
<details id="license"> <details id="license">

View File

@ -19,7 +19,7 @@ Browse <a href="/notes">here</a> or by tag <a href="/tags">here</a>.
<div id="results"> <div id="results">
</div> </div>
<p class="smallText"> page generated by <a href="https://github.com/alvierahman90/notes2web">notes2web</a> (commit {{ n2w_commit }}) {% if notes_git_head_sha1 %}notes commit {{ notes_git_head_sha1 }}{% endif %}</p> <p class="smallText"> page generated by <a href="https://github.com/alvierahman90/gronk">gronk</a> (commit {{ n2w_commit }}) {% if notes_git_head_sha1 %}notes commit {{ notes_git_head_sha1 }}{% endif %}</p>
</div> </div>
<script src="/js/fuse.js"> </script> <script src="/js/fuse.js"> </script>
<script> const search_data = {{ search_data|tojson }} </script> <script> const search_data = {{ search_data|tojson }} </script>

View File

@ -35,10 +35,10 @@
{% if content_after_search %} {% if content_after_search %}
{{ content }} {{ content }}
{% endif %} {% endif %}
<p style="font-size: 0.7em;"> page generated by <a href="https://github.com/alvierahman90/notes2web">notes2web</a></p> <p style="font-size: 0.7em;"> page generated by <a href="https://github.com/alvierahman90/gronk">gronk</a></p>
</div> </div>
<script src="/js/fuse.js"> </script> <script src="/js/fuse.js"> </script>
<script> const search_data = {{ index_entries }} </script> <script> const search_data = {{ index_entries|tojson }} </script>
<script src="/js/indexsearch.js"> </script> <script src="/js/indexsearch.js"> </script>
</body> </body>

View File

@ -1,5 +0,0 @@
author: {{ author }}
date: {{ date }}
title: {{ title }}
tags: {{ tags }}
uuid: {{ uuid }}

View File

@ -12,8 +12,8 @@ You should be being redirected...
Otherwise, click <a id="manual_redirect">here</a>. Otherwise, click <a id="manual_redirect">here</a>.
</p> </p>
<p class="smallText"> page generated by <a href="https://github.com/alvierahman90/notes2web">notes2web</a></p> <p class="smallText"> page generated by <a href="https://github.com/alvierahman90/gronk">gronk</a></p>
</div> </div>
<script> const data = $data$ </script> <script> const data = {{ data|tojson }} </script>
<script src="/js/permalink.js"> </script> <script src="/js/permalink.js"> </script>
</body> </body>

View File

@ -1,6 +1,6 @@
{% extends "article.html" %} {% extends "article.html" %}
{% block body %} {% block body %}
<p> This file was not rendered by notes2web because it is a plaintext file, not a markdown <p> This file was not rendered by gronk because it is a plaintext file, not a markdown
file. file.
You access the raw file <a href="{{ raw_link }}">here</a>. You access the raw file <a href="{{ raw_link }}">here</a>.
Below is an unformatted representation of the file: Below is an unformatted representation of the file: