From 381297c95c7446182e90e459cd0257a8fc86b4cf Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 29 Dec 2020 12:24:04 +0100 Subject: Improved CSS classes for page content, added proper ref list macro, build scripts load and watch Pandoc filters automatically --- scripts/build_content.sh | 32 +++++++++++++++++++++++++++----- scripts/metadata_tpl.json | 0 scripts/watch_filters.sh | 7 +++++++ 3 files changed, 34 insertions(+), 5 deletions(-) mode change 100644 => 100755 scripts/metadata_tpl.json create mode 100755 scripts/watch_filters.sh (limited to 'scripts') diff --git a/scripts/build_content.sh b/scripts/build_content.sh index 719b7c9..b258449 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh @@ -1,14 +1,31 @@ #!/bin/bash CONTENT_DIR="content/" +FILTERS_DIR="filters/" METADATA_DIR="metadata/" TEMPLATES_DIR="templates/" OUTPUT_DIR="output/" -CATEGORY_SHORT_LEN=3 CATEGORY_MAP=$(cat "$METADATA_DIR/categories.json") -target_filename () { +get_filters() { + filters_args="" + + mapfile -d $'\0' filters < <(find $FILTERS_DIR \ + -type f \ + -name "*.lua" ! -name ".*" \ + -print0) + + for file in "${filters[@]}"; do + filters_args="$filters_args --lua-filter $file" + done + + echo $filters_args +} + +FILTERS=$(get_filters) + +target_filename() { filename=$1 filename=${filename#"$CONTENT_DIR"} if [ "${filename##*.}" = "md" ]; then @@ -17,7 +34,7 @@ target_filename () { echo "$OUTPUT_DIR$filename" } -target_url_rel () { +target_url_rel() { basedir=$1 filename=$2 filename=$(realpath --relative-to="$basedir" "$filename") @@ -28,7 +45,7 @@ target_url_rel () { echo "$filename" } -target_url_abs () { +target_url_abs() { echo "/$(target_url_rel "$CONTENT_DIR" "$1")" } @@ -148,6 +165,10 @@ handle () { # echo "$(get_metadata "$1")" echo "$(get_metadata "$1")" > "$subpages_meta_file" + # echo $(pandoc "$1" \ + # -f markdown \ + # -t json) + pandoc "$1" \ -f markdown \ -t html5 \ @@ -157,7 +178,8 @@ handle () { --metadata section=$section \ --metadata "is$section" \ --metadata-file metadata/metadata.yaml \ - --metadata-file "$subpages_meta_file" + --metadata-file "$subpages_meta_file" \ + $FILTERS # --lua-filter "filters/add_refs.lua" rm "$subpages_meta_file" diff --git a/scripts/metadata_tpl.json b/scripts/metadata_tpl.json old mode 100644 new mode 100755 diff --git a/scripts/watch_filters.sh b/scripts/watch_filters.sh new file mode 100755 index 0000000..9bb3b44 --- /dev/null +++ b/scripts/watch_filters.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +inotifywait -qrme close_write,delete,move --format "%w%f" filters \ + | while read file + do + scripts/build_content.sh "all_md" + done -- cgit v1.2.3-70-g09d2