From 8dbab1b9f26faf9b94a90a0fb3b600692f8ab99f Mon Sep 17 00:00:00 2001 From: Alvie Rahman Date: Sat, 1 May 2021 12:21:59 +0100 Subject: [PATCH] add config options for article template, listitem template, index template, stylesheet --- notes2web | 21 +++++++++++++++++---- readme.md | 8 ++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/notes2web b/notes2web index 69bc4b1..1c82220 100755 --- a/notes2web +++ b/notes2web @@ -3,11 +3,24 @@ [[ "$1" == "--help" ]] && echo "USAGE: $0 [NOTES_DIRECTORY_1 [NOTES_DIRECTORY_2 [...]]]" && exit 0 +# set default config values, load user config, export config variables +name="" +article_template="/opt/notes2web/templates/article.html" +listitem_template="/opt/notes2web/templates/listitem.html" +index_template="/opt/notes2web/templates/index.html" +stylesheet="/opt/notes2web/styles.css" + for configpath in "$HOME/.notes2web.conf" "$HOME/.config/notes2web/config" ".notes2web.conf" do [[ -f "$configpath" ]] && source "$configpath" done +export name +export article_template +export listitem_template +export index_template +export stylesheet + function _renderarticle { echo "rendering $1" @@ -15,7 +28,7 @@ function _renderarticle { --toc\ --standalone\ -t html\ - --template /opt/notes2web/templates/article.html\ + --template "$article_template"\ -o "$(dirname "$1")/index.html"\ "$1"\ --mathjax @@ -34,7 +47,7 @@ function _addarticletoindex { pandoc\ -t html\ -V "filepath=$(dirname "$1")"\ - --template /opt/notes2web/templates/listitem.html\ + --template "$listitem_template"\ "$1"\ >> index.md } @@ -70,12 +83,12 @@ find -name '.2web' -exec bash -c "_adddirtoindex '{}'" \; echo "copying styles.css to current directory" -cp /opt/notes2web/styles.css . +cp "$stylesheet" ./styles.css echo "rendering index.md" pandoc\ -t html\ - --template /opt/notes2web/templates/index.html\ + --template "$index_template"\ -o index.html\ "index.md" diff --git a/readme.md b/readme.md index 1816585..a2f3d31 100644 --- a/readme.md +++ b/readme.md @@ -31,10 +31,14 @@ Then you just have to point a webserver at your notes directory. `notes2web` looks for a config file called `.notes2web.conf` in your current directory and your home directory. -Right now the only config available is `name`: +Default config values: ```bash -name="alv" +name="" +article_template="/opt/notes2web/templates/article.html" +listitem_template="/opt/notes2web/templates/listitem.html" +index_template="/opt/notes2web/templates/index.html" +stylesheet="/opt/notes2web/styles.css" ``` If the name is not set, the title is set to 'notes'.